LPsLux Proposals
Markets & DeFi
LP-9202

StableSwap AMM

Final

Curve-style StableSwap invariant for pegged assets, interpolating between constant sum and constant product by an amplification coefficient

Category
LRC
Created
2025-12-01

Abstract

StableSwap implements the Curve invariant for trading between assets that should maintain a 1:1 peg (stablecoins, wrapped assets, liquid staking derivatives). The invariant interpolates between constant-sum (x + y = k, zero slippage) and constant-product (x * y = k, full slippage) based on an amplification parameter A. At typical operating ranges, StableSwap achieves 100-1000x lower slippage than constant-product AMMs for pegged pairs.

Motivation

Two dollars are not two different assets. Pricing them on x*y=k charges the trader slippage for a risk that does not exist while the peg holds — and offers no protection when it breaks. The amplification coefficient makes that trade-off explicit and tunable: near the peg the curve is nearly flat, and it degrades continuously into constant product as the pool skews.

Specification

Invariant

The StableSwap invariant for n tokens:

A * n^n * sum(x_i) + D = A * D * n^n + D^(n+1) / (n^n * prod(x_i))

Where:

  • A: amplification coefficient (higher = closer to constant-sum)
  • D: total deposit value at equilibrium
  • x_i: reserve of token i
  • n: number of tokens in the pool

Pool Types

TypeTokensTypical AUse Case
2-poolUSDC/USDT200USD stablecoins
3-poolUSDC/USDT/DAI100Multi-stablecoin
Meta-poolnewStable/3pool-LP50New stablecoin bootstrapping
LST-poolLUX/sLUX30Liquid staking derivatives

Amplification Ramping

The amplification parameter A can be adjusted by governance over a ramping period:

  • Ramp duration: minimum 1 day
  • Max change: 10x per ramp
  • Direction: increase (tighter peg) or decrease (more like constant-product)

Ramping prevents sudden invariant changes that could be exploited.

Fee Structure

  • Swap fee: 0.04% (4 bps) -- lower than constant-product or concentrated pools because stable pairs have lower IL risk
  • Admin fee: 50% of swap fee goes to protocol treasury
  • LP fee: 50% of swap fee accrues to LP tokens

LP Tokens

StableSwap LP tokens are fungible ERC-20. Deposits and withdrawals can be single-sided (any one token) or balanced (all tokens proportionally). Single-sided operations incur a small fee to compensate for the imbalance.

Virtual Price

The LP token's virtual price is D / totalSupply. It monotonically increases as fees accrue. This makes LP tokens suitable as collateral in lending protocols (LP-9203).

Rationale

A is a single knob with a physical meaning: the depth of the flat region around the peg. Ramping it over at least a day rather than in one transaction is what prevents a governance action from re-pricing the pool inside a block — the exploit that an instantaneous A change would enable.

Security Considerations

  1. De-peg risk: if an asset in the pool loses its peg, the pool concentrates into the depegged asset. The amplification parameter A determines how quickly this happens.
  2. Amplification attacks: malicious governance could ramp A to extreme values. The ramp rate limit and timelock mitigate this.
  3. Read-only reentrancy: the get_virtual_price() function must be called with a reentrancy guard when used as an oracle by external protocols.

Reference

ResourceLocation
StableSwap contractsgithub.com/luxfi/standard/contracts/amm/stable/
Pool factoryStableSwapFactory.sol
Math libraryStableSwapMath.sol
  • LP-9200 — constant-product pools
  • LP-9201 — concentrated liquidity
  • LP-9203 — LP tokens as collateral

Copyright (C) 2024-2026, Lux Industries Inc. All rights reserved.

Licensed under the MIT License.