Calculating Accrued Interest

Interest rates for each market update on any block in which the ratio of borrowed assets to supplied assets in the market has changed. The amount interest rates are changed depends on the interest rate model smart contract implemented for the market, and the amount of change in the ratio of borrowed assets to supplied assets in the market.

Utilization rate

All interest rates in Onyx are determined as a function of a metric known as the utilization rate. The utilization rate UaU_a for a money market aa is defined as:

Ua=Borrowsa/(Casha+Borrowsaβˆ’Reservesa)U_a = Borrows_a / (Cash_a + Borrows_a - Reserves_a)

  • BorrowsaBorrows_a refers to the amount of aa borrowed.

  • CashaCash_a refers to the amount of aa left in the system.

  • ReservesaReserves_a refers to the amount of aa that Drops keeps as profit.

Intuitively speaking, this is the percentage of money borrowed out of the total money supplied.

Borrow & Supply rates

The borrowing rate's calculation depends on something called an interest rate model - the algorithmic model to determine a money market's borrow and supply rates.

Borrow and supply rates are calculated using the utilization rate and several arbitrary constants.

Markets follow what is known as the "Jump Rate" model, which contains the following parameters:

  • Base rate per year - the minimum borrowing rate

  • Multiplier per year - the rate of increase in interest rate with respect to utilization

  • Kink - the point in the model in which the model follows the jump multiplier

  • Jump Multiplier per year - the rate of increase in the interest rate with respect to utilization after the "kink"

The borrow rate of the jump rate model is defined as follows:

Interest accrues to all suppliers and borrowers in a market when any Ethereum address interacts with the market’s oToken contract, calling one of these functions: mint, redeem, borrow, or repay. Successful execution of one of these functions triggers the accrueInterest method, which causes interest to be added to the underlying balance of every supplier and borrower in the market. Interest accrues for the current block, as well as each prior block in which the accrueInterest method was not triggered (no user interacted with the oToken contract). Interest compounds only during blocks in which the oToken contract has one of the aforementioned methods invoked.

Here is an example of supply interest accrual:

Alice supplies 1 ETH to the Onyx protocol. At the time of supply, the supplyRatePerBlock is 37893605 Wei, or 0.000000000037893605 ETH per block. No one interacts with the oEther contract for 3 Ethereum blocks. On the subsequent 4th block, Bob borrows some ETH. Alice’s underlying balance is now 1.000000000151574420 ETH (which is 37893605 Wei times 4 blocks, plus the original 1 ETH). Alice’s underlying ETH balance in subsequent blocks will have interest accrued based on the new value of 1.000000000151574420 ETH instead of the initial 1 ETH. Note that the supplyRatePerBlock value may change at any time.

Last updated