How can you buy instantly when nobody is selling?
On a traditional exchange, buying requires someone to have placed a sell order at that price. On a decentralized exchange (DEX), you can usually swap instantly even when no counterparty order exists. The reason is a design called the automated market maker (AMM).
This guide explains how AMMs replace the order book with liquidity pools and a pricing formula. It works through how pool size changes the price impact of the same trade using hypothetical numbers, covers what liquidity providers earn and risk, and lists what to check before trading.
A liquidity pool instead of an order book
The BIS Quarterly Review explains that centralized exchanges generally rely on limit order books, while in DeFi the cost of managing every order on-chain would be prohibitive, so AMMs are widely used instead. In an AMM, the counterparty is not a person but a pool holding two assets.
The best-known design is the constant-product formula, x × y = k, which keeps the product of the two asset quantities fixed. When someone adds asset A and removes asset B, B's price rises automatically to keep the product constant. Nobody sets the price; it follows from the ratio of assets left in the pool.
How pool size affects price
The table compares buying 30,000 USDC worth of ETH from two hypothetical pools, both starting at 1 ETH = 3,000 USDC. Fees are excluded to keep the arithmetic simple.
| Pool | ETH received | Average price paid | Vs. starting price |
|---|---|---|---|
| 100 ETH + 300,000 USDC | ≈ 9.091 | ≈ 3,300 USDC | +10.0% |
| 1,000 ETH + 3,000,000 USDC | ≈ 9.901 | ≈ 3,030 USDC | +1.0% |
Under the constant-product formula, ETH left after the trade = k ÷ new USDC balance. A pool ten times larger cuts the price impact of the same trade to roughly one-tenth.
Price impact and slippage
The gap between the starting price and the average price actually paid is called price impact, and it grows as the trade gets larger relative to the pool. Uniswap's documentation notes that traders can assess price impact before confirming a swap, and that slippage, price movement between submitting and executing a trade, must be considered separately.
Price impact is the cost you can calculate just before trading; slippage is the extra movement caused by other trades executing first. That is why swap interfaces show an expected output alongside a minimum amount you are willing to accept, set through a slippage tolerance.
What liquidity providers earn
The assets in a pool come from liquidity providers (LPs), who deposit both assets in the required ratio and in return receive a share of the trading fee on every swap. More trading relative to the size of the pool generally means a higher fee yield on each dollar deposited.
Some services add their own token rewards on top of fees. Advertised yields can then look very high, but if the reward token's price falls, real returns shrink quickly. Always separate the yield that comes from trading fees from the part paid in incentive tokens.
The risks behind the yield
The best-known LP risk is impermanent loss: when the relative price of the two assets moves significantly, simply holding them would have done better than depositing them. LPs also face smart-contract bugs, price manipulation, and the risk that one of the pooled tokens loses value.
The BIS has pointed out that DeFi services are often less decentralized than their name suggests, with control concentrated among developers or large token holders. Who can change the pool's fee rate or contracts, and whether anyone can pause them, are part of the risk.
Before you trade or provide liquidity
Work through these steps before swapping on an AMM or depositing into a pool.
- Confirm the pool and token contract addresses against official documentation to avoid look-alike tokens.
- Compare the pool's total liquidity with your trade size to estimate price impact.
- Check the expected output, the minimum received, and the slippage tolerance, and keep tolerance no wider than needed.
- For liquidity provision, split the advertised yield into trading fees and token incentives.
- Review audit reports, admin powers, and whether the contracts can be upgraded.
What AMMs do not solve
AMMs make trading possible without a counterparty, but shallow pools still produce large price impact. The same asset trades at different prices and depths across pools, and arbitrageurs constantly trade away the differences.
The pools and calculations above are hypothetical and exclude fees. When using a real service, check its latest documentation and pool data with their dates, and start with amounts you could afford to lose.
