# Asteria Essentials #13: Deriving the Impermanent Loss Formula

In our previous posts, we gave an oversimplified overview of impermanent loss in automated market makers. Today, we will go deep into analyzing the risk of an AMM from a quantitative perspective.

**Even though there are stellar resources out there that explain impermanent loss and how it is calculated, they typically iterate it without the original derivation and the assumptions that were used to reach the formula. So first, let’s address that.**

Quoted formula for calculating impermanent loss:

IL (k) = (2√k/1+k) — 1

Now let’s derive it:

Constant product liquidity pools (UniV2) require the following equation to always be satisfied when a trade is executed:

We assume that a market has liquidity **L, **and **“x” **amount of asset** “X”** and** “y” **amount of asset** “Y”**

So,

**x ✕ y = L²**

We set the starting price “P” of asset “X” relative to asset “Y” = x/y and the price movement to P’=Pk (where k>0).

Hence,

y=L√P

and

x = L/√P

Here we describe:

V’0 — which is the value of the initial state when the asset were being held, in terms of asset Y

V’1 — which is the value of total capital if the assets were kept in the liquidity pool (here we see the movement of x and y with the price);

V’H — which is the value of the total capital if it was stored outside the liquidity pool in a wallet (here x and y remain constant)

So the price of asset Y in terms of Y is 1, and the price of asset X in terms of asset Y is N. By using the equations for x and y mentioned above we can derive:

V’O = y ✕ 1 + x ✕ P

= 2L√P

Here it is clear that the formula for V’0 only depends on the liquidity **L **and starting asset price **P**. This means that during any price movement we can use the formula for V’0 to calculate the value of total capital if the assets were kept in the Liquidity pool or V’1:

V’1 =2L√P’

= 2L√Pk

Now to derive the formula for when the capital was held outside the liquidity pool in a wallet, we use the original amount of assets X and Y which are x and y respectively with the new asset prices 1 and P’ = Pk

V’H =y + xP’

= L√P (1 +k)

Stretching too long? Don’t worry, we are almost done here:

Let’s calculate IL or impermanent loss of holding position in V’1 relative to holding position in V’H.

So we get,

IL (k)= V’1 — V’H/VH

= L √P (2√k — 1- k)/L√P (1+k)

= 2√k 1+k- 1

**Would you like to read more such articles? Keep a keen eye on ****our blog**** and ****follow Asteria on Twitter ****to stay up to speed!**