Day 17 — AMMs and the magic of liquidity pools
In 2018, an Ethereum researcher named Hayden Adams launched a small project called Uniswap. He had no formal trading background. The protocol was a few hundred lines of Solidity code. It implemented a single, almost embarrassingly simple formula. Within four years, it would be processing more daily trading volume than the New York Stock Exchange does in dollars, and the design pattern it introduced would be copied across every major blockchain in the world.
The formula is x × y = k.
Let me explain what that means and why it changed everything.
A traditional exchange uses an order book. Buyers post bids at the prices they're willing to pay. Sellers post asks at the prices they're willing to accept. When a bid and an ask match, a trade happens. This is how stock exchanges work, how every major centralized crypto exchange works, and how the entire history of formal finance has worked.
Order books require continuous active participation from market makers. Someone has to be there, watching the price, ready to fill orders. On a blockchain where every action costs gas and runs at the speed of block times (12 seconds on Ethereum), maintaining an order book this way is expensive and slow. Early attempts to build on-chain order book exchanges failed for exactly this reason.
The AMM design takes a completely different approach. Instead of matching buyers to sellers, an automated market maker holds reserves of two assets in a single pool and uses a mathematical formula to set the price.
Imagine a pool that holds 100 ETH and 200,000 USDC. The product x × y = k where x = ETH balance and y = USDC balance gives us 100 × 200,000 = 20,000,000. That value of k is what the formula preserves. Every trade has to keep x × y equal to 20,000,000.
What happens when someone wants to buy ETH from this pool?
They send USDC in. The USDC balance grows. To keep x × y = 20,000,000, the ETH balance has to shrink. The amount the ETH balance shrinks tells you how much ETH the trader receives. The implicit price emerges from the math.
If the trader sends in 2,000 USDC, the new USDC balance is 202,000. To keep the product equal to 20,000,000, the new ETH balance must be 20,000,000 ÷ 202,000 = 99.0099 ETH. The trader receives 0.9901 ETH. The implied price was 2,000 ÷ 0.9901 = $2,020 per ETH.
This is the price discovery mechanism. As people trade, the ratio of assets in the pool changes, and the implied price changes with it. The pool itself is the market. No order book required.
A few important consequences fall out of this design.
Slippage. The larger your trade relative to the pool size, the worse the price you get. Trading 1 ETH out of a pool that holds 100 ETH moves the price meaningfully. Trading 100 ETH out of a pool that holds 100 ETH would empty the pool entirely (mathematically, the price would approach infinity before that happens). This is why deep liquidity matters: bigger pools = less slippage = better prices.
Liquidity providers. The assets in the pool come from users who deposit them. These are called liquidity providers (LPs). LPs deposit both assets of a trading pair in equal dollar value (50/50 ETH and USDC, in our example). In exchange, they earn a fee on every trade that happens through the pool. Typical Uniswap fee tiers are 0.05%, 0.3%, and 1% depending on the pair's volatility.
Impermanent loss. This is the part that breaks most people's intuition. When you provide liquidity to an AMM pool, the value of your position can lag behind what you would have had if you'd just held the two assets separately. This happens because the AMM rebalances your position as prices move. When ETH rises, the pool sells some ETH and accumulates more USDC, so your share of the pool ends up with less ETH than you started with. The opposite happens when ETH falls. The "loss" is relative to holding, not to your initial dollar amount. It's called impermanent because if prices return to the level you entered at, the loss disappears. In practice, prices don't always return, so impermanent loss often becomes permanent loss. Real LPs accept this tradeoff because the trading fees usually compensate, but new LPs should understand they are not getting a free yield. They are getting paid for absorbing price-rebalancing risk.
Composability. Because the pool is a smart contract, anything can interact with it. A wallet can swap directly. A lending protocol can liquidate collateral by swapping it on Uniswap. An aggregator like 1inch can split a trade across multiple pools to get a better price. A flash-loan attacker can manipulate a pool's price within a single transaction. The composability is a feature and a vulnerability simultaneously.
Uniswap V3 and concentrated liquidity. The original Uniswap design (V2) spread liquidity evenly across all possible prices. That was wasteful: most trading happens within a narrow price range, but the liquidity in the pool was just as available at prices that never trade. Uniswap V3, launched in 2021, lets liquidity providers choose specific price ranges to provide liquidity within. This dramatically improves capital efficiency for active LPs but also requires more sophisticated management. The trade-off: V2 is passive and forgiving, V3 is active and optimized.
A few practical things.
Most retail DeFi users don't provide liquidity directly. They use aggregators like 1inch, Matcha, or Cowswap, which route trades across multiple AMMs and order book DEXs to find the best price. The aggregator is the consumer interface; the AMMs are the underlying liquidity.
Most trading volume in DeFi happens on a small number of AMMs. Uniswap (Ethereum, multiple L2s, increasingly multi-chain) is the dominant general-purpose AMM. Curve is specialized for stable-asset trading (USDC ↔ USDT ↔ DAI, etc.) and uses a modified formula that produces less slippage between assets that should trade close to 1:1. PancakeSwap dominates on BNB Chain. Jupiter is the dominant aggregator on Solana.
The on-chain order book is making a small comeback in places like Hyperliquid and dYdX, which run their order books on application-specific chains optimized for high throughput. AMMs and on-chain order books will probably coexist long-term, with AMMs winning the long tail and order books winning the high-volume major pairs.
Tomorrow we look at yield. Where it actually comes from, what's real, what's a trap, and how to evaluate any "earn yield on crypto" claim against the small number of mechanisms that produce sustainable returns.
Glossary
| Term | Definition |
|---|---|
| AMM (Automated Market Maker) | A DEX that uses a mathematical formula and a pool of two assets to set prices, instead of matching buyers to sellers via an order book. |
| Liquidity pool | A smart-contract holding reserves of two (or more) assets that an AMM uses to facilitate trades. |
| Constant-product formula | The x × y = k formula used by Uniswap V2 and many other AMMs. The product of the two asset balances stays constant through every trade. |
| Liquidity provider (LP) | Someone who deposits assets into a liquidity pool to earn a share of trading fees. |
| LP token | A token representing your share of a liquidity pool. Can often be used as collateral elsewhere in DeFi. |
| Slippage | The difference between the expected price of a trade and the actual price received, caused by the size of the trade relative to pool depth. |
| Impermanent loss | The opportunity cost an LP bears when the price of the pool's assets diverges from their entry price. The "loss" is relative to holding, not to the initial dollar amount. |
| Aggregator | A protocol (1inch, Matcha, Cowswap) that routes trades across multiple AMMs and DEXs to find the best price. |
| Concentrated liquidity | The Uniswap V3 mechanism that lets LPs provide liquidity within a specific price range, improving capital efficiency. |
| Fee tier | The percentage fee an LP earns on each trade. Typical Uniswap tiers are 0.05% (stables), 0.3% (mainstream pairs), and 1% (exotic pairs). |
Reality check
A friend hears that providing liquidity to a Uniswap pool pays a yield and wants to deposit $10K. What's the one question they need to answer before they do it?
The strongest answer involves understanding impermanent loss. The full answer: what is your conviction on the relative price movement of the two assets in the pool? If you believe they will trade close to where they are now, providing liquidity is a reasonable yield play. If you believe one will significantly outperform the other, you would be better off just holding the one you believe in. Anyone who pitches "Uniswap yield" without explaining impermanent loss is either ignorant or selling you something.
Read deeper
1. Understanding DEXs (Decentralized Exchanges) by The Block (revisited)
The architectural picture from Day 10, now with the AMM mechanics underneath.
Read on IMPCT (curated commentary) | Read original (theblock.co)
Deven's take. Re-read this with today's lesson in mind. The first time through (Day 10), the focus was on the CEX vs DEX distinction. This time, focus on what the smart contract is actually doing under the hood. That mental model is what lets you evaluate any new DEX you encounter for the rest of your time in this space.
2. Uniswap V2 Whitepaper (uniswap.org)
Eight pages. The clearest single explanation of how an AMM works.
Read on IMPCT (curated commentary) | Read original (uniswap.org)
Deven's take. If you remember nothing else from Week 3, remember that this whitepaper exists and is short enough to read in an evening. It is one of the most important documents in crypto. The math is high-school algebra. The implications are systemic. If you want to be conversant in DeFi, you read the Uniswap whitepaper at least once.
3. Curve and Jupiter (the other major AMMs worth knowing)
Stable-asset specialization and Solana-side aggregation.
Deven's take. Curve uses a modified formula (StableSwap) that produces dramatically less slippage when trading assets that should be close to 1:1 (USDC ↔ USDT, stETH ↔ ETH). Most stablecoin-to-stablecoin and major LST trading on Ethereum happens on Curve. Jupiter is Solana's dominant aggregator and arguably the smoothest trading interface in all of crypto. Worth visiting both if you want to see what the category looks like across different chains and use cases.
4. Impermanent Loss explained (Bankless, a16z, or similar)
The concept that breaks most new LPs.
Read on IMPCT (curated commentary + interactive calculator)
Deven's take. I'd argue impermanent loss is the single most misunderstood concept in DeFi. New LPs deposit into a "yield-bearing" pool, see numbers go up in fees, watch their underlying position go down in value relative to just holding, and conclude DeFi is a scam. It isn't. They just didn't understand what they were being paid for. Spend ten minutes on an impermanent loss calculator. The math is straightforward once you see it. The implication is large: providing liquidity is a directional bet, not a passive yield. Treat it accordingly.
5. DEX Volume on DeFi Llama (defillama.com/dexs)
The live scoreboard of DEX activity.
Deven's take. Bookmark this. Watch it. The chains and protocols that are winning the DEX volume race tell you a lot about where the on-chain economy is moving. Solana and Base have taken meaningful share in the last 18 months. Order book DEXs like Hyperliquid are growing fast on the derivatives side. The data is real. The narratives downstream of the data are often premature.
Tomorrow
Yield. Where it actually comes from in DeFi, what's sustainable, what's a Ponzi mechanic, and how to evaluate any "earn X% APY" claim using the framework we've been building. Lots of pattern recognition. Some hard lessons from real protocol failures.
See you in the morning.
Preview reader
You are reading a private preview of IMPCT Institute. If something landed, didn't land, or felt confusing on this lesson, tell us. Short notes are useful. Long notes are useful. No notes are also fine.