Dexalot’s Sample Bot
Dexalot has abstracted some of the backbone of its Market Maker’s source code into the SampleBot repository for use with Dexalot’s newest contracts. Some ideas and terms about trading, market making and what you might consider building on top of Dexalot can be found in Trading & Market Making and Trading Glossary.
SampleBot extends the AbstractBot and utilizes connections to the Dexalot RestAPI on the Testnet (api.dexalot-test.com/api/). Please note that this code is not compatible with the currently deployed Mainnet contracts nor the mainnet RestAPI. However, it can be used to interact with contracts deployed on Fuji testnet as a preparation for production release planned for early January 2023. Dexalot’s latest RestAPI documentation is available here.
Feel free to change SampleBot and/or add a new bot type that extends the AbstractBot. Please see the README.md file for installation instructions and more details. Here are some of the functions that SampleBot can perform:
- Get the mainnet/subnet environments, pairs listed, token details from the RESTAPI
- Create references to the necessary contracts
- Requests open orders from the RESTAPI in case of crash recovery
- Keeps a list of its outstanding orders, and a local orderbook in memory
- Gets the best 2 bid/asks orderbook from the chain
- SampleBot listens to OrderStatusChanged events from the blockchain in case one of its outstanding orders gets hit/lifted.
- SampleBot also captures OrderStatusChanged events as a part of tx results when sending an order and updates the order status in memory. The OrderStatusChanged event is raised from the blockchain to all the listeners a few seconds later. So the same event is processed twice. Once when the order is sent out and again when it is received from the blockchain by the independent listener thread. Hence it is normal to see the message “Duplicate Order event: ……”
- Double Checks the order status from the chain every 10 min, in case an OrderStatusChanged event is missed.
Author: Brad McFall
Editor: Dan Marcoulis
Graphics: Can Toygar
Dexalot is a revolutionary decentralized exchange bringing the traditional centralized exchange look and feel to a decentralized on-chain application. Its mission is to bring a truly inclusive and transparent environment where Dexalot users can trade crypto securely and efficiently, with no slippage or custody risk. It is built on Avalanche, the fastest smart contracts platform in the blockchain industry.