Deep Dive: Filling Orders on Drift
Understanding Order Books and Their Limitations
In the world of cryptocurrency trading, many platforms use what’s called a Central Limit Order Book (CLOB). The original document notes that CLOBs are often referred to as “Only Possible On Solana” (#OPOS), highlighting their prevalence on the Solana blockchain.
CLOBs, while functional, have some limitations, especially on blockchain platforms like Solana:
-
Write Locks: The document states, “Across makers only a single maker can perform a place/cancel operation per slot.” This means only one person can place or cancel an order at a time, potentially slowing down the system.
-
Scalability Issues: As more users interact with the system, it becomes harder for everyone to place orders quickly and efficiently. The original text implies this when discussing the competition between makers.
-
Liquidity Challenges: The document mentions “Liquidity Bootstrapping” as a problem that needs to be addressed.
Drift’s Solution: The Distributed Limit Order Book (DLOB)
Drift tackles these problems with what they call a Distributed Limit Order Book (DLOB). The document explains:
“Drift took a different approach with a Distributed Limit Order Book (DLOB). Instead of a central data structure that results in write-locking contention and upper bounds, Drift gives each user an orders account.”
Here’s how it works:
-
Personal Order Accounts: Each user gets their own space to place orders.
-
Reduced Congestion: The document states, “when users place orders in their own account, they don’t write-lock any global state for the market.”
-
Efficient Matching: As per the original text, “Only the less frequent matches will write-lock the market account.”
Ensuring Fair Pricing in a Distributed System
With orders spread out, Drift ensures fair pricing through two main strategies:
1. Auctions
The document explains: “The Drift orderbook is asynchronous. Searchers construct the price-time order.” It further details:
- Users can specify their auction parameters, including “start/end price/duration, IOC, post-only, oracle offset, limit, expiry timestamp, etc.”
- These parameters allow users to ensure “they are satisfied with the result at runtime or after N slots.”
2. Keeper Incentives
The original text states: “Keeper bots earn fee when matching orders and earn higher fees when adhering to price-time ordering AND giving takers fills closer/better than oracle price.”
Additional Liquidity Methods
Drift incorporates additional methods to ensure liquidity:
1. Just-In-Time (JIT) Liquidity
The document explains: “Instead of posting on the DLOB, makers can also provide JIT liquidity. Once an order goes through the auction, both JIT makers and keepers compete to match resting orders.”
Pros and cons are outlined in the original text, including gas savings for makers and potential missed opportunities.
2. Virtual Automated Market Maker (vAMM)
The document describes the vAMM as “a per-market, advanced, open, and on-chain liquidity provider partially serviced/expanded by user LPs (Liquidity Providers).”
Key points from the original text:
- The vAMM uses various data points to set prices, including oracle price, market volatility, and current inventory.
- It has specific restrictions to ensure fairness, such as not discriminating between users.
- The vAMM can provide “supplemental liquidity at prices filled by external makers” to help rebalance the market.
Additional Details and Considerations
Auction Parameters and Open Problems
The original document mentions that “Setting the right auction parameters is an open problem, similar to what’s discussed in the Uniswap v4 paper.” This indicates that determining the optimal settings for auctions is an ongoing area of research and development in decentralized finance.
The document suggests that this challenge “can be resolved through UI/UX design and real-time analysis feeds/services.” This points to the importance of user interface and data analysis in making the system more effective and user-friendly.
vAMM as a Backstop and Its Mechanisms
The vAMM plays a crucial role as a “backstop liquidity provider of last resort.” Some key points about the vAMM’s operation:
- It’s only used after a “speed bump” (e.g., 10 slots) and earns a higher fee rebate for this service.
- Before every fill attempt, the vAMM can update its quotes based on various factors.
- If the oracle is deemed invalid, the vAMM won’t offer liquidity for that slot.
- There are limits on how much liquidity a single fill can take before the vAMM updates again.
- The vAMM can become one-sided if one side has been heavily traded against.
vAMM Restrictions and Principles
The vAMM is built natively into the protocol with specific principles:
- It cannot discriminate between users (e.g., offer better prices to some users over others).
- Its profits are reinvested in increasing liquidity for that market, not extended to insurance stakeholders.
- The only exception is when a market is delisted, at which point the vAMM’s balance is sent to the revenue pool.
vAMM JIT Liquidity for Rebalancing
In certain scenarios, the vAMM can provide Just-In-Time (JIT) liquidity to help rebalance the market:
- The vAMM typically quotes prices in a wide range around the oracle price.
- To help ‘unload’ toxic flow (unfavorable trades), the vAMM can provide supplemental liquidity at prices filled by external makers.
- In some cases, the vAMM can take up to half of a taker’s order to help rebalance.
- This feature is a compromise to ensure protocol solvency, though it’s noted that if external makers filled competitively at all times, this situation would not arise.
Conclusion
The Drift Protocol represents a novel approach to addressing the limitations of traditional Central Limit Order Books (CLOBs) in the context of blockchain-based trading. By distributing the order book, implementing auctions, and incorporating advanced features like the vAMM, Drift aims to create a more efficient, scalable, and resilient trading system.
The protocol tackles key challenges such as write-lock contention, liquidity provision, and fair pricing. While some aspects, like optimal auction parameters, remain areas for ongoing research and development, the overall design offers a promising direction for the evolution of decentralized exchanges.
By balancing the needs for speed, fairness, and liquidity, Drift seeks to provide a robust platform that can adapt to various market conditions while maintaining the benefits of decentralized, on-chain trading.
See Original Post Here: The Life of an Order (on Drift Protocol)