DeFI Decode: Liquidity mining yield, impermanent loss, and set optimal range
My purpose is to provide an Open-Source Tool (github link) that everyone can use to boost your liquidity mining return (of course, only after you have fully checked the assumption and agrees with it).
Let’s get started.
Introduction
Uniswap V3 has introduced the concentrated range, which provides new opportunites with caveats:
- Smaller range leads to highly efficient capital allocation (meaning higher LP yield with same capital)
- Smaller range means higher impermanent loss when price move, esp out of range.
Setting balance need analysis on volatility of the underlying crypto pairs, and choose according to your risk appetite ( loss you comfortable with).
This article focuses on WBTC/ETH pool, we find out that by setting range of [-8%, +8%], it can give you an average annualised yield of 8% with potential imp loss < 5%, based on past 1 year data.
Before we get into details, let’s first go through a real example on cost of wrong ranges.
A real example of narrow range leads to relatively large loss
The chart below was extracted around 2023–12–23 (Merry Xmas, guys!). You can see a high bin sitting outside the current price range (~0.0526 BTC per ETH).
Further check reveals that this missing-out bin asset is ~7btc, locked in price range 0.0513 to 0.052:
Assuming this position was initially provided when price at middle between [0.0513, 0.0520], (or 0.0516), we can back-out the BTC and ETH holdings at that moment (shown in the table below). Overall, the narrow bin [0.0512, 0.0520] (or +/-0.78% ) leads to 0.77% imp loss when price only moved < 2% (from 0.0516 to 0.0520), plus no fee income.
We next move on to show how to set range in better way.
Content
- Summary of results
- Methodology Details
- Data Details: price change, coverage % and impact of LP range
- Final thought
Summary of results
In order to get optimal range, we need to first produce the yield vs range profile (the risk / return profile). Below is an overview of how to get this profile.
- Choose a time horizontal for risk (1 month) and for back testing (1 year). and collect the price data for the pool pairs.
- Define a set of bin range choices for evaluation. Note range has up & down limit, and we simplify the problem by using symmetrical ranges (in terms of imp loss), where range_up_limit = range_down_limit / (1-range_down_limit). so in this artilce, we only need the down % to denote the range.
- Get all month returns, and calculate the impermanent loss against this pre-defined set of range choices
- For each month, calculate the yield gain of each range choice. This part needs further 3 detailed estimation of daily LP fee yield , liquidity boosting factor, and range coverage percentage (likelihood of price stay within chosen range).
- Finally, derive the expected net gain for each range choice and choose the one based on your risk appetite.
Chart below show the risk/return profile we produced.
The above chart shows the gross_fee_gain (LP yield), gross_loss (impermanent loss) and net_gain (difference of the two). you can see net_gain (green line) first grows with smaller range (benefit from higher capital efficiency), then reduce:
- impermanent loss increases exponentially as range decreases.
- gross_gain also increase exponential but with lower speed (this is actually due to range coverage percentage reduce significantly with smaller range)
Put the above chart into table below for range up to -20%, you can see clearer of the risk/return trade off:
- Even though range_limit [-4 %, ~4%] gives the highest expected return of 11.17%, its imp loss is also high at -9.51%.
- If you accept an loss max -5%, then range of -/+8% is better , with the expected gain of 8.14%.
- more conservative range like [-18%, 22%] have imp loss of only 2%, also with smaller expected gain of 4.11%. (note the 22% = 18%/ (1–18%) ).
- If the range goes too narrow, like [-2%, 2%], the imp loss can increase exponentially to -14.6%.
Methodology Details
here we provide details on how risk/return profiles are calculated.
Problem: Find a range limit such that the expected LP yield is maximised,
where y is the expected net LP yield, {\triangle d} is the range limit. Again note that range has both down and up limit, and we simplify the problem of using {\triangle d} only while the up side can be solved symmetrically (meaning same amount of liquidity for up & down side) as
Then expected net yield y with given range limit can be defined as
where r_p is the price_change at the end of the evaluation horizon, p(r_p) is the probability, and pool_net_return is the net return of the LP mining given r_p and range limit {\triangle d}.
below we give further explanation of gross_fee and imp_loss:
Gross_fee depends on several factors:
- the LP daily return, which depends on TVL, liquidity concentration and trading volume.
- Coverage percentage, this parameter describes how likely the current price will be within the range (you get 0 income if price moved outside).
- capital efficiency (or boost) provided from narrow liquidity range.
The corresponding formula for gross_fee is
Also note that in theory, coverage_percentage statistically depends on r_p, since a higher r_p would mean a lower coverage percentage. For simplicity, we use average coverage % accross all returns.
The calculation of impermanent loss is simple, the detail can be found in the github code. We provide a chart here to see the relation between imp loss and price change. Assume the underlying price move -10%:
- if your LP range is -/+18%, your imp loss will be ~1.5%.
- but if your LP is -/+ 5%, your imp loss will ~4%, or 2.7x higher.
Data Details: price change, coverage % and impact of LP range
Price change will impact the final return in 2 ways:
- Impermanent loss depends on final price change (monthly in our risk horizon) but not the price change in between.
- Daily fee income depends on the cumulative daily price change in between, since it impacts what are the days we can earn a fee income (coverage ratio).
Below 3 charts give the 1 year price, monthly price return, and daily price change (vs month begin) for a visual sense of the impact.
Out of above 3, the most interesting is the 3rd one. you can see that on a monthly basis, most cumulative price change stays with beyond [+10%, -15%]. Note that this range cannot be simply used for range setting:
- imp loss happens even when when price stays within such range. For example, range of [-18%, 22%] has a imp loss of 2%.
- Need trade-off against expected gains.
let’s dive a bit more into this trade-off. Two charts below show the gain and cost of narrower range:
- It boosts the capital efficiency (multiplier) exponentially;
- It reduces coverage % exponentially from a starting point (around -18% in our data)
By now, we have explained all the details of this algorithm. you can went back to the summary and connect it all.
Final thought
The results are based on monthly return, hence it needs monthly rebalance to get the expected return. Also, simulation shows the results can be sensitive (due to price return statistics can change significantly across the time). As a result, conservative investor can tweak the range a wider to fit for its purpose.
Hope you have learnt some thing useful for your investment. keep it up! If you also work in yield farming areas, can msg me as well for progress together.
— By BitBlock Technology.