# Stableswaps
To synergize with the proliferation of stablecoins and stable pairs in the Cosmos ecosystem, the Nibi-Swap AMM supports stableswap pools based on Curve Financeβs Stableswap curve (opens new window).
The stableswap curve operates like a constant-price curve when a portfolio of assets is balanced and tends toward behaving like a constant-product curve if the tokens lose peg.
Variable | Description |
---|---|
Liquidity depth. The liquidity depth denotes the sum of all token quantities when they have an equal price. | |
Reserve amount amount of coin | |
The total number of tokens. The number of elements in the set . |
# Amplification
How strongly the stableswap curve behaves like a constant-price curve is expressed by a non-negative quantity called the "Amplification", . When , the curve behaves more like a constant product, and as , the curve acts more like a constant-sum.
When changes occur to the reserves of a stableswap pool, we solve for the liquidity depth using the following this constraint equation:
This is done iteratively with Newton's method (opens new window), which is useful for approximating roots, zeros, or intercepts of real-valued functions. It's particularly useful here because the constraint equation doesn't have a clear analytical solution. The implementation for this is inside the SolveStableswapInvariant
function of dex/types/pool.go (opens new window)