What is Impermanent Loss?

Pujeet Manot
London Blockchain Labs
6 min readJan 8, 2021

Automated Market Makers (AMMs) or Decentralized Exchanges (DEXes) are crucial infrastructure to Decentralized Finance (DeFi) and rely on users to provide liquidity so that trades happen smoothly. In the case of a centralized world, this liquidity is provided by trusted parties like banks. Liquidity in a decentralized world can be provided by incentivizing people to act as liquidity providers (LPs).

With the rising popularity of yield farming, one of the biggest risks that most people tend to overlook is an impermanent loss. It might sound very complicated but at the end of the day, it is the losses liquidity providers experience due to price divergence

So what is impermanent loss? How can providing liquidity to a liquidity pool make you lose your money? This blog has been written to provide answers to the above questions and also explain to you a few risks of yield farming.

What is Impermanent Loss?

When the price of a token inside an AMM diverges from the external value in any direction, it is called an impermanent loss. The greater is the divergence, the greater will be the loss.

As long as the relative price of the tokens in the AMM returns to their original state the loss disappears and you earn 100% of the trading fees which is why it is called impermanent or temporary. More often than not, an impermanent loss becomes permanent and you end up with negative returns.

Impermanent loss is observed in liquidity pools where LPs have to provide both assets in the correct ratio with one asset being more volatile as compared to the other.

Example

Let us take the example of a WBTC-ETH liquidity pool. If the value of ETH goes up then the pool has to rely on arbitrageurs to ensure that the price in the pool reflects the real-world price so as to maintain the same value of both tokens in the pool.

This means that the arbitrageurs would take profit from the rise in the price of ETH tokens. If the LP decides to withdraw his liquidity then his impermanent loss becomes permanent.

So, in the given example of WBTC-ETH on Uniswap, the user has to pool in WBTC and ETH tokens of equivalent value. Since the value at the time of pooling is the same, everything is in order. Now, let the price of ETH tokens on a centralized exchange, for example, CoinDCX rise. Arbitrageurs try to take advantage of the situation to make a profit out of this situation.

As mentioned in our blog on Uniswap, the constant product market-making technique ensures that the correct ratio of the tokens is maintained in the pool. As the price of ETH is more on centralized exchanges, more ETH will be swapped from liquidity pools in exchange for other ERC-20 tokens. As more and more tokens of ETH are swapped, due to the formula x*y = k, its price starts rising.

The x*y = k formula can be written as

eth_liquidity_pool * token_liquidity_pool = constant_product

Here, 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. So, if the price of ETH on an external platform rises, this means that traders will take our ETH in return for WBTC in the example. In situations when the trades are very small in value as compared to the size of the liquidity pool, the formula can be written as

eth_price = token_liquidity_pool / eth_liquidity_pool

(eth_price * eth_liquidity_pool = token_price * token_liquidity_pool = value)

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)

To understand this, let’s imagine our liquidity provider supplies 1 ETH and 100 DAI to the Uniswap DAI exchange, giving them 1% of a liquidity pool that 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. Holding on to the tokens than adding to liquidity pools would have been better in this case.

Why would someone pool in tokens?

Basically, the price of one token must not rise or fall significantly when you pool ETH and some other ERC-20 token in the liquidity pool. If this happens then this would lead to an impermanent loss to the LP.

In the case where there would be no impermanent loss, LPs would be making money by collecting their share from the trading fees on the platform. LPs would be happy to pool in their tokens as long as the amount collected by them is greater than the impermanent loss experienced. Some protocols also provide additional tokens that completely negate the impermanent loss. This process is called liquidity mining.

Synthetix is one of the first DeFi projects that started rewarding users with SNX tokens if users would add liquidity to the sETH/ETH pool on Uniswap.

To minimize exposing yourself to impermanent loss, try those liquidity pools where the assets are relatively stable. The pools also attract more capital than the pools with non-stable assets.

Calculating Impermanent Loss

If the price were to return to the same value as when the liquidity provider added their liquidity, this loss would disappear. This loss is only realized when the liquidity provider withdraws its liquidity and is based on the divergence in price between deposit and withdrawal. We can therefore call it divergence loss (previously described as an impermanent loss). Using the equations above, we can derive a formula for the size of the divergence loss in terms of the price ratio between when liquidity was supplied and now. We get the following:

divergence_loss = 2 * sqrt(price_ratio) / (1+price_ratio) — 1

Source: Uniswap Docs

Or to put it another way:

a 1.25x price change = 0.6% loss relative to HODL

a 1.50x price change = 2.0% loss relative to HODL

a 1.75x price change = 3.8% loss relative to HODL

a 2x price change = 5.7% loss relative to HODL

a 3x price change = 13.4% loss relative to HODL

a 4x price change = 20.0% loss relative to HODL

a 5x price change = 25.5% loss relative to HODL

Conclusion

Impermanent loss is therefore a fundamental concept that everyone must be aware of before providing liquidity in any pools or participating in any DeFi protocol.

--

--