Technical Design
Capital efficient multi-Asset stableswap
Last updated
Capital efficient multi-Asset stableswap
Last updated
Numéraire is a Stableswap AMM which pools a number of stablecoins together into a single multi-asset pool. This pool has properties of both a weighted pool and a stableswap pool.
The multi-asset pool is the composition of two asset pairs, one per stablecoin, where each two asset pair has liquidity in the respective stablecoin, and liquidity in another asset, star (*). Star can be thought of as value, or as a numéraire, and codifies the concept of a single US dollar worth of value.
Initially each two asset pair is seeded with an equal amount of its stablecoin and of star, representative of the assumption that every stable trades 1:1 with *. Therefore initially all stables trade 1:1 with each other, through *. We only require that each pair has the same amount of * and its stable, but different pairs amongst a single pool can have different initial deposits of stables. Hence the proportion of the multi-asset pool that is made up of each stable gives an equilibrium weight for each stablecoin, where .
For example we might seed the pool with 45% USDC, 35% USDT, and 20% PYUSD. Swaps between any pair of stables which pair to * can be implemented as two-hop swaps, first into *, then out of it. Thus the star graph of LPs this setup creates can be thought of itself as a single multi-asset pool. By restricting swaps to only be two hops (never terminate at *), the exchange rate of * to each token is in a way an oracle to the free market value of these stablecoins, without * itself being a holdable asset.
Open market arbitrage: The exchange rate offered by our multi-asset pool (amount of token out over amount of token in) is , equaling the open market exchange rate, assuming rational arbitrages.
Swaps preserve constant value of *: The amount of * across the multi-asset pool is constant across swaps. * is only being moved across two asset pools, but never exiting the system.
Achieves value weights only at equilibrium: Let be the proportion of the multi-asset pool (ignoring *) that is made up of stablecoin . The multi-asset pool has token proportions equal to the initial seeding weights (), if and only if . Otherwise there is an imbalance whereby some stablecoin can be traded to get more than 1 of some other stablecoin.
💡Intuitively the multi-asset pool is most capital efficient when the liquidity is distributed according to the initial weighting (the initial weighting is an anchor point for our CFMM). When this is not the case, the pool offers swaps towards equilibrium a premium.
Recall that good StableSwap invariants balance a tradeoff between constant product and constant sum , trying to behave like the latter as much as possible while still charging a price impact as reserves deplete.
Our two asset pool bonding curve is based on the Wombat invariant (see page 5), which provides an elegant formulation of a Curve-like stableswap invariant. Specifically given token amounts and , we start with the invariant
where is an amplitude parameter to control how much we behave like constant product vs. constant sum. Note that we do not adopt the coverage ratio formulation of Wombat.
Note that Curve Finance's StableSwap AMM invariant with the settings of its PYUSD/USDC pool reserves 5% of the pool liquidity for prices more than 1% off from the peg. To seek more capital efficiency out of our invariant, we seek to bound the prices at which liquidity is concentrated. Let be the price of token in our pool, in terms of token (, where is the amount of token we get out for swapping in an infinitesimal amount of token ). We want the price to be bounded at all valid states under our invariant, where these price bounds are decided at pool creation time (ie. ).
To achieve this bounded StableSwap property, we borrow the virtual reserves concept of Gyroscope Finance’s CLP. We modify the invariant to be:
where is a function of and is a function of . Unlike most CFMMs which satisfy output-boundedness (page 11) (no matter how much you swap, there is some of each asset left), we have removed this property, so at the price points and the pool will be at max extent, containing all token and no token , or all token and no token , respectively. In these states the pool only supports swapping in one direction.
By setting the liquidity constant of the right hand side to , we get the intuitive definition of that it is the total value of tokens in the pool. This is because initially , making the left hand side equal the right hand side.
The pool was initially seeded in equilibrium state where . Call this state , where all tokens trade 1:1 and all reserves are proportionate to the asset weighting of the pool. It serves as a constant function anchor point. Let be the state of the multi-asset pool (a set of two-asset pools, each between a different stablecoin and *). Then in all valid multi-asset states:
So there is always a sequence of two asset swaps, one per pool (some of which may be empty swaps) bringing the pool to the equilibrium state. Specifically the state where all tokens trade 1:1:…:1 (each two asset pair has equal amounts of token and star, ), and the pool has token balances proportionate to the token weights. The composition of the two asset invariants under our star-preserving swap rule defines a CFMM, whole multi-asset pool invariant is that is an anchor point to our current state .
We know that this invariant trivially holds initially, as we start in state . Furthermore any sequence of swaps is reversible (each swap has an inverse swap undoing its action) and therefore the invariant holds across swaps.