Detailed Explanation of Decentralized Order Books: The Best Combination of Pricing Quality and Capital Security
Authors: ELLA, KEONE
Compiled by: Deep Tide TechFlow
Since the peak of DeFi Summer, crypto traders have been trading on DEXs like Uniswap and CEXs like Binance. However, DEXs are primarily implemented in the form of AMMs, while CEXs are mainly in the form of limit order books (LOBs). Traders often find that AMM pricing is straightforward and avoids the need to entrust assets to centralized participants, while CEX LOBs provide better pricing due to more precise liquidity from active market makers.
Despite other trade-offs between the two types of exchanges, such as liquidity mining on AMMs and richer information trading on LOBs, these trade-offs can play a role in deciding which platform to trade on, but pricing is the most important factor. Therefore, the natural question is, why don’t we decentralize centralized exchanges? A decentralized LOB would be a clear game changer, providing the non-custodial advantages of dapps while offering better pricing from a complete order book.
Let’s take a closer look.
Automated Market Makers: Crypto-Native Liquidity
AMMs are on-chain programs (smart contracts) that allow users to swap between asset pairs. They achieve this by maintaining paired liquidity pools that serve as exchange facilities. The price of assets is typically determined by the well-known first-generation AMM curve formula x*y=k, pioneered by DEXs like Uniswap v1/v2 (constant product market maker). There are other types of AMMs, such as constant sum market makers, constant mean market makers, and (more generally) constant function market makers, but the concept of maintaining an invariant formula to fairly determine asset conversion ratios is the same.
Here is a simplified example of how AMM pricing works in UniV2 (assuming no fees):
When trading on an AMM, users typically provide liquidity within a specified price range, which can be relatively narrow or span the entire range from 0 to infinity. Regardless of the choice, there is an issue of capital inefficiency:
- For a narrow range, more capital can be utilized when the price is within the range, but the price is only within the range in rare cases;
- For a wide range, capital is dispersed, and most capital cannot be utilized at any given time.
Due to constant price fluctuations, capital on AMMs can only be fully utilized when liquidity providers use a narrow range and frequently update these ranges. However, frequent updates incur significant Gas fees on the Ethereum mainnet, so providers rarely update their ranges.
The result of this capital inefficiency is greater slippage for end users. The larger the trade relative to total liquidity, the greater the slippage, which is also affected by how shallow the liquidity pool is. This can be visually seen in the following chart, which is a typical x*y=k curve: the larger the trade size, the further we move horizontally along the curve, resulting in a flatter diagonal (worse pricing).
For larger trades, more experienced traders often choose CEXs.
(According to CoinMarketCap, as of August 3, 2023, Binance's trading volume for spot trading was over 18.5 times that of UniV3 on Ethereum.)
Lessons from Centralized Exchanges
Centralized exchanges are almost all implemented in the form of limit order books. A limit order book is a list of buy and sell orders arranged by price and time. These orders are executed based on price and time priority, meaning the lowest selling price and the highest buying price are executed first, incentivizing market makers to compete to provide the best prices. This competition results in lower slippage for end users.
Here is an example of an order book for ETH/USDC spot trading on Deribit.
The spreads on the order book can be very small because market makers continuously adjust orders based on supply and demand and new information. This means that market makers are constantly sending a large number of new orders to the exchange throughout the day.
Binance and Coinbase remain the two largest crypto exchanges by spot trading volume, while Deribit is the preferred choice for most institutional crypto options trading.
On-Chain Limit Order Books
For frequent traders, balancing execution quality with the risk of entrusting funds to centralized entities can be tricky.
Decentralized LOBs have the potential to offer the best of both AMMs and centralized exchanges: providing excellent execution quality while retaining user assets.
Currently, the main challenge of implementing LOBs on-chain is the lack of an environment with sufficiently cheap Gas and rich trading. LOBs require cheap and frequent transactions because market makers frequently adjust quotes. Next-generation high-throughput (>2k) blockchains are gradually making fully on-chain LOBs more feasible. This has led to some notable examples of on-chain LOBs, including Econia (Aptos), DeepBook (Sui), and OpenBook/Serum (Solana).
The second barrier to achieving full-capacity LOBs is running LOBs at scale on EVMs. EVM-compatible LOBs can not only provide low-slippage decentralized trading but also offer composability opportunities for a wider range of EVM applications.
Ultimately, if DeFi is to surpass CeFi, it needs to provide a user experience that is comparable to or better than that of CeFi. An important aspect of user experience for traders is execution quality. On-chain LOBs are a key part of narrowing the execution gap between DeFi and CeFi.