Drift Protocol Launches: Limit Orders

Powered by our novel hybrid Decentralised Limit Orderbook (DLOB) and our keeper bot network.

Drift Protocol
7 min readFeb 23, 2022
Trade with limit orders now at app.drift.trade

Drift Protocol is launching the most anticipated feature since our mainnet launch — limit orders!

Limit orders on Drift are powered by a hybrid decentralised orderbook (DLOB) model that settles trades against our DAMM.

Drift’s focus is building a feature-complete decentralised DEX, that uses crypto-native infrastructure built from the ground-up with blockchain-first principles in mind.

Why now?

Drift’s growth so far in the past two months since launch was driven entirely by its DAMM system which offered market orders only. Traders loved the DAMM due to its instant liquidity that was always available with slippage that was comparable to other exchanges.

In order to build limit orders that conserved the liquidity properties of the DAMM, we had to design a system that was computationally efficient and was compatible with our novel DAMM. The former was particularly pertinent as:

  1. in an on-chain environment, there is a trade-off for high computational requirements. This trade off is typically speed and reliability; and
  2. traditionally, placing all orders and order matching algorithms fully on-chain leads to inefficiency.

Our vision was to design a limit order system that was crypto-native, scalable and married the best of the DAMM’s guaranteed liquidity and adaptable slippage with the flexibility of limit orders.

As a result, we came up with the Decentralised Limit Orderbook (DLOB).

Now Live — trade limit orders on Drift.

Drift’s Hybrid Decentralised Limit Orderbook (DLOB)

What is a DLOB?

Drift’s Decentralised Limit Order Book (“DLOB”) is a computationally efficient and decentralised system that utilises economic incentives to enable limit orders to be placed against the DAMM.

Underlying the design of the DLOB is two core values:

  1. decentralisation; and
  2. computational efficiency.

Decentralisation is achieved through our network of hybrid off-chain keeper bots (“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.

Our thesis behind this design is that a DLOB will remain efficient across various types of network conditions. Whether or not this will be the case, is yet to be tested.

How is a DLOB different to a regular on-chain orderbook?

Both DLOBs and on-chain orderbooks achieve the same objective — that being the placement and execution of limit orders. However, the key differences lie in:

  1. definition;
  2. operation; and
  3. origin.

Definition — on-chain orderbooks refers to traditional orderbooks that are built and operate on a blockchain. In contrast, DLOB refers to a novel mechanism that settles limit orders against the DAMM when certain conditions are met.

Operation — on-chain orderbooks algorithmically match orders between buyers and sellers at an agreed price. Whereas, DLOBs are maintained by a network of Keepers that work for a financial incentive to fulfil valid open orders against the DAMM.

Origin — on-chain orderbooks are similar to traditional electronic orderbooks. They’re an evolution of a tradfi product invented by NASDAQ adapted for the blockchain. The DLOB is a novel crypto-native concept built with blockchain-first principles in mind.

How Drift’s DLOB Works

Limit orders are executed by Keepers on the network. Keepers function in a similar manner as liquidators. You can think of limit orders as taker orders that are queued to be filled against the DAMM once certain conditions are met. Keepers play the role of compensated agents that facilitate this process.

The result is that the DLOB allows users to enjoy the full functionalities of limit orders, whilst also enjoying the benefits of a DAMM, that being: (a) lower slippage and (b) guaranteed liquidity.

Here are the sequence of events that occur before a limit order is filled on-chain:

  1. User submits a limit order on-chain

The user submits a limit order and the order is stored on-chain in the user’s order account. There is no fee for submitting a limit order aside from gas fees on Solana (which are negligible).

2. Program validates limit orders

The program checks for whether the order structure is valid. If it is, then the program stores the order on-chain into the user’s current order accounts.

3. Keepers keep track of users’ open orders and check for validation

Keepers continuously monitor users’ on-chain order accounts for active and valid open limit orders. This is similar to how liquidators keep track of users’ margin ratio state by continuously listening to users’ positions.

Once a Keeper finds an active and valid open limit order, it stores this order off-chain along with all the other valid open limit orders that it has found. The Keeper then chronologically sorts orders by age and then size in an orderbook-esque structure.

4. If limit conditions hit, the Keeper fills the order against the DAMM and the user’s position is opened

If the DAMM’s mark price hits the limit price (or better) of a user’s limit order, the Keeper will fill this order against the DAMM. If there are multiple orders, the Keepers will fill orders based on age and best price as priority. There is no guarantee that this will happen, but the Keepers are financially incentivised to fill the oldest orders first.

5. The Keeper receives a fee reward for filling the open order

When the order fills, the Keeper that fills the order is rewarded a % of the fees paid by the user for filling the order.

A Keeper’s Role in the DLOB

In a DLOB, 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 orderbook off-chain. 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 are then sorted by position size.

For performing this critical duty, the Keepers earn a small 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:

  1. the fastest; and
  2. the ones that fulfil orders in the protocol’s desired sequence — oldest and largest first.

The exact calculation of Keeper fees can be found here.

When limit orders?

The answer is: Now.

Our community has been going wild for limit orders on Drift.

We had over a hundred expressions of interest to pilot test our limit orders on Devnet.

Limit orders were also, by far, the highest upvoted Canny post — ever.

Now you can finally place stop losses, take profits and queued orders as easily (and as conveniently) as you can place any trade against Drift’s DAMM.

What are limit orders useful for?

Limit orders (and conditional limit orders) are useful for many things, the least of which is to prevent partial or full liquidations. Beyond that, limit orders are also useful for:

  • Specifying exactly the price you want to be filled: Place an order to get filled at 5 or 10bps less than the current mark price! Save yourself them pesky fees and slippage 😉
  • Buying the Dip: Set buy orders for 10–15% below mark price to catch those dips! Never miss the dip again 📈
  • Downside protection: Use stop losses to choose a price to exit your position and prevent the market from moving against you unexpectedly! Don’t get caught with your pants down 😱
  • Taking profit: We also have a take profit function, to exit your open position at a price that you’d be willing to reduce or close your position at. No one ever went broke taking profits 🤑

Limit Orders FAQ

A full list of FAQs relating to limit orders can be found here.

How can you get involved?

Well, for starters — you can trade with limit orders as well as conditional limit orders (stops and take profits) and let us know what you think!

You can also access our developer resources here and learn how to run your own Keeper!

Finally, you can help us by providing feedback via Canny. Your feedback will help us refine the product and make room for more advanced order features to come (e.g. floating orders offset from an oracle, post only etc).

This is only the start. We have so much more room for expansion and we’re excited to see you be part of Drift’s ecosystem today!

❤ ❤ ❤ ️

🚨🚨 We are hiring 🚨🚨

Get in touch with us via email if any of the below roles suit you.

  • Frontend Engineer (Mobile)
  • Frontend Engineer
  • Smart Contract Engineer
  • Full Stack Engineer
  • Head of Community/Community Manager
  • Product Designer

View full list of available roles at Drift Protocol here.

Get in touch!

Stay in touch with us as we journey towards becoming the #1 decentralised futures exchange across all chains!

🌐 Visit us at drift.trade 🌐

📩 Email us at hello@drift.trade 📩

💬 Connect with us on Discord 💬

👾 Find us on Twitter — @DriftProtocol 👾

🧵 Check out Drift Education on Substack 🧵

📺 Watch Drift Education on Youtube 📺

--

--

Drift Protocol

A scalable, decentralised, capital-efficient derivatives exchange built on Solana.