Impermanent Loss Calculator
What's Impermanent Loss?
Impermanent loss is one of the most intimate experiences liquidity providers ever have with their money. When you deposit tokens into a liquidity pool and its price changes a few days later, the amount of money lost due to that change is your impermanent loss.
What causes impatient loss?
To understand why the value of a liquidity provider’s stake can go down despite income from fees, we need to look a bit more closely at the formula used by Uniswap to govern trading. The formula really is very simple. If we neglect trading fees, we have the following:
• eth_liquidity_pool * token_liquidity_pool = constant_product
In other words, the number of tokens a trader receives for their ETH and vice versa is calculated such that after the trade, the product of the two liquidity pools is the same as it was before the trade. The consequence of this formula is that for trades which are very small in value compared to the size of the liquidity pool we have:
• eth_price = token_liquidity_pool / eth_liquidity_pool
Combining these two equations, we can work out the size of each liquidity pool at any given price, assuming constant total liquidity:
• eth_liquidity_pool = sqrt(constant_product / eth_price)
• token_liquidity_pool = sqrt(constant_product * eth_price)
So let’s look at the impact of a price change on a liquidity provider.
To keep things simple, let’s imagine our liquidity provider supplies 1 ETH and 100 DAI to the Uniswap DAI exchange, giving them 1% of a liquidity pool which contains 100 ETH and 10,000 DAI.
This implies a price of 1 ETH 100 DAI. Still neglecting fees, let’s imagine that after some trading, the price has changed; 1 ETH is now worth 120 DAI. What is the new value of the liquidity provider’s stake? Plugging the numbers into the formulae above, we have:
• eth_liquidity_pool = 91.2871
• dai_liquidity_pool = 10954.4511
Since our liquidity provider has 1% of the liquidity tokens, this means they can now claim 0.9129 ETH and 109.54 DAI from the liquidity pool. But since DAI is approximately equivalent to USD, we might prefer to convert the entire amount into DAI to understand the overall impact of the price change. At the current price then, our liquidity is worth a total of 219.09 DAI. What if the liquidity provider had just held onto their original 1 ETH and 100 DAI? Well, now we can easily see that, at the new price, the total value would be 220 DAI. So our liquidity provider lost out by 0.91 DAI by providing liquidity to Uniswap instead of just holding onto their initial ETH and DAI.
We get the following:
• impermanent_loss = 2 * sqrt(price_ratio)/(1 + price_ratio)- 1
Final Conclusion:
1. Relative to the spot
• 1.25x price change results in a 0.6% loss relative to HODL
• 1.50x price change results in a 2.0% loss relative to HODL
• 1.75x price change results in a 3.8% loss relative to HODL
• 2x price change results in a 5.7% loss relative to HODL
• 3x price change results in a 13.4% loss relative to HODL
• 4x price change results in a 20.0% loss relative to HODL
• 5x price change results in a 25.5% loss relative to HODL
2. The loss is the same whichever direction the price change occurs in (i.e. a doubling in price results in the same loss as a halving).