Why DEXs Exist — and Why They Look Nothing Like Exchanges
A centralized exchange is, at bottom, a matching engine: a server that maintains a sorted data structure (the limit order book) and executes insert/cancel/match operations at microsecond latency. The entire competitive moat of firms like Citadel Securities or Jump Trading rests on shaving nanoseconds off those operations.
Now place that workload on a blockchain.
The Throughput Constraint
| Chain | Approx. TPS (2024) | Block time | Finality |
|---|---|---|---|
| Ethereum L1 | ~15 | 12 s | ~13 min (2 epochs) |
| Solana | ~4,000 actual (65K theoretical) | 400 ms | ~13 s |
| Arbitrum (L2) | ~40 | 250 ms | 7 days (challenge) |
Even Solana’s throughput is roughly below a single NYSE Arca partition. Ethereum L1 is below. An order book requires multiple transactions per quote update — a market maker adjusting 20 price levels emits 20 state-modifying transactions. At 15 TPS, the book would be stale before the block is mined.
This is not a temporary engineering gap. Block production is an inherently sequential, globally-replicated consensus process. Even with sharding and rollups, on-chain throughput will remain orders of magnitude below co-located matching engines for the foreseeable future.
From Order Book to Pricing Function
The intellectual leap — made independently by several people, but most influentially by Hayden Adams (Uniswap, November 2018) — was to replace the order book entirely.
The key insight: if you cannot afford to let market makers continuously update quotes, make the pricing rule itself a deterministic function of pool state. A trader sends tokens in; the smart contract computes how many tokens come out. No order queue. No cancellations. One transaction per trade.
Adams cited Robin Hanson’s logarithmic market scoring rule (LMSR, 2003) as intellectual precedent. Hanson showed that a scoring-rule-based automated market maker could provide liquidity for prediction markets without any human market maker. The constant-product rule is, in spirit, the same idea applied to a two-asset spot market with a different invariant function.
Three Design Principles
Every AMM-based DEX follows the same structural pattern:
1. A formula replaces human judgment
The exchange rate is computed from a conservation function (or invariant) . The function is public, deterministic, and evaluated on-chain. There is no order book, no queue priority, no time-price priority matching.
2. A pool replaces the book
Instead of a collection of resting limit orders from individual traders, a liquidity pool holds reserves of both assets. The pool is a single on-chain account (or set of accounts) whose balances define the current state.
3. Anyone can provide liquidity
Liquidity provision is permissionless. Any address can deposit tokens into the pool and receive LP tokens representing a pro-rata claim on the reserves. This replaces the regulated, credentialed market-maker role of TradFi — with very different risk characteristics (see impermanent-loss).
The Invariant Zoo
Different invariants produce different behaviors:
| Invariant | Name | Shape | Used by |
|---|---|---|---|
| Constant product | Hyperbola | Uniswap V2, Raydium V4, PumpSwap | |
| Constant sum | Line | (Unstable — allows full drainage) | |
| StableSwap | Flattened hyperbola | Curve V1 | |
| Concentrated ranges | Tick-based | Piecewise | Uniswap V3, Orca Whirlpools |
The constant-product rule is the simplest non-trivial invariant that prevents pool drainage, which is why it dominates. Its full derivation is in constant-product-amm.
What the Constraint Does Not Force
It is worth noting what AMMs sacrifice. The limit order book allows traders to express conditional intent — “I will buy at 100 but not at 101.” An AMM trade is unconditional: you accept whatever price the formula gives at execution time (subject to a slippage bound). This creates MEV (maximal extractable value) opportunities for block producers, which is an entirely separate and large topic.
Similarly, an order book naturally aggregates heterogeneous beliefs via the supply and demand schedules. An AMM’s pricing curve is a single mechanical function — it does not directly aggregate information. Price discovery happens indirectly, through arbitrageurs aligning the AMM price with external markets. This is why Kyle’s model of informed trading remains relevant: the LP’s loss to informed flow is the mechanism by which AMMs incorporate information.
Companion notebook: notebooks/defi/01-throughput-and-design.py —
simulate order-book update rates under block-time constraints; compare
with AMM single-transaction execution.
Questions to sit with:
- If Solana can handle ~4,000 TPS, why do AMMs still dominate on Solana rather than on-chain CLOBs? What else matters beyond raw throughput?
- Hanson’s LMSR uses a logarithmic scoring rule. Why did Uniswap choose a product invariant instead? What properties does the log rule have that are undesirable for a spot market?
- The AMM removes time-priority from the matching process. What takes its place? (Hint: think about transaction ordering within a block.)