Order book vs AMM: How DEX trades get priced
Order book vs AMM: an order book matches resting orders, while a pool sets price from reserves, changing how a DEX trade fills and how you cap output.
iCrypto Editorial5 min read
An order book matches your trade with resting orders, while an AMM prices it against a liquidity pool, so a DEX swap’s price changes with the pool’s reserves and the size of your trade.
Who sets the price in an order book and an AMM?
An order book price comes from traders’ offers, while an AMM price comes from the tokens held in a pool. That changes what your order is matched against.
In an order book, buyers post bids and sellers post asks. A market order takes the best available prices, matching orders by price-time priority: the best price goes first, and earlier orders at that price are ahead in line. If there is not enough volume at the best price, the trade may continue through worse prices or fill only in part.
With an AMM, your counterparty is a pool funded by liquidity providers, or LPs. These users deposit tokens into the pool so traders can swap against them. The AMM uses the pool’s reserves to set the price; it does not wait for another trader to post the other side of your trade.
Uniswap v2 pools use a constant product formula, written as x*y=k. Here, x and y are the amounts of two tokens in the pool, and the formula keeps their product constant as a trade changes those amounts. The ratio of the reserves helps determine the current price.
Why does a larger AMM trade get a worse average price?
A larger AMM trade moves the pool farther along its pricing curve, so it receives a worse average price than a smaller trade at the same starting point. Pool reserves, not a list of individual orders, determine how much the price moves.
Say you swap one token for another in a pool. The pool gives you tokens from its reserves and takes in yours. As the reserve balance shifts, the price shifts too. A small trade may barely move it; a trade large relative to the pool can move it much more. This change caused by your trade is price impact.
That is different from an order-book spread. A spread is the gap between the best bid and best ask; price impact is the change in pool pricing as your trade alters reserves. In practice, an AMM quote is an estimate of what the pool will return for your chosen amount, rather than a promise that every unit will trade at the starting price.
There is no partial fill in the usual AMM swap flow: the transaction either swaps the full amount at the resulting average price or fails. Set a minimum output to put a floor under what you will accept. If the pool would return less than that amount when the trade executes, the swap reverts instead of completing. That makes minimum output your practical limit: choose it with the quoted return and the price movement you can tolerate in mind.
How can a DEX aggregator change the trade?
A DEX aggregator can split a swap across AMM pools to reduce the impact on any one pool. KyberSwap finds routes across supported liquidity sources for token swaps, so it can help a trader compare paths instead of relying on one pool alone.
A token swap involving the KNC token is one kind of trade KyberSwap can route across AMM pools; its aggregation feature makes it a concrete example of how a swap can draw on multiple liquidity sources. The route affects the quoted output, while the minimum-output setting remains the trader’s floor for the completed swap.
KyberSwap also offers KyberSwap Limit Order, which lets traders specify a price for a swap. That brings back an order-book-style idea: you state the price you want, rather than taking the pool’s current curve price immediately. The trade depends on finding a match at that price, unlike an AMM market swap that executes against available pool reserves.
When reading an AMM quote like an order-book fill, compare the total output for your chosen input, not only the starting price. Then set a minimum output that reflects the least you are willing to receive. That makes the key execution difference visible: an order book may fill against several posted prices or partially, while an AMM swap trades the full amount against pool pricing or reverts.
What changes when AMM liquidity is concentrated or prices drift?
How do concentrated liquidity pools change AMM pricing?
Concentrated liquidity places liquidity within selected price ranges, so the pool’s available depth can vary across prices. A trade may have less price impact while it stays in a well-funded range, then move price more sharply when it reaches thinner liquidity.
Why can an AMM price drift from the CEX price?
An AMM price reflects its pool reserves, while a CEX price reflects its order book. Trades and changes in available liquidity can move the two prices apart; traders and arbitrage activity can bring them back toward each other, but a pool quote can still differ when you trade.