Decentralised Limit Orderbook (DLOB)
The Decentralised Limit Orderbook (DLOB) enables limit orders to be placed against the DAMM.
Underlying the design of the DLOB is two core values:
- decentralisation; and
- computational efficiency.
Decentralisation is achieved through our network of hybrid off-chain Keepers that anyone can build and run — similar to liquidator bots.
Computational efficiency is achieved by leaving the order-filling logic — the part that requires the most computational power — off-chain, and filling them on-chain upon a trigger.
Hence, Drift’s unique limit order system is a hybrid system that uses a combination off-chain Keepers and on-chain settlement.
The DLOB is managed by a network of decentralised keeper bots ("Keepers") that are incentivised to fill orders against the DAMM in exchange for a % of fees from each order.
The Keeper’s job is to listen, store, sort and fill valid limit orders. Keepers do this by compiling all valid open orders found on-chain, and organising them into a data structure that resembles an off-chain orderbook. Keepers will then fill these orders on-chain against the DAMM when the users’ trigger or limit price is met.
Each keeper effectively stores its own off-chain data structure containing all on-chain orders. These orders are sorted by age; and if two orders have the same age, they’re then sorted by position size.
For performing this critical duty, the Keepers earn a fee for every trade they execute. Keepers are financially incentivised to fill the oldest orders first. Similar to liquidation bots, Keepers will compete for fees in a decentralised system; with the most profitable Keepers being:
- the fastest; and
- the ones that fulfil orders in the protocol’s desired sequence — oldest and largest first.
Currently the USDC reward function for keepers (f_keeper) is designed as:
where: t_order is seconds since order was placed f_user is the taker fee paid by user who placed the order This reward is subject to evolve to incentivise CLOB-like execution ordering. See [source code] for the on-chain calculation.