MrDeFi
DeFi Protocols2026-07-194 min read

What Is the StableSwap Invariant Used by Curve?

The StableSwap invariant blends constant-sum and constant-product math for low-slippage swaps between pegged assets. Here's how it works.

The StableSwap invariant is a specialized automated market maker formula, popularized by Curve, that blends a constant-sum pricing model with a constant-product pricing model to achieve dramatically lower slippage than a standard AMM for trades between assets expected to trade near the same value — like different stablecoins or wrapped versions of the same underlying asset.

Why standard AMM math isn't ideal for pegged assets

A standard constant-product formula, used by most general-purpose AMMs, prices trades so that the product of the two pooled assets' quantities remains constant. This works reasonably well for any pair, but it produces meaningful price impact (slippage) even for moderately sized trades, because the formula assumes no special relationship between the two assets' relative value.

For assets that should trade near parity — two different stablecoins pegged to the same currency, or a token and its wrapped representation on another format — this is wasteful. The market already expects these assets to be worth nearly the same amount; a swap between them should ideally execute at close to a 1:1 rate regardless of trade size, as long as the pool has reasonable depth. Standard constant-product math doesn't take advantage of this expectation, producing more slippage than the underlying relationship between the assets would justify.

The constant-sum alternative — and its flaw

A constant-sum formula, at the other extreme, prices trades so that the total sum of the two assets stays constant, allowing genuinely 1:1 swaps with zero slippage — but only as long as the pool holds both assets in reasonable proportion. The critical flaw: if one asset in the pool depegs or the market genuinely believes the two assets are no longer equivalent, a constant-sum pool can be completely drained of one asset, since it keeps offering a 1:1 rate even when it shouldn't, with no automatic price adjustment to reflect changing reality.

StableSwap's hybrid solution

The StableSwap invariant combines both formulas, weighted by an amplification parameter. Near the pool's balanced point — where both assets are held in roughly the proportion expected — the formula behaves almost like constant-sum, offering very low slippage for typical trades. As the pool becomes increasingly imbalanced (moving away from that expected proportion), the formula progressively shifts behavior toward constant-product, which naturally increases price impact and discourages further imbalance, while still never becoming worthless in the way pure constant-sum could.

This gives StableSwap pools the best of both worlds within their expected use case: extremely low slippage for the common case (assets genuinely near parity), while retaining a self-correcting price mechanism if the pool becomes significantly imbalanced or one asset's peg comes under real stress.

The amplification parameter

The degree to which a StableSwap pool behaves like constant-sum versus constant-product near the balanced point is controlled by an amplification coefficient. A higher amplification value makes the pool behave more like constant-sum across a wider range of balances (tighter, more efficient pricing for typical trades, but a sharper transition if the pool becomes significantly imbalanced). A lower amplification value makes the pool behave more conservatively, closer to standard constant-product math, across more of its range.

Comparing the formulas

Formula Slippage near balance Behavior if pool becomes imbalanced Best suited for
Constant-product Moderate to high Gradual, self-correcting General, uncorrelated asset pairs
Constant-sum Near zero Can be fully drained — no self-correction Never used alone in practice
StableSwap (hybrid) Very low near balance Shifts toward constant-product, self-correcting Pegged/correlated asset pairs

Why this matters beyond Curve

The StableSwap invariant became foundational infrastructure for stablecoin liquidity across DeFi — it's the reason large stablecoin swaps can execute with minimal price impact, which in turn supports the practical usability of stablecoins as a medium of exchange within DeFi. The same underlying approach has been adopted, in varying implementations, by other protocols building pools for correlated assets, including some of the specialized pool types offered by Balancer.

Bottom line

The StableSwap invariant solves a real limitation of general-purpose AMM math by recognizing that pegged or correlated assets deserve a specialized pricing formula — one that offers near-zero slippage under normal conditions while still retaining a self-correcting mechanism if a peg genuinely comes under stress. Understanding this distinction helps explain why stablecoin swaps on specialized pools consistently outperform the same trade on a general-purpose AMM, and why a pool's amplification parameter is worth checking before assuming a stablecoin swap will always be nearly free of slippage. Compare current pool depth and rates on the yield dashboard.

Related articles

This article is for educational purposes only and is not financial advice. DeFi involves significant risk, including total loss of funds. Always do your own research.