The Investor’s Guide to Navigating Impermanent Loss
Impermanent loss is when a token’s price change causes your share in a liquidity pool to be worth less than the present value of your deposit. It is considered impermanent because you can recover the loss if the token pair returns to the initial exchange rate. — Amberdata
Amberdata impermanent loss
Investors often claim that you can’t see the full damage of impermanent loss until funds are withdrawn. According to the experts at Amberdata though, this isn’t the case. All data is open and measurable. Anyone can provide an estimate. The real challenge is finding a precise calculation and in analyzing the risk of impermanent loss versus the reward of transaction fees.
The complexity of data sources makes this analysis difficult to account for all investment strategies. But a review of the basics can provide the tools necessary for such a report.
We sat down with Amberdata, a leader in cryptoeconomic data, to better understand impermanent loss (IL) and how to navigate it. This guide will offer context to IL by explaining the technology behind automated market maker (AMM) liquidity pools. It will explain why it happens and why it is difficult to assess. And it will detail the data resources needed to detect clues before loss occurs.
When does impermanent loss happen?
Impermanent loss happens when the price of a token changes relative to its pair, between the time you deposit it in a liquidity pool and when you withdraw it.
Think of it as primarily an unrealized opportunity cost. It’s not a real loss, because the loss is measured against the value your investment would have been if the tokens were held outside of the liquidity pool. So if you are measuring your investment in cash, impermanent loss may not cause you to lose money. And it’s unrealized because token pairs can return to the same ratio before liquidity is withdrawn.
Where does it occur?
Impermanent loss can occur in any decentralized exchange (DEX) that uses liquidity providers to fund pools segregated by trading pairs. But before we explain the mathematical phenomenon of the loss, we need to explain the purpose behind this new type of exchange and how it works.
Decentralized Exchanges
The purpose
DEXs were created for people to swap different tokens without a trusted third party. Unlike a centralized exchange (CEX), assets remain in your wallet and the exchange never has custody of them. They use two blockchain-based innovations to maintain decentralization: automated market maker algorithms and liquidity pools.
Automated Market Maker Algorithms
An automated market maker algorithm is what sets the exchange rates for specific asset pairs within a DEX.
The traditional CEXs facilitate trades through an order book. Exchange rates are set when buyers create demand and sellers offer supply. The order book matches the price a buyer is willing to pay with the price a seller is willing to accept.
In contrast to setting prices to match buy and sell orders, AMM algorithms are programmed to automatically adjust exchange rates to keep the supply of paired tokens balanced within a pool.
Liquidity Pools
Liquidity pools are smart contract enforced deposits of two tokens needed to enable swaps on a DEX. These pairs are usually set at a 50/50 ratio (but there are also uneven liquidity pools).
How they work
Imagine that you are a brand new exchange looking to open a single pool for BTC and ETH. Before anyone is able to swap BTC for ETH or vice versa, you need to attract liquidity providers to the pool.
The liquidity provider
Exchanges do this by first charging a fee for every swap and then sharing those fees as rewards with all liquidity providers in the pool. For example, if you provide 1% of the liquidity in a pool, you’ll receive 1% of the fees for that pool. Understanding the fee structure is critical to assessing the risk vs reward of adding liquidity. Because ultimately, the rewards from fees could more than offset the risk of impermanent loss.
In the ETH/BTC pool, a liquidity provider would need to include both tokens in their deposit. Most exchanges require a 1:1 ratio. So if a liquidity provider deposited 2 BTC and 1 BTC = 5 ETH, then you would need to match your BTC with 10 ETH. Once funds are deposited, you are given LP tokens as a representation of your percentage of the combined value of both tokens in the pool. LP tokens earn rewards from transaction fees and can be used to farm yield outside of the protocol.
The trader
Now that you have attracted enough liquidity providers, traders can start swapping tokens. But unlike CEXs, traders can’t toggle between their preferred token or currency in a single pool. Instead, they are required to swap one token for the other. So everytime BTC is withdrawn, the equivalent in exchange rate value is added in ETH — and vice versa.
How AMMs price tokens and balance liquidity pools
At a pool’s onset, AMMs use market rates to set prices and an equal balance in value between the supply of both tokens. So if 1 BTC = 5 ETH, total supply in the pool will reflect that ratio. As users swap tokens, the AMM uses a mathematic formula to adjust prices and balance the liquidity pool.
For example, say that there was initially 100 BTC and 500 ETH in the pool. The current price of BTC would therefore be 5 ETH. If you were to take 1 BTC for 5 ETH, the total supply would be 99 BTC and 505 ETH. This would change the price of BTC from 5 ETH to about 5.1 ETH.
But say market-wide, the price of BTC is still 5 ETH. Arbitrage traders would then take that opportunity to buy BTC at a discount and sell it for ETH in the liquidity pool. This arbitrage would continue until the price falls back to market rates.
Examples of impermanent loss
The ultimate cause of impermanent loss is unequal price changes. Though, it is important to remember that your return is calculated after collecting fees. So even if unequal price fluctuations cause impermanent loss, you may still be able to make a profit if rewards from transaction fees cover the difference.
For example, let’s say an ETH/BTC pool is programmed to keep the value of both baskets set at a 1:1 ratio. Meaning, the value of all BTC should be the same as all ETH. At the time of your deposit, 1 BTC equals 10 ETH across most other exchanges, so you deposit 4 BTC and 40 ETH.
At the time of depositing the tokens, the size of the pool was 20 BTC and 200 ETH, so your total share of liquidity is 20%.
A month later, ETH doubled in value while BTC’s price stayed the same. But the value of both token baskets in the pool don’t yet reflect the ETH market-wide price of .2 BTC. So arbitrage traders rush in to buy ETH at the discount until the pool ratio and token prices match the market rate.
So once the pool supply reaches 20 BTC and 100 ETH, your 20% deposit will be worth 4 BTC and 20 ETH. That is a 20 ETH price difference from the initial 40 ETH deposit, resulting in an impermanent loss of 20 ETH. But it just so happened that transaction fees were extraordinarily high, providing an additional 10 ETH to your share of the pool. In this case, the loss on your return would only be 10 ETH at market value. It is impermanent because the supply of tokens in the pool can return to a 1 BTC to 10 ETH ratio in the future. The loss becomes permanent once funds are withdrawn from the pool. But if a liquidity provider gains enough exposure, rewards from transaction fees can potentially make up for the impermanent loss.
Is impermanent loss actually difficult to spot?
The reason many find it difficult to spot impermanent loss isn’t because it is an inherent mystery – it is a calculable math problem. The team at Amberdata explained that due to its complexity, most resources only provide estimates.
Say that you use your LP tokens in a yield farming endeavor that generates rewards on another protocol. Estimates on the exchange can’t account for those rewards. So even if it is showing impermanent loss, it could be that your yield farming endeavor makes back the loss.
A full assessment requires multiple data points, but if you have a clear view of what’s needed, that calculation can be precise and provide actionable investing data.
Plus, IL is different for everyone because portfolios have a different mix of tokens pairs. People also don’t deposit and withdraw at the same times or prices.
To calculate PnL for a liquidity position, you need data on:
- Each token’s price at deposit
- The amount of each token deposited
- Date of deposit
- Rate of reward for the liquidity pool
- Estimated price of each token at withdrawal
- Date of withdrawal
- LP token yield farming strategies
Because there are so many variables in calculating the difference between projected gains from holding tokens versus LP fees, many struggle to make a useful conclusion about whether to enter or exit a liquidity pool.
As an added complication, the risk and reward is different for every token pair depending on each one’s volatility. The more diverse the portfolio, the more difficult this becomes.
How to calculate impermanent loss
There are detailed mathematical explanations for how to calculate IL, but in brief, a formula can be used. IL increases the more an asset’s price changes relative to its pair. This is plotted on a graph.
In this very simplified example, you can see that IL happens whether prices go up or down. But the loss is much greater as a token’s price goes down. This causes many liquidity providers to look for token pairs that are likely to appreciate at a similar rate over time.
Can you avoid impermanent loss?
Since impermanent loss is triggered by unequal prices changes, the best way to avoid it is by avoiding volatile token pairs. But Amberdata stresses that there are always a wide array of investment choices in a cost-benefit analysis. For example, simply avoiding IL may not make sense when you measure a pool’s IL costs vs transaction fee rewards. The most informed decision evaluates the potential return in relation to other pools and opportunities. This comprehensive approach helps the liquidity provider find alpha.
In our conversation, Amberdata said that they offer their clients comprehensive insights across decentralized finance, and can quantify historical performance in context to other liquidity pools and investment strategies. They provide the data needed for a full risk/reward assessment that ultimately informs liquidity providers in their search for alpha.
One of the most useful tools for providing liquidity is Amberdata’s impermanent loss endpoint. With it, liquidity providers can get the exact data needed to evaluate IL risk for token pairs in specific liquidity pools on different DEXs.
Why comprehensive data is important
Amberdata said that their endpoint tools don’t take shortcuts when it comes to calculating impermanent loss. Their application collects liquidity pool data from across exchanges and tracks activity to get accurate, customized calculations.
For example, many IL calculations do not account for the mints and burns that a liquidity provider may make in a single day. Minting refers to the LP tokens that are created when funds are deposited. Those tokens are then burned when funds are withdrawn. Liquidity providers will often try to time minting and burning to avoid volatile price swings in a pool. If their IL estimate is only a 24 hour snapshot of what impermanent loss would be from the start to the close of the day, then they will not be able to measure the impact of their liquidity positions. Amberdata takes those intraday mints and burns into consideration when calculating IL.
While the precision of an IL calculation is critical, it doesn’t provide the full story. Even if a liquidity provider is able to avoid IL through savvy burning and minting practices, it doesn’t mean that they maximized return. Effective back-testing of liquidity provider strategies requires comprehensive data points that detail the potential transaction fee rewards when an LP is in and out of a position. Amberdata said that they built their services so that liquidity providers could use this comprehensive approach to put their best strategies forward.
This post is sponsored by Amberdata.
Start your day with top crypto insights from David Canellis and Katherine Ross. Subscribe to the Empire newsletter.
Explore the growing intersection between crypto, macroeconomics, policy and finance with Ben Strack, Casey Wagner and Felix Jauvin. Subscribe to the Forward Guidance newsletter.
Get alpha directly in your inbox with the 0xResearch newsletter — market highlights, charts, degen trade ideas, governance updates, and more.
The Lightspeed newsletter is all things Solana, in your inbox, every day. Subscribe to daily Solana news from Jack Kubinec and Jeff Albus.