- The concept of impermanent loss, though new, is not strange to investors in the decentralized finance (DeFi) ecosystem.
- DeFi presents an opportunity to earn passively, with liquidity provision being one of the major ways. Liquidity provision involves depositing capital (liquidity) into a liquidity pool of a cryptocurrency protocol to earn interest.
- A similar problem liquidity providers encounter is impermanent loss which affects the underlying value of assets they deposit in the pool.
- With Uniswap being among the most popular Automated Market Maker (AMM) protocols, it is imperative that investors who provide assets into its multi-asset liquidity pool will face impermanent loss.
- The ability to track impermanent loss while on a quest to earn passively is important. This guide explores how to track impermanent loss on Uniswap V3.
What is Impermanent Loss?
Impermanent loss is a phenomenon where the price of an investor’s token changes compared to the price at the initial point of deposit into the liquidity pool. Impermanent losses are often associated with AMM-based exchanges. AMMs are decentralized exchanges that pool liquidity from users and set the prices of the assets in the pool using specific algorithms.
In simple terms, when investors deposit tokens into liquidity pools and encounter a loss at the time of withdrawal, the investors are said to suffer impermanent losses. This usually occurs due to the volatile nature of cryptocurrencies. There are instances where investors do not have to lose money for impermanent loss to occur. It could be that such investors’ gains may be way smaller than would have been achieved with the “buy and hold” strategy.
For instance, if a liquidity provider (LP) decides to add liquidity to a liquidity pool of 50:50 ETH/DAI, it means they would have to provide an equal value of both tokens to the pool.
If at the time of deposit, ETH is exchanging hands at $1500, and it suddenly goes up to $1700 on an external exchange, the difference between the price of the ETH in the pool and an external exchange gives room for arbitrage traders to make a profit. They simply buy the cheaper ETH from the liquidity pool and then sell it at a higher price on the external exchange.
The ratio of assets in a liquidity pool is often kept constant, all thanks to the AMM feature. This means as the ETH is being bought, the price will increase against the DAI, pushing the price of ETH in the investor’s trading pair to drop. While this is done to maintain equilibrium, the amount of DAI will rise till it reaches a new equilibrium where the value of ETH and DAI become equal.
It is worth mentioning that impermanent loss is not permanent. This is because volatility is not always about the sharp decrease in price, but also the increase in asset price. Consider the previous scenario where ETH was valued at $1,500 at the time of deposit. If the price steeply drops to $1,350, an impermanent loss is said to occur.
But to show that impermanent loss is not permanent, the price of ETH can suddenly bounce back to $1,500 and continue to soar.
What is Uniswap V3?
Uniswap remains one of the most popular AMM-based decentralized exchanges that showcase several interesting features. Version 3 of the protocol is not any different.
The Uniswap V3 introduces new features that facilitate capital efficiency and focus on more active market makers than passive ones. The protocol features concentrated liquidity which offers individual liquidity providers (LP) control over what price ranges their capital is allocated to. This way, individual positions can be combined in a single pool to give a combined curve that investors can trade against.
Uniswap V3 also features multiple fee tiers that allow liquidity providers to be adequately compensated for the varying degree of risks they take.
The Uniswap V3 protocol is more flexible and efficient than other AMM-based protocols in the DeFi ecosystem. Some features that make this possible are outlined below.
- Liquidity providers swap one asset for another by adding liquidity to a price range that is entirely above or below the market price, approximating a fee-earning limit order that executes a smooth curve.
- Liquidity providers can add liquidity with up to 4000x capital efficiency; earning potentially more returns compared to Uniswap V2.
- Liquidity providers can be exposed to more preferred assets and reduced levels of downside risks.
- Capital efficiency allows for the execution of low-slippage trades that exceed those of centralized exchanges and stablecoin-based AMMs.
- The oracles are faster and easier to integrate, providing time-weight average prices (TWAP) on demand for periods within nine days.
- Compared to V2, gas fees of Uniswap V3 swap on Ethereum mainnet are quite cheaper, prompting slightly cheaper transactions.
How the Uniswap V3 Concentrated Liquidity Works
In Uniswap V2, liquidity is distributed evenly along an x * y = k price curve, with prices between 0 and infinity. Liquidity providers in V2 only earn fees on a small portion of their capital, preventing them from being adequately compensated for the impermanent losses they may encounter. With liquidity being spread across thin prices, traders in V2 are often subjected to a high degree of slippage.
With Uniswap V3, liquidity providers can concentrate their capital within custom price ranges. This means they can provide more significant amounts of liquidity at desired prices. To concentrate liquidity, liquidity providers construct individual price curves that showcase their preferences.
Liquidity providers can merge any number of distinct concentrated positions within a single pool. For example, a liquidity provider in the YLD/USDT pool can allocate $150 to the price range of $1,000 – $2,000 and an additional $50 to the range of $1,500 -$1,700. This means liquidity providers change the shape of any automated market maker or active book. It also means users can trade against the combined liquidity of individual curves with no increase in gas cost per liquidity provider. The liquidity providers collect trading fees at a given price range and are split based on the amount of liquidity they contributed at that range.
Factors that Trigger Impermanent Loss on Uniswap V3
There are several factors that contribute to impermanent loss on Uniswap V3. They include:
- Extreme Volatility: Volatility simply refers to the degree at which the price of an asset increases or decreases. Crypto assets are extremely volatile as their prices rapidly change in the blink of an eye. These rapid price changes often trigger impermanent losses which are to the detriment of liquidity providers.
- Price divergence: Should the price of two assets in a liquidity pool diverge from each other, there will be an increased chance for impermanent loss to occur.
- Concentrated Liquidity: Uniswap V3 embraces concentrated liquidity – provision of liquidity in a fixed price range – which can increase the impact of impermanent loss in tight position ranges.
- Since liquidity is provided in fixed price ranges, high fees are generated and the impact of impermanent loss increases.
How to Track Impermanent Loss on Uniswap V3
There are various mathematical explanations investors can use to calculate impermanent losses. Because these may be complex, there is a derivation formula that Uniswap V3 users can run with.
Considering a market with liquidity L and x and y amounts of assets labeled X and Y respectively; liquidity will be:
If the initial price P of asset X in terms of Y is y/x and then a price movement to P’ = Pk (and k . 0), it means that:
V_0 = Value of initial holding in terms of Y; V_1 = Value of holding if kept in the pool (where x,y moves with price); V_held = value of holding if kept outside the pool (where x,y is constant).
By using the derivation formula for x, y, assuming the price of Y in terms of Y is 1 and the price of X in terms of Y is P, it can be said that
The formula above works only on L and P. If the price changes, it can be used to calculate the price of future holdings in the same pool.
If we consider the value of a position that was held using the original quantities of x and y with new prices 1 and P’ = pk:
To calculate the impermanent loss, the percentage loss of V_1 in comparison to V_held is also calculated.
The crypto market changes rapidly, hence would take a lot of time for investors to keep up with these complex calculations for every price change.
To simplify the process of trading impermanent loss on Uniswap V3, a number of Data analytics platforms now have algorithms with a user dashboard that can be used to track impermanent loss. Some of them include:
Merlin, VALK’s DeFi portfolio tracker is able to analyze all transactions related to DeFi protocols including liquidity provision on a DEX such as Uniswap V3. Key information related to PNL, total liquidity, fees earned and impermanent loss are all shown
By viewing recent transactions on Merlin, we can view recent positions (distinguishable open positions are marked by the green circle while closed positions are marked by the gray circle). Merlin can filter out information by protocol and transaction (e.g., added liquidity, exchange, deposit, borrow and more).
Let’s take a look at this wallet’s most recent transactions. This time stamped record (most recent first) shows all actions done on these protocols, i.e., the still-yielding deposit of ETH in a Compound pool, or the addition of liquidity to a UNI/WETH pool. This particular action has yielded in a PNL of $184.23 or 12.48% so far.
Let’s zoom in further on this particular action. We can see further details related to the LP’s position, total liquidity $6,000.31) from when the first action (deposit) was taken, as well as the Uniswap V3 NFT given to the LP as a representation of their position. Impermanent loss (currently at -$32.12) is also calculated. The transactional history is laid out clearly to show the inner parts of the LP position, and as can be shown, the position is still open and thus generating yield.
Regarding the fee structure, it is displayed in two parts: claimed (at $30.60) and unclaimed fees (also at $30.60). Merlin will soon have a function that allows the investor to claim fees directly from the interface, without having to enter the DEX in question. Additionally, Merlin can identify if the position is in range or not.
Finally, Merlin gives the investor an overview of the general UNI/WETH pool. The investor’s share as a percentage of the total liquidity is shown, as well as the level of slippage for these particular assets, and the APR and APY can be compared against other pools, not only on Uniswap V3 but also other global pools (for premium subscribers only).
Frequently Asked Questions (FAQs)
What are the major features of Uniswap V3?
Two major features that make Uniswap V3 stand out are its flexibility and efficiency which helps liquidity providers to swap more crypto assets, add more liquidity, and earn more interest to compensate users for the risk of impermanent loss.
What is the simplest way of avoiding impermanent loss?
Impermanent losses are often triggered by unequal prices of assets and one of the simplest ways of avoiding them is providing capital to liquidity pools that are composed of only stablecoins and wrapped tokens such as USDC, USDT, GUSD, and DAI.
What kind of data is needed to calculate profit and loss in liquidity provision?
The data needed to calculate profit and loss in liquidity provision include the price of each token at the time of deposit, the amount of each token deposited, the date of deposit, reward for the liquidity pool, estimated price of each token at the point of withdrawal, date of withdrawal, and liquidity provider token yield farming strategies.