Quant Memo
Core

Stableswap and Curve-Style AMMs

A pool built to trade two assets that should always be worth about the same amount needs a different pricing formula than a normal AMM — one that stays flat near parity and only gets expensive once the pool is badly imbalanced.

Prerequisites: Automated Market Makers, Stablecoins and How Pegs Are Held

A plain constant-product pool (x×y=kx \times y = k) prices trades off a curve that gets steep fast. That is fine for two assets whose relative price can move a lot, but it is wasteful for two assets that are supposed to trade near 1:1, like two dollar stablecoins. A trader swapping $1 million of one stablecoin for another should get back close to $1 million, not suffer constant-product's slippage, which assumes any trade might be moving the "true" price.

Curve's StableSwap invariant solves this by blending two pricing rules: a constant-sum curve (x+y=kx + y = k, which prices every unit the same regardless of pool balance) near the 1:1 point, and a constant-product curve away from it. An amplification parameter, AA, controls how wide that flat region is — a higher AA means the pool behaves like constant-sum over a wider range of imbalance before the constant-product penalty kicks in.

StableSwap trades near-zero slippage close to the peg for a curve that gets steep fast once the pool drifts badly out of balance — a trade-off that only makes sense for assets that are supposed to be worth the same thing.

Why the blend matters

pool imbalance → price constant product StableSwap (flat near peg)
Near a 1:1 balance, StableSwap barely moves price at all; a plain constant-product pool starts penalizing size immediately.

The practical effect: liquidity providers earn fee income on high volume with much less exposure to being picked off by arbitrageurs, as long as the two assets actually hold their peg. If one asset depegs — trades away from $1 — the pool's flat region works against LPs, because the invariant keeps quoting close to 1:1 even as the true market price diverges, so the pool absorbs the falling asset and pays out the stable one until arbitrage rebalances it or the pool empties of the good asset.

Worked example

A StableSwap pool holds 5 million USDC and 5 million USDT with a high amplification coefficient. A trader swaps 500,000 USDC for USDT. Because the pool sits near perfect balance, the flat region of the curve applies almost fully: the trader receives close to 499,700 USDT (a few basis points of fee and negligible slippage), rather than the roughly 476,000 USDT a constant-product pool of the same size would return for a trade that large (using x×y=kx \times y = k: new x=5.5x = 5.5m, so new y=25m/5.5m4.545y = 25\text{m}/5.5\text{m} \approx 4.545m, a loss of about 455,000 USDT off the mid, far worse than StableSwap's few thousand dollars of slippage).

Now suppose USDT trades at $0.97 on outside markets after a rumor about its reserves. Arbitrageurs sell USDT into the pool (which still prices it near $1) and buy USDC, pushing the pool's USDT balance up and USDC balance down until the pool's implied price also reflects the discount. An LP in that pool ends up holding disproportionately more of the depegged asset — the same mechanism that makes the pool efficient in normal times concentrates depeg risk onto LPs when it isn't.

A high amplification coefficient makes slippage nearly invisible under normal conditions, which can lull LPs into treating the pool as risk-free. The flat pricing region is a bet that the assets stay pegged — it does not protect against one of them actually breaking the peg; it can make the pool absorb more of the bad asset before arbitrage catches up.

Related concepts

Practice in interviews

Further reading

  • Egorov, StableSwap: Efficient Mechanism for Stablecoin Liquidity
ShareTwitterLinkedIn