Onchain Order Books: Bringing CEX-Grade Trading to DeFi
Learn how onchain order books bring CEX-like performance to DeFi, how teams implement them, and more.

Trading is arguably crypto’s top use case. Centralized exchanges (CEXs) like Binance and Coinbase were first in the category and still lead in overall usage, with the speed and familiar order book experience professional traders expect – but at the cost of trust in a centralized intermediary. Decentralized exchanges (DEXs) emerged in response, with Uniswap’s breakthrough automated market maker (AMM) model allowing for trading without intermediaries.
But now, a new wave of DEXs is bridging the gap between the two models with the onchain order book. Onchain order books aim to combine the high-performance trading functionality of a CEX with the self-custody and trustlessness of a DEX. At Conduit, we’ve seen first-hand the growing interest from teams in putting all trading functionality onchain, as well as the next-gen infra and throughput it requires. Below, we’ll break down everything you need to know about onchain order books.
What is an onchain order book?
An order book is a list of all buy and sell orders for a given asset on a trading platform. Order books are common across all of finance, not just cryptocurrency. Most exchanges, from Coinbase to the New York Stock Exchange, use the central limit order book (CLOB) model, which places all orders in a centralized database, organizes them by price-time priority, and automatically matches overlapping orders.
An onchain order book implements this familiar architecture onchain, rather than in a centralized database. The smart contracts that make up the onchain order book receive buy and sell orders from DEX users, record them onchain, and match orders based on price-time priority.
While the idea is simple, executing it is extremely difficult.
The performance limitations inherent to decentralized networks like Ethereum make it difficult to match orders at the speed and scale of a CEX. Uniswap first addressed the problem with AMMs, which algorithmically price assets based on liquidity pools for pairs of tokens. While AMMs have been highly successful, more sophisticated traders need the ability to submit orders at a range of prices rather than simply execute them at the current algorithmic price, hence why so many teams are exploring onchain order books.
Onchain order book benefits versus CEXs and AMMs
The onchain order book model offers a number of advantages over both the CEX model and the traditional DEX AMM model, though there are tradeoffs as well. We’ll compare onchain order books to both below.
Onchain order books versus CEX order books
The primary advantage over CEXs lies in adherence to DeFi's core principles. With self-custody, traders retain full control over their assets, eliminating counterparty risk from centralized intermediaries. The entire order book and matching process are auditable on the public ledger, providing transparency that’s impossible on traditional exchanges.
All of this contributes to censorship resistance and trustlessness. No single entity can unilaterally block or reverse transactions, and there's also no risk of manipulation by a central operator. For projects targeting institutional users who value neutrality of shared infrastructure, this can be crucial.
Onchain order book versus AMM
Onchain order books provide a more sophisticated trading experience compared to AMMs. For example, an order book supports functionality like limit orders, which allow traders to set desired entry and exit prices – an important trading feature absent in most AMM designs. Transparent order book depth also lets traders gauge market sentiment more effectively and make more informed decisions. Direct order matching can also lead to more efficient execution for large trades, minimizing price impact compared to AMM slippage.
Onchain order books also eliminate impermanent loss. Instead of drawing liquidity from passive liquidity providers as AMMs do, order books draw liquidity from market makers who actively place buy and sell orders and earn on the bid-ask spread rather than pool fees, providing greater capital-efficiency.
Trade-offs of onchain order books
Despite those benefits, onchain order books come with challenges. There’s generally a performance gap compared to CEX order books, as the underlying blockchain’s speed limits the order book’s throughput and latency, whereas the CEX runs on centralized servers. Gas fees can also be significant, particularly on congested networks. We’ll explore these limitations and ways to address them below.
Technical challenges of building an onchain order book
Building a performant onchain order book requires addressing several technical hurdles that can make or break the user experience.
Throughput and latency requirements
Traditional financial markets operate on sub-second timescales. While DeFi hasn't reached that level, users still expect responsive trading. Achieving that with an onchain order book is difficult, as every single component of the trading process, from order to matching to settlement, must be executed as a transaction onchain. Onchain order books therefore demand fast block times and ultra-high throughput. For that reason, most DEXs with onchain order books have launched on dedicated L1 or L2 appchains, though there are exceptions. Other DEXs have pursued a hybrid order book model, in which some components live offchain.
In addition to powerful chain infrastructure, onchain order books demand gas-efficient smart contract design in order to limit costs on all of the transactions the order book carries out in the course of operating.
Complex matching
Running a matching engine onchain can be quite complex. For instance, consider the case of multi-level fills. If someone places a large enough buy order, there may not be enough liquidity at the best price to fill the entire order. Instead, the exchange must execute the order against multiple sells at progressively worse prices – a process known as "walking the book." On a CEX, this happens instantly on centralized infrastructure. For a DEX with an onchain order book, each fill requires updating the order book state, transferring assets between parties, calculating weighted average prices, and potentially triggering cascading orders, all in one transaction. This computational complexity can result in large gas costs, which is why many DEX order books adopt a hybrid model with offchain matching and onchain settlement (more on this later).
MEV risk
MEV also poses fairness concerns. Public mempool exposure can lead to front-running and other UX-negative forms of MEV. Mitigation strategies include:
- Frequent batch auctions, which match orders in discrete time and clear at a uniform price so that arrival time doesn’t confer advantage
- Private mempools to keep trades hidden until inclusion
- Consensus-level transaction ordering rules that can reduce reorder incentives
Storage and scalability
Order books create lots of state growth: open orders, queues per price, fill accounting, and more. Operators can mitigate this in a few ways. For instance, they can use parallel execution to have their order book maintain state separately for different assets, and can employ gas-efficient data structures to reduce computational work per trade.
Onchain order book examples
Below are a few examples of DEXs with onchain order books operating today.
Hyperliquid runs a perps DEX with a fully onchain order book on a custom-built L1 chain. Hyperliquid’s sub-second finality and gasless trading has made it one of the most popular perps platforms for traders in a short time since launch.
Orderly Network is a trading and liquidity infrastructure provider supporting DEXs across several different chains, all powered by its own OP Stack chain built with Conduit. Orderly uses a hybrid order book model, in which all orders are visible onchain, but matching occurs offchain.
dYdX v4 is another perps DEX operating as a sovereign appchain in the Cosmos ecosystem, with a hybrid order book model. While the order book and matching engine are offchain for higher performance, they’re decentralized in that the chain’s validators run matching deterministically.
OpenBook is an onchain order book powering several DEXs on Solana, and one of the few examples of an onchain order book operating as a protocol on a shared L1 chain.
The future of trading is onchain
Onchain order books are a significant evolution for DeFi, blending the speed and trading experience of a CEX with the transparency and self-custody of a DEX. With the right infrastructure, partners, and community incentives, this model is now within reach as a viable business model for more teams – but most will need their own dedicated chain. Reach out to Conduit to start building that chain today.