Onchain Atlas

Curve StableSwap

An AMM invariant that blends constant-sum and constant-product curves to give like-pegged assets (stablecoins, wrapped assets) dramatically lower slippage than Uniswap-style pools, making Curve the deepest stablecoin liquidity venue in DeFi.

▶ Run interactive simulation animated mechanism with editable parameters

Statusmajor success
Launched2020-01
ChainsEthereum, later: many EVM L2s/sidechains
Mechanismshybrid invariant (constant-sum + constant-product), amplification coefficient (A), LP fee income + yield rehypothecation, metapools, vote-escrowed governance (veCRV) and gauge-weighted emissions (added Aug 2020)
Official sitehttps://curve.finance/
Project X@CurveFinance (verified_by_project_documentation)
FoundersMichael Egorov (@newmichwill)

How it works onchain

Diagram of how Curve StableSwap's mechanism worksOpen full-size diagram
Original diagram derived from this entry’s researched mechanism description.

Summary

Curve StableSwap is the AMM design published by physicist-turned-founder Michael Egorov in a November 2019 whitepaper ("StableSwap — efficient mechanism for Stablecoin liquidity") and launched on Ethereum mainnet in January 2020, initially under the StableSwap name before rebranding to Curve. Its core insight: Uniswap's constant-product invariant (x·y=k) wastes capital when the traded assets are supposed to be worth the same (DAI/USDC/USDT, or stETH/ETH). StableSwap interpolates between a constant-sum curve (zero slippage, but drainable) and a constant-product curve (never drainable, but high slippage), governed by an amplification coefficient. The result was order-of-magnitude better pricing for pegged-asset swaps, which made Curve the settlement layer for stablecoin liquidity in DeFi, the substrate of the "Curve Wars," and at its January 2022 peak roughly $24B in TVL.

Design (Mechanism)

The StableSwap invariant is a weighted combination of the constant-sum invariant (Σxᵢ = D, ideal for perfectly pegged assets) and the constant-product invariant (Πxᵢ = (D/n)ⁿ). The whitepaper introduces a "leverage" parameter χ that scales the constant-sum component: when χ→∞ the pool behaves like constant-sum (flat curve, near-zero slippage); when χ→0 it degrades to pure constant-product. Crucially, χ is made dynamic — it is largest when the pool is balanced and falls off as the pool becomes imbalanced, so the curve stays nearly flat around the peg but bends into a hyperbola near the edges, guaranteeing the pool can never be fully drained at a finite price. In implementation this is parameterized by the amplification coefficient A (e.g., A=2000 for tightly pegged assets, low A for looser pegs), and the invariant D is solved iteratively via Newton's method inside the contract.

Around the invariant, the production system added:

  • Vyper contracts (e.g., StableSwap3Pool.vy), audited by Trail of Bits; the canonical 3pool (DAI/USDC/USDT) at 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7 became DeFi's stablecoin benchmark.
  • Small swap fees (~0.04% originally) plus yield rehypothecation — early pools lent idle liquidity into Compound/yearn, so LPs earned lending yield on top of trading fees, offsetting the low fee tier.
  • Metapools — new stablecoins pair against the 3pool LP token instead of fragmenting liquidity across pairs, a permissionless bootstrap path any issuer could use.
  • CRV + veCRV (August 2020) — the Curve DAO layered vote-escrowed tokenomics and gauge-weighted emissions on top, letting CRV lockers direct inflation to pools. This is a separate experiment historically, but it is what weaponized StableSwap liquidity and triggered the Curve Wars (Convex, Yearn, StakeDAO accumulating veCRV).

Outcome

Major success — arguably one of the most consequential mechanism designs in DeFi. Curve became the default venue for pegged-asset swaps and the liquidity kingmaker for every new stablecoin and liquid-staking token; TVL peaked around $24B in early 2022 and the protocol still holds multi-billion TVL in 2026 (see DefiLlama). The invariant itself was never broken economically. The design was extended by Curve's own CryptoSwap/V2 whitepaper (dynamic-peg AMM for volatile assets, 2021) and copied or forked across essentially every chain (Saddle, Ellipsis, Wombat's variant, PancakeSwap stable pools, etc.). Failures happened at the edges: the July 30, 2023 exploit (~$70M initially at risk, roughly $50M+ drained, substantial amounts later recovered/returned) came from a Vyper compiler bug (broken reentrancy locks in versions 0.2.15–0.3.0) affecting pETH/ETH, msETH/ETH, alETH/ETH, and CRV/ETH pools — an implementation-toolchain failure, not a failure of the StableSwap math. Separately, StableSwap pools faithfully executed during depegs (UST 2022, USDC March 2023): pools drained into the depegging asset exactly as the curve dictates, transferring losses to LPs — behavior working as designed, painfully.

Why it worked

  • It priced a real economic fact into the curve. Pegged assets have a strong prior of 1:1; encoding that prior gave 10–100x better slippage per dollar of TVL than constant-product, so liquidity and volume compounded toward Curve.
  • Fail-safe geometry. The dynamic-leverage construction keeps constant-product behavior at the extremes, so the pool cannot be drained at a fixed price even when the peg breaks — a graceful-degradation property competitors' naive constant-sum designs lacked.
  • LP economics were stacked: trading fees + lending yield + (later) CRV emissions made passive stablecoin LPing genuinely attractive, solving the cold-start problem.
  • Metapools made Curve infrastructure, not just an exchange: every new stablecoin issuer had a standard, permissionless way to bootstrap deep liquidity, entrenching the 3pool as a Schelling point.

Limitations and criticisms

  • Toolchain risk materialized: the 2023 Vyper compiler reentrancy bug showed that even heavily audited contract logic inherits the failure modes of its compiler; ~$70M was put at risk across four pools, and large CRV-collateralized loans elsewhere in DeFi nearly cascaded into a liquidation event as the token price fell — exposing how concentrated a governance token's use as external lending collateral had become.
  • LPs are structurally the exit liquidity in depegs — StableSwap concentrates liquidity at the peg, so when a peg breaks (UST, briefly USDC), LPs end up holding almost entirely the failing asset.
  • A (amplification) is a governance-set parameter, and a wrong A for an asset's true peg-tightness misprices risk; ramping A on an imbalanced pool can also leak value.
  • The moat migrated from math to emissions: once the invariant was freely forked, Curve's defensibility came to depend on veCRV politics and bribe markets rather than the mechanism itself, and fee revenue relative to CRV emissions was a persistent criticism.

Lessons

  • Encode your prior into the invariant. The biggest AMM efficiency gains come from shaping the bonding curve around what you know about the assets' relative value, not from fee tuning — a lesson later generalized by Uniswap v3 concentrated liquidity and Curve V2.
  • Degrade gracefully. Blending toward constant-product at the extremes meant peg failures hurt LPs but never produced an infinite-loss or fully-drained-at-fixed-price state; safety came from geometry, not from admin intervention.
  • Your security perimeter includes your compiler. Audits of source code did not catch a codegen bug; critical DeFi infrastructure needs compiler-level verification, differential testing, and version diversity.
  • Capital-efficiency mechanisms create political economies. Because StableSwap liquidity was so valuable to stablecoin issuers, the emissions layer on top of it (veCRV gauges) became a market for influence — mechanism designers should anticipate that whoever allocates liquidity incentives becomes a power broker.
  • Concentrated liquidity concentrates depeg risk. The flatter the curve at the peg, the more completely LPs absorb a peg break; disclosure and risk-tranching for LPs matter.

Redesign (EDITORIAL — hypothesis, not fact)

This section is a hypothesis, not established fact. A modern redesign would keep the invariant but attack the two proven weak points: toolchain risk and depeg tail-risk. (1) Ship pools with formally verified codegen (or at minimum, N-version deployments across two compilers with an on-chain output-equivalence check) and per-pool circuit breakers that pause only the affected pool when reentrancy-lock invariants are violated. (2) Make A endogenous: derive amplification from a trailing oracle of realized peg deviation instead of governance votes, so the curve automatically flattens for tight pegs and steepens as an asset shows depeg variance — reducing both governance attack surface and LP tail losses. (3) Offer tranched LP shares (senior tranche exits first in a depeg, junior earns higher fees), converting the implicit "LPs are exit liquidity" tail into a priced, opt-in instrument. (4) Route a hard-coded minimum of swap fees to an on-chain insurance backstop before emissions, addressing the criticism that security spending was subordinate to token politics.

Sources

  1. StableSwap — efficient mechanism for Stablecoin liquidity (Michael Egorov, Nov 2019 whitepaper, mirror) — primary (docs)
  2. curvefi/curve-contract — Vyper StableSwap pool contracts (incl. StableSwap3Pool.vy) — primary (contract)
  3. Curve: DAI/USDC/USDT (3pool) on Etherscan — primary (contract)
  4. Curve official docs — primary (docs)
  5. Curve Pool Reentrancy Exploit Postmortem, July 30 2023 (LlamaRisk) — primary (audit)
  6. Vyper Incident Analysis (CertiK) (analysis)
  7. Curve Finance TVL & metrics (DefiLlama) (analysis)
  8. Curve V1: The StableSwap Invariant (mechanism walkthrough) (analysis)
  9. Automatic market-making with dynamic peg (CryptoSwap/Curve V2 whitepaper) — primary (docs)

Related experiments

Last verified: 2026-07-26 · Spot an error? Suggest a correction