# Interest Rate Models

The role of the interest rate model is to calculate the total interest for a loan and to distribute the interest to the liquidity ticks used. Ticks and their use in loans are described in more detail in the Liquidity Ticks section.

The primary interest rate model is the `WeightedInterestRateModel`

. It determines the total interest of a loan by summing the weighted interest due to each tick at their assigned rate. For example, if a 25 ETH, 30 day loan borrowed funds from the three ticks: `5 ETH at 10%`

, `10 ETH at 10%`

, and `10 ETH at 30%`

, the total interest would be:

$\begin{aligned}\text{Total Interest} &= \quad \text{5 ETH} \times 10\% \times 30/365 \\ &\quad + \text{10 ETH} \times 10\% \times {30/365} \\ &\quad + \text{10 ETH} \times 30\% \times 30/365 = \text{0.369863 ETH}\end{aligned}$

The interest rate model is also responsible for distributing the interest to the ticks, which does not necessarily correspond to the individual interest amount contributed by each tick. For example, the `WeightedInterestRateModel`

will redistribute more of the total interest towards the higher ticks, in compensation for their greater default risk.

The `WeightedInterestRateModel`

assigns a weighted interest to each tick based on its capital contributed and the cumulative repayment. In other words, ticks that contribute more capital, closer to the total repayment, receive a greater weight. The weighting is determined by:

$\text{Tick Contribution}[i] = \text{Amount Used}[i] \times (1 + \text{Tick Rate}[i] \times \text{Loan Duration})$

$\text{Tick Weight}[i] = ( \sum_{j=0}^{i} \text{Tick Contribution}[j] ) \times \text{Tick Contribution}[i]$

Finally, the interest is assigned to each tick using its weight and the normalization of all weights:

$\text{Tick Interest}[i] = \frac{\text{Total Interest} \times \text{Tick Weight}[i]}{\sum_{j=0}^{N} \text{Tick Weight}[j]}$

For most balanced liquidity tick usage, this will result in higher ticks receiving greater effective APRs and lower ticks receiving lower effective APRs compared to the loan's overall APR. Ticks that contribute little or dust liquidity, anywhere in the capital stack, will receive little interest, due to their weight being diminished by their absolute contribution.

Interest rate models are implemented with the internal `InterestRateModel`

abstract contract API.

Below are examples showing the distribution of interest and effective APRs by the `WeightedInterestRateModel`

under various tick usage profiles:

#### Profile: Balanced, 10 Ticks

#### Profile: Balanced, 32 Ticks

#### Profile: Large + Dust, 32 Ticks

#### Profile: Large + Dust, 6 Ticks

#### Profile: Large + Dust + Small, 32 Ticks

#### Profile: Random, 32 Ticks

Last updated