Topics Blockchain

How to Avoid Impermanent Loss When Providing Liquidity in DeFi

Intermediate
Blockchain
DeFi
3 de may de 2023

A relatively popular sector in decentralized finance (DeFi) is liquidity mining, which is how users place their cryptocurrencies into liquidity pools on automated market maker (AMM) decentralized exchanges (DEXs). In return, liquidity providers (LPs) earn rewards for increasing the liquidity available in these DEXs for market participants to swap.

These AMM DEXs utilize algorithms that drive the token rebalancing formula for the pools, allowing for sustainable swapping. However, using such algorithms result in divergence between the new price of the cryptocurrency in the liquidity pool and the original price at which LPs have deposited it. This difference in price is known as impermanent loss, and becomes greater when the change in price is larger.

In this guide, we’ll discuss impermanent loss, the pros and cons involved in providing liquidity, and how you can avoid or minimize your level of impermanent loss.

Liquidity Pools and Automated Market Makers (AMMs)

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

DEXs were developed to enable token exchanges that don’t need to use a reliable intermediary. Assets never leave users’ wallets, and are never in the possession of the exchange, unlike when using a centralized exchange (CEX). DEXs preserve decentralization through AMM algorithms and liquidity pools, two blockchain-based inventions.

Understanding Automated Market Makers (AMMs)

Traditional order book models depend upon the matching of buyers and sellers in order to carry out transactions. When you use an AMM DEX, you’re trading against pools of tokens instead of other traders, with the liquidity in the pool provided by LPs. Although liquidity pools can be made up of multiple tokens, they are usually just made up of two pools of tokens. The ratio of tokens available within these pools is controlled by the following algorithm:

x * y = k

where x and y represent the value of each type of token in the pool. K is the fixed constant that keeps the total liquidity of the pool constant.

According to this formula, the total value of each liquidity pool are always equal to each other. The fixed constant creates an automatic pricing mechanism  that maintains the equal value of each token pair.

Understanding Liquidity Pools

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 in value to make it simpler for users to conduct trading. The number of tokens can be different in each pool but the total value of each pool must equal each other. For example, in terms of dollar value, the ratio will be 50% DAI and 50% ETH in this pool.

Liquidity pools are essentially smart contract–enforced deposits of two tokens needed to enable swaps on a DEX.

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, when you purchase DAI from an ETH/DAI pool using ETH, you are essentially reducing the supply of DAI in the pool. At the same time, the supply of ETH increases as you add ETH to the ETH/DAI pool. In such a situation, the quantity of ETH increases and DAI decreases, which results in each ETH being worth less DAI.

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

What Is Impermanent Loss?

When you deposit into a liquidity pool and the price of the tokens change compared to when you deposit them, this is referred to as impermanent loss. 

Another way to look at impermanent loss is when you provide liquidity by depositing two cryptocurrencies in a liquidity pool, and make a profit that’s less than what you would have made by simply holding the two cryptocurrencies. It occurs when a cryptocurrency’s market price shifts, depreciating the value of the cryptocurrency you deposited in a liquidity pool below its current market value. The loss is even greater with a greater price change.

Impermanent loss can be negated if the token price reverts to its previous value, making the loss "impermanent", or “temporary”. It's also critical to remember that this loss does not account for trading fees that investors receive in exchange for supplying liquidity, which can cancel out losses.

If investors remove their cryptocurrencies from the pool, the impermanent loss becomes realized. In order to make up for this loss, pools have trading fees that go to liquidity providers to hopefully make up for their impermanent loss.

Which Pools Are Prone to Impermanent Loss?

Some pools are more prone to impermanent loss than others. Typically, these pools contain volatile cryptocurrencies. 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, a pool with cryptocurrencies that are correlated, such as a liquidity pool consisting of ETH and cryptocurrency correlated to ETH such as frxETH, or USDT and USDC that are both correlated to the USD, will have no impermanent loss as prices move in tandem with each other. 

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

How Does Impermanent Loss Happen in DeFi?

Let’s use an example: As a liquidity provider, Jack stakes 1 ETH and 100 USDT. According to the AMM concept, the staked tokens need to be of equivalent value. Thus, Jack’s 1 ETH would be equal in value to 100 USDT. At that moment, Jack’s stakes translate to 10% of 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. Thus, the pool is now imbalanced as 10 ETH is worth 4,000 USDT but the pool is paired with only 1,000 USDT. 

Arbitrageurs will quickly spot this pricing inefficiency in this pool and buy up ETH from the pool with USDT, removing ETH and adding USDT, until the total value of ETH in the pool is equal to the total value of USDT in the pool, also known as rebalancing the pool. In this case, arbitrageurs will rebalance the pool until there is 5 ETH and 2,000 USDT left, as 5 ETH at 400 USDT is equal to 2,000 USDT. 

To know if Jack will suffer an impermanent loss or profit from his stakes, he’ll have to withdraw 10% of his share from the liquidity pool of 0.5 ETH and 200 USDT, which amounts to $400:

0.5 ETH × $400 = $200

200 USDT + $200 = $400. However, Jack would have made $500 if he’d held onto his ETH and USDT because 1 ETH has increased in value to $400.

By providing liquidity in an AMM, Jack’s gains are 50% less than they would have been if he’d held his cryptocurrencies. 

This loss is called “impermanent” because it is not realized before the LP position is withdrawn. Also, if ETH’s value returns to 100 USDT in the above example, 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 your cryptocurrencies are 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.

What if you’d just held your assets and hadn’t provided them as liquidity? You would have more of both currencies, which would translate to a higher value.

For an advanced impermanent loss calculation with formula, The Chain Bulletin provides an in-depth method for step-by-step calculation.

Pros of Liquidity Provision

By becoming an LP and providing liquidity to AMM DEXs, you receive rewards in the form of platform trading fees. With increased trading activity and higher volatility, the rewards earned by LPs also increases. Hence, with sufficient trading volume on the platform, it’s likely that the accumulated fees earned by LPs will be able to cover their impermanent losses, making the liquidity provision profitable.

More recently, AMM DEXs have also begun to reward LPs with their governance tokens. Examples include UNI, CRV and BAL. Such tokens can either be utilized elsewhere in the DeFi ecosystem or traded on exchanges for a profit.

However, the profitability of being an LP is highly dependent on the time and pool you choose to provide liquidity to. Picking a pool with high trading activity fueled by market conditions is often profitable for LPs.

Limitations

The most prominent disadvantage of liquidity pools is impermanent loss, because it can occur regardless of the direction in which the market moves.

How to Avoid Impermanent Loss

In some cases, 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, you can consider providing liquidity to a stablecoin pair. For example, if you provide liquidity using 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 receive any returns on them.

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

Look Out for Trading Fees

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

Sometimes, these fees are enough to offset the impermanent loss you’ve experienced during liquidity provision. The impermanent loss therefore decreases with an increase in the amount of fees collected. Hence, LPs should look for popular pools that have significant amounts of trading activity.

Invest in Low-Volatility Pairs

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

For instance, if you intend to provide liquidity to a particular cryptocurrency pair and, studying the market, you believe one of them will outperform the other soon, it’s not recommended that you provide the liquidity, because the discrepancy between the cryptocurrencies’ prices will lead to a larger impermanent loss.

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 factor that increases the chances of impermanent loss is the 50:50 ratio of most AMMs. This feature prioritizes creating a balanced liquidity pool, and in turn creates impermanent loss for liquidity providers.

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.

With Balancer Pools, you can provide liquidity with different ratios. For example, your LP position can be made of 95% of cryptocurrency A and 5% of cryptocurrency B. With this ratio of 95:5, any price change in this instance doesn’t cause as much impermanent loss as a 50:50 pool does. Therefore, one can choose to provide liquidity to these pools with more flexibility, reducing the level of impermanent loss.

Wait for the Exchange Rate to Return to Normal

When you provide liquidity to a cryptocurrency pair, their rates will naturally change in the market. The more the prices deviate from the rates at which you’ve made your deposit, the higher your impermanent loss will be.

You can wait for the crypto prices to return to their initial rates and not withdraw your currency until then, which will remove the risk of impermanent loss. However, this isn’t as simple as it may sound, due to the cryptocurrency market’s volatility. Should the prices not return to the initial state, it might result in you suffering from a greater loss.

One-Sided Staking Pools

Not all AMMs have two-currency liquidity pools. Some popular AMMs allow for one-sided staking pools. In this type of pool, you can supply a stablecoin to the pool.

In exchange for this liquidity, you’ll get a cut of the accrued fees of the platform. Since there is only one currency being provided, there will be no discrepancy of prices between two assets. Hence, impermanent loss is removed in this scenario.

Providing Liquidity Into Reputable AMM DEXs and Liquidity Pools

It’s recommended you provide liquidity into AMM DEXs that have been tested and proven to be reputable. Some of the newer AMM DEXs tend to offer unusually high returns. Despite the seemingly increased chance of profits, this poses a higher risk of rug pulls, in which developers drain the liquidity within pools, causing LPs to lose their deposits.

Providing Liquidity for Highly Correlated Pairs

You can create a portfolio of cryptocurrencies that are moderately well-correlated to reduce impermanent loss. This way, your portfolio will continue to be largely balanced when the prices of the cryptocurrencies diverge, and you can steer clear of any unforeseen losses.

Final Note

In closing, it’s imperative to remember that you can experience impermanent loss irrespective of a change in price 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 your 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 cryptocurrency prices in the market. More importantly, to maximize passive income, don’t provide liquidity to volatile pairs, since they’re more 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 cryptocurrency user, these tips should be sufficient.