Lesson 1 — AMMs explained: Uniswap V2, V3, V4, Curve, Balancer
An automated market maker is a deterministic pricing formula plus a pool. Today: the formulas, where they differ, and where slippage actually comes from.
Every DEX swap on Ethereum, Solana, or any other major chain runs through some variation of an AMM. The user-facing experience — pick token, pick amount, swap — hides a deterministic pricing algorithm whose properties decide everything that follows. This lesson is about reading that algorithm well enough that the next question becomes natural: not 'what is the price?' but 'why is the price what it is, and what would move it?'
**Uniswap V2** is the canonical constant-product AMM. The pool holds two reserves (call them x of token A and y of token B). The product x·y is held constant across every swap: if a trader removes Δx of token A, they must add enough B so that (x − Δx)(y + Δy) = x·y. Solving for the price impact gives the swap output and the slippage. The smaller your trade relative to the reserves, the smaller the slippage. The larger your trade, the more nonlinearly slippage grows. The constant-product formula is symmetric — it provides liquidity at every price from zero to infinity — which means capital is spread thin everywhere and concentrated nowhere.
**Uniswap V3** introduced concentrated liquidity. LPs deposit liquidity within a chosen price range — say between $1,800 and $2,200 for ETH/USDC — and capital is active only within that range. Inside the range, the effective depth is much greater than V2 for the same capital, so traders see less slippage. Outside the range, the position holds 100 percent of one asset and earns nothing. The trade-off: LPs must choose ranges and monitor them, which is a more involved operation than V2's set-and-forget model. The protocol uses a 'tick' system where the price space is discretized into log-spaced intervals; positions are bounded by ticks.
**Uniswap V4** (released 2024–2025) keeps V3's concentrated-liquidity model and adds 'hooks' — programmable callbacks that execute before or after each pool operation. Hooks let pool creators add features like custom oracles, dynamic fees, MEV protection, or limit orders without forking the protocol. V4 also moves all pool accounting into a single 'PoolManager' singleton contract, which dramatically reduces gas costs for multi-hop swaps. The risk surface expands accordingly — every hook is custom code that can have its own bugs.
**Curve Finance** uses a different formula entirely: the StableSwap invariant, which behaves like a constant-sum formula (x + y = k, near-zero slippage) when prices are near 1:1 and like a constant-product formula (x·y = k, normal AMM slippage) when they diverge. This is the right curve for assets that should trade at a fixed ratio — stablecoins, ETH and stETH, BTC and WBTC — and it's why Curve dominates stablecoin-pair trading. The cost is higher computational complexity and a more complex oracle surface that has been exploited multiple times (most notably the July 2023 Vyper-compiler reentrancy exploit affecting Curve, JPEG'd, Alchemix, and Metronome for ~$70M).
**Balancer** generalizes the AMM model further: any number of tokens in a pool, with arbitrary weights summing to 100 percent. A 'BAL-WETH-USDC 33/33/33' pool prices each pair against the others using a weighted geometric mean. Balancer's design enables index-fund-style baskets and was a foundation for protocols like Element and Aura. Like Curve, the additional complexity expands the audit surface.
**Where slippage actually comes from.** Three sources, often confused. (1) Price impact — the deterministic movement caused by your trade against the curve. Large trades against shallow pools cause large price impact. This is what the AMM math computes. (2) Sandwich-attack slippage — value extracted by MEV bots that detect your pending transaction in the mempool, front-run with a buy that pushes price against you, then back-run with a sell to close out. This is recoverable in principle with private mempools (Flashbots Protect, MEV-Share). (3) Adverse selection / informed flow — sophisticated traders pick off LP positions when external markets have moved but the AMM price hasn't yet, effectively buying from LPs at stale prices. This is a structural cost of being an LP and is the main driver of LVR (loss-versus-rebalancing) covered in academic literature.
**The right question for any AMM deposit.** Not 'what's the APY?' but 'on which curve, against what flow, with what fee tier, in what price range?' The APY headline number assumes specific volume, fees captured, and absence of adverse selection. The breakdown matters because the same APY can come from sustainable fee yield or from being adversely-selected by every informed trader.
Example
Walk through a USDC → ETH swap on Uniswap V3 with a 0.05 percent fee tier. Pool has $50M in concentrated liquidity around the current price. User wants to swap $10K USDC. Price impact at this depth: roughly 0.02 percent. Fee paid to LPs: 0.05 percent of $10K = $5. Total cost to the user excluding gas: ~0.07 percent. Now do the same trade on Uniswap V2 with the same USD-equivalent reserves spread across the full price curve: effective depth at the current price is far lower, so price impact rises to ~0.5 percent, and the user pays the 0.30 percent V2 fee. Total cost: ~0.8 percent — about 11× the V3 cost for the same trade. This is the structural value of concentrated liquidity: better execution for users and (when ranges are managed well) better capital efficiency for LPs.
Common mistakes
- Treating 'slippage' as a single concept. Price impact, sandwich slippage, and adverse selection are different costs with different mitigations.
- Choosing AMM positions based on the APY headline without understanding which fee tier, which price range, and which trade flow generates that yield.
- Assuming V3's concentrated liquidity is universally better. It is for active LPs who manage ranges; it can be worse for passive LPs whose positions go out of range and stop earning.
- Forgetting that Curve's StableSwap is optimised for near-1:1 pairs. Using Curve for volatile pairs is using the wrong tool.
- Treating Balancer/Curve/V4-hook pools as having the same risk profile as V2/V3 single-curve pools. Additional complexity expands the audit surface — and historically the largest DeFi exploits have happened at the complex end.
Check your understanding
You're providing concentrated liquidity in a Uniswap V3 ETH/USDC pool with a range of $3,200–$3,800. ETH's market price moves to $4,200 and stays there for a week. What happens to your position?
Key terms covered
Sources & further reading
- PrimaryUniswap V3 Whitepaper
Specification of concentrated liquidity and tick math.
- Primary
- Primary
- Primary
We prioritise primary sources. Where a topic moves quickly (regulation, security incidents), we re-check sources on the cadence shown by the page's "Next review" date.