If you follow us in our previous blogs such as **KMM Swap: What’s the difference?**** **you may already know that reducing impermanent loss to liquidity providers (LPs) is an advantage of KMM Swap.

Impermanent loss is a risk that any AMM can barely avoid. Let’s find out what is impermanent loss and how it affects liquidity providers!

## What is Impermanent loss in Constant product AMM?

Impermanent loss is a temporary loss of funds involved when providing liquidity to dual-asset pools in AMM protocols. It’s often explained as a difference between providing liquidity in that assets versus holding assets. In this article, we will go into the root of Impermanent loss.

**How does Impermanent loss work?**

Impermanent loss is a downside of the Constant product function model and affects the most when it comes to liquidity pools that have an equal ratio of assets (50/50). When a liquidity provider provides their asset to a liquidity pool, the pool requires him to add 2 assets equally in value to remain the current price in the liquidity pool. Later on, the price in another market changes which creates arbitrage opportunities.

Arbitragers exploit the difference between the price on AMM and other markets to take profit. Arbitragers buy the asset in one market and sell it in the other market at the same time to pocket the difference between the two prices until the pool price reflects the real-world price to maintain the same value of both tokens in the pool —AMMs rely on arbitragers to adjust the price, remain 2 assets stay in the same value.

After this process of adjusting the pool price, if the liquidity provider withdraws his assets the ratio of 2 assets will be different from when he first provides them. The total value of these assets is now less than the value of holding them, creating Impermanent loss. Although it’s called “Impermanent” because the loss only happens if he decides to withdraw the assets. When the ratio of two assets in the pool recovers to when he provided liquidity, the impermanent loss moves to zero.

**Let’s jump onto an example!**

Assume that an LP provided liquidity to BNB/BUSD Pancakeswap pool, he added both BNB and BUSD in the same value. He provided 10 BNB and 5,000 BUSD at the price of BNB/BUSD = 500, the value of both assets is $5,000. Since Pancakeswap uses the Constant product model, the pool follows the formula: x*y=k which means k = 10*5000 = 50,000.

Later on, the price of BNB/BUSD in Binance goes up to 550, but the price in Pancakeswap is still 500. Arbitragers see arbitrage opportunities to trade between Binance and Pancakeswap, arbitragers buy BNB from Pancakeswap to sell it on Binance, the more BNB took out from the pool the higher the price of BNB becomes until it reaches 550.

Following the formula: x*y=k we can find the point where the price of BNB/BUSD = 550.

- x’ * y’ = 50000
- y’ / x’ = 550

Solve the math formulas, we have

- x’ = 9.53
- y’ = 5244.04

So in this case, the arbitrager buys 0.47 BNB and returns 244.04 BUSD to the pool, he immediately sells BNB on Binance at the price of 550 for 258.5 BUSD, pocketing 14.46 BUSD.

At this point, the liquidity pool has 9.53 BNB and 5244.04 BUSD, the asset of the liquidity provider is now worth $10485.54.

If the liquidity providers just held his assets without providing liquidity, his assets will be worth $10500, which is $14.46 more than providing liquidity — this $14.46 is called impermanent loss.

If the liquidity provider withdraws his assets at this point, the $14.46 loss becomes permanent. Otherwise, the loss is only on paper and it can become 0 when the ratio of 2 assets moves back to when he added it to the liquidity pool.