# Interest Rate

Calculating interest rates and cumulation of debt.

Interest rates are recalculated in the

`Teller`

contract every time `updateAccumulators`

is called.The system interest rate is proportional to the opportunity cost of supplying loanable funds with underlying assets. The most common underlying asset for lending is the US dollar. Probity uses the following formula to calculate the annualized interest rate

*R*for every change in supply. Let*U*be the utilization ratio, i.e., the ratio of the amount borrowed to the total supply. The function takes the form:$R \cdot (1-U)=\frac{1}{100}$

A maximum interest rate can be set to comply with jurisdictions with restrictions on the amount of interest that can be charged. The function curve makes it easy. A max of 10% APR can be enforced by a modification such that the function is used for U = [0, 90] and is set to 10% for all U > 90.

The annualized interest rate is dependent on the utilization at time

*t*and defined as:$R(t)=\frac{1}{100 \cdot (1-U_t)}$

In the Trustline Credit Network, interest compounds on a per-second basis. Thus, the per-second interest rate

*r*is taken as the*n*-th root of the annualized interest rate. Given that a year is comprised of 60** 60** 24 * 365.25 = 31,557,600 seconds, the per-second interest rate is defined as:$r=\sqrt[31557600]{1+R}=(1+R)^{\frac{1}{31557600}}$

And the per-second compound interest function, which gives us the total debt after

*t*periods, is given as:$D(t)=D_0 \cdot r^{t}$

Where

*D(t)*is the debt at time*t*,*D_0*is the loan principal, and*r*is a constant rate. However, since the interest rate changes whenever underlying supply changes, we use the concept of a rate accumulator.The rate accumulator

*A*at time*t*is given as:$A(t)=A_{0} \prod_{i=1}^{t} r_{i} = A_{0} \cdot r_{1} \cdot r_{2} \cdot \cdot \cdot r_{t-1} \cdot r_{t}$

With A

*_0*as the initial cumulative rate. Now, we take the normalized debt amount$\hat{D}$

as the principal amount over the initial cumulative rate:$\hat{D}=D_0/A_0$

The total debt at time

*t*can be calculated with the normalized debt and rate accumulator:$D(t)=\hat{D} \cdot A_t = D_0 \prod_{i=1}^{t} r_{i}$

Suppose that the initial supply has $1,000. Alice borrows $500 from the pool. The utilization ratio is 500/1000 = 0.5 or 50%. The annualized interest rate set to:

$\frac{1}{100 \cdot (1-0.5)}=0.02=2\%$

From the annualized rate, we derive the per-second rate as follows:

$\sqrt[31557600]{1+0.02}= 1.000000000627507392906712188$

The initial cumulative rate is equal to the initial interest rate, so the normalized debt balance turns out to be:

$\frac{500}{1.000000000627507392906712188}=499.999999686246303744$

One month contains 2,629,800 seconds. Assuming that the interest rate stays constant this entire time, the total debt after one month is equal to:

$500 \cdot 1.000000000627507392906712188^{2629800}=500.825790650960087401$

Now suppose that Bob adds $200 to the pool at this time, bringing the total to $1,200. The utilization ratio is now 500/1200, or roughly 41.7%, and the annualized interest rate decreases from 2% to to 1.71428571428571428571428571429%. This corresponds to a per-second rate of 1.000000000538620692738000247%. The rate accumulator is now updated:

$\begin{equation}
\begin{split}
A(2629801)&=(1.000000000627937192491)^{2629800} \cdot 1.000000000538620692738000247\\
&=1.001652713995777719208305868
\end{split}
\end{equation}$

The multiplier at the end of the second month will be:

$\begin{equation}
\begin{split}
A(5184000)&=(1.000000000627937192491)^{2629800} \cdot 1.000000000538620692738000247^{2629800}\\
&=1.003072524482622234898573734
\end{split}
\end{equation}$

Which comes out to 1.003072524482622234898573734. We multiply this by the normalized debt to get Alice's new outstanding debt balance:

$\begin{equation}
\begin{split}
&=1.003072524482622234898573734 * 499.9999996860314039517 \\
&=501.536261926377845203
\end{split}
\end{equation}$

Alice owes $1.54 in interest. If Alice makes a repayment at the end of the second month, the normalized debt is readjusted. For example, if she makes a payment of $100, then the new balance is 401.536261926377845203 and the normalized amount is:

$\frac{401.536261926377845203}{1.003072524482622234898573734}=402.769991921807255489182059768$

This section is outdated and will be updated soon

The interest payable is the amount of earned interest that a supplier is entitled to withdraw at any given time. It is essentially the same calculation as total debt with a couple of differences: (1) we scale the interest rate by the utilization ratio and (2) since lending pool reserves are burned when underlying assets are redeemed, the investor's entitlement is toward interest earned, and not the pool supply plus interest.

As we did with Interest Rates, we normalize the supplied amount by dividing by the rate accumulator:

$\hat{E}_0=\frac{E_0}{A_0}$

Except, in this case, the rates are scaled by the utilization ratio:

$A(t)=A_{0} \prod_{i=1}^{t} U_i r_{i} = A_{0} \cdot U_1 r_{1} \cdot U_2 r_{2} \cdot \cdot \cdot U_{t-1} r_{t-1} \cdot U_{t} r_{t}$

Scaling by the utilization is necessary because the interest is paid on the amount of USD currently being borrowed, not on the total amount supplied. If the utilization ratio is 80% and you supply $1,000, then you receive interest on 80% of your provided liquidity.

The interest payable at time

*t*is equal to:$I(t)=\hat{E_0} \cdot A_t - E_0= E_0 \prod_{i=1}^{t} U_i \cdot r_{i} - E_0$

When earned interest amount

$\delta$

is redeemed at time *t*, the normalized equity amount readjusts:$\hat{E}_t=\frac{(\hat{E}_0 \cdot A_t) - \delta}{A_t}$

Note that

$\delta$

is bounded by $(0, I(t)]$

.Assume that there is a total supply of $10,000 with $6,000 outstanding (U=60%). Alice adds $2,000 to the reserves so that U=50% and r=2%. If the rate accumulator is set to 1.00081816993115769498 then Alice's normalized equity amount is:

$\hat{E}_0=\frac{2000}{1.00081816993115769498}=1998.364997847283340912$

At the moment there is no interest entitlement, but assuming that the rate is constant without any changes in supply and Alice waits one month, the rate accumulator will be:

$\begin{equation}
\begin{split}
A(2592000)&=1.00081816993115769498 \cdot (1 + 0.02 \cdot \frac{6000}{12000})^\frac{2592000}{31536000}\\
&=1.001637009264351640547
\end{split}
\end{equation}$

And interest entitlement will be roughly equal to:

$\begin{equation}
\begin{split}
I(2592000)&=1998.364997847283340912 \cdot 1.001637009264351640547-2000\\
&=1.6363398623153899593
\end{split}
\end{equation}$

Now suppose that Alice withdraws the interest at this time with

$I=1.6363398623153899593$

from the TCN contract. The normalized amount from the Treasury contract is readjusted:$\hat{E}_1=\frac{(1998.364997847283340912 \cdot 1.001637009264351640547)-1.6363398623153899593}{1.001637009264351640547}$

Which leads to a balance of

$\hat{E_1} \cdot A_{t+1} = 2000$

. This new amount sets the basis for future accumulated interest.Last modified 4mo ago