What is an AMM, and why do decentralized exchanges need it?
On a traditional centralized exchange (like Binance), trades are matched by an order book: buyers post buy orders, sellers post sell orders, and they execute when prices match. But order books need enough buyers and sellers online simultaneously for adequate liquidity; for small tokens, the bid-ask spread can be unacceptably wide. The deeper problem: a decentralized exchange (DEX) has no central server to efficiently match orders — porting a traditional order book on-chain is too expensive and too slow. AMM's answer: replace the order book with a liquidity pool, and manual matching with a math formula. The pool holds reserves of two tokens (say ETH and USDC), and a formula determines the exchange rate and price at any moment. No buy/sell orders to wait for, no counterparty to find — you want to buy, you trade directly with the pool; the formula automatically calculates how many tokens you receive and how much of the other you put in, updating the price instantly.
How does the constant-product formula x × y = k work?
This is the core mechanism of most AMMs, and you don't need a math background to understand it. Imagine a liquidity pool with only ETH and USDC, holding 100 ETH and 200,000 USDC. Then k = 100 × 200,000 = 20,000,000, and the pool's implied ETH price is 200,000 ÷ 100 = $2,000. Now someone wants to buy 10 ETH from the pool. After they take it, the pool has only 90 ETH — but k must stay constant, so USDC must become 20,000,000 ÷ 90 ≈ 222,222. That means the buyer must put in 222,222 – 200,000 = 22,222 USDC to get 10 ETH, an average price of about $2,222 — 11% more expensive than the original $2,000. That gap is slippage. After the trade, ETH is scarcer (90 units) and the implied price rises to 222,222 ÷ 90 ≈ $2,469. No one needs to quote a price; the formula automatically completes the entire cycle of 'trade changes supply → supply changes price.' The curve can mathematically never let one token reach zero reserves (it would take infinite amounts of the other to buy it all out) — that's the formula's mathematical guarantee.
What is the fundamental difference between AMMs and order books, and what are the pros and cons of each?
Order books' strengths: price precision and no forced slippage — buyers and sellers name their own prices, trades execute at your chosen price, and large orders aren't necessarily costlier than small ones (depends on order depth). Weakness: requires liquidity providers to actively post orders; for small tokens, there's no counterparty at all or the bid-ask spread is prohibitively wide. AMMs' strengths: always liquid, no counterparty needed, 24/7 and permissionless — as long as the pool has tokens, anyone can trade anytime. Revolutionary for long-tail tokens (newly launched, small market cap). Weakness: high slippage on large orders, and AMMs are natural arbitrage targets — whenever external market price diverges from the pool's implied price, arbitrageurs come in to correct it, and liquidity providers bear the arbitrage loss (the source of impermanent loss). These aren't locked in a zero-sum battle; many DEXs use hybrid models (e.g. dYdX uses an order book), each serving different needs.
What do liquidity providers receive, and why isn't it all upside?
Liquidity providers (LPs) deposit both tokens at the current ratio into the pool, receiving 'LP tokens' representing their share. Their income comes from transaction fees on every trade through the pool (Uniswap V2: 0.3%), distributed proportionally to their share. For example, if you hold 1% of the pool and it sees $1 million USDC in daily volume, you'd collect roughly 1,000,000 × 0.3% × 1% = $30 per day in fees. But LPs have two hidden costs to understand. First is impermanent loss, detailed in another entry in this series: when the relative price of the two tokens diverges, the value you withdraw is less than simply having held both tokens without doing anything. The greater the divergence, the larger the loss; fees must exceed that loss for LPing to actually be profitable. Second, fees are not guaranteed income: if trading volume is low or the pool is deep (many LPs splitting), your fee yield may be very thin — potentially eaten by gas costs. The core equation to evaluate whether a pool is worth joining: estimated annualized fee APR > impermanent loss estimate + gas costs + opportunity cost.
A real Uniswap scenario to ground the concept. During the DeFi peak season in 2021, the ETH/USDC 0.3% fee pool saw daily volumes often in the hundreds of millions. Say you became an LP with $10,000 USDC and equivalent ETH, representing roughly 0.01% of the pool. At trading volumes of that period, you'd collect roughly $50–100 USDC per day in fees, annualizing close to 200%. Sounds extremely attractive — but during the same period ETH rose from $2,000 to $4,000. Because you were an LP, the system continuously 'sold your ETH' for USDC (arbitrageurs constantly re-balancing the pool), so you didn't fully capture ETH's doubling. Some analyses showed: simply holding ETH and USDC without LPing over that stretch would have yielded far more than the fees. This example perfectly illustrates the double edge of LPing: when markets range and relative prices stay stable, fees are real and substantial. When markets make a one-directional surge, the LP mechanism systematically erodes your upside capture.
The core trade-off of trading on an AMM is 'always liquid, no permission needed' in exchange for 'slippage and possible MEV loss.' For small trades and long-tail tokens, AMMs are often the only option — there's no order book market. For large trades, AMM slippage costs can far exceed expectations; aggregators (like 1inch) split your large order across multiple DEXs and AMM pools to reduce total slippage. For providing liquidity, the trade-off is 'earning fees' in exchange for 'bearing impermanent loss and opportunity cost.' No AMM pool is 'unconditionally good' — always calculate expected fee APR, impermanent loss, gas, and opportunity cost together.