The impermanent loss is not so difficult to understand after a while. Let me show you with another example with more formulas (based on this post):
Suppose that you want to provide liquidity to the PRV/USDC
pair and at the time you add the liquidity, the exchange rate is 1 PRV = 1 USDC
. If you want to provide 100 USDC, 100 PRV must be paired.
The underlying model is based on:
constant_product = prv_liquidity_pool * uscd_liquidity_pool = 100 * 100 = 10 000
And since:
prv_price = usdc_liquidity_pool / prv_liquidity_pool = 100 / 100 = 1.00
Combining the above to equations we have:
prv_liquidity_pool = sqrt(constant_product / prv_price) = 100.00
usdc_liquidity_pool = sqrt(constant_product * prv_price) = 100.00
Later, the price changes, so 1 PRV = 1.2 USDC. The liquidity pools must change, since the constant cannot:
prv_price = 1.20
prv_liquidity_pool = sqrt(constant_product / prv_price) = 91.29
usdc_liquidity_pool = sqrt(constant_product * prv_price) = 109.54
constant_product = prv_liquidity_pool * uscd_liquidity_pool = 91.29 * 109.54 = 10 000
That is the logic for the liquidity pool, but what about the impermanent loss?
Originally you had 100 PRV and 100 USCD, converting all to USDC, with the current price, you would have:
(100 PRV @ 1.2 USDC = 120 USDC) + 100 USDC = 220 USDC
But in the liquidity pool you have:
(91.29 PRV @ 1.2 USDC = 109.54 USDC) + 109.54 USDC = 219.09 USDC
That difference is the impermanent loss. It is impermanent because if the exchange rate comes back to 1 PRV = 1 USDC
, there is no loss.
But if you must wait the exchange rate to get back to the original one to avoid the loss, why would anyone want to be locked as a liquidity provider for an unknown amount of time?
Hope it helps.