What is impermanent loss? Image of scales with RUBY/USDP
DeFi and AMM Farming Education

What Is Impermanent Loss?


Impermanent loss (IL) is a DeFi concept that every liquidity provider should understand. When a user deposits tokens to an AMM's liquidity pool, they receive an LP token that acts as a voucher for a proportion of the pool's total contents (not the specific number of tokens they contributed). As traders buy and sell tokens, the composition of the pool changes, and when the user redeems their LP token, they claim their share of the pool's contents at that moment.

Impermanent loss is the change in the value of the liquidity provider's share of an AMM pool, compared to the value if the original tokens had simply been held in an external wallet.

Understanding Impermanent Loss (IL)

DeFi operates on the principle of shared liquidity. For example, AMMs replace the order books of a centralised exchange with funds pooled by many users. A smart contract sets the price of each asset in the pool for traders, based on supply and demand.

Depending on the AMM's model, Liquidity Providers generally deposit the same USD value for both tokens in a trading pair. If ETH is trading at $4,000, the LP might deposit 1 ETH and 4,000 USDP, worth a total of $8,000.

The price of ETH against USDP is determined by the ratio of ETH to USDP in the pool, as set by an algorithm, with trades quoted by a smart contract. Many AMMs use the "xy=k" model, in which the product of the number of each token for the pair ("x" and "y") always equals a constant "k".

Assume the pool starts out with 100 ETH and 400,000 USDP. The total pool value is $800,000 ($400,000 of ETH and 400,000 USDP), and k = 40,000,000. The liquidity provider described above has contributed 1 ETH and 4,000 USDP, or 1% of the pool, and receives LP tokens that act as a voucher for this proportion. However the composition of the pool and the price of ETH change, they will always be able to redeem their LP tokens for 1% of the overall pool. (For simplicity, we're assuming that no other providers deposit liquidity to the pool, and we'll ignore the effect of fees.)

How many ETH and USDP will the pool contain when the price of ETH is $8,000, and how many of each token will the LP own?

The price of ETH in USDP is simply the ratio of ETH to USDP tokens in the pool, so there will be 8,000x more USDP than the number of ETH (y/x = 8000). The formula x*y=40,000,000 remains unchanged. A simultaneous equation gives the answer as 70.71 ETH and 565,685 USDP. The liquidity provider owns 1% of this, or 0.707 ETH and 5,657 USDP.

An example of impermanent loss.
An algorithm sets the price of tokens according to the proportion of each held in the pool.

This represents a total value of $11,314 (0.707*8,000 + 5,657). However, had the liquidity provider simply held their assets rather than depositing them in the pool, their 1 ETH and 4,000 USDP would now be worth a combined $12,000—meaning they have theoretically lost out on $686 of gains (5.7%), essentially by selling a proportion of their holdings as the price rose.

This "loss" is only crystallized when the liquidity provider withdraws their proportion of tokens from the pool. And, of course, if the price of ETH drops back to its original levels, this effect is cancelled out—which is why it's known as "impermanent" loss.

The same principle applies if the price moves in the other direction. Had the price of ETH instead fallen to $2,000, the pool would hold 141.4 ETH and 282,823 USDP. The LP would own 1.414 ETH and 2,828 USDP for a total value of $5,656, instead of the $6,000 they would have if they still held the original 1 ETH and 4,000 USDP—again, an impermanent loss of 5.7%.

Offsetting Impermanent Loss

The idea of impermanent loss discourages some users from depositing liquidity to AMM pools. There are two factors that offset IL and often enable liquidity providers to profit more than they have lost:

  • Fees. LPs receive a proportion of the trading fees charged to users, which are typically around 0.3% per exchange.
  • Farming rewards. Additional platform tokens may be distributed to liquidity providers to incentivize them to deposit funds in an AMM's pools.

The greater the price volatility between the two tokens, the greater the potential for IL. For the yield farmer, the best case scenario is high trading volumes but relative price stability, meaning they collect trading fees and farming rewards without incurring IL. A stablecoin pair is the least volatile combination, reducing impermanent loss to a minimum.

Dai, USDT, USDC, USDP icons
Stablecoin-to-stablecoin swaps enable liquidity providers to earn rewards with minimal risk of impermanent loss.

Farm RUBY Tokens

Impermanent loss refers to the way that price volatility impacts the value of a stake in a liquidity pool in a different way than if the same assets had simply been held in an external wallet. This loss is only realized when funds are withdrawn from the pool, and can be offset by earning trading fees and pool rewards. Ruby will be offering attractive opportunities to farm RUBY tokens on supported liquidity pools.

Learn more about DeFi and stay up-to-date with the latest developments for Ruby.Exchange by subscribing to the blog, or following us on Twitter and Telegram.