Interest Rate Calculation
#
Compounding vs. LinearThe length of an interest rate calculation period is one second. As the computation power in smart contracts should be efficient to limit gas fees, the interest rate feature of the youves tracker tokens uses a mixed approach between simple interest rates and compounded interest rates. The simple interest rate is applied during one interest rate period between calculations. Whenever there is a calculation of interest rate amounts, however, these amounts get added to the balances which are used as the basis for the calculation. In effect this mimics a compounding feature. At the end of an interest rate period, the final value of this period is calculated and added to the balance. Therefore, from one interest rate period to the next compounding is applied. The exact mix of a simple interest rate and a compounding rate will be the same on both balances of holders and also on the outstanding amount of vaults, as any calculation will always be done on both sides. Each period on the platform is one second.
#
Formulas#
1-Period CaseIn the 1-period case there is no distinction between the simple and the compounding interest rate calculation.
Asset[t_1] = Asset[t_0] * (1 + Interest_Rate)
#
n-Period CaseFor the n-period case, there are two ways of doing the calculation. In any case, this only works if the interest rate does not change during the n periods. Otherwise, two or more shorter period calculations - each with a constant interest rate - have to be made.
#
n-Period Simple Interest Rate CalculationThe simple interest rate calculation has the advantage that it is less computationally demanding, especially over a larger number of periods and hence saves gas and storage fees. Unfortunately, this shortcut ignores compounding effects. However, whenever the calculation is performed and a new result is calculated (Asset[t_n]
below) and used as a basis for further calculations, there is implicit compounding. This is the method which the platform uses. It ensures that such a calculation step is done at least once a week and so the difference to a pure compounding method will remain small.
Asset[t_n] = Asset[t_0] * (1 + n * Interest_Rate)
#
n-Period Compounding Interest Rate CalculationThis would be the correct method to used for an n-period calculation. However, it is computationally very demanding, therefore this method is not used on the platform.
Asset[t_n] = Asset[t_n-1] * (1 + Interest_Rate) = Asset[t_0] * (1 + Interest_Rate)^n
#
ExampleFor this example we use only 2 decimals to keep it legible. The precision in the platform is higher. The interest rate per second is 1.55E-9, i.e. 5% p.a. The asset at time 0 is set to 100,000.
Asset[t_0] = 100,000
After 3,600 seconds (one hour), the first interest rate calculation is done. We get
Asset[t_3600] = Asset[t_0] * (1 + n * Interest_Rate) = 100,000 * (1 + 3,600 * 1.55E-9) = 100,000.56
After another 400 seconds, another calculation is done. We get
Asset[t_4000] = Asset[t_3600] * (1 + n * Interest_Rate) = 100,000.56 * (1 + 400 * 1.55E-9) = 100,000.62