On an order book (CLOB), you trade against other traders’ bids and asks at prices you can see before you click; on an AMM (automated market maker), you trade against a liquidity pool that prices every trade with a formula. That single difference, who your counterparty is, decides what a trade costs: the pool’s price moves against you roughly in proportion to your size ÷ the pool’s depth, while a book charges the spread plus a fee until you run through the visible orders.
| Order book / CLOB Hyperliquid, Lighter | AMM Uniswap | Oracle-priced pool GMX | |
|---|---|---|---|
| Your counterparty | Other traders’ and market makers’ resting orders | The pool: liquidity providers’ deposits, priced by x × y = k | The GM liquidity pool, at the oracle price |
| Price impact, $1M ETH buy (October 19, 2026) | Hyperliquid ≈ 0.015% (0.06% with the taker fee); Lighter ≈ 0.016%, no fee on Standard | ≈ 10.3% incl. the 0.30% fee in a $19.9M Uniswap v2 pool; deeper v3 pools cost less, an aggregator splits the order | None at entry; a net price impact is charged on close, capped at 0.5% on ETH |
| Trading fees | Hyperliquid 0.045% taker / 0.015% maker (tier 0); Lighter Standard 0% / 0% | One swap fee: 0.30% on Uniswap v2, 0.01%–1% tiers on v3 | 0.04% or 0.06% position fee on open and close, plus borrow and funding fees |
| MEV / sandwich exposure | No sandwich: a limit order cannot fill worse than its price; ordering rules are fixed (Hyperliquid processes cancels before new GTC/IOC orders, Lighter proves its FIFO matching) | Highest: a swap on a public mempool can be sandwiched up to your slippage tolerance | No curve to push; the risk moves to the oracle and the keeper delay |
| Order types | Market, limit, post-only, stop, TP/SL, TWAP | A swap with a slippage limit (range orders on v3/v4) | Market, limit and TP/SL, executed at the oracle price |
| Best for | Perps, active trading, large size | One-off swaps, new and long-tail tokens | Simple leveraged bets on a few majors |
| Examples | Hyperliquid, Lighter, dYdX, Aster Pro | Uniswap, Curve, PancakeSwap, Raydium | GMX, Jupiter Perps |
Fees from each venue’s fee page (registry). The $1M figures are our simulations on public data read October 19, 2026, 06:06 UTC: DefiLlama for the Uniswap v2 USDC-WETH pool on Ethereum, the Hyperliquid l2Book and Lighter orderBookOrders endpoints for the ETH perps. GMX mechanics from docs.gmx.io. Depth changes by the second.
Short answer with real numbers. On October 19, 2026, 06:06 UTC, a $1M ETH buy cost about 10.3% in a $19.9M Uniswap v2 pool, but about 0.06% all-in on Hyperliquid’s order book (roughly 172 times cheaper) and about 0.016% on Lighter’s, which charges no fee on Standard accounts. That is why one-off swaps and long-tail tokens live on AMMs and almost all perpetual futures volume lives on order books, and why sandwich attacks are an AMM problem. Full comparison table · which one to use.
Trade on the deepest on-chain order book
Hyperliquid runs a fully on-chain CLOB with no gas on orders. Join with HOLYGRAIL for 4% off fees on your first $25M of volume.
We earn a commission when you sign up through our links; it never raises your fees.
1. What is an order book (CLOB)?
An order book is the live list of every open buy order (bids) and sell order (asks) in one market, sorted by price. A central limit order book (CLOB) is the version almost every exchange runs: one shared book per market, limit orders rest in it at the price their owner chose, and a matching engine fills each incoming order against the best price first and, at the same price, the oldest order first. That is price-time priority. Binance, Coinbase and virtually every other centralized exchange work this way, and so do the order-book DEXs: Hyperliquid, Lighter, dYdX and Aster’s Pro mode.
How an order book works
- Makers post limit orders that rest on the book (“I will sell 1 ETH at $2,700”). They supply the liquidity.
- Takers send market orders, or limit orders that cross the spread, and fill immediately against the best resting orders. They consume the liquidity.
- The highest bid and the lowest ask form the top of the book; the gap between them is the spread, and a market order that is larger than the best level “walks” down the book to worse prices.
- Fees follow the same split: makers pay less than takers, and on some venues large makers are paid a rebate.
What an order book tells you
The book shows the price and size at which people are willing to trade right now: the spread is the cost of trading immediately, the size stacked near the price (the depth) tells you how large a market order can be before it moves the price, and the number of orders per level separates a crowd from one large player. It is a snapshot of intentions, which can be cancelled. The order flow, the orders that actually arrive and trade (the trades tape), shows what people are doing. Section 10 reads a real Hyperliquid BTC book level by level.
Order book: pros
- Tight spreads where market makers compete: one $1 tick on BTC, about 0.12 basis points, in our September 25 snapshot.
- Real order types: limit, post-only, stop, TP/SL, TWAP.
- Cheaper to add liquidity than to take it (maker/taker pricing), with rebates for top makers.
- You see the depth and your likely fill before you trade; a limit order never fills worse than its limit.
- Depth grows with market-maker competition, not with how much capital is parked in a pool.
Order book: cons
- Needs active market makers; a thin market has a wide spread or an empty book.
- Every order and cancel is a state update, so it needs a fast chain, an app-chain or a verified off-chain matcher.
- You trust whoever sequences orders (validators or a sequencer) to order them fairly.
- Listing is controlled by the venue; brand-new tokens usually start elsewhere.
- Quotes can be pulled instantly, so depth can vanish in a crash.
2. What is an AMM?
An automated market maker (AMM) replaces the book with a smart contract that holds two (or more) tokens, the liquidity pool, and a pricing formula. Anyone can deposit both tokens and become a liquidity provider (LP); traders swap against the pool; and after every trade the formula moves the price, because the pool now holds more of what you paid in and less of what you took out. In Uniswap’s classic constant-product pool the rule is x × y = k, and the price is simply the ratio of the two reserves (the math is in section 6). A swap fee on each trade is paid to the LPs. Uniswap, Curve, PancakeSwap, Aerodrome and Raydium are AMMs.
AMM: pros
- Always a quote, at any size, with no market maker needed.
- Permissionless: anyone can create a pool for any token, so new and long-tail tokens trade from day one.
- Simple: one transaction, choose an amount and a slippage limit.
- Passive income for LPs from the swap fee.
- Composable: other contracts and aggregators can swap through it in the same transaction.
AMM: cons
- Price impact grows with size ÷ pool depth: the $1M example costs about 10.3% (October 19, 2026).
- Capital-inefficient on plain x × y = k; concentrated liquidity fixes that at the cost of active management.
- LPs suffer impermanent loss and lose to arbitrageurs when prices move.
- Swaps on a public mempool can be sandwiched, up to your slippage tolerance.
- No native limit, stop or take-profit orders, plus smart-contract and fake-token risk.
3. Order book vs AMM: key differences
If you are new to DEXs, start with What is a DEX?, which covers wallets, custody and first steps. The table puts the two models (CLOB vs AMM) side by side; the fee figures come from the venues’ fee pages and the cost figures from our dated snapshots below.
| Order book (CLOB) | AMM | |
|---|---|---|
| Your counterparty | Other traders and market makers | The pool (liquidity providers’ deposits) |
| How the price is set | The best resting bid and ask; orders match in price-time priority | A formula over the pool’s reserves (x × y = k); arbitrageurs keep it in line with other markets |
| Where liquidity comes from | Market makers posting limit orders at prices they choose | LPs depositing both tokens of a pair |
| Price discovery | Happens on the book, quote by quote | Mostly imported: arbitrage pulls the pool toward prices set elsewhere |
| Order types | Market, limit, post-only, stop, TP/SL, TWAP | A swap at market with a slippage limit (range orders on Uniswap v3/v4) |
| Fee model | Maker/taker: Hyperliquid 0.015% / 0.045% at tier 0 (rebates for top makers), Lighter Standard 0% / 0% | One swap fee per trade, paid (mostly) to LPs: 0.30% on Uniswap v2, 0.01%–1% tiers on v3 |
| Cost of a large trade | Flat until you run through the visible depth, which you can see first | Roughly your size ÷ the pool’s reserve: ~10.3% for $1M in a $19.9M pool (October 19, 2026) |
| Capital efficiency | High: quotes sit at the current price | Low on plain x × y = k; better with concentrated liquidity |
| Who can list a market | The venue (or a staked deployer, e.g. Hyperliquid HIP-3) | Anyone can create a pool for any token |
| What it needs to run | High throughput: an app-chain, a rollup or a verified off-chain matcher | Any smart-contract chain; one transaction per trade |
| Main risks | Thin books in stress, quotes pulled instantly, trust in whoever sequences orders | Price impact, sandwich MEV, impermanent loss for LPs, contract and token scams |
| Best suited for | Perpetuals, active trading, large size, majors | One-off swaps, new and long-tail tokens, passive LPs |
| Where it is used | Every major CEX; Hyperliquid, Lighter, dYdX, Aster Pro | Uniswap, Curve, PancakeSwap, Aerodrome, Raydium |
4. Which should you use?
Go down the list and stop at the first line that fits your trade:
- Trading perpetual futures or using leverage? An order book: Hyperliquid or Lighter. Perps need stops, liquidations and funding, and on a deep book the spread is a fraction of a basis point.
- Moving $100k or more in one go? An order book, or a TWAP on one. On October 19, 2026 a $1M ETH buy cost about 0.06% all-in on Hyperliquid against about 10.3% in a $19.9M Uniswap v2 pool. If you must use a pool, an aggregator splits the order across deeper pools.
- Need limit, stop-loss, take-profit or TWAP orders? An order book. AMMs only offer a swap with a slippage limit.
- Swapping a token you hold for another, once, at small size? An AMM or an aggregator, with slippage set by hand and MEV protection on (the sandwich checklist). At small size the pool fee is the whole cost.
- Buying a brand-new or long-tail token? An AMM: no market maker quotes it, so it only exists in a pool. Check the contract address first; permissionless listing means fake tickers.
- Swapping stablecoin to stablecoin? A stable-curve AMM (Curve) or a concentrated pool built for pegged pairs.
- Earning passive yield? An AMM LP position (fees minus impermanent loss) or an order-book venue’s vault such as HLP (market-making PnL, with a lock-up). See LP economics.
For perpetual futures the choice is really between order books. Hyperliquid has the deepest book and a long market list; Lighter charges 0% on Standard accounts and proves its matching on Ethereum; dYdX is a fully validator-run chain. The live volume league table is on the perp DEX ranking, the buyer’s guide on best DEXs in 2026, and the fee comparison with Binance and Bybit in DEX vs CEX fees. For a first trade, follow how to use Hyperliquid; every fee tier is in Hyperliquid fees explained.
Verdict: swap on an AMM, trade perps on an order book
Most traders use both: an AMM or an aggregator for the occasional token swap, an order-book DEX for anything leveraged, large or frequent. For the order book, Lighter Standard costs 0% / 0% (code 718610TD gets you the first week of Premium fees rebated if you upgrade, open Lighter), and Hyperliquid has the deepest on-chain book at 0.045% taker / 0.015% maker, minus 4% on your first $25M of volume with HOLYGRAIL.
5. Why DeFi started with AMMs, and why perps moved to order books
On Ethereum mainnet every action is a transaction that costs gas and waits for a block. A market maker cancels and replaces quotes every time the price moves, so a fully on-chain order book would have charged makers for every requote and left them too slow to avoid being picked off by faster traders. The result was wide spreads and empty books. An AMM sidesteps the problem: there is no market maker to pay, one transaction per trade is enough, and the formula requotes automatically after each swap. That is why the first wave of DeFi trading went to pools such as Uniswap and Curve, and on-chain order books stayed a niche.
Two things changed. First, throughput: chains built for trading made placing and cancelling orders cheap or free. Hyperliquid runs its own layer 1 in which the book is chain state and orders cost no gas; dYdX runs its own Cosmos chain; Lighter matches on a sequencer and proves every batch on Ethereum (section 9). Second, perpetual futures: leverage multiplies trading costs, so a perp trader who turns over their account many times cares about the gap between a fraction of a basis point and a percent, and needs stops, liquidations and funding that a simple swap pool does not offer. Perps therefore moved to order books, while spot swaps of long-tail tokens stayed on AMMs.
Are AMMs replacing order books?
No, and order books are not replacing AMMs either. The two designs are converging. Uniswap v3 and v4 let LPs place liquidity in narrow ranges, which behave like limit orders. Hyperliquid’s HIP-2 runs a formula-driven market maker that places orders on its spot book. Jupiter, whose main perps use a pool, launched its newer Beta perp markets on an order-book engine. Each model is winning the trades it is built for.
6. How an AMM prices a trade: x × y = k
A Uniswap-style pool holds two tokens, say x ETH and y USDC. Uniswap’s docs describe the rule: the pool “prices tokens algorithmically using a constant product formula”, x × y = k, where k “must stay constant (or increase) after every trade”. The current price is simply the ratio of the reserves, y ÷ x.

When you buy ETH with Δy USDC, the pool must keep the product constant, so it pays out
ETH received = x × Δy ÷ (y + Δy)
That gives two rules of thumb you can apply to any constant-product pool (before the pool fee):
- Your average price is worse than the quoted price by Δy ÷ y, i.e. your trade size divided by the pool’s reserve on the side you pay in. Trade 1% of that reserve and you pay about 1% more than the spot price.
- The pool’s price after your trade moves by about twice that, (1 + Δy ÷ y)² − 1. Arbitrageurs then trade it back toward the market price and keep the difference, which is part of how LPs lose money (section 14).
The pool fee is added on top: 0.30% on every Uniswap v2 pool; 0.05%, 0.30% or 1% on standard v3 pools (plus a 0.01% tier); and any level the pool creator chooses on v4. The fee goes to liquidity providers, minus a protocol share on some pools.
7. Worked example: $10k, $100k and $1M ETH buys
Real pool, real books, same minute. At October 19, 2026, 06:06 UTC, DefiLlama listed the Uniswap v2 USDC-WETH pool on Ethereum with $19.9M of liquidity, so roughly half of that in USDC on the side you pay into. Hyperliquid’s ETH perp had a mid price of $2,432.85, a $0.10 spread and $9.5M of asks within 0.080% of mid on its 20 best levels; Lighter’s ETH perp showed $24.3M on its 250 best asks. We simulated market buys against all three.
| Buy size | Uniswap v2 pool: cost vs spot, incl. 0.30% fee | Hyperliquid book: cost vs mid, incl. 0.045% taker fee | Lighter book (Standard, 0% fee): cost vs mid | How far the v2 pool price moves |
|---|---|---|---|---|
| $10,000 | ≈ 0.40% | ≈ 0.047% | ≈ 0.004% | 0.2% |
| $100,000 | ≈ 1.30% | ≈ 0.047% | ≈ 0.007% | 2.0% |
| $1,000,000 | ≈ 10.34% | ≈ 0.060% | ≈ 0.016% | 21.0% |
October 19, 2026, 06:06 UTC. Pool: DefiLlama yields API, Uniswap v2 USDC-WETH (Ethereum), split 50/50, constant-product math with the fee on the input. Books: Hyperliquid l2Book ETH (20 levels) and Lighter orderBookOrders ETH (250 asks), walked level by level. Gas, funding and the book changing during execution are ignored. A snapshot, not a guarantee: depth changes by the second.
Earlier snapshots, same method: on September 25, 2026 the pool held $20.89M and a $1M buy cost about 9.9% against about 0.08% on Hyperliquid; on September 26 it was 9.8% against 0.05%. The ratio has stayed in the hundreds: on October 19, 2026 the pool was about 172 times more expensive than Hyperliquid’s book for the same $1M.
Three lessons follow. First, at small size both are cheap and the fee dominates: 0.30% on the pool versus 0.045% plus a sliver of spread on Hyperliquid, and almost nothing on Lighter Standard. Second, AMM cost grows linearly with size while a deep book stays nearly flat until you exhaust the visible levels. Third, nobody sensible routes $1M through a v2 pool: an aggregator would split it across deeper concentrated-liquidity pools and other venues. The point is structural. A pool’s depth is fixed by how much capital LPs have parked; a book’s depth is set by how many market makers compete to quote, and on a busy perp market that is far more.

8. Concentrated liquidity (Uniswap v3 and v4)
The flaw in plain x × y = k is that liquidity is spread across every price from zero to infinity, and most of it never trades. Uniswap’s docs give the example of the v2 DAI/USDC pair, which used only about 0.50% of its capital for trading between $0.99 and $1.01, where almost all the volume happens.
Uniswap v3 (and v4, which keeps the same implementation) lets each LP choose a price range. The price space is cut into ticks, each a 0.01% price step; a position is active only while the price is between its lower and upper tick. Within the active range the pool behaves like a much bigger constant-product pool, so traders get deeper liquidity near the mid and LPs earn more fees per dollar.
The numbers show the effect. On September 25, 2026 DefiLlama showed the v3 0.05% USDC-WETH pool on Ethereum turning over $56.7M a day on $99.1M of liquidity (0.57× its TVL), while the v2 pool turned over $0.83M on $20.9M (0.04×). Traders route to where the depth near the price is.
The costs are real, though:
- Out of range = no fees. The docs are explicit: when the price exits a position’s interval, “the position’s liquidity is no longer active and no longer earns fees”, and the position ends up holding only one of the two tokens.
- Active management. Narrow ranges earn more but need re-centering, which costs gas and realises the loss.
- Amplified impermanent loss. Concentrating capital concentrates the loss from price moves inside the range as well.
Concentrated liquidity also blurs the line with order books: a very narrow range just above the current price behaves like a sell limit order (Uniswap calls this a range order). An order book is, in a sense, the limit of that idea: every maker chooses exactly one price.
9. How order-book DEXs match orders: Hyperliquid, Lighter, dYdX
Every order-book DEX has to answer two questions a centralized exchange never faces: where does the book live, and who decides the order in which orders arrive. The designs below answer them differently.
| Venue | Where it runs | How matching works | What is on-chain / provable | Who orders transactions |
|---|---|---|---|---|
| Hyperliquid | Own L1 (HyperCore) | Every validator runs the book as part of consensus state | Book, margin and liquidations are on-chain state; cancels are processed before new GTC/IOC (taker) orders inside each block | HyperBFT validator set |
| Lighter | Ethereum zk-rollup | A sequencer matches first-in-first-out; a prover generates ZK proofs that Ethereum verifies | Matching and liquidations are provable; an escape hatch on Ethereum lets you exit if the sequencer stops | Sequencer ordering (execution is verified) |
| dYdX | Own Cosmos L1 (dYdX Chain) | Validators keep the book in memory, “off chain and not committed to consensus”; the block proposer matches | Matched trades settle on-chain when 2/3 of stake commits the block | Proposer of each block |
| Aster | Own L1 (Aster Chain) | Order book (Pro mode), with optional encrypted hidden orders | Also offers an AMM-style Shield Mode | Aster’s own validators (no external validators in its first phase) |
Hyperliquid: the book is the chain state
Hyperliquid’s docs describe HyperCore state as including “an order book for each asset”, working “similarly to that of centralized exchanges”, with orders “matched in price-time priority”. Margin checks happen when an order is placed and again for the resting side at the moment of matching. The unusual part is that the mempool and consensus are aware of order-book transactions: within each block, actions that send no GTC or IOC order (post-only orders among them) go first, then cancels, then actions that send GTC or IOC orders. Processing cancels before new takers protects market makers from being picked off on stale quotes, which is one reason makers can quote tight spreads. As of October 20, 2026 the API showed 178 live perp markets, $4.03B of 24-hour volume and $11.05B of open interest. More: Hyperliquid review, order types.

Lighter: an off-chain matcher you can verify
Lighter takes the opposite route. A sequencer orders transactions first-in-first-out and executes them at low latency; a prover then generates succinct proofs of every batch, and smart contracts on Ethereum verify each proof before updating the state root. If the sequencer ignores exit requests submitted on Ethereum within the deadline, Escape Hatch mode freezes the contract and users withdraw with proofs built from the data Lighter posted to Ethereum. You trust the operator for liveness and ordering, not for correct execution. Standard accounts pay 0% maker and 0% taker. More: Lighter review, Hyperliquid vs Lighter.
dYdX: an in-memory book on every validator
dYdX Chain is a Cosmos SDK L1. Its docs say validators store orders “in an in-memory orderbook (i.e. off chain and not committed to consensus)” and gossip them to each other. The validator chosen as block proposer matches crossing orders and puts the fills in its proposed block, which is committed once validators with two-thirds of the stake approve. Only fills and settlement are on-chain; the resting book is not. Base fees are 0.050% taker and 0.010% maker. More: dYdX review, Hyperliquid vs dYdX.
10. How to read and trade an order book
If you trade perps on a DEX you will be looking at a book, so here is how to read one, using a real snapshot of Hyperliquid’s BTC perpetual pulled from the public l2Book endpoint at 17:19:49 UTC on September 25, 2026.
| Side | Price (USD) | Size (BTC) | Orders at level |
|---|---|---|---|
| Ask 3 | 83,902 | 0.870 | 2 |
| Ask 2 | 83,899 | 0.031 | 2 |
| Best ask | 83,898 | 4.274 | 30 |
| Best bid | 83,897 | 0.730 | 9 |
| Bid 2 | 83,896 | 0.052 | 1 |
| Bid 3 | 83,895 | 0.004 | 1 |
Source: Hyperliquid API l2Book for BTC, full precision, top 3 of 20 levels per side, 17:19:49 UTC September 25, 2026. The “orders” column is the API’s n field.
Bid, ask, spread and mid
Bids are resting buy orders, asks resting sell orders. The best bid (83,897) and best ask (83,898) form the top of book; their difference is the spread, here one $1 tick or about 0.12 basis points; their average is the mid, 83,897.5. A market buy pays the ask, a market sell receives the bid. Read spreads in basis points so you can compare markets: under 1 bp (BTC, ETH in normal conditions) the spread is noise next to the fee; when it grows wider than the 4.5 bps taker fee, liquidity has stepped away, usually around news or liquidation cascades, and a limit order is the better tool.
Depth: how much the market can absorb
The API returns at most 20 levels per side; at $1 ticks that covered only $83,878–$83,919 on BTC, with $3.67M of asks and $2.49M of bids. For a wider view, the nSigFigs parameter aggregates levels (2 to 5 significant figures). With 4 significant figures ($10 buckets, 17:20:19 UTC) the book held roughly $9.3M of asks and $8.2M of bids within 0.05% of mid, and $26.4M / $23.5M within 0.1%. Walking the raw ask side, a $10,000 or $100,000 market buy would have filled entirely at the best ask (0.06 bp above mid, the half-spread) and a $1M buy would have averaged about 0.67 bp above mid, roughly $67 of price impact against a $450 taker fee. On BTC, below seven figures, the fee is the cost; on a thin altcoin the order is reversed. A practical rule from this: keep a market order to a small fraction of the depth within 0.1% of mid, and use limit orders, a scale ladder or TWAP beyond that.
Maker vs taker
An order that rests on the book and is filled later is a maker order; one that crosses the spread and fills immediately is a taker. On Hyperliquid tier 0 that is 0.015% vs 0.045%, so on a one-tick book “buying the bid” means joining the bid and waiting, which costs a third of the fee but may not fill. Use the ALO (post-only) time-in-force when you want to be sure you never pay taker: the order is rejected instead of crossing. On Lighter’s Standard account both sides are 0%, so the spread is the only cost of crossing.
Queue priority
Matching is price-time priority: a better price always fills first, and at the same price the earlier order fills first. The 4.27 BTC at the best ask above is a queue of 30 orders; a new sell at 83,898 joins the back of it. Improving the price by one tick puts you at the front of a new level. Hyperliquid adds one twist: inside each block, actions without GTC/IOC orders (post-only orders among them) go first, then cancels, then GTC/IOC orders, so a maker can pull a stale quote before a taker in the same block hits it. The docs’ latency notes put cancel/ALO end-to-end latency at about 380 ms.
Reading the book without fooling yourself
- Look at the
nfield. 4.27 BTC from 30 orders is a crowd; the same size from one order is one decision that can be cancelled in one action. - Walls are free to pull. There is no gas per order or cancel, and cancels are processed before takers, so a large resting order is only meaningful once it has absorbed trades in the tape without price moving through it.
- Imbalance is a filter, not a signal. Imbalance = (bid size − ask size) ÷ (bid size + ask size) over a fixed window, from −1 (only sellers) to +1 (only buyers). At 17:19:49 the 20 visible levels held $2.49M of bids against $3.67M of asks, an imbalance of about −0.19; that kind of reading changes within seconds as market makers requote, so only a sign that holds over many consecutive snapshots means anything.
- Pull it yourself. POST
{"type": "l2Book", "coin": "BTC"}tohttps://api.hyperliquid.xyz/info(no API key). The response’slevelsfield holds two lists, bids then asks (with atimestamp alongside), each level withpx(price),sz(size in coins) andn(number of orders). Multiplysz×pxbefore adding levels up, and add"nSigFigs": 4for the aggregated view used above. - Stream it for anything timing-sensitive. The WebSocket
l2Booksubscription pushes the book on changes; polling REST snapshots is too slow for signals. See the WebSocket guide.
More on execution cost: price impact and slippage on Hyperliquid and DEX speed and fill quality.
11. Oracle-priced pools: the third model for perps
Perpetual DEXs that do not run a book usually do not use x × y = k either. They use a pool as the counterparty and an oracle for the price. Jupiter Perps is the largest example on Solana: traders borrow from the JLP pool, trades on SOL, ETH and wBTC execute at the oracle price “without orderbook slippage”, and a price impact fee replaces the slippage a book would have charged. The pool earns 75% of the fees and wins when traders lose. The trade-offs are an hourly borrow fee, a small set of markets and a dependence on oracle quality. We compare it directly with Hyperliquid in Hyperliquid vs Jupiter Perps, and the older GMX version in Hyperliquid vs GMX.
All three designs side by side:
| AMM (e.g. Uniswap) | Order book / CLOB (e.g. Hyperliquid) | Oracle-priced pool (e.g. Jupiter Perps) | |
|---|---|---|---|
| How a price is set | A formula over pool reserves (x × y = k, or a curve inside a range) | The best resting bid and ask; trades match in price-time priority | An external oracle price, plus a size-based impact fee |
| Who is your counterparty | The pool (liquidity providers) | Other traders and market makers | The pool (e.g. JLP, GLP-style) |
| Cost of a small trade | Pool fee (e.g. 0.05%–0.30%) + tiny impact | Half the spread + taker fee (0.045% on Hyperliquid, 0% on Lighter Standard) | Open/close fee (0.06% on Jupiter) + borrow fee while open |
| Cost of a large trade | Rises fast: impact grows with size ÷ pool depth | Depends on visible depth; you can see it before you trade | Capped impact fee, but position size limited by pool liquidity |
| Limit orders | Not native (range orders approximate them) | Native: limit, post-only, stops, TWAP | Oracle-triggered limit and TP/SL orders |
| Who can list a market | Anyone can create a pool | The venue (or a staked deployer, e.g. Hyperliquid HIP-3) | The venue |
| Typical use | Token swaps, long-tail tokens | Perpetuals, active trading, large size | Simple leveraged bets on a few majors |
Telling detail: Jupiter’s newer “Beta” perp markets (JUP, HYPE, ZEC and stock perps, open to any wallet since the JUP-stake gate was dropped) do not use the pool at all. The docs say they are “powered by GUM, an orderbook trading engine”, with maker and taker fees and hourly funding. Even pool-first venues reach for an order book when they add markets.
12. Hybrids: AMM + order book
- Velocity (formerly Drift, Solana). Drift’s relaunch runs at app.velocity.exchange, and Velocity’s docs call it a fork of Drift v2. A taker order first opens a short just-in-time auction for market makers; then the program walks crossing maker orders from its decentralized limit order book (an off-chain view of orders stored on-chain) and lets its own virtual AMM fill whatever is left, or step in wherever it prices better than a maker. Its docs say a PropAMM + CLOB redesign is in progress and not live yet.
- Hyperliquid HIP-2 (Hyperliquidity). A formula-driven strategy, built into the chain with no operator, that places orders on the spot order book of newly deployed tokens: levels 0.3% apart, updated no more than once every 3 seconds. It gives thin tokens AMM-like “always a quote” liquidity without leaving the book.
- Aster. A product-level hybrid: its Perpetuals (Pro) mode is an order book, while Shield Mode is a simplified AMM-style interface for private, high-leverage trades. See the Aster review.
- Aggregators. Jupiter swap, 1inch and CoW Swap route a spot swap across many AMMs and, where available, RFQ market makers. They are the practical way to get order-book-like prices on an AMM chain.
13. Sandwich attacks: the AMM-only risk
A sandwich attack is a bot buying just before your AMM swap and selling just after it, so you fill at a worse price and the bot keeps the difference. It needs two things: a pending transaction others can see, and a price curve that your own trade moves in a predictable way. An AMM swap on a public mempool offers both. An order book offers neither in that form: you trade against resting orders at stated prices, and a limit order cannot fill worse than its limit. That is why sandwiches are an AMM problem, and why the defences below are mostly about swaps.
How a sandwich works
When you submit a swap you also sign a minimum output, your slippage tolerance. If the transaction is visible before it is included in a block, a searcher bot can:
- Front-run: buy the token you are buying, placing its transaction just before yours. The pool price rises.
- Let your swap execute at the higher price, still inside your slippage tolerance, so it does not revert.
- Back-run: sell right after you, into the price your trade pushed up.
The bot sizes its front-run so your swap lands just above your minimum output, so the tolerance you set is the budget you hand to the attacker. The same traits show up in every study of who gets sandwiched: a large swap relative to the pool, a loose slippage tolerance, a thin or low-fee pool, a transaction visible in a public mempool, and flow that repeats on a schedule. Memecoin buys tick most of those boxes at once.
A real case: jaredfromsubway.eth. The best-known sandwich bot on Ethereum was measured by the MEV analytics firm EigenPhi. Between February 27 and May 8, 2023 it made 238,000 sandwich attacks on more than 106,000 victims, earning $40.65M in revenue, paying about $34.35M in gas and keeping roughly $6.3M (EigenPhi, May 10, 2023). The gas bill shows why sandwiches concentrate on trades with room to take: the bot needs your slippage to pay its own costs.
Worked example: a $100,000 ETH buy
Same Uniswap v2 USDC-WETH pool as in section 7 ($19.9M, 0.30% fee, ETH at $2,432.85, October 19, 2026). Without an attacker, a $100,000 buy receives about 40.57 ETH, 1.30% worse than spot (price impact plus the fee). Now add a bot that front-runs exactly enough to push you to your minimum output:
| Your slippage tolerance | Bot’s front-run | Extra cost to you | Bot’s gross profit |
|---|---|---|---|
| 0.1% | $5,016 | $99 | $70 |
| 0.5% | $25,156 | $494 | $352 |
| 1% | $50,502 | $987 | $703 |
| 3% | $153,838 | $2,961 | $2,104 |
Our arithmetic on the October 19, 2026 pool size: constant-product pool, 0.30% fee on each leg, before gas and builder tips. The gap between your loss and the bot’s profit goes to liquidity providers as fees.
- Your loss scales with your tolerance. Moving from 3% to 0.5% cuts the damage from about $2,961 to about $494 on the same trade.
- Small swaps in high-fee pools are poor targets. Repeating the simulation for a $10,000 swap, the bot loses money at every tolerance from 0.1% to 3%, because it pays the 0.30% pool fee on both legs. Low-fee pools (0.05%, 0.01%) and large swaps are where sandwiches pay.
- Gas and tips cut into the bot’s margin, which is why sandwiches cluster on large trades, thin pools and loose tolerances.
Sandwich and MEV protection checklist (anti-MEV settings)
- Set slippage by hand, and tight. Around 0.5% or lower on majors, 0.1% or less on stablecoin pairs. If a swap fails, wait or split it instead of raising the tolerance: EigenPhi documented jaredfromsubway.eth catching traders within a few blocks after they retried a failed memecoin swap with a looser minimum (EigenPhi, July 2023).
- Turn on MEV protection (a private RPC). MetaMask’s protection is automatic and free for Ethereum transactions on its default Infura RPC and for all Solana transactions (and BNB Smart Chain with Smart Transactions on); in other wallets add
https://rpc.flashbots.net/fast(Flashbots Protect, hidden “from frontrunning and sandwich bots”) orhttps://rpc.mevblocker.io(MEV Blocker, which pays you 90% of the back-run profit), chain ID 1. On BNB Chain, PancakeSwap MEV Guard ishttps://bscrpc.pancakeswap.finance, chain ID 56. In MetaMask a custom RPC overrides Smart Transactions, so use one or the other. - Route larger swaps through an intent router. CoW Swap settles batches at one uniform clearing price, 1inch Fusion lets resolvers compete in a Dutch auction, and UniswapX has solvers fill your signed order (Uniswap’s API uses it above 300 USDC or when it quotes at least 0.2% better). You never broadcast a raw swap, but the worst price you sign is still your worst price.
- On Solana, use a router with protected landing (Jupiter Ultra) and switch on your trading bot’s Anti-MEV setting. Developers can add a
jitodontfrontaccount so Jito’s block engine rejects bundles that put anything before the transaction. - Split size, prefer deep pools, and do not repeat the same trade on a timer. Predictable flow is easy to hunt.
- For leverage, use an order-book venue. Limit and Post Only orders cap your price; lower Hyperliquid’s 8% default max slippage on market orders in thin markets (Hyperliquid slippage and price impact settings). Trade perps on Hyperliquid’s order book with code HOLYGRAIL for 4% off fees.
Should MEV protection stay on? Yes, for nearly every swap. Infura says its protection adds on average 1 extra slot and hands a transaction that nobody picks up within 2 slots back to the public mempool; MetaMask itself says protection “is not always guaranteed”. You also trust a relay and its builders with your transaction. Those costs are small next to the table above.
How protected is “protected”?
A September 2026 paper, “No Place to Hide: An Analysis on Protected Order Flow Sandwich Attacks” (arXiv 2609.28115), measured sandwiches against transactions that were supposed to be protected, from July 2023 to June 2026. On Ethereum it found 30,607 sandwiches on protected order flow, by 7 bots, with order-flow auctions the main leak; on Solana, 28.0 million sandwiches by 8,631 bots worth $383.4M gross, concentrated on a few trading front-ends and Telegram bots; on Base 1,889; on Arbitrum none. A few tens of thousands of attacks over three years on Ethereum’s protected flow is far less than the public mempool, so private RPCs remain worth using, but tight slippage stays your hard limit.
Why order-book DEXs are not sandwiched
- Order book: no sandwich in that form. A limit order cannot fill worse than its limit, so there is nothing to squeeze. A market order on a book still has a maximum-slippage setting, but moving a deep book costs the attacker real money. The remaining question is sequencing: who decides whether your order or someone else’s lands first. Hyperliquid answers with deterministic in-block ordering (cancels before new GTC and IOC orders), Lighter with a first-in-first-out sequencer whose execution is proven on Ethereum, dYdX by letting the proposer of each block do the matching. Speed is still for sale on Hyperliquid (IOC orders can pay a priority fee), so a paying taker can reach the same resting liquidity first; a limit order caps your price regardless.
- Oracle-priced pools: no book to front-run, but oracle risk. You trade at the oracle price, so a sandwich cannot move your fill. The attack surface moves to the oracle (stale or manipulated prices) and to the delay between your request and the keeper’s execution; GMX’s docs say its slippage setting only has to cover that oracle move.
| Where you trade | Sandwich exposure | What to do |
|---|---|---|
| Uniswap, PancakeSwap, Raydium (AMM swap) | High for large swaps with loose slippage | Tight slippage, private RPC or an intent router |
| CoW Swap, UniswapX, 1inch Fusion (intents) | Low: you never broadcast a raw swap | Still set a sensible limit; solvers can fill at your worst price if the market moves |
| Hyperliquid (on-chain order book) | No pool to push; cancels are processed before new GTC/IOC (taker) orders in each block | Limit or Post Only orders; lower the 8% default max slippage on market orders |
| Lighter (zk-rollup order book) | No public mempool; FIFO sequencer; matching proven on Ethereum | Limit orders (0% fees on Standard remove the reason to take) |
| GMX, Jupiter Perps (oracle-priced pools) | No curve to push; oracle and keeper-delay risk instead | Sensible slippage for the oracle move between request and execution |
| AMMs on HyperEVM, Solana, Base, Arbitrum | Normal AMM risk; lower where the sequencer is private, but attacks were found on Base | Tight slippage; do not repeat the same trade on a predictable timer |
Architecture from each venue’s official docs (re-read October 19, 2026); attack counts from arXiv 2609.28115.
Other MEV you may meet
MEV (maximal extractable value) is any profit a builder or bot can take by inserting, reordering or excluding transactions around yours. Sandwiches cost swappers most directly; the others matter less, or not at all, to a trader:
| Type | What happens | Does it cost you? | Protection |
|---|---|---|---|
| Sandwich | A bot buys just before your swap and sells just after | Yes: a worse fill, up to your slippage | Tight slippage, private RPC, intents |
| Front-running | A bot copies a profitable pending transaction and outbids it | Yes: your trade fails or fills worse | Private RPC, intent routers |
| Back-running / arbitrage | A bot trades right after your swap to realign prices | No direct cost | MEV Blocker pays you 90% of the back-run profit |
| Liquidation MEV | Searchers race to liquidate unhealthy loans for the fee | Yes, if you are the one liquidated | Margin buffer and stops; Hyperliquid sends liquidations to the book first |
| Priority / latency (order books) | Paying takers reach the same resting liquidity first | Sometimes, on market orders | Limit and Post Only orders |
How secure are AMMs, and order-book DEXs?
The constant-product formula is simple and well understood; the risks sit around it. Contract risk is highest in new or forked pools and in Uniswap v4 hooks, which attach custom code to a pool. Token risk comes with permissionless listing: anyone can create a pool for a fake token with a familiar ticker, or for a token with transfer taxes or a blacklist. MEV is covered above, and LPs carry impermanent loss (next section). Order-book DEXs trade those risks for others: the bridge or deposit contract that holds your collateral, the validators or sequencer that order your transactions, and, for perps, liquidation and auto-deleveraging rules. On either model, use the official front-end, check contract addresses, keep slippage tight and never approve unlimited spending to a contract you do not know.
14. LP economics and impermanent loss
Someone has to provide the liquidity, and each design pays them differently.
AMM LPs: fees minus impermanent loss
An AMM LP earns the pool fee on every trade. A September 25, 2026 snapshot (earlier than section 7’s): the v2 pool had $0.83M of daily volume × 0.30% ≈ $2,480 a day on $20.9M, which DefiLlama showed as a 4.33% fee APY. The v3 0.05% pool: $56.7M × 0.05% ≈ $28,400 a day on $99.1M, a 10.45% fee APY. Against that stands impermanent loss (IL): the pool automatically sells the token that is rising and buys the one that is falling, so an LP ends up worse off than someone who just held both tokens. In a 50/50 constant-product pool, IL for a price ratio change r is 2√r ÷ (1 + r) − 1:
| Price of one token vs the other | Impermanent loss vs holding |
|---|---|
| +25% (1.25×) | −0.62% |
| +50% (1.5×) | −2.02% |
| +100% (2×) | −5.72% |
| +200% (3×) | −13.4% |
| +400% (5×) | −25.5% |
| −50% (0.5×) | −5.72% |
| −75% (0.25×) | −20.0% |
So at that 4.33% fee APY, a v2 LP who stays in for a year beats simply holding only if ETH ends the year less than about 80% higher or 45% lower against USDC than where it started (IL of 4.3% at those points). Fee APY moves with volume: on October 19 at 06:06 UTC the same pool did $438k of daily volume and DefiLlama showed a 2.41% fee APY, which narrows the break-even band to about 56% higher or 36% lower. In a concentrated position the same price move inside your range costs more, and outside your range you earn nothing. The loss is “impermanent” only if the price comes back.
Order-book liquidity: market makers and vaults
On an order book, liquidity comes from market makers who choose their own prices and pull quotes when they want. They are paid by the spread and, on many venues, by low maker fees or rebates (Hyperliquid’s largest makers earn a rebate of up to 0.003% of volume; Lighter Standard makers pay 0%). Retail users can join through a vault: Hyperliquid’s HLP vault runs market-making and liquidation strategies and held $179.1M at a 3.5% APR as of October 20, 2026 (vaultDetails API). HLP has a 4 days deposit lock-up, and it can lose money in violent markets. See Hyperliquid vaults and how perp DEX vaults (HLP, LLP, ALP) work.
Perp pool LPs: the house
In an oracle-priced pool such as JLP, LPs are the counterparty to every trader. They collect most of the fees (75% on Jupiter) plus traders’ losses, pay out traders’ profits, and hold the pool’s basket of SOL, ETH, wBTC and stablecoins. It is closer to owning a casino with a crypto balance sheet than to AMM market making.
15. FAQ
What is the difference between an order book and an AMM?
The counterparty. On an order book you trade against other traders’ bids and asks, matched in price-time priority, so you can see the prices before you trade. On an AMM you trade against a liquidity pool that prices every trade with a formula over its reserves (Uniswap v2 uses x × y = k), so there is always a quote but the price moves against you in proportion to your size. On October 19, 2026, 06:06 UTC, a $1M ETH buy cost about 10.3% in a $19.9M Uniswap v2 pool and about 0.06% including the 0.045% taker fee on Hyperliquid’s order book.
Is Uniswap an order book?
No. Uniswap is an AMM: you swap against liquidity pools whose price is set by a formula over the pool’s reserves (x × y = k, applied inside each LP’s price range on v3 and v4), not against other traders’ bids and asks. Concentrated liquidity and range orders make parts of a pool behave like limit orders, and UniswapX adds solver-filled orders on top, but there is no central limit order book. Hyperliquid, Lighter and dYdX are order-book DEXs.
Are order-book DEXs safer than AMMs?
Safer for the trader against two specific risks, not safer in every way. A limit order on a book cannot fill worse than its price, so there is no AMM-style sandwich, and you can see the depth before you trade. You also avoid the fake-token pools that permissionless AMM listing allows. But an order-book DEX has its own risks: the bridge or deposit contract that holds your collateral, the validators or sequencer that order transactions, thin books in a crash, and, for perps, leverage, liquidation and auto-deleveraging rules. Check how each venue custodies funds and who orders transactions.
Is an order-book DEX or an AMM better for large positions?
An order book, as long as the book is deep. In our October 19, 2026 snapshot a $1M ETH market buy averaged 0.015% above mid on Hyperliquid (0.06% with the taker fee) and about 0.016% on Lighter, against about 10.3% in a $19.9M Uniswap v2 pool. Oracle-priced perp pools such as GMX cap the price impact (0.5% on ETH) but limit position size to the pool’s liquidity. Above a few hundred thousand dollars, split the order or use a TWAP even on a book.
Which is better, AMM or order book?
For perpetual futures, active trading and large size, an order book: tighter spreads, maker/taker fees, stops and visible depth. For a one-off swap of a small amount, or a token no market maker quotes, an AMM is simpler and always available. Most traders use both: an AMM or an aggregator to swap tokens, an order-book DEX such as Hyperliquid or Lighter to trade perps.
What does CLOB mean in trading?
Central limit order book: one shared book per market where every limit order rests at its price, and incoming orders fill against the best price first and, at equal prices, the oldest order first. Almost every centralized exchange runs a CLOB. A CLOB DEX runs the same model on a blockchain or on a matcher whose results are verified on-chain: Hyperliquid, Lighter and dYdX are CLOB DEXs; Uniswap and Curve are AMMs.
What does an order book tell you?
The price and size at which people are willing to trade right now. The best bid and best ask give the spread (the cost of trading immediately), the size stacked on each level shows how large a market order can be before it moves the price, and on Hyperliquid the n field shows how many separate orders sit at each level. On Hyperliquid’s BTC perp at 17:19 UTC on September 25, 2026 the best bid was 83,897 and the best ask 83,898, a spread of about 0.12 basis points, and the 20 visible ask levels held $3.67M. Resting orders can be cancelled at any time, so depth is a snapshot, not a promise.
What is the difference between the order book and order flow?
The order book is the set of orders waiting to be filled: intentions that can be cancelled. Order flow is the stream of orders that actually arrive and trade, which you see in the trades tape. A large bid on the book says someone may buy; a run of market buys in the order flow says someone is buying. Traders read both, and trust the flow more.
Is Hyperliquid an AMM or an order book?
An order book. HyperCore, Hyperliquid’s own layer 1, keeps an order book for each asset in chain state and matches orders in price-time priority. Placing and cancelling orders costs no gas. Newly deployed spot tokens can also get automated quotes through HIP-2 Hyperliquidity, which places orders on the same book.
Why did DeFi start with AMMs instead of order books?
Because on Ethereum mainnet every order and every cancel is a paid, slow transaction, and market makers requote constantly. An AMM needs no market maker at all: one transaction per trade, and the formula requotes by itself. Order books became practical on-chain once chains built for trading appeared: Hyperliquid and dYdX run their own chains, and Lighter matches off-chain and proves the result on Ethereum.
Are AMMs replacing order books?
No. The two are converging rather than replacing each other. Spot swaps and long-tail tokens stay on AMMs, while perpetual futures run almost entirely on order books. AMMs borrowed order-book ideas (concentrated liquidity and range orders on Uniswap v3/v4), and order-book venues borrowed AMM ideas (Hyperliquid’s HIP-2 places formula-driven quotes on its book; Jupiter’s newer Beta perp markets run on an order-book engine rather than its pool).
How secure are AMMs?
The pricing formula itself is simple; the risks sit around it. Smart-contract bugs matter most in new or forked pools and in Uniswap v4 hooks, which add custom code to a pool. Because anyone can create a pool, fake tokens and tokens with transfer taxes or blacklists are common. Swaps on a public mempool can be sandwiched up to your slippage tolerance, and LPs carry impermanent loss. Use official front-ends, check the token contract, keep slippage tight and prefer MEV-protected routing.
What is a sandwich attack in crypto?
A form of MEV (maximal extractable value) where a bot sees your pending AMM swap, buys the same token just before you so the pool price rises, lets your swap execute at the worse price, then sells right after. Your trade is the filling between the bot’s two trades, and the bot’s profit comes out of the price you receive, up to the slippage tolerance you set.
How do I protect myself from sandwich attacks?
Keep slippage tight (around 0.5% on majors, less on stablecoin pairs), send swaps through MEV protection (MetaMask’s built-in protection, or a private RPC such as Flashbots Protect or MEV Blocker on Ethereum, PancakeSwap MEV Guard on BNB Chain), route larger swaps through an intent router (CoW Swap, UniswapX, 1inch Fusion), split size and avoid repeating the same trade on a timer. For leveraged trading, use an order-book DEX with limit orders, where there is no pool to push.
What slippage should I set to avoid being sandwiched?
As low as still fills. In our simulation of a $100,000 ETH buy on the $19.9M Uniswap v2 pool (October 19, 2026), a 3% tolerance left about $2,961 of room for a sandwich, 1% about $987 and 0.5% about $494. Small swaps in 0.30% pools are poor targets because the bot pays the pool fee on both legs. Around 0.5% is a common starting point for majors; volatile tokens need more, so split the swap instead of raising the tolerance.
Should I turn MEV protection on?
Yes, for almost every swap. The trade-offs are small: inclusion can be a little slower (Infura, MetaMask’s default Ethereum RPC, says protection adds on average 1 extra slot), protection is best effort rather than guaranteed, and you trust a relay and its builders with your transaction. With MEV Blocker you also receive 90% of any back-run profit. Do not stack by accident: in MetaMask a custom RPC overrides its Smart Transactions, so pick one.
Can you be sandwiched on an order-book DEX?
Not in the AMM sense. A sandwich works because an AMM swap accepts any price within your slippage tolerance. A limit order on a book never fills worse than its limit price. Order books have their own ordering questions (who sequences the orders), which is why Hyperliquid processes cancels before new GTC and IOC orders in each block, and Lighter orders transactions first-in-first-out and proves the execution of every batch on Ethereum. A market order on a thin book can still fill badly, so lower Hyperliquid’s 8% default max slippage in thin markets.
What is impermanent loss?
The value an AMM liquidity provider gives up versus simply holding the two tokens, caused by the pool selling the rising token and buying the falling one. In a 50/50 constant-product pool it is 2√r ÷ (1 + r) − 1 for a price ratio change r: about −5.7% if one token doubles, −13.4% if it triples. Fees earned must exceed it for LPing to beat holding.
Put the order-book advantage to work
Open Hyperliquid with HOLYGRAIL: 4% off every fee on your first $25M of volume, gas-free orders, 178 perp markets (as of October 20, 2026). Details in the HOLYGRAIL referral code guide.
Disclosure: HOLYGRAIL (Hyperliquid) and 718610TD (Lighter) are our referral codes; we earn a share of referred accounts’ fees at no cost to you. We hold no codes for the swap and MEV-protection tools mentioned. Architecture descriptions come from each venue’s official documentation; fees come from the venues’ fee pages; pool and order-book snapshots were fetched from DefiLlama and the Hyperliquid and Lighter APIs on the dates stated, the sandwich table is our own simulation, and Hyperliquid market and vault figures are refreshed at every site build. Not investment advice.