Guide

Liquidity pools and AMM mechanics explained

A liquidity pool is a shared pot of two (or more) tokens locked in a smart contract so traders can swap between them without a traditional order book. An automated market maker (AMM) is the pricing rule that decides how much token B you receive when you deposit token A. Together they power most decentralized exchanges on Solana, Ethereum, and beyond. This guide walks through how the math works, why people supply liquidity, what impermanent loss actually measures, and when concentrated liquidity or order-book venues make more sense.

Order books vs pools

A centralized exchange matches buyers and sellers on an order book — discrete bids and asks at specific prices. A market maker posts quotes on both sides and earns the spread. Depth is limited by how many resting orders exist at each price level.

An AMM flips the model: instead of waiting for a counterparty, you trade against the pool's reserves. The pool always quotes a price derived from its current token balances. Anyone can become a market maker by depositing tokens — a liquidity provider (LP) — and earn a share of swap fees.

Trade-offs in one glance:

  • Order books excel when professional makers quote tight spreads on liquid pairs (BTC/USD, ETH/USD) and when price discovery needs fine granularity.
  • AMMs excel at permissionless listing — any token pair can get a pool on day one — and at composability: other protocols can route through pools programmatically.
  • Hybrid DEXes combine both: on-chain order books with AMM fallback, or routers that split flow across venues for best execution.

The constant-product formula (x × y = k)

The classic Uniswap v2-style AMM keeps a simple invariant: the product of the two reserve amounts stays constant (before fees). If the pool holds x units of token A and y units of token B, then after any trade (ignoring fees):

x × y = k

When you buy token B with token A, you add A to the pool and remove B. The formula recalculates the new balances so the product equals the same k. Larger trades move the ratio more — that price impact is slippage.

The spot price of B in terms of A is approximately y / x (how much B per unit of A). As you buy B, y falls and x rises, so the marginal price climbs. Small swaps near the current ratio pay near the displayed price; whale swaps walk the curve and pay progressively worse average prices.

Most live pools charge a fee on each swap — often 0.05% to 1% — that stays in the reserves, slightly increasing k over time. That fee stream is what LPs compete for.

Providing liquidity: LP tokens and fee share

To join a pool you deposit both assets in proportion to the current price — for a 50/50 ETH/USDC pool at $3,000, that might mean 1 ETH and 3,000 USDC. The contract mints LP tokens representing your share of the pool. Redeeming LP tokens withdraws your proportional slice of both reserves, including accumulated fees.

Your earnings depend on:

  • Volume — more swaps mean more fees collected.
  • Fee tier — 0.3% pools earn more per dollar traded than 0.05% pools, but may attract less volume if traders route elsewhere.
  • Your share — if you own 1% of LP supply, you claim ~1% of fees.
  • External incentives — governance token emissions can boost APY but dilute holders and often dry up.

Quoted APYs on pool dashboards usually assume fee income continues at recent rates. They rarely stress-test impermanent loss or token price crashes. Treat headline yield as a starting point, not a bond coupon.

Impermanent loss — what it really means

Impermanent loss (IL) is the opportunity cost of LPing versus simply holding the same two tokens in your wallet. The AMM rebalances your position as prices move: if token A rallies, the pool automatically sells A for B, so you end up with less of the winner than if you had held.

"Impermanent" because if prices return to your entry ratio, the loss versus holding disappears — you are back on the curve. The moment you withdraw at a different price, the loss becomes real.

Rough intuition for a 50/50 pool when one asset doubles in price versus the other:

  • Holding: your portfolio value rises ~50% (half doubled, half flat).
  • LPing: the pool sold some of the winner; your portfolio rises ~25% plus fees.
  • The gap (~25% before fees) is impermanent loss at that price divergence.

IL grows with price divergence in either direction. Stablecoin-stablecoin pools (USDC/USDT) have minimal IL because prices stay pegged; volatile/volatile pairs (SOL/meme coin) can see IL swamp fee income in a trending market. LPs in trending pairs are effectively selling rallies and buying dips — fine in a range, painful in a breakout.

Slippage, price impact, and routing

Wallets and aggregators show price impact before you confirm a swap. Impact rises when:

  • Your trade size is large relative to pool depth.
  • The pool is thin — few LPs, or most liquidity concentrated far from spot.
  • You trade illiquid long-tail tokens with shallow pools.

Slippage tolerance is your maximum acceptable deviation from the quoted price. Set it too tight and volatile txs fail; too loose and MEV bots or stale quotes can fill you at a bad rate. Aggregators split orders across multiple pools (and chains) to minimize total impact — the same economic problem as smart order routing on traditional exchanges.

On Solana, fast block times and low base fees make splitting across pools cheap, but failed simulations still happen when pools move between quote and execution. Always simulate before signing — see our transaction simulation guide for preflight patterns.

Concentrated liquidity and newer AMM designs

Classic x*y=k spreads capital across every price from zero to infinity. Most of that liquidity never trades — USDC/ETH liquidity at $0.01 per ETH is useless when ETH trades at $3,000.

Concentrated liquidity (Uniswap v3 style, and analogs on Solana) lets LPs choose a price range. Capital inside the range acts like a deeper pool; outside the range it earns no fees until rebalanced. Active LPs can earn higher fee APY on the same capital but must monitor ranges and pay gas to reposition.

Other variants address specific pain points:

  • Stableswap curves (Curve-style) — flat pricing near 1:1 for pegged assets, steeper penalties far from peg.
  • Weighted pools (Balancer-style) — 80/20 or custom weights instead of strict 50/50.
  • Single-sided staking — protocols sometimes accept one token and auto-hedge, shifting IL risk to the protocol (not eliminating it).

No formula removes risk; each design reallocates it between traders, LPs, and governance token holders.

Risks beyond the math

Understanding the curve does not make LPing safe. Real pools carry:

  • Smart contract risk — bugs, upgrade keys, or malicious admin functions can drain reserves.
  • Oracle and peg risk — lending protocols that use LP tokens as collateral can cascade liquidations if a stablecoin depegs.
  • Rug pulls and fake tokens — permissionless listing means scam pairs sit next to legitimate ones; verify contract addresses.
  • Regulatory and bridge risk — cross-chain wrapped assets may not redeem 1:1 if a bridge fails.

Fee yield is compensation for taking these risks plus IL. When APY looks too good on a thin, anonymous pair, assume you are the product.

When to use an AMM vs something else

Use a pool when you need instant execution on a long-tail pair, when you are willing to pay visible slippage for simplicity, or when you want passive fee income on pairs you believe will trade in a range. Use an order book or OTC desk when size is large relative to on-chain depth, when you need a fixed price quote, or when regulatory KYC requirements apply.

For stablecoin swaps near peg, prefer stable-optimized curves or deep stable pools over generic 0.3% volatile pairs — IL and slippage are usually lower. For macro context on why pegs matter, see our stablecoin peg mechanics explainer.

Key takeaways

  • AMMs price swaps from pool reserves using formulas like x × y = k, not from resting limit orders.
  • Liquidity providers earn swap fees but face impermanent loss when prices trend away from their entry ratio.
  • Slippage grows with trade size and shrinks with pool depth; aggregators route across pools to reduce impact.
  • Concentrated liquidity improves capital efficiency but demands active management.
  • Quoted APY ignores smart contract, peg, and rug risk — model fees minus IL minus tail risks.

Related reading