Skip to main content

Impermanent Loss

Introduction#

Impermanent loss (IL) refers to the loss that funds can be exposed to when they are deposited in a liquidity pool. This is one of the main challenges of liquidity providers (LPs) who provide the funds for these pools. If IL exceeds earned fees, it means they suffered negative returns compared with simply holding their tokens outside the pool. Generally, the larger the relative price changes in a pool, the bigger the impermanent loss will be. Indeed, the most valuable tokens should in theory be bought from the pool, leaving liquidity providers with more less-valuable tokens.

APWine's AMM#

APWine's AMM is derived from Balancer V1's AMM designs. You can read more information about Balancer's AMM following this link.

As explained in this section about the AMM architecture, each future has two AMM pools: a PT-FYT pool and a PT-Underlying pool.

The former is a classical Balancer pool with fixed 50/50 weights. Hence, the impermanent loss you suffer from in this pool is the same IL you would suffer from in any 50/50 pool. You can read more about Balancer's IL following this link.

On the other hand, the latter has dynamic weights: the weighting of assets starts at 50/50 and the PT's weights progressively increase during the period. Specifically, as the price of the PT starts at a discounted price and should progressively converge to the price of one underlying, the weights are updated based on the yield generated to update the discount and protect liquidity providers from arbitrages. Therefore, the purpose of this weighting mechanism is to mitigate the impermanent loss. You can read more about the dynamic weights mechanism here. In particular, this will give you an intuition about the conditions for updating the weights.

Impermanent Loss formula for the PT-Underlying pool#

Let us now focus on the PT-Underlying pool to better understand the impact of the dynamic weights mechanism on the impermanent loss.

The Balancer's AMM design works with a simple invariant formula called the Cost Function:

V=โˆiBiwiV=\prod_i B_i^{w_i}

This value can also be expressed in underlying by multiplying each token balance with the price in underlying of the corresponding token:

V=โˆi(Biร—Pi)wiV=\prod_i (B_i \times P_i)^{w_i}

This function ensures all the properties of the AMM. In Balancer's case, weights can be set to any value but are then static. This simplifies a lot the IL formula which can be expressed as a function of the AMM weights and the relative price change of each token (cf. this link for more details). In the case of APWine's AMM, the dynamic weights make the formula untractable. This section will explain the steps to understand the logic of APWine's IL formula.

Note that in the following computations UU represents the underlying tokens and PTPT represents the principal tokens. Also, for completeness, let us introduce a liquidity provider lp holding a certain amount TlpT^{lp} of LP tokens. The total supply of LP tokens is TtotT^{tot}. Then, the pool share of the lp is Slp=TlpTtotS^{lp} = \frac{T^{lp}}{T^{tot}}. Finally, let us define the proportion of the balance of the token i held by lp as ฮฒit=Slpร—Bit\beta_i^t = S^{lp} \times B_i^t. The following IL computations concern lp.

The impermanent loss is a ratio of performance between a return from a position in the AMM against the return of a simple hodling position (hang tight...):

IL=ฮ”AMMUฮ”HODLUโˆ’1IL = \frac{\Delta AMM_{U}}{\Delta HODL_{U}} - 1

Where the holding value change can be expressed as the sum of the weighted price changes:

ฮ”HODLU=ฮ”PPTร—wPT0+ฮ”PUร—wU0\Delta HODL_{U} = \Delta P_{PT} \times w_{PT}^0 + \Delta P_{U} \times w_{U}^0

with ฮ”Pi=PitPi0\Delta P_i = \frac{P_i^t}{P_i^0} the price change between the deposit time t=0t=0 and the withdraw time tt.

And the AMM value change is expressed as the ratio between the values of the AMM's function at withdraw (tt) and deposit time (t=0t=0):

ฮ”AMMU=VtV0\Delta AMM_{U} = \frac{V^t}{V^0}

with Vt=โˆi(ฮฒitร—Pit)wit=(ฮฒpttร—PPTt)wPTtร—(ฮฒUtร—PUt)wUtV^t = \prod_i (\beta_i^t \times P_i^t)^{w_i^t} = (\beta_{pt}^t \times P_{PT}^t)^{w_{PT}^t} \times (\beta_{U}^t \times P_{U}^t)^{w_{U}^t}.

All the variables in this formula depend on the time tt and evolve during the period.

We can therefore express the final ฮ”AMMU\Delta AMM_{U} as:

ฮ”AMMU=VtV0=(ฮฒpttร—PPTt)wPTtร—(ฮฒUtร—PUt)wUt(ฮฒpt0ร—PPT0)wPT0ร—(ฮฒU0ร—PU0)wU0\Delta AMM_{U} = \frac{V^t}{V^0} = \frac{(\beta_{pt}^t \times P_{PT}^t)^{w_{PT}^t} \times (\beta_{U}^t \times P_{U}^t)^{w_{U}^t}}{(\beta_{pt}^0 \times P_{PT}^0)^{w_{PT}^0} \times (\beta_{U}^0 \times P_{U}^0)^{w_{U}^0}}

This leads to the final impermanent loss formula:

IL=(ฮฒpttร—PPTt)wPTtร—(ฮฒUtร—PUt)wUt(ฮฒpt0ร—PPT0)wPT0ร—(ฮฒU0ร—PU0)wU0ฮ”PPTร—wPT0+ฮ”PUร—wU0โˆ’1IL = \frac{\frac{(\beta_{pt}^t \times P_{PT}^t)^{w_{PT}^t} \times (\beta_{U}^t \times P_{U}^t)^{w_{U}^t}}{(\beta_{pt}^0 \times P_{PT}^0)^{w_{PT}^0} \times (\beta_{U}^0 \times P_{U}^0)^{w_{U}^0}}}{\Delta P_{PT} \times w_{PT}^0 + \Delta P_{U} \times w_{U}^0} -1

Impermanent Loss behavior#

The IL function above is quite untractable and difficult to grasp. In the following sections, you will get a better intuition on the impermanent loss behavior under different angles. In particular, you will be able to compare the behavior of APWine's IL with the IL of a Balancer-like pool with fixed weights.

AMM behavior#

The weights in the AMM represent how much liquidity providers are exposed to a token price change. The fact that the AMM's weights progressively change by increasing the weights of the PT proportionally to the yield already generated makes you more exposed to the PT during the period.

At the end of the period, the LP withdraws liquidity from the AMM (i.e. getting your PT and Underlying tokens back) and then withdraws his Interest Bearing Tokens (IBTs) from the APWine protocol (1 PT for 1 underlying worth of IBTs). It is useful to consider this when thinking about the IL as the end of the period is the only moment when the PT can redeem one underlying no matter what its price on the AMM is. Otherwise, the price of the PT is oscillating around its discount price because of market speculation.

LPs are therefore advised to withdraw the liquidity by withdrawing their funds from the protocol and are not advised to sell their assets using the AMM (as they might suffer from slippage).

We ran simulations of our AMM, fixing some parameters to abstract the impact on the impermanent loss for several behaviors. We also only focus on the impermanent loss in underlying, without taking into account the impermanent loss in FIAT. It is liquidity providers' job to manage their FIAT exposure to different assets.

Entry price#

Considering LPs that will withdraw their liquidity at the end of the period from the AMM and then from the APWine protocol, the only price that matters is the entry price (aka the prices reflected on the AMM when they add liquidity). It is thus useful to visualize the impact of the entry price on the impermanent loss.

This first experiment was run for a future on an Interest Bearing Token with a fixed 50% APY during the period. We consider an LP providing liquidity to the PT-Underlying pool of the AMM at the beginning of the period and withdrawing its funds at the end. With a 50% APY during the period, the discounted price of the PT at the beginning of the period is 1PT = 0.667U (1/(1+r)1/(1+r) with r=0.5r = 0.5) and is therefore the correct spot price derived from this APY.

The graph below shows the impact of the entry price on the empirical impermanent loss. Clearly, the impermanent loss is shifted up compared to the fixed weight case.

Keep in mind that, accounting for a positive interest, the value of a PT should always lie between 0 and 1U during the period and progressively increase in value to reach a price of 1U at the end of the period. Hence, the graph above is here to get intuition on the impact of relative price change on the impermanent loss. Note that some areas of price change are not likely to happen in practice. For instance a relative change of 2 would make the entry price at 1PT = 1.334 underlying. No LP should add liquidity at this price. There is an important arbitrage opportunity.

Unlike with most AMMs, it is possible for liquidity providers to achieve a positive IL on APWine's AMM without taking fees into consideration. This is due to the fact that we only consider the price in terms of the underlying. The only asset changing in price is the PT that increases in value. The weight mechanism makes the liquidity provider more exposed to the PT asset that increases in value. In certain situations, the liquidity providers get more and more exposure to an asset that increases in price, making it more interesting compared to a fixed 50% exposition to the PT while holding the tokens outside the AMM.

This protection mechanism (dynamic weights) is therefore biased to hedge the risk of liquidity providers. The value gained by LPs in case of positive impermanent loss is taken from all the trades. It thus results in a safer pool for LPs, which allows to have more liquidity, boosting the usability of the AMM. For traders, on the one hand the arbitrages opportunities are reduced but on the other hand the usability increases (more liquidity โ‡’\Rightarrow less slippage).

il

Relative price offset#

We study thereafter the impact on the impermanent loss of a discrepancy between the correctly derived spot price and the average spot price in the AMM. For instance, what happens with the impermanent loss if traders always underestimate (overestimate) the price of a PT in underlying?

As the PT price in underlying is the discounted price of one underlying with respect to the discount rate for the remaining of the period, underestimating (overestimating) this price is equivalent to overestimate (underestimate) the APY and so the discount rate of the token.

Recall that at any time the price of the PT is PPT=11+rP_{PT} = \frac{1}{1+r} with rr the discount rate for the remaining of the period.

The simulation was once again for a future on an Interest Bearing Token with a fixed 50% APY during the period, and with an LP providing liquidity to the PT-Underlying pool of the AMM at the beginning of the period and withdrawing its funds at the end. Let us further assume the liquidity provider makes a good entry (for example 1PT = 0.667U at the beginning of the period) and then traders will always underestimate (negative relative change) or overestimate (positive relative change) during the period.

The graph below clearly shows that underestimating the price benefits the liquidity provider. Traders trading at these price ranges will let more PT at the benefit of liquidity providers. Overestimating the price induce a negative Impermanent Loss. As observed the Impermanent Loss then gets positive again but similarly to the previous simulation, you should keep in mind that some prices are very unlikely to happen in practice (e.g. PT prices over 1U).

il

Examples#

Let us now work out a few examples to better visualize these different scenarios. Several simulations were run with different parameters to compute the Empirical Impermanent Loss (EIL) of different investment positions.

The EIL is computed directly from the token amount and their respective prices when entering and leaving the pool:

EIL=APTtร—PPTt+AUtร—PUtAPT0ร—PPT0+AU0ร—PU0ฮ”PPTร—APT0+ฮ”PUร—AU0EIL = \frac{\frac{A_{PT}^{t} \times P_{PT}^t + A_{U}^{t} \times P_{U}^t}{A_{PT}^{0} \times P_{PT}^0 + A_{U}^{0} \times P_{U}^0}}{\Delta P_{PT} \times A_{PT}^{0} + \Delta P_{U} \times A_{U}^{0}}

with Ai0A_i^0 the amount of token provided in the AMM (at time t=0t=0) and AitA_i^t the amount of token ii withdrawn from the AMM (at time tt).

For all the scenarios, we still compute the impermanent loss in underlying. Hence, the price of the underlying token in underlying is obviously 1U.

Example 1: Optimistic scenario#

Patrick is an APWine liquidity provider in the PT-Underlying pool for a future on an IBT with a fixed APY of 20% during the period (optimistic scenario). He adds liquidity at the beginning of the period with a PT price of 1PT = 0.834U (the correct pricing).

He provides 100.0PT and 83.3334U and owns โˆผ1%\sim1\% of the pool liquidity.

During the entire period, the PT price follows its theoretical discount curve with small variance (ฯƒ=0.1\sigma = 0.1). This means that on average, trades follow the right discount curve.

At the end of the period, 1PT = 1U and Patrick withdraws his liquidity from the AMM and gets 83.3324PT and 100.0008U.

By computing the Empirical Impermanent Loss, Patrick has an EIL of EIL=โˆ’6.4783eโˆ’7%โ‰ˆ0%EIL = -6.4783 e^{-7}\% \approx 0\%.

Example 2: Under-priced entry#

In this second scenario, with the same conditions on the future as in the previous example (20% fixed APY), Patrick enters the pool at a PT price of 1PT = 0.75U. As mentioned, the correct pricing would be 1PT = 0.834U. Hence he enters at a price 10% below the true discount price.

He provides 100.0PT and 75.0U and owns โˆผ1%\sim 1\% of the pool liquidity.

During the entire period the PT price eventually converges back to it's theoretical discount curve with small variance (ฯƒ=0.1\sigma = 0.1). This means that on average, trades end up following the right discount curve.

At the end of the period, 1PT = 1U and he withdraws his liquidity from the AMM and gets 94.8688PT and 79.0562U.

By computing the Empirical Impermanent Loss, Patrick has an EIL of EIL=โˆ’0.0061%EIL = -0.0061\%.

Example 3: Over-priced entry#

The following is the opposite scenario: Patrick enters the pool at a PT price of 1PT = 0.9167U, whereas the correct pricing would still be 1PT = 0.834U. Hence he enters at a price 10% above the true discount price.

He provides 100.0PT and 91.6667U and owns โˆผ1%\sim 1\% of the pool liquidity.

During the entire period the PT price eventually converges back to it's theoretical discount curve with small variance (ฯƒ=0.1\sigma = 0.1). This means that on average, trades end up following the right discount curve.

At the end of the period, 1PT = 1U and he withdraws his liquidity from the AMM and gets 104.8802PT and 87.4013U.

By computing the Empirical Impermanent Loss, Patrick has an EIL of EIL=0.0032%EIL = 0.0032\%. A positive impermanent loss!

Example 4: Overestimation of the APY#

Let us now focus on the impact on the impermanent loss when traders (on average) underestimate the PT price during the period. Having such price discrepancies with the true generated yield impacts the weight shifting and thus the trade sizes.

To keep things simple, let us keep the same asset as before: an IBT with a 20% fixed APY during the period.

Patrick enters the pool at a PT price of 1PT = 0.8334U, which is the correct pricing for an APY of 20%. Hence he made a good entry.

He provides 100.0PT and 83.3334U and owns โˆผ1%\sim 1\% of the pool liquidity.

Then, traders, on average, always underestimate the PT price by 10%.

At the end of the period, 1PT = 1U and he withdraws his liquidity from the AMM and gets 105.4087PT and 79.0573U.

By computing the Empirical Impermanent Loss, Patrick has an EIL of EIL=0.0062%EIL = 0.0062\%. A positive impermanent loss!

Example 5: Underestimation of the APY#

For the opposite scenario: Patrick enters the pool at a PT price of 1PT = 0.8334U, which is the correct pricing for an APY of 20%. Hence he made a good entry.

He provides 100.0PT and 83.3334U and owns โˆผ1%\sim 1\% of the pool liquidity.

Then, traders, on average, always overestimate the PT price by 10%. We still assume the APY to be fixed during the period.

At the end of the period, he withdraws his liquidity from the AMM and gets 91.0984PT and 91.8559U.

Note that in this scenarios, we simulate the fact that traders overestimate the PT price until the end. At the end of the period the PT price in the AMM ends up being above 1U. This should not happen in practice as traders will eventually sell PTs to profit from this arbitrage opportunity.

By computing the Empirical Impermanent Loss, Patrick has an EIL of EIL=โˆ’0.0021%EIL = -0.0021\%.