Topics Blockchain
Bybit Learn
Bybit Learn
Sep 21, 2021

How to Avoid Impermanent Loss When Providing Liquidity in DeFi

Impermanent loss refers to a situation in which your token’s prices change compared to when they were deposited into the pool. The risk increases with the magnitude of the change. Although liquidity provision can benefit a liquidity pool, knowing how to avoid impermanent loss is crucial.

Liquidity significantly impacts asset prices, so it’s essential in both traditional markets and decentralized finance (DeFi). Anyone who’s jumped on the DeFi bandwagon via staking knows the immediate risks of a liquidity pool.

Among them is impermanent loss, which comes as a result of providing liquidity in DeFi. Although impermanent loss can be counteracted later, it’s still essential for investors to be familiar with it and understand how to avoid it.

In this guide, we discuss the risks associated with liquidity provision to a liquidity pool and give tips on avoiding those risks.

What Is Impermanent Loss?

Impermanent loss refers to the reduction that occurs when the price of the assets you’ve deposited changes during the period between deposit and withdrawal. If the difference is more extensive, you have a higher loss, and if less, a smaller loss.

The impermanent loss only becomes realized once it is withdrawn from the liquidity pool.

The loss occurs as a result of depositing two cryptocurrencies into an automated market maker (AMM) and withdrawing them at a later time with a difference in value, which is less than what you would have gotten if you’d held the coins in your wallet.

In some cases, you might not even lose any money. But your gain would be relatively lower than if you’d kept the tokens untouched in your wallet.

The phenomenon is called “impermanent loss” because you can only realize the loss once you’ve withdrawn your funds from the pool. Before withdrawing, any loss incurred will only be “on paper” and could end up disappearing entirely or reducing significantly, depending on how the market moves.

Liquidity Pools and Automated Market Makers

In order to understand how impermanent loss works, it’s vital to be familiar with liquidity pools and automated market makers (AMMs).

A liquidity pool (LP) usually comprises two tokens, known as a pair. For instance, DAI and ETH form a pair. The weightage of both cryptocurrencies is equal to make it simpler for users to conduct trading. For example, the ratio will be 50% DAI and 50% ETH in this pool.

Therefore, liquidity pools are a smart contract-locked collection of funds. They facilitate lending and trading in DeFi markets.

When you buy a coin on an AMM, there is no seller on the other end. Instead, an algorithm manages the activity of the liquidity pool. Plus, the algorithm is also determining the pricing according to the trades in the pool.

In basic liquidity pools, like those in Uniswap, there’s a constant formula-based algorithm that ensures the values of the two cryptocurrencies remain the same. Moreover, the algorithm allows liquidity to be provided, no matter the trade’s magnitude.

The algorithm does this by asymptotically increasing a token’s price as its desired quantity rises. As a result, the price of a token in a liquidity pool is dictated by the proportion of that currency.

For example, if you buy DAI from an ETH/DAI pool, you reduce DAI supply in the pool. Owing to this, the price of DAI in the pool will increase, and ETH will decrease.

As the size of the pool increases, the impact of providing liquidity will decrease. Thus, there will be a more negligible price difference if you provide liquidity in a larger pool.

Since these pools offer a better trading experience, some systems began to incentivize liquidity providers with additional tokens to provide liquidity to some pools. This process is more commonly called liquidity mining.

Understanding Automated Market Maker

AMMs have made things much easier for liquidity providers. They are basically decentralized exchange protocols with a mathematical formula as their underlying basis to price assets.

Unlike traditional exchanges, AMMs don’t use order books. Instead, they use algorithms for asset pricing. For instance, Uniswap is an AMM that uses the following formula:

x * y = k

In this formula, “x” and “y” represent the value of each type of token in the pool. Meanwhile, “k” is the fixed constant that keeps the total liquidity of the pool the same.

Although all AMMs use different formulas, they use algorithms rather than ordering books for pricing.

Which Pools Are Prone to Impermanent Loss?

Some pools are more prone to impermanent loss than others. Typically, these contain volatile currency pairings. If the price of a cryptocurrency has been volatile for a while, it makes for a risky cryptocurrency pair, since price fluctuations will likely result in impermanent loss.

Likewise, currencies that have significant price differences between them could also be prone to impermanent loss, compared to those that follow similar prices. However, there is no standard rule to determine impermanent loss before withdrawing your assets.

Instead, you can take some precautions, discussed further in this article, in order to avoid impermanent loss.

How Does Impermanent Loss Happen in DeFi?

As a liquidity provider, Jack stakes 1 ETH and 100 USDT. According to the AMM’s concept, the staked tokens need to be of equivalent value. Thus, Jack’s 1 ETH would have an equal value of USDT. At that moment, Jack’s stakes would translate to 10% from the total of 10 ETH and 1,000 USDT in the liquidity pool.

One week later, the price of 1 ETH is equivalent to 400 USDT, meaning the ratio of ETH is higher than USDT. Thus, arbitrageurs need to remove ETH from the pool to achieve an equilibrium. But the change in ratio affects the actual value of ETH and USDT since arbitrageurs removed ETH from the pool to increase the flow of USDT.

To know if Jack suffers an impermanent loss or profited from his stakes, he’ll have to withdraw 10% of his share from the liquidity pool of 0.5 ETH and 200 USDT which amounted to $400, as explained below:

0.5 ETH x $400 = $200

200 USDT + $200 = $400 However, Jack would have made $500 if he held onto his ETH and USDT. That is because 1 ETH is increased to $400.

By providing liquidity in an AMM, Jack’s gains are 50% lesser than he would have been if he held his coins. Even if the loss doesn’t translate to USD or another fiat currency, it’s still considered an impermanent loss since the gains are lower than what he could have earned if they hadn’t provided liquidity.

This loss is called “impermanent” because it’s impossible to know about it unless the assets have been withdrawn. Also, if ETH’s value returns to 100 USDT, the loss will be reversed. Therefore, it’s an impermanent loss that changes with the dynamism in the market.

An Example with USD Loss

As discussed above, liquidity providers don’t always experience a monetary setback because of impermanent loss. However, it can happen in some cases, such as the example below.

Suppose you have $500 worth of two cryptocurrencies. We’ll use UNI and ETH for this example. Let’s assume you have 150 UNI and 1 ETH, that 1 ETH is worth 150 UNI, and that the total value of each is $500. However, once you deposit both the currencies in the pool, the ratio will differ, since the currencies will fluctuate in terms of price as trades occur in the market.

Consequently, based on the impermanent loss calculator, you might have more UNI or more ETH in the pool. So, what happens when the rate differs from the time you deposited both the currencies? You’ll suffer from impermanent loss once withdrawn from the liquidity pool. 

Keep in mind that the rates have changed since you first deposited the currencies. Therefore, when you withdraw them, you may have more of one currency and less of the other — or vice versa.

Let’s suppose you now have 0.8 ETH and 170 UNI, or 1.2 ETH and 110 UNI.

Let us look at the other side of the spectrum. What if you’d just held your assets and hadn’t given them liquidity? You would have more of both currencies, and it would translate to a higher value in USD.

For an advanced impermanent loss calculation with formula, ChainBulletin has an in-depth step-by-step calculation.

The Pros of Providing Liquidity

The primary benefit of liquidity pools is that you’re making exchanges, not trades. You don’t need to look for a partner who assigns the same value to a currency as you do.

Anyone who’s traded crypto knows that remarkable negotiation skills are required to deal with someone who might want to sell their crypto at a higher price. With a pool, you can exchange even if you don’t have these skills.

Secondly, liquidity pools have a low market impact, since transactions tend to be smoother. The pool is locked in a smart contract whose prices change based on the algorithm.

Most importantly, you receive rewards for providing liquidity since you’re staking tokens and renouncing your ability to sell them.

The Limitations

The most prominent disadvantage of pools is impermanent loss. Your asset’s values are reduced when you make them liquid.

In the absence of any third party in DeFi, your asset’s custodian is the smart contract. If it acquires a bug, you could lose your funds. Therefore, investors should try to deposit their funds in pools that are less likely to suffer impermanent losses. We’ve already discussed these above.

More importantly, try to opt for AMMs that are tried and tested. If you come across an AMM that’s promising unusually high returns, there’s likely some sort of trade-off in the whole process, which makes the risks higher.

How to Avoid Impermanent Loss

In some cases of liquidity mining, if the market is volatile, an impermanent loss is inevitable since prices are bound to fluctuate. However, you can take some steps to make sure you avoid impermanent loss or at least don’t suffer a heavier blow when prices move.

Use of Stablecoins Pair

If you want to avoid impermanent loss altogether, make two stablecoins liquid. For example, if you provide liquidity to USDT and USDC, there will be no risk of impermanent loss since stablecoin prices are meant to be stable.

However, the major downside to this approach is that you won’t benefit from any rise in the market. If you’re liquidity mining in a bull market, there’s no point in holding stablecoins because you won’t get any returns on them.

However, if you’re liquidity mining in a bear market, try to provide liquidity to stablecoins and earn trading fees. This way, you’ll be profiting through trading fees without losing any money.

Look Out for the Trading Fees

In all the examples we’ve provided above, we haven’t factored in trading fees. Traders using the pool are required to pay trading fees. The AMM gives a share of these fees to the liquidity providers.

Sometimes, these fees are enough to offset the impermanent loss you’ve experienced during liquidity provision. The impermanent loss decreases with an increase in the number of fees collected.

Invest in Low Volatility Pairs

Some cryptocurrency pairs are more volatile than others, so providing liquidity to them can increase your risk of impermanent loss.

For instance, if you intend to provide liquidity to a particular crypto pair and, studying the market, you believe one of them will outperform the other soon, don’t provide the liquidity.

However, if you think both currencies will rise or fall relative to each other in terms of price, you’re good to go, since it won’t make much of a difference.

The bottom line is to stay wary of volatile currencies by monitoring their current and future performance.

Opt for a Flexible Liquidity Pool Ratio

One thing that increases the chances of impermanent loss is the 50:50 ratio that most AMMs have. In doing so, they want to create a balanced liquidity pool.

However, there are many decentralized exchanges where you can provide liquidity in different ratios. Moreover, these exchanges, such as Balancer, allow you to pool more than two cryptocurrencies.

When Balancer pools have higher ratios, like 95:5, any price change in this instance doesn’t cause as much impermanent loss as a 50:50 pool does. Therefore, if possible, provide liquidity to these pools.

Wait for the Exchange Rate To Return to Normal

When you provide liquidity to a crypto pair, their rates will naturally change in the market. However, the more the prices deviate from those at which you made your deposit, the higher your permanent loss will be.

Therefore, you can wait for the crypto prices to return to their initial rates, and not withdraw your currency until then. However, this isn’t as simple as it may sound because the cryptocurrency market is quite volatile.

One-Sided Staking Pools

Not all AMMs have two-currency liquidity pools. Some popular AMMs, such as Liquidity, have a single asset type. In this type of LP, you can supply a stablecoin, such as the LUSD, to the pool to ensure its solvency.

In exchange for this liquidity, you’ll get a cut of the accrued liquidation fees of the platform. Since there’s only one currency, and there are no ratios between two assets, there’s no impermanent loss in this scenario.

Final Note

Finally, it’s imperative to remember that you can experience impermanent loss irrespective of the price change direction. It doesn’t matter which of the two currencies in the crypto pair undergoes an increase or decrease in price. The result will be an impermanent loss.

The only way you won’t have any impermanent loss is if the price at the time of the withdrawal is the same as that at the time of deposit.

But suppose you want to leverage the potential of liquidity provision as passive income. In that case, it’s best to calculate impermanent loss using the fluctuations in crypto prices in the market. Most importantly, to maximize passive income, don’t provide liquidity to volatile pairs, since they’re the most susceptible to impermanent loss.

By now, you’ve hopefully learned enough about both impermanent loss and ways to avoid it. For a beginner or intermediate crypto user, these tips should be sufficient. But if you’re an experienced user, use yield farming techniques to ensure your returns are always greater than the potential impermanent losses.