Drift Protocol v2

โŒ˜K
๐Ÿ‘พWelcome to Drift Protocol
๐ŸงฎDrift DEX
๐Ÿ‘‹Getting Started
๐Ÿ“ˆPerpetual Futures
๐Ÿ“ŠSpot Margin Trading
๐ŸฆBorrow & Lend
๐Ÿ›๏ธStaking
๐Ÿ”ฌTechnical Explanations
๐Ÿ“Accounting and Settlement
โž—Borrow Interest Rate
๐Ÿ“œDelisting Process
โ›ฒDrift AMM
๐ŸƒJust-In-Time (JIT) Auctions
๐Ÿ“šKeepers & Decentralised Orderbook
โ˜ ๏ธLiquidators
๐Ÿ’งLiquidity Providers (LPs)
๐Ÿ“‹Protocol Guard Rails
๐Ÿ“Risks
๐Ÿ–ฅ๏ธDeveloper Resources
๐Ÿ“”Overview
โŒจ๏ธSDK Documentation
โŒจ๏ธTutorial: Bots
โš ๏ธTroubleshooting
๐Ÿ› ๏ธKeeper Bots
๐Ÿ› ๏ธTrading Bots
โŒจ๏ธHistorical Data (v1)
โŒจ๏ธAPI
๐Ÿ›ก๏ธSecurity
๐Ÿ›ก๏ธAudits
๐Ÿ›ก๏ธBug Bounty
โš–๏ธLegal and Regulations
๐Ÿ“Terms of Use
๐Ÿ“Disclaimer
๐Ÿ“Privacy Policy
๐Ÿ“Competition Terms and Conditions
๐Ÿ“šGlossary
Docs powered byย archbeeย 
14min

Keepers & Decentralised Orderbook

Overview

Drift's decentralised orderbook is powered by our network of Keeper Bots.

The Keeper Bots match open orders with various on-chain liquidity mechanism once they cross or their trigger condition is met. These scenarios include:

  • Taker auction against Taker auction;
  • Taker/Maker limit orders against Taker auction;
  • Maker limit orders against Taker limit orders;
  • Taker/Maker orders against the Drift's AMM.

Note: that (1) two post only maker orders cannot be crossed; (2) maker orders that fill against the vAMM are not eligible for rebate reward; and (3) limit orders can be filled by market orders that. gothrough the JIT auction.

Keepers earn rewards that incentivise:

  1. providing the best execution for takers (relative to the oracle price) and;
  2. following First-Come-First-Serve execution ordering

While a robust Keepers network improves throughput/usability, the protocol's core functionality is not crunched upon it. Existing trading bots (JIT makers and resting order takers) implicitly fulfill the role of Keepers.

Keeper Bots

Keeper Bots listen, store, sort and fill valid limit orders. Keepers do this by compiling all valid open orders found on-chain and organising them into an off-chain orderbook. These orders are sorted by price, age, and if two orders have the same age, theyโ€™re then sorted by position size.

Each Keeper holds its own orderbook (hence 'decentralised orderbook').

Keepers then listen to trigger conditions and match crossing orders and limit orders against the DAMM when the usersโ€™ trigger or limit price is met.

For performing this critical duty, the Keepers earn a fee for every trade they execute. Similar to liquidation bots, Keepers will compete for fees in a decentralised system; with the most profitable Keepers being:

  1. the fastest;
  2. the best price improvement for takers; and
  3. the ones that fulfil orders in the protocolโ€™s desired sequence โ€” oldest and largest first.

Reference implementations for the filler and trigger Keepers are provided: Tutorial: Keeper Bots.

Document image

Keeper Rewards

Currently the USDC reward function for keepers (f_keeper) is designed as:

Document image

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.๏ปฟ

plot of filler rewards (given user fee)
plot of filler rewards (given user fee)

A Keeper reward multiplier (for taker price improvement) is applied to the keeper's minimum time based reward component in the function above. Any percent improvement versus the baseline oracle +/- 10bps, increases this multiplier.

Build Philosophy

The decentralised orderbook is designed with two core values in mind:

  1. decentralisation;ย and
  2. 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.

Updated 29 Dec 2022
Did this page help you?
Yes
No
UP NEXT
Keeper Incentives
Docs powered byย archbeeย 
TABLE OF CONTENTS
Overview
Keeper Bots
Keeper Rewards
Build Philosophy