Tutorial: Order Matching Bot
Order Matching Bots (Matching Bots) are responsible for matching two orders that cross or a taker order against the DAMM. Specifically, this includes:
- Market Orders: Market Buy and Market Sell
- Limit Orders: Limit Buy and Limit Sell
Matching Bots receive a small compensation for each order that they successfully fill.
See Keepers & Decentralised Orderbook for a technical explanation of how the decentralised orderbook (DLOB) and matching incentives work.
Matching Bots are similar to Tutorial: Order Trigger Bot in that they:
- also maintain a local copy of the Decentralised Limit Orderbook (DLOB);
- do not require the operator to manage collateral; and
- receive a small reward for performing their duties.
The reference implementation of the Order Matching Bot is available here.
Follow the instructions at Keeper Bots to set the required environment variables and make sure a ClearingHouseUser is initialized.
Start the Matching Bot:
Market orders that are sent on the Drift Protocol first go through the Just-In-Time (JIT) Auctions. After the auction period, Matching Bots step in to fill orders for a small reward.
The DLOB implementation includes a method for getting orders ready to be filled:
To avoid trying to fill orders that aren't ready to be filled, filter out orders that are too small to fill