> ## Documentation Index
> Fetch the complete documentation index at: https://docs.allium.so/llms.txt
> Use this file to discover all available pages before exploring further.

# AMMs vs CLOBs

> The two ways trades get matched onchain, and the two very different shapes of data they produce.

Every trading venue has to answer one question: when someone wants to buy, who sells, and at what price? Onchain there are two answers, and they produce data that looks nothing alike.

## Central limit order book (CLOB)

The model traditional finance uses. Traders post **orders** — "sell 10 ETH at \$3,000" — into a book. The venue matches a new order against the best available order on the other side, and each match is a **fill**.

Price comes from the book. If nobody is willing to sell below \$3,000, that is the price.

CLOBs need fast, cheap execution because market makers update quotes constantly. That makes them a natural fit for high-throughput chains and appchains — Hyperliquid, Lighter, dYdX — and for a handful of Solana venues. On a chain where every quote update costs a transaction fee, a book is impractical.

## Automated market maker (AMM)

The model native to blockchains. There is no book and no counterparty. Liquidity providers deposit both assets of a pair into a **pool**, and a formula sets the price from the pool's balances. A trade is a **swap** against the pool.

The classic formula is the constant product, `x * y = k`: buying token X from the pool depletes X and adds Y, which raises X's price along a curve. Later designs — concentrated liquidity, stable-swap curves, weighted pools — change the curve's shape but not the principle.

Price comes from the pool's ratio, which means an AMM will always quote a price, for any size, without a counterparty needing to show up. That is why AMMs dominate long-tail assets: a token with no market makers can still trade.

## Side by side

|                           | AMM                                                       | CLOB                                                |
| :------------------------ | :-------------------------------------------------------- | :-------------------------------------------------- |
| **Who you trade against** | A pool                                                    | Another trader's resting order                      |
| **What sets the price**   | A formula over pool reserves                              | The best bid and ask                                |
| **Liquidity comes from**  | Passive LP deposits                                       | Active market maker quoting                         |
| **Cost of trading size**  | Price impact along the curve, plus a swap fee             | Walking the book, plus taker fee                    |
| **The atomic record**     | A swap                                                    | An order, and separately a fill                     |
| **Onchain footprint**     | One transaction per trade                                 | A transaction per order placement, cancel, and fill |
| **Examples**              | Uniswap, Curve, Balancer, Raydium, Orca, Aerodrome        | Hyperliquid, Lighter, dYdX, Phoenix                 |
| **Failure mode to know**  | Impermanent loss for LPs; sandwich attacks on large swaps | Thin books; quote flicker; wash trading             |

<Info>
  Hybrids are common. Request-for-quote and intent-based venues take an order from the user and have professional market makers compete to fill it offchain, settling onchain — so the trade looks like a single settlement transaction with no pool and no book. Aggregators split one user trade across many pools and venues, which is why Allium keeps aggregator trades in separate tables from pool-level swaps.
</Info>

## What this means for the data

**AMM data is complete by construction.** Every swap is an onchain event because it *is* a state change to the pool. If you index the pool, you have every trade.

**CLOB data is not, unless the venue publishes it.** Orders that are placed and cancelled without filling may never touch chain state, and on some venues the book itself lives offchain. So order-level data depends on what the venue exposes, while fills are always recoverable.

**Volume is not comparable without care.** An AMM aggregator routing one \$1M trade through five pools produces five swaps. Counting all of them plus the aggregator's own record double-counts the volume. Allium keeps `dex.trades` to pool-level swaps only and puts routed trades in `dex.aggregator_trades` for exactly this reason — see [DEX Trades](/historical-data/dex-trades).

**Price derivation differs.** An AMM's price is implied by each swap's ratio, so it can be computed from trade data alone. A CLOB's mid price requires the book. This shapes how Allium builds price data — see [Oracles](/guides/oracles) and [Prices](/historical-data/prices).

## Where to look in Allium

| Venue type                    | Tables                                                                                                                                   |
| :---------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------- |
| AMM swaps, all chains         | [`crosschain.dex.trades`](/historical-data/dex-trades)                                                                                   |
| Aggregator-routed trades      | `dex.aggregator_trades` per chain, see [DEX Trades](/historical-data/dex-trades)                                                         |
| CLOB orders, fills, and books | [Perpetuals](/historical-data/perpetuals/overview) for perp venues; [order books](/historical-data/perpetuals/order-books) for snapshots |
| Centralized exchange trades   | [CEX](/historical-data/cex)                                                                                                              |
| Derived token prices          | [Prices](/historical-data/prices)                                                                                                        |

## Next steps

* [Perpetuals](/guides/perpetuals) — the derivatives layer built mostly on CLOBs
* [MEV](/guides/mev) — why AMM swaps are vulnerable to ordering games
