Skip to main content

Pendle AMM

The Pendle AMM aims to minimize time-dependent impermanent loss that arises from the provision of liquidity using tokens with time decay.

The Math behind Pendle's AMM

The Pendle AMM observes the formula:

xαi+1yβi+1=xiαi+1yiβi+1x^{\alpha_{i+1}} \cdot y^{\beta_{i+1}} = x_i^{\alpha_{i+1}} \cdot y_i^{\beta_{i+1}}

where

α\alpha: the weight of xx at time=i+1time = i + 1
β\beta: the weight of yy at time=i+1time = i + 1
xix_i and yiy_i: the equilibrium point of xx and yy at time=itime = i

At time=0time = 0, α\alpha and β\beta are initiated at 0.5, the quantity of Token X and Token Y is initiated by the market creator which translates to xx and yy. The curve will resemble Uniswap's constant product curve. When a swap happens, the equilibrium point shifts along the curve. At subsequent time step time=itime = i, α\alpha and β\beta will change with the following formulas:

αi+1=αiϵiβi+1=βi+ϵi\alpha_{i+1} = \alpha_i - \epsilon_i \beta_{i+1} = \beta_i + \epsilon_i

where

ϵi=αiβi(1Ri)(Riαi)+βiRi=p(tnow)p(teq)p(t)=ln(3.14t+1)ln(4.14)t(T)=TendTTendTstarttnow=t(Tnow)teq=t(Teq)\epsilon_i = \cfrac{\alpha_i \cdot \beta_i \cdot (1 - R_i)}{(R_i \cdot \alpha_i) + \beta_i} \\ R_i = \cfrac{p(t_{now})}{p(t_{eq})} \\ p(t) = \cfrac{ln(3.14 \cdot t+1)}{ln(4.14)} \\ t(T) = \cfrac{T_{end} - T}{T_{end} - T_{start}} \\ t_{now} = t(T_{now}) \\ t_{eq} = t(T_{eq})

tt: time to maturity from 1 to 0 TT: UNIX timestamp TstartT_{start}: contract start timestamp TendT_{end}: contract end timestamp

The changing weights of X and Y cause changes in the shape of the curve.

Graph

The pivot point for curve shifting is the equilibrium point of X and Y at the time of curve shift. Swapping between X and Y changes the equilibrium point, and the pivot point for curve shift will vary accordingly.

At time close to TendT_{end}, the slope of the curve will be near zero. And reaches zero at TendT_{end}.

Curve Shifting

The Pendle curve shifting algorithm closely resembles the concept of option pricing models, where price decays more drastically towards the end of the contract than at the beginning. The magnitude of price decay over time is represented by the p(t) formula outlined in the section above.

The motivation for the constants chosen for the above formula is the fact that the price loses about 1/3 of its original value (at the beginning of the contract period) when time to maturity reaches 50%.

Graph
The function of price (fraction) w.r.t. time remaining to maturity

Fees

There will be a default 0.35% liquidity provider fee for all trades against liquidity pools on the Pendle's AMM. This fee will be adjustable via governance proposals and voting once it goes live.

The Pendle AMM is designed to support a protocol-level exit fee to be used to support continual work on the Pendle platform. However, it is currently being set to 0% and will be changeable via governance proposals if deemed necessary.

LP Token Issuance/Burning

The LP token issuance will be in proportion to the liquidity provided to the pool.

Liquidity Provision

Taking inspiration from Balancer, for a generic joinMarketByAll, the LP tokens received by the depositor is the ratio of deposited tokens to the current reserves of the token in the pool. In other words:

inAmount=(totalLP+outAmountLPtotalLP1)BininAmount = (\cfrac{totalLP + outAmount LP}{totalLP} - 1) \cdot B_{in}

derives to

outAmountLp=(inAmountBin)totalLpoutAmountLp = (\cfrac{inAmount}{B_{in}}) \cdot totalLp

where

BinB_{in}: inTokenReserve.balance
WinW_{in}: inToken Reserve.weight

Liquidity Withdrawals

Without considering the swapFee, the liquidity withdrawal formula is the inverse of that provision (without swapFee considerations).

With swapFee, adapting from Balancer, the formula for outAmountToken given inAmountLp is:

outAmountToken=Bout(1(1inAmountLptotalLp)1Wout)(1(1Wout)swapFee)outAmountToken = B_{out} \cdot (1 - (1 - \cfrac{inAmountLp}{totalLp})^{\cfrac{1}{W_{out}}}) \cdot (1 - (1 - W_{out}) \cdot swapFee)

where

BoutB_{out}: outTokenReserve.balance
WoutW_{out}: outTokenReserve.weight