In Muffin web app, when you are creating a liquidity position, and have selected a pool, fee tier, and price range, we’ll show you an estimated APR. This estimated APR is indeed a historic daily returns projected over a year. So, how do we calculate it?

Brief Explanation

  1. For each fee tier of a pool, we keep track of the amount of fee accrued per unit of liquidity.
  2. We calculate the cash value of the total fee accrued per unit of liquidity yesterday.
  3. We calculate the cash value of one unit of liquidity with your specified price range.
  4. Dividing (2) by (3), we obtain the percentage returns of a position with your specified price range for yesterday.
  5. Annualizing it, we obtain the APR of such concentrated liquidity position yesterday.
This calculation assumes your position would be in-range all the time yesterday. And, when using this historic returns to estimate future returns, we’re also assuming the position will stay in-range all the time in the future. This is inapplicable to single-sided positions.
The potential divergence loss (IL) is not taken into account in the APR calculation. The APR here is intended to only communicate the fee-generating ability, which you can compare between pools or between fee tiers.

Detailed Explanation

In each swap, the trader pays a swap fee in either one of the two underlying assets. Let’s say the pool’s underlying assets are tokenX or tokenY. Let’s denote the fee amount in tokenX by $F_x$, and the fee amount in tokenY by $F_y$ .

For each fee tier of the pool, after each swap, we record the fee accrued per unit of liquidity in the tier, i.e. $\frac{F_x}{L}$ and $\frac{F_y}{L}$.

Then, we can find out the total fee accrued per unit of liquidity yesterday, i.e. $\sum_{i=1}^{m} \frac{F_{x,i}}{L_i}$ and $\sum_{j=1}^{n} \frac{F_{y,j}}{L_j}$, assuming there’re $m$ payments in tokenX and $n$ payments in tokenY yesterday. For simplicity, let’s use $H_x$ and $H_y$ to represent them respectively.

Then, we calculate $V_{fee/l}$, the value of the total fee accured per unit of liquidity yesterday, using the current exchange rate $p$, in terms of tokenY:

$$ V_{fee/l} = p H_x + H_y $$

And, in the previous article, we know the value of one unit of liquidity in a full-range position is:

$$ V_{l,\text{full-range}} = 2 \sqrt{p} $$

Thus, the percentage returns of a full-range position yesterday, $r_{\text{full-range}}$, is:

$$ r_{\text{full-range}} = \frac{V_{fee/l}}{V_{l,\text{full-range}}} = \frac {\sqrt{p} H_x + \frac{1}{\sqrt{p}} H_y} {2} $$

Similarly, from the previous article, we know the value of one unit of liquidity in a concentrated liquidity position with a price range $[p_\text{lower}, p_\text{upper}]$ is:

$$ V_{l,\text{conc}} = p \left( \frac{1}{\sqrt{p_c}} - \frac{1}{\sqrt{p_\text{upper}}} \right) + \left(\sqrt{p_c} - \sqrt{p_\text{lower}}\right) $$

$$ p_c = \text{max}\left\{p_{\text{lower}}, \text{min}\left\{ p_{\text{upper}}, p\right\}\right\} $$

Thus, the percentage returns of such concentrated liquidity position yesterday, $r_{\text{conc}}$, is:

$$ r_{\text{conc}} = \frac{V_{fee/l}}{V_{l,\text{conc}}} = \frac {p H_x + H_y} {p \left( \frac{1}{\sqrt{p_c}} - \frac{1}{\sqrt{p_\text{upper}}} \right) + \left(\sqrt{p_c} - \sqrt{p_\text{lower}}\right)} $$

Alternatively, if you already know the returns of full-range position ($r_{\text{full-range}}$) and the capital efficiency of the concentrated position ($CE$), you can compute $r_{\text{conc}}$ by:

$$ r_{\text{conc}} = r_{\text{full-range}} \cdot CE $$

Annualizing $r_{\text{conc}}$, we can get the yesterday APR of such concentrated liquidity position:

$$ APR_\text{conc} = r_{\text{conc}} \cdot 365 $$

Note that we could compute a more accurate historic returns by considering when the position would be “in-range” and “out-of-range” yesterday. However, since the purpose of the historic returns here is to provide a reference to future returns, taking account of the historic “in-range” status will mean we assume the future token price and price movement are similar to those of yesterday. This assumption is unrealistic and likely leads to an irrelevant APR estimation.

On the other hand, this calculation does take account of the historic liquidity distribution, e.g. if the token price moved closer to the tail of liquidity distribution, the fee accrued per unit of liquidity should be theoretically higher than usual (i.e. $L\downarrow \implies \frac{F}{L} \uparrow$). Taking account of this is unwanted because we do not want to assume the future token price will move like yesterday. But, if we consider the fact that a big part of trading volume of an AMM is from arbitrage, then the trading volume, and thus the fee amount, should decrease when liquidity decreases, intuitively cancelling off the unwanted consideration of historic liquidity distribution.

Sophiscated LPs may have their own ways to interpret the profitability of providing liquidity. If you don’t mind to share your method, please talk to us and see if we can help calculate and display it on the UI. Also, let us know if you have any thoughts on the APR calculation described here.