# How to calculate Impermanent Loss: full derivation

Impermanent loss is a popular concept when it comes to automated market makers (AMMs) like Uniswap. As a liquidity provider, your position may fall in value with respect to either asset (before fees) and impermanent loss is often defined as the percentage loss an LP would experience for a given price movement.

There are some excellent articles that explain the concept well and provide examples, but they all quote a formula for impermanent loss without offering a derivation:

This article will contain the full derivation and explain all the assumptions involved.

**Definitions**

We consider a market with liquidity L and amounts x and y of assets X and Y respectively.

We set the initial price P of asset X in terms of asset Y = y / x and consider a price movement to P’ = Pk where k > 0.

It follows immediately that:

We define three values:

- V_0, the value of the initial holding in terms of asset Y
- V_1, the value of the holding if kept in the pool (x, y move with price)
- V_held, the value of the holding if kept outside of the pool (x, y constant)

**Derivation**

The price of asset Y in terms of Y is 1 and the price of asset X in terms of asset Y is P. By using the formulas for x, y we conclude:

We note that this formula only depends on L and P, so if the price changes, we can use it to calculate the value of future holdings if kept in the same pool:

Finally, to understand the value of a position that was simply held, we have to use the original quantities x and y with the new prices 1 and P’ = Pk:

Finally, to get Impermanent Loss, we calculate the percentage loss of having V_1 as compared to V_held:

And we can also get the usual Impermanent Loss curve by plotting the above function:

**Caveats**

The most important caveat to the above calculation is that impermanent loss is only calculated with respect to one asset. Impermanent loss examples often assume one of the assets is stable, but that assumption is not always true.

If this asset is a stablecoin like DAI, the loss may be meaningful. In other cases it will matter how the underlying pool assets move in relation to your reserve currency.

Ready to build your own smart contracts? We just launched a knowledge base that can help you every step of the way. Join here.