IMPCT Institute
← Course outline
Module 17·Part 3DeFi & Applications

Automated Market Makers (AMMs) in depth

By Deven Davis·9 min read

Uniswap was not the first decentralized exchange. It was the first one that worked. The breakthrough — the Automated Market Maker — replaced order books with a mathematical formula and solved a chicken-and-egg problem that had killed every prior attempt. Understanding the math is understanding why DEXs work at all.

By the end of this module

You will be able to:

  • Explain the constant-product formula (x*y=k) that powers basic AMMs and why it solves the liquidity bootstrapping problem.
  • Distinguish Uniswap v2 (uniform liquidity) from v3 (concentrated liquidity) and why the change matters for capital efficiency.
  • Identify specialized AMMs (Curve for stablecoins, Balancer for multi-asset pools) and the use cases each is built for.
  • Calculate impermanent loss for a specific scenario and recognize when liquidity provision is worth it.
Automated Market Makers (AMMs) in depth

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

x · y = kBefore swapx=10, y=10After buying 6 of token Ax=16, y=6.25POOL BALANCE OF TOKEN A (x)POOL BALANCE OF TOKEN B (y)

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

  1. 01.Explain the constant-product formula (x*y=k) that powers basic AMMs and why it solves the liquidity bootstrapping problem.
  2. 02.Distinguish Uniswap v2 (uniform liquidity) from v3 (concentrated liquidity) and why the change matters for capital efficiency.
  3. 03.Identify specialized AMMs (Curve for stablecoins, Balancer for multi-asset pools) and the use cases each is built for.
  4. 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.

  1. Question 1 of 6

    What is the constant-product formula used in AMMs?

  2. Question 2 of 6

    What is concentrated liquidity in Uniswap v3?

  3. Question 3 of 6

    What is Curve Finance specialized for?

  4. Question 4 of 6

    What is impermanent loss?

  5. Question 5 of 6

    How are AMM prices set?

  6. 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

Up next

Module 18 · Intermediate · 9 min

Bridges and cross-chain infrastructure

Back to Module 16 · Lending and borrowing on chain

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.

Send feedback on Module 17Opens your email with a short template prefilled.