Module Overview
AMMs are the foundation of every decentralized trading interaction in crypto. Understanding the math beneath them changes how you evaluate trades, liquidity provision, and yield opportunities.
- An AMM is a smart contract that sets prices algorithmically based on the balance of tokens in a liquidity pool — no order book required.
- Uniswap's original formula is x*y=k: the product of token balances stays constant after each trade. This automatically sets prices and rebalances the pool.
- Uniswap v3 introduced concentrated liquidity — letting providers specify which price ranges they want to provide liquidity in, dramatically improving capital efficiency.
- Curve uses a different formula optimized for stablecoin pairs that should trade close to 1:1, delivering far lower slippage for stablecoin swaps than Uniswap.
- Impermanent loss is the cost liquidity providers pay for price volatility — what you would have had if you had simply held the tokens versus providing them as liquidity.
Key Terms
The vocabulary this module unlocks. Skim before you read.
- 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.
- 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.
- Concentrated liquidity
- The Uniswap V3 mechanism that lets LPs provide liquidity within a specific price range, improving capital efficiency.
The problem AMMs solved
Decentralized exchanges existed before Uniswap. They did not work.
The early DEXs (EtherDelta, IDEX, others) tried to recreate traditional order books on-chain. Traders would post buy and sell orders at specific prices, and the exchange would match them when the prices crossed. The architecture mirrored centralized exchanges with the trust assumptions removed.
The problem was liquidity. Without market makers willing to constantly post and update orders, order books would sit empty. Without order-book liquidity, traders would not show up. Without traders, no one wanted to provide liquidity. The chicken-and-egg problem killed every early DEX attempt.
Then Uniswap launched in November 2018 with a different design. No order book at all. Instead, a smart contract held a pool of two tokens and used a mathematical formula to set prices automatically. Anyone could swap. Anyone could deposit liquidity. The whole system bootstrapped without any centralized market making.
That design — the Automated Market Maker — is now the foundation of nearly all decentralized trading. Understanding the math is understanding why DeFi works at all.
The constant-product formula
Uniswap's original AMM used what is called the constant-product formula:
x times y equals k
Where x is the balance of token A in the pool, y is the balance of token B, and k is a constant that does not change during trades. When someone buys some of token A (removing it from the pool), they must add token B (increasing its balance) such that the product x times y stays equal to k.
This single equation does several things automatically.
It sets prices. The implied price of token A in terms of token B is y divided by x — the ratio of balances. As more token A is bought (decreasing x), the implied price rises. As more A is sold (increasing x), the price falls. The price moves continuously and responsively without any external input.
It enables slippage. Large trades move prices more than small trades, because they change the ratio more. This is built into the formula, not bolted on.
It eliminates the need for matched orders. There is no buyer and seller to pair up. There is one trader and one pool. The pool always has liquidity for some price, even if the price slips dramatically for very large trades.
It lets anyone be a market maker. Liquidity providers deposit token A and token B in equal proportional value into the pool. They get back LP tokens representing their share. They earn a share of trading fees proportional to their pool ownership.
This design was elegant enough that it bootstrapped instantly. Within months of launch, Uniswap had more liquidity than every previous DEX attempt combined. Within two years it was processing billions in daily volume.
The pricing curve
How buying token A pushes its price up — automatically
The hyperbolic curve is the set of all valid (x, y) pool states for a given k. As a trader buys token A, the pool moves rightward along the curve — y decreases (less of token B available) so each subsequent unit of A costs more. Slippage emerges from the math; no order book required.
How LP fees work
Every trade on an AMM pays a fee — usually 0.3% on Uniswap v2 — that goes to the liquidity providers in the pool. The fees are split proportionally to LP shares.
For a stable pool that processes high volume relative to its TVL, fees can be substantial. A $1B Uniswap pool that processes $500M in daily volume generates $1.5M per day in fees, distributed to LPs based on their share. That works out to a meaningful annualized return.
For a pool that processes low volume relative to its TVL, fees are minor. The LP is essentially holding the two tokens without earning much.
The math of LP returns is therefore: pool volume relative to TVL determines fee yield. Volatility of the tokens determines impermanent loss. Net return is fees minus impermanent loss. This is the calculation every liquidity provider should do before depositing.
Impermanent loss explained
The most important concept for liquidity providers to understand is impermanent loss. The name is misleading — once you withdraw, the loss is permanent — but the mechanism is straightforward.
When you provide liquidity to a pool, you deposit two tokens in equal value. As the price of the tokens moves, the AMM's formula automatically rebalances the pool. If one token rises in price, the pool ends up holding more of the cheaper token and less of the more expensive one. When you withdraw your liquidity, you receive the rebalanced amounts, not the original amounts.
The result: if you had simply held the two tokens in your wallet, you would have ended up with more value than if you had provided them as liquidity to a pool that experienced price divergence.
Concretely: suppose you deposited 1 ETH (worth $3,000) and 3,000 USDC into a Uniswap pool. ETH then rises to $4,000. The AMM rebalances. You withdraw and find you have less ETH and more USDC than you started with. The total value is something less than what you would have had if you had just held the original 1 ETH and 3,000 USDC.
The trading fees you earned during the period offset this loss to some degree, sometimes entirely. But in periods of rapid price movement, impermanent loss can exceed the fees collected.
The practical guidance: for pools of pegged or correlated assets (stablecoin pools, ETH/staked-ETH pools), impermanent loss is minimal. For pools of volatile assets, it can be substantial. Most experienced DeFi participants concentrate liquidity provision in pools where impermanent loss is structurally limited.
Uniswap v3: concentrated liquidity
Uniswap v3, launched in May 2021, introduced concentrated liquidity. The change was substantial enough to be a different game.
In Uniswap v2 (constant-product), liquidity is spread across the entire price range from zero to infinity. Most of that liquidity sits at prices that will never trade, doing no useful work. Capital efficiency is poor.
In v3, liquidity providers specify a price range. If ETH is trading at $3,000 and you think it will stay between $2,800 and $3,200 for the next month, you can provide liquidity only in that range. Every dollar you deposit is concentrated where actual trading happens. You earn much more in fees per dollar than the same liquidity would earn in v2.
The tradeoff: if the price moves outside your range, your position stops earning fees. The position is fully converted to whichever token underperformed in your range. You either re-deposit in a new range (paying gas) or wait for the price to come back.
Concentrated liquidity is more capital-efficient but requires active management. For institutional LPs and professional market makers, v3 dramatically improved economics. For ordinary users who do not want to actively manage positions, v2-style pools (or v3 full-range positions, which approximate v2) remain the simpler choice.
Specialized AMMs
Uniswap dominates general-purpose token trading. Specialized AMMs win in specific niches.
Curve Finance specializes in stablecoin and pegged-asset swaps. The Curve formula is optimized for pairs that should trade close to 1:1 — USDC/USDT/DAI, ETH/stETH, etc. The result is far lower slippage than Uniswap for these pairs. For converting between major stablecoins, Curve is the default. The CRV token and Curve's gauge-voting system created the "Curve Wars" of 2021-2022, where protocols competed to direct liquidity rewards to their own pools.
Balancer generalized Uniswap's design to support pools with more than two tokens and arbitrary token weights. A Balancer pool could hold 50% ETH, 30% WBTC, and 20% USDC. As prices move, the AMM automatically rebalances the pool back to those weights through trades. This is useful for creating on-chain index-fund-like products.
SushiSwap forked Uniswap in 2020 with a community-owned token model. It is smaller than Uniswap but operational across many chains.
PancakeSwap is the dominant DEX on BNB Smart Chain, with mechanics similar to Uniswap adapted for that ecosystem.
Across other chains — Solana's Jupiter and Raydium, Arbitrum's Camelot, Base's Aerodrome — the same patterns repeat with chain-specific variations.
The practical takeaway
AMMs are the foundation of decentralized trading. The constant-product formula is one of the cleanest design insights in crypto, and it is what allows DEXs to work at all. Understanding the math beneath it changes how you evaluate every trade and every liquidity opportunity.
For traders: AMM slippage is real and proportional to your trade size relative to pool depth. Use aggregators (1inch, Matcha) for trades of meaningful size. Check the pool's TVL and recent volume before assuming a quoted price is realistic.
For liquidity providers: impermanent loss is real. Most beginners should concentrate LP activity in stablecoin pools or pegged-asset pools where impermanent loss is structurally limited. Volatile-pair LP is closer to active trading than passive yield earning, and the math should be checked before depositing meaningful amounts.
For investors: AMMs are critical infrastructure. Uniswap's protocol fees alone produce hundreds of millions in revenue annually that flows to LP positions and (when activated) to UNI token holders. Understanding the mechanics is part of understanding where on-chain value capture actually happens.
The next module looks at bridges — the infrastructure that lets assets move between chains. Bridges have been the largest single source of crypto hacks historically, so understanding how they work and what makes them safe is essential.
Key takeaways
Carry these with you
01
The constant-product formula is one of the cleanest design insights in crypto. It solved a problem (DEX liquidity) that order-book designs could not.
02
Concentrated liquidity (v3) is a different game — capital-efficient but requires active management. Most ordinary users should stick with v2-style pools or full-range positions.
03
Specialized AMMs win in their categories: Curve for stablecoins, Balancer for portfolio rebalancing, Uniswap for everything else.
04
Liquidity provision is not free yield. Impermanent loss is real. Understand the dynamics before depositing meaningful amounts.
What you should now be able to do
- 01.Explain the constant-product formula (x*y=k) that powers basic AMMs and why it solves the liquidity bootstrapping problem.
- 02.Distinguish Uniswap v2 (uniform liquidity) from v3 (concentrated liquidity) and why the change matters for capital efficiency.
- 03.Identify specialized AMMs (Curve for stablecoins, Balancer for multi-asset pools) and the use cases each is built for.
- 04.Calculate impermanent loss for a specific scenario and recognize when liquidity provision is worth it.
Module quiz
Test what you learned
Pick an answer, see the result immediately, and check your reasoning against the explanation. The questions are tied directly to the outcomes promised at the top of this module.
Question 1 of 6
What is the constant-product formula used in AMMs?
Question 2 of 6
What is concentrated liquidity in Uniswap v3?
Question 3 of 6
What is Curve Finance specialized for?
Question 4 of 6
What is impermanent loss?
Question 5 of 6
How are AMM prices set?
Question 6 of 6
Why don't most ordinary users provide liquidity in volatile token pairs on Uniswap?
Read deeper
Curated readings for Module 17
Curve · and *Jupiter* (the other major AMMs worth knowing)
Curve is an Ethereum decentralized exchange specialized for trading assets that should be close to 1:1 in price (stablecoin pairs, liquid staking tokens, wrapped asset variants). The StableSwap formula produces dramatically lower slippage for these pairs than a constant-product AMM. Curve dominates stablecoin-to-stablecoin and LST trading on Ethereum. The CRV token and vote-escrow (veCRV) system have spawned a substantial derivative economy including Convex Finance and the 'Curve Wars' competition for governance influence. Jupiter is the Solana equivalent (architecturally an aggregator rather than an AMM) and is widely regarded as the smoothest trading interface in all of crypto.
DEX Volume on DeFi Llama
DeFi Llama's DEX Volume dashboard is the most-used independent tracker of on-chain decentralized exchange activity. It aggregates trading volume across chains and protocols with historical trend data. The metric matters because it's verifiably on-chain (resistant to wash-trading manipulation) and economically meaningful (real users moving real value). Patterns worth watching include chain market share shifts (Solana and Base gaining share in 2024-2026), protocol concentration within chains, the rise of order book DEXs like Hyperliquid on the derivatives side, and the growth of aggregators over direct DEX usage. The data is a current scoreboard, not a leading indicator of future price action.
Impermanent Loss explained
Impermanent loss is the difference between what an automated market maker liquidity provider holds in their pool position versus what they would have held if they'd just kept the original tokens. It arises because AMMs automatically rebalance the pool composition as trades happen — when one token appreciates, the pool sells your appreciating asset and buys more of the depreciating one. The 'impermanent' label is misleading because the loss becomes permanent if prices move and stay moved. The magnitude depends on the pair: nearly zero for stablecoin pairs, minimal for correlated pairs, significant for volatile-to-stable, and most complex for volatile-to-volatile. The literate framing is that liquidity provision is a directional bet, not a passive yield — you give up upside in exchange for fee income.
Understanding DEXs (Decentralized Exchanges) · The Block
Decentralized exchanges (DEXs) are smart contract-based trading venues that allow users to swap tokens without depositing assets at a centralized intermediary. The dominant architecture is the Automated Market Maker, which uses liquidity pools and mathematical formulas (most commonly the constant-product formula x·y=k) to determine swap prices. Variations include concentrated liquidity AMMs (Uniswap V3), StableSwap formulas (Curve), on-chain order books (dYdX, Hyperliquid), and aggregators that route across multiple sources (1inch, Jupiter, ParaSwap). Structural advantages over centralized exchanges include self-custody throughout, transparent state, permissionless access, and composability. Structural disadvantages include gas costs (mitigated by L2 deployment), slippage on illiquid pairs, and user responsibility for transaction construction.
Uniswap V2 Whitepaper
Eight pages. The clearest single explanation of how an AMM works.
Up next
Module 18 · Intermediate · 9 min
Bridges and cross-chain infrastructure
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.

