Return Rates in Crypto Farming
A basic introduction to some fundamental concepts in crypto asset farming
Decentralized Finance (DeFi) has attracted a lot of attention in the recent years. A rather new and hot topic inside the world of DeFi is yield farming, which allows to earn passive income on token holdings using various investment strategies coded into smart contracts. There is an ever growing number of products labeled as yield farming. Many of those are advertised with an APY (Annual Percentage Yield) rate. We emphasize that in this context, the term APY is to be read with caution. In classical finance, it refers to the annual rate of return in an investment and is a predefined rate. Hence, an investor can be sure to obtain the corresponding interest in their investment. However, most farming products heavily rely on the investment strategy in volatile crypto markets. In contrast to APYs in lending and borrowing, rates published in farming are either APYs of past periods or projections based on past data.

Pool Rates

Due to the complexity of this topic, our first step consists of publishing the pool rates as emitted in the smart contracts of various farming products such as yearn.finance or CVault. The basic idea of pool rates is pretty straightforward and can be understood as follows. Consider a farming pool of token
XX
and let
AX(i)A_X(i)
be the amount of token
XX
at block number
ii
. Assume, farming starts at block number
i0i_0
, then we have the following equation
AX(i)=AX(i0)pX(i)A_X(i)=A_X(i_0)\cdot p_X(i)
where
pX(i)p_X(i)
is the price corresponding to the pool of token
XX
. Initially,
i=i0i=i_0
and hence
pX(i0)=1p_X(i_0)=1
. Motivated by this fact, we write
pX(i)=1+rX(i).p_X(i)=1+r_X(i).
Here,
rX(i)r_X(i)
is the pool rate corresponding to the pool of token
XX
.
As the initial supply
AX(i0)A_X(i_0)
is constant, the price depends on the evolution of
AX(i)A_X(i)
and hence on the pool's investment strategy - if the number of tokens
AX(i)A_X(i)
increases with block number
ii
, so will the pool rate. In other words, the return of an investment is determined by the change in the pool rate. The following example illustrates the relation between the pool rate and the return on an investment. We remark that in general, as for interest rates in traditional finance, differences of pool rates can be used for simple interest calculation as well as for compounded interest.
Example: Assume an investor puts an amount of
100100
tokens
XX
into an empty pool at block number
1000000010000000
. With the notation from above this means
i0=10000000i_0=10000000
and
AX(10000000)=100A_X(10000000)=100
. Further assume that
10001000
blocks later, the investment strategy has increased the number of tokens in the pool to
101101
tokens, so
AX(10001000)=101A_X(10001000)=101
. The return on the initial investment after these
10001000
blocks can be obtained by the difference of the pool rates at blocks
1000100010001000
and
1000000010000000
respectively. Indeed, we have
pX(10000000)=1p_X(10000000)=1
and thus
rX(10000000)=0r_X(10000000)=0
. By the above equation for
AX(i)A_X(i)
we have
pX(10001000)=AX(10001000)AX(10000000)=101100p_X(10001000)=\frac{A_X(10001000)}{A_X(10000000)}=\frac{101}{100}
and thus
rX(10001000)=1100r_X(10001000)=\frac{1}{100}
. This yields
rX(10001000)rX(10000000)=1100r_X(10001000)-r_X(10000000)=\frac{1}{100}
and hence a return rate of 1%.
Again, whether the amount of tokens in a pool increases or decreases solely depends on the investment strategy. The return rates for past time ranges can be computed by considering pool rate differences, such as done in the example above. In order to estimate future return rates, one can apply mathematical methods which allow for the estimation of future values based on past data. The simplest way of doing so is to fit a linear function to the data, which is also known under the name of (linear) regression. However, for most cases, such simple models do not yield good results for bigger time ranges. Mathematicians have tackled such problems since a long time and there is a wide range of techniques available. Nowadays, many of these are used under the name of machine learning.

Total Debt Systems

A slightly different approach for farming is presented by other platforms such as Synthetix. Apart from constant fee rates on transactions such as trades, the dynamical return rate depends on the average return of all investments on the platform. The corresponding gains (or losses) for the investors are paid out periodically, for instance weekly. We will first explain the general mechanism and then illustrate it with an example.
Consider a platform with
nn
different pools associated to an investment strategy. In most cases, the investment strategy is short or long on a cryptocurrency, represented by a minted synthetic asset. Assume an investor makes an investment by buying from a pool of such a token
XX
worth
p0p_0
US-Dollar (it could be any other currency obviously). She thereby increases the so-called system's total debt from the previous value to
D0D_0
(also in US-Dollar). Here, the total debt is just the value of all investments across the platform. Now assume that after one farming period has elapsed, the value of her investment is
p1p_1
. Furthermore, the system's total debt, i.e. the US-Dollar value of all investments together changed to
D1D_1
. The idea is that the system does not owe the investor her initial investment, but rather her initial proportion of the system's total debt, which is
p0D0\frac{p_0}{D_0}
. Hence, her actual personal debt
DInvD_{Inv}
is
DInv=p0D0D1.D_{Inv}=\frac{p_0}{D_0}\cdot D_1.
In other words, the total debt is distributed among all investors according to their initial share of the total debt. In particular, everyone wins if
D1>D0D_1>D_0
, that is, the total debt increases, and everyone looses if
D1<D0D_1<D_0
. Furthermore, the investor's total gain
GG
after one farming period is given by her personal debt minus her initial investment
G=DInvp0=p0(D1D01).G=D_{Inv}-p_0=p_0\left( \frac{D_1}{D_0}-1 \right).
Let us quickly illustrate this equation before making the connection to the pool rate
rr
. Assume the total debt has increased from
D0=1000D_0=1000
by
10%10\%
to
D1=1100D_1=1100
. Plugging into the above equation for the gain
GG
leads to
G=p0110G=p_0\frac{1}{10}
and hence, the investor makes a gain of
10%10\%
. In order to see the relation to the pool rate
rr
from the previous section, we rewrite the personal debt
DInvD_{Inv}
in a somewhat artificial manner as
DInv=p0(1+(D1D01)).D_{Inv}=p_0\left(1+\left(\frac{D_1}{D_0}-1\right)\right).
And hence, the pool rate
rr
is given by
r=D1D01.r=\frac{D_1}{D_0}-1.
It should come as no surprise that this leads to the pool rate
r=0.1r=0.1
for the above example. Let us now consider a slightly more comprehensive example.
Example:
Step
Investment 1 in $
Investment 2 in $
Investment 3 in $
Total Debt in $
sBTC
sETH
0
100
0 48
2
0
D0=150D_0=150
sBTC
sETH
0
100
0
48
4
0
D1=152D_1=152
DInvD_{Inv}
100152150=101,33100\cdot\frac{152}{150}=101,33
48152150=48,6448\cdot\frac{152}{150}=48,64
2152150=2,032\cdot\frac{152}{150}=2,03
GG
1002150=1,33100\cdot\frac{2}{150}=1,33
482150=0,6448\cdot\frac{2}{150}=0,64
22150=0,032\cdot\frac{2}{150}=0,03
Consider a protocol with just two pools, namely sBTC and sETH, and three investors as shown in the first row. The system's total debt is the sum of the investments. Assume that after one farming period the ETH price miraculously remains the same, and the price of BTC doubles, leading to the balances shown in row 2. In the third row, the personal debt for each investor is computed using the above formula for
DInvD_{Inv}
. In the last row, the corresponding total gains are computed. Although investor 3's strategy made a gain of
100%100\%
, the investor himself only made a gain of
1,5%1,5\%
, as he was the only one winning and his total gain is distributed among all investors. Furthermore, it is distributed according to the initial shares. As Investors 1 and 2 have far bigger initial shares, they get a large amount of Investment 3's gain, although their strategy did not win. Finally, we can easily compute the farming period's pool rate for this example, using the above formula
r=1521501=0,013ˉ=1,3ˉ%.r=\frac{152}{150}-1=0,01\bar{3}=1,\bar{3}\%.

Estimation of Pool Rates from Total Rewards

Some platforms such as Loopring emit total system rewards, i.e. accumulated rewards distributed among all pools. We remark that, given a particular staking pool's balance
DD
and the total reward
RR
, an average pool rate
r~\tilde{r}
can be estimated as follows
r~=RD.\tilde{r}=\frac{R}{D}.

Fixed Reward Systems

In fixed reward systems as used by Barnbridge, a fixed (and predefined) reward
RR
is distributed among all investors in a pool after a given staking period. The reward is distributed according to an investor's share of the pool. More precisely, let again
DD
be the total staking pool's balance at the end of the staking period. Assume a particular investor has staked the amount
DID_I
. Then the investor's reward
RIR_I
is given by
RI=DIDR.R_I=\frac{D_I}{D}\cdot R.
For instance, assume the reward is
R=32000R=32000
, the staking pool's balance at the end of the staking period of one week is given by
D=200000000D=200000000
and an investor invested
DI=400000D_I=400000
of an arbitrary currency. Then the reward is given by
RI=40000020000000032000=64.R_I=\frac{400000}{200000000}\cdot 32000=64.
Here, the pool rate
rr
is simply given by the quotient
r=RDr=\frac{R}{D}
, so in the above example
r=0.00016.r=0.00016.
We remark that there might be slight differences on how to implement these systems. Especially whether to allow deposits in the middle of a staking period and if so, how to distribute the reward among these "late" investors.
Last modified 8mo ago