Automated market maker

Curve Finance

Short answer Curve runs separate AMMs for pegged assets, volatile assets, and markets priced elsewhere. StableSwap flattens the price near a peg. CryptoSwap concentrates liquidity around a moving scale. FXSwap recenters that kind of curve with a refuel budget. Stableswap-NG is the pegged-pool factory.

Written by
Published
Updated
What changed
Last verified
What this date means
Reading time
About 9 min
Version context
Stableswap-NG is the documented factory for pegged pools. CryptoSwap and FXSwap are separate AMM families. crvUSD is a collateralized stablecoin that uses LLAMMA, not a StableSwap pool.

Curve is an AMM project with more than one invariant. The one it is known for, StableSwap, prices assets that are supposed to be worth nearly the same thing: two dollar stablecoins, or an ETH derivative and ETH. A second design, CryptoSwap, prices assets that move. A third system, crvUSD, mints a stablecoin against collateral and is not a StableSwap pool at all. Treating “Curve” as a single constant-product exchange misses all three.

The generation guide separates the factory eras. This page is the mechanism.

Why constant product is the wrong default for a peg

A constant-product pool spreads liquidity from price zero to infinity. Two assets that should both be worth a dollar do not need that. Traders want depth at one. The StableSwap whitepaper builds an invariant between a constant sum, which has no slippage and eventually runs out of one coin, and a constant product, which always has a price but wastes depth.

The derivations page writes the invariant as:

A * n^n * Σ x_i + D = A * D * n^n + D^(n+1) / (n^n * Π x_i)

x_i is the balance of coin i, scaled into the pool’s math. n is the number of coins. D is the invariant, equal to the total balance when every coin is equal. A is the amplification coefficient.

When balances are near equal and A is large, the curve behaves like a constant sum: a trade barely moves the price. When one coin dominates, the product term dominates and the price can move sharply, which is what gives arbitrage a reason to return the pool toward the peg. The understanding-StableSwap page describes high A (it gives 500 to 10,000 as examples) as deep liquidity near the peg and a sharp drop if an asset leaves the peg. Lower A spreads liquidity and moves the price earlier. Those ranges are illustrations of the shape, not a recommendation for a new pool.

Conceptual illustration Two pricing shapes
Constant-product and StableSwap shapes A constant-product curve bends across the whole price range. A StableSwap-style curve stays flatter near the peg and steepens when balances diverge.
  • Constant product: liquidity is spread from a very low price to a very high price.
  • StableSwap shape: more of the liquidity sits near equal balances, then the curve steepens.

The paths are drawn to show the idea. They are not a plot of a live pool and they are not the StableSwap invariant evaluated at a particular amplification coefficient.

StableSwap is a poor fit for assets that are not meant to share a price. The same page says so and points volatile pairs at CryptoSwap. A high A on a volatile pair concentrates liquidity at a peg the assets will not keep.

What a liquidity provider actually holds

In Stableswap-NG, the integration guide and the factory overview say the pool contract and the LP token are the same contract. A deposit mints LP tokens. A withdrawal burns them. The LP token is a share of the pool’s liquidity, accounted against D, not a voucher for the exact basket deposited. If the pool is imbalanced, the coins you withdraw in a balanced removal are the current mix, and a one-coin withdrawal moves the price and pays the invariant’s slippage.

The NG factory deploys plain pools of up to eight coins and metapools. A metapool pairs one coin with the LP token of a base pool, so a swap can reach the base pool’s coins without merging their reserves into one contract.

Each coin has an asset type. The factory source documents four:

IdNameRate
0StandardNo extra rate. The unit is the token balance.
1OracleAn external rate, used for tokens such as wrapped staked ETH.
2RebasingThe balance itself changes, as with stETH.
3ERC-4626convertToAssets supplies the exchange rate.

The pool can therefore hold a rebasing token or a vault token without pretending every ERC-20 has a static balance. That rate is an input. If the oracle or convertToAssets is wrong, the invariant will still clear trades against the wrong value. The oracle page is the general version of that dependency.

NG pools are deployed from a factory implementation index. The integration docs say a pool keeps the implementation it was deployed with when the factory later adds a new one. “The NG factory” is not a single bytecode frozen for every pool address.

Fees are pool parameters. The integration guide describes an off-peg fee multiplier that raises the fee when the pool is away from balance. It also says the admin share in Stableswap-NG is hardcoded at 50 percent of trading fees, with the rest accruing to liquidity providers through the virtual price. That figure belongs to NG pools; older generations have their own settings.

CryptoSwap

CryptoSwap is for assets whose price should move. The whitepaper starts from a StableSwap-like invariant and replaces the constant amplification with a dynamic K:

K0 = Π x_i * n^n / D^n
K = A * K0 * γ^2 / (γ + 1 - K0)^2

A still concentrates liquidity. The understanding-CryptoSwap page says an A of 10,000 in CryptoSwap corresponds to an A of 1 in StableSwap. Copying a stablecoin pool’s A into a tricrypto pool uses the wrong scale.

gamma (γ) changes how the curve leaves the concentrated region. In the formula above, K is A times K0 times γ² / (γ + 1 − K0)². When the pool is away from balance, K0 is below 1, and a larger γ keeps that last factor closer to 1. The StableSwap-like behavior therefore persists further from balance: the concentrated region is wider. The understanding-CryptoSwap page is inconsistent on this. One sentence says higher gamma pulls more liquidity in around the center, while later sentences and the parameterization note say a higher gamma spreads liquidity wider. The formula, which the CryptoSwap whitepaper also gives, supports the second reading.

The internal price is a price_scale the pool updates. Liquidity concentrates around that scale. A trade away from it pays more slippage, which is the point: the pool is not offering v2-style depth at every price, and it is not offering StableSwap’s peg. The same page says a rebalance runs only after the internal price clears an adjustment step and the cost stays under half of the trading fees earned. If fees are too small, the center of liquidity can sit away from the market. That stuck state is a documented CryptoSwap failure mode.

FXSwap

FXSwap is a third pool family, for a market whose price is discovered somewhere else: the understanding-FXSwap page gives fiat pairs and an externally priced BTC pair as the examples. It prices with a StableSwap-style invariant so the depth stays concentrated, and it recenters that concentration with a profit buffer plus an explicit refuel budget. The page says refuels pay for the pool’s normal recentering. They do not set the price, and they do not guarantee the pool stays balanced. The page also says FXSwap is generally not the tool for primary price discovery. It is not a CryptoSwap deployment with a new ticker, and it is not a Stableswap-NG metapool.

crvUSD is not a pool type

The crvUSD overview describes a stablecoin minted against approved collateral. The monetary mechanism is LLAMMA, an AMM that converts collateral toward the stablecoin as the collateral price falls, instead of a single auction at a liquidation ratio. Soft liquidation is a different idea from Aave’s liquidationCall or Maker’s grab.

The same page versions the controller and AMM blueprints. V3 is described as the current blueprint on the controller factory. Existing markets keep the blueprint they were deployed with; setting a new implementation does not rewrite them. The overview lists markets on V1, V2, and V3. LlamaLend is a related lending deployment and is not the same contract family as a Stableswap-NG pool. The overview says LlamaLend v1 adopted the V3 blueprint, while LlamaLend v2 is a separate Vyper 0.4.3 modular architecture, so a market’s version decides which code it runs.

Savings crvUSD (scrvUSD) is described there as a yield-bearing wrapper that takes a portion of borrower interest. It is another tokenized claim, not the StableSwap LP token.

CRV, veCRV and gauges

The pool invariants above say nothing about who gets paid to provide liquidity. Curve’s incentive layer is separate and has its own vocabulary.

Holders lock CRV for between one week and four years and receive veCRV, computed as CRV locked times years remaining divided by four. Locking one CRV for four years gives one veCRV, and for one year gives 0.25. The balance decays linearly toward the unlock date and is not transferable. Each address has one active lock, which can be topped up or extended. The Curve docs give veCRV three uses: a share of protocol fees, a boost on CRV rewards, and voting power in the DAO, including the gauge weight votes that direct CRV emissions between pools.

A gauge is the contract where a pool’s LP tokens are staked to earn CRV. A pool becomes eligible for emissions when a DAO vote adds its gauge to the gauge controller, and gauge weights decide how much CRV each receives. The boost is the way veCRV reaches liquidity providers. The docs give it as B = min(2.5, 1 + 1.5 × (your veCRV / total veCRV) / (your deposit / gauge total)), between 1x and 2.5x. A provider with a small deposit in a large gauge and a large share of veCRV gets close to the maximum. A provider with none gets 1x. The page adds that the boost updates when a deposit, a withdrawal or a claim touches the gauge.

Three reading notes. The invariant and the emissions are independent: gauge weights change a pool’s CRV income, not its prices. A reported pool yield often includes boosted CRV, so a provider without veCRV should expect the low end of a range. And lock-based influence is concentrated by design, since four-year locks cost liquidity. The same mechanism appears in other protocols’ governance, and Pendle’s move from vePENDLE to sPENDLE is a case of a protocol dropping it. Aerodrome pushed the model further, with a weekly vote that directed nearly all emissions until Aero replaced it in October 2026, and Balancer retired veBAL in 2026.

When the compiler was the bug: July 2023

In late July 2023 several Curve pools were exploited, and the cause was not in the invariant or in the pool’s own logic. The Vyper project’s post-mortem says the flaw was in compiler versions 0.2.15, 0.2.16 and 0.3.0, where a change made to the compiler in 2021 removed a check that kept one storage slot per @nonreentrant key. Each decorator got its own slot, so functions that were meant to share a reentrancy lock did not. A contract compiled with an affected version and with a function that made an external call before updating its storage was exposed. The Curve pools hit were affected through that guard, and the fix landed in 0.3.1. The Vyper post-mortem dates the exploit to 30 July 2023, and it notes that protocols using those compilers had not been explicitly notified.

The lesson is about where trust sits. A pool can be correct as written and wrong as compiled. Immutable contracts cannot be patched, so the compiler version is part of the audit surface. Security assumptions lists toolchain risk with the others. A reader auditing a Curve pool or any Vyper contract should check which compiler version produced the bytecode.

Trust that remains

A StableSwap pool does not know whether a “stablecoin” will keep its peg. A makes the pool willing to sell the depegged asset slowly at first and then very quickly. Liquidity providers own that inventory. Governance, and in NG the pool creator, chooses coins, A, fees, and any rate oracle. Gauges that emit CRV are an incentives layer on top of the invariant. They do not change D.

An integrator pricing a pegged asset from a Curve pool is reading an invariant that assumes the peg. That price is only as good as the assumption. The security assumptions page puts pool-as-oracle risk next to the other external inputs these protocols take.

Versions in this overview

  • StableSwap (active) The pegged-asset invariant. Stableswap-NG is the current factory form documented for integrators.
  • CryptoSwap (active) A separate invariant for volatile pairs, with amplification and gamma around an internal price scale.
  • FXSwap (active) A two-asset pool for externally priced markets. StableSwap-style pricing, with refuels that pay for recentering.
  • crvUSD (active) A lending-and-mint system beside the AMMs. Controller blueprints are versioned, and existing markets keep the blueprint they were deployed with.

Common questions

Why does Curve StableSwap give low slippage near the peg?

Its invariant sits between a constant sum, which has no slippage, and a constant product, which always has a price. With balances near equal and a large amplification coefficient A, the curve behaves like a constant sum, so a trade barely moves the price. When one coin dominates, the product term dominates and the price moves sharply.

What does a Curve liquidity provider hold?

In Stableswap-NG the pool contract and the LP token are the same contract. The LP token is a share of the pool’s liquidity, accounted against the invariant D, not a voucher for the exact basket deposited. After an imbalance, a balanced withdrawal returns the current mix.

Is crvUSD a Curve pool?

No. crvUSD is a stablecoin minted against approved collateral. Its mechanism is LLAMMA, an AMM that converts collateral toward the stablecoin as the collateral price falls, which makes liquidation soft instead of a single auction at a liquidation ratio. It is not a StableSwap pool.

Can I reuse a StableSwap amplification value in a CryptoSwap pool?

No, the scales differ. The understanding-CryptoSwap page says an A of 10,000 in CryptoSwap corresponds to an A of 1 in StableSwap, so copying a stablecoin pool’s A into a tricrypto pool uses the wrong scale.

Sources

Check the claims yourself: each group below is a different kind of evidence. Code and specifications show what the contracts do. Documentation shows what the protocol says they do.

Source code

Documentation

Whitepaper

Security

Changes

  • : Resolved the CryptoSwap gamma direction from the invariant, and added the hardcoded 50 percent admin fee of Stableswap-NG.
  • : Re-read the CryptoSwap gamma wording, which still contradicts itself, and added the LlamaLend v1 and v2 distinction from the crvUSD overview.
  • : Added veCRV, gauges and the boost formula, and the July 2023 Vyper compiler incident that affected several Curve pools.

Every change to the publication is listed on What changed.

Keep reading

See something wrong or missing? Propose a change via pull request (src/content/protocols/curve.md) or report a correction. See how to contribute.