What Is a DEX? No Order Book at All

On a stock exchange, a trade happens when a buyer meets a seller. The exchange keeps an order book: sellers sorted by price, buyers sorted by price, and a match whenever they meet.

Most decentralised exchanges (DEXs) don’t work that way. Running an order book on a blockchain is slow and expensive, because every new order, change and cancellation would be a transaction someone pays for. So instead of matching you with another person, a DEX lets you trade against a pool.

That is the main difference between a DEX and a centralised crypto exchange (CEX): a CEX runs an order book, like a stock exchange, and holds your funds; on a DEX you trade from your own wallet.

Most pools pair a token with a dollar stablecoin. How those hold their price is in What Keeps a Stablecoin at $1?

How an AMM Liquidity Pool Sets the Price

A pool holds two tokens, say token A and a dollar stablecoin. People called liquidity providers deposit both tokens into it, and earn a small fee on every trade. When you trade, you put one token into the pool and take the other out.

The price comes from a formula. The best-known design, used by Uniswap’s early versions, keeps the product of the two balances constant:

amount_of_A × amount_of_USD = k   (stays the same after every trade)

Say the pool holds 100 A and 10,000 USD, so k = 1,000,000 and one A costs about 100 USD. You want to buy 10 A. After your trade the pool will hold 90 A, so to keep k the same it must hold 1,000,000 ÷ 90 = 11,111 USD. You pay the difference: about 1,111 USD, or 111 USD per A, before fees.

Price Impact and Slippage: Why Big Trades Cost More

The quoted price was 100, but you paid 111. That gap is price impact: every token you take out makes the next one more expensive, because the pool has fewer of them left. Buy 1 A instead of 10 and you pay about 101. Buy 50 and you pay about 200 each.

That’s the same idea as walking up an order book, where a big order eats through the cheapest sellers and then the more expensive ones. The difference is that here, the size of the pool decides how steep the walk is. Small pool, steep price. Deep pool, gentle price.

  • Slippage limits protect you: you set the worst price you’ll accept, and the trade fails instead of filling worse.
  • Arbitrage keeps the price honest. If the pool’s price drifts from the price elsewhere, traders buy the cheap side and sell the expensive side until it lines up again.

Impermanent Loss: What Liquidity Providers Risk

Liquidity providers earn fees, but their deposit doesn’t stay the same. When the price of A rises, traders buy A out of the pool, so the provider ends up holding less A and more dollars than they put in. Compared with simply holding the two tokens, they can come out behind. This is called impermanent loss: it shrinks if the price comes back, and becomes real if they withdraw before it does.

For Engineers: Integrating With a DEX

If your platform swaps tokens through a DEX, the checks that matter are the ones above: quote the price impact before the user confirms, always send a slippage limit and a deadline with the swap, and never trust a single pool’s price as the market price. A thin pool can be pushed around cheaply, which is how many price-manipulation attacks start.

This article explains how the systems work. It is not financial or investment advice, and the rules for crypto assets change and differ from country to country: check the current ones where you live.