Rate Adjusted StableSwap pools

In the following, we consider an Interest Bearing Token integrated in Spectra. We assume all instruments start at t=0t=0 and expire at t=Tt=T.

StableSwap pools

Overview

StableSwap pools, developed by Curve Finance, are an AMM (Automated Market Maker) designed for trading pegged assets. They elaborate on the constant sum invariant to support an infinite price range by interpolating it with the constant sum invariant, while maintaining price impact minimal on almost all of the pool's range. For further information, we refer to the StableSwap Whitepaper.

Rate Adjusted StableSwap for PT/IBT market making

Using a raw StableSwap pool for exchanging Interest Bearing Tokens for Principal Tokens will not be efficient, since they are not necessarily pegged.

Indeed, we make take as an example Interest Bearing assets with external cash flows, such as rewards or points. The implied rate will take the external cash flows into account, while the value of the Interest Bearing token in underlying asset will not grow as quickly.

The oracle adjusts the internal prices of the AMM with rate oracles by converting the balances into underlying asset, both for the Principal Token and the Interest Bearing token, so that the pair behaves as a pegged pair inside of the AMM. This is achieved through the rate adjustment mechanism inside of Curve StableSwap, as described below.

The AMM's bonding Curve is exclusively used to incorporate implied interest rate volatility, delegating the predictable market drift's accounting to the rate oracles. This drastically improves liquidity usage for trading such a pair, compared to a classical AMM.

Rate Adjustment Oracles

Interest Bearing Token Oracle

Interest Bearing Tokens are ERC4626 compliant vaults. These vaults consist of an underlying asset reserve and a rate at which this reserve evolves. One can convert between shares of the vault and the underlying asset using the convertToAssets() method.

In mathematical terms, if (rt)t[0,T](r_t)_{t \in [0,T]} denotes the instantaneous rate process, then the price of an Interest Bearing Token since deployment is given by

B(t)=exp(0trudu)B(t) = \exp(\int_0^t r_u du )

Hence, to virtualise the Interest Bearing Token balance of the pool to its underlying value, we have to multiply that balance by the above rate.

This is achieved in practice by flagging the token at index 0 as an asset of type 3, i.e as an ERC4626 token, so that the StableSwap AMM knows it has to adjust the balances with the vault's rate.

Principal Tokens pricing

Principal Tokens are time bound instruments corresponding to a unit of underlying discounted by the implied interest rate over the term it is deployed on. They are the equivalent of zero-coupon bonds. They are redeemable for a unit of underlying at maturity when no negative interest rate has been registered in the underlying Interest Bearing Token, or else for a unit of underlying adjusted by the cumulative loss incurred by the negative interest. In Spectra, the variable that tracks the negative rate in the PT is referred to as the ptRate . In mathematical terms, the ptRate can be expressed as

α(t)=exp(0truχ{ru<0}du)\alpha(t) = \exp(\int_0^t r_u \chi_{\{r_u < 0\}}du )

Given an implied APY RR, the fair value of the Principal Token in underlying asset is given by

P(t,T,R)=PT.previewRedeem(1)(1+R)TtyearP(t,T,R) = \frac{\text{PT.previewRedeem(1)}}{(1+R)^{\frac{T-t}{\text{year}}}}

the previewRedeem\text{previewRedeem} function will diminish the par value proportionally to the amount of negative interest.

Let Rˉ\bar{R} be the expected implied APY. The Principal Token oracle will report P(t,T,Rˉ)P(t,T,\bar{R}). If X(t)X(t) denotes the internal price of the pool at time tt, we have that

X(t)P(t,T,Rˉ)B(t)=P(t,T,R)B(t)X(t) \frac{P(t,T,\bar{R})}{B(t)} = \frac{P(t,T,R)}{B(t)}

Rearranging, we get

X(t)=P(t,T,R)P(t,T,Rˉ)X(t) = \frac{P(t,T,R)}{P(t,T,\bar{R})}

or

X(t)=(1+RRˉ1+Rˉ)TtyearX(t) = \left (1 + \frac{R - \bar{R}}{1+\bar{R}}\right )^{\frac{T-t}{\text{year}}}

Therefore, with such choice of oracle for the Principal Token, the AMM prices the deviation of the implied rate from the expected rate over the given term.

In practice, this is achieved by flagging the token at index 1 as asset of type 1, i.e an asset whose price with respect to an underlying asset depends on an oracle. The oracle contract is RateAdjustmentOracle.sol and its value is fetched by the StableSwap algorithm before every state change.

Adjusting liquidity concentration

Holding RRˉR-\bar{R} constant, if RRˉ>0R-\bar{R} > 0, then XX is strictly decreasing and if RRˉ<0R-\bar{R} < 0 , then XX is strictly increasing. That means that assuming a constant maximal deviation of the implied rate from the expected implied rate, the price range in which liquidity is concentrated should get smaller the closer we get to maturity, to achieve a constant liquidity concentration profile in the implied interest rate space.

Let (A(t))t[0,T](A(t))_{t \in [0,T]} be the time-dependent amplification factor and Ft(x,y,A)F_t(x,y,A) be the StableSwap invariant, where x,yx,y represent the rate adjusted balances of Interest Bearing Token and Principal Token, respectively. Assume we want to support a maximal deviation of a factor β\beta of the implied APY, that is

Rmax=(1+β)RˉR_{\text{max}} = (1+\beta)\bar{R}

achievable at IBT/PT ratio of l<0.5l < 0.5 . Assume that xy>l\frac{x}{y} > l (the other case is analogue). Then A(t)A(t) is defined implicitly by

DyFt(xΔx,y,A(t))DxFt(x,y+φ(Δx),A(t))(1+βRˉ1+Rˉ)Ttyear=0\frac{D_yF_t(x-\Delta x,y,A(t))}{D_xF_t(x,y+\varphi(\Delta x),A(t))} - \left (1 + \frac{\beta \bar{R}}{1+\bar{R}}\right )^{\frac{T-t}{\text{year}}} = 0

where φ\varphi is the trading function implicitly defined by the invariant and Δx\Delta x is chosen such that

xΔxy+φ(Δy))=l\frac{x - \Delta x}{y + \varphi(\Delta y))} = l

Adjusting the fees

The fees are adjusted such that the base fee , taken on the implied APY, stays constant over the term.

Last updated