Interest Model

Interest Rate Calculations

Definitions:

  • u is the capital utilization rate of a certain token

  • Compound Supply Rate: the real-time supply rate on the money market

  • Compound Borrow Rate: the real-time borrow rate on the money market

  • Compound Supply Rate Weight: the weight parameter of the Compound Supply Rate

  • Compound Borrow Rate Weight: the weight parameter of the Compound Borrow Rate

  • Compound Supply Ratio: the percentage of capital deployed on money market

Borrow Rate Model

BorrowAPR=CompoundSupplyRateWeights×CompoundSupplyRate+CompoundBorrowRateWeights×CompoundBorrowRate()+RateCurveConstant÷(1u)Borrow APR= Compound Supply Rate Weights \times Compound Supply Rate + Compound Borrow Rate Weights \times Compound Borrow Rate () + RateCurve Constant\div(1-u)

When uu >0.98,

RateCurveConstant÷(1u)=RateCurveConstant÷(10.98)=RateCurveConstant×50Rate Curve Constant\div(1-u) = Rate Curve Constant \div(1-0.98)= RateCurveConstant\times50

For assets that are not available on Compound or other money markets, Compound Supply Rate Weights=0, Compound Borrow Rate Weights=0,

In summary, there are two factors that decided the Borrow APR, the prevailing market rate that is available in the market and the capital utilization rate in the DeFiner protocol. Also, it's a non-linear model. The borrowing interest can adapt quickly if the utilization of the pool approaches a relatively high level.

Pseudocode:

function getBorrowRatePerBlock(address _token) public view returns(uint) {    
    if(isSupportedOnCompound) {
        if (u>0.999) {
            BorrowAPR= compoundSupplyRateWeights*(compoundSupplyRate) + compoundBorrowRateWeights*(compoundBorrowRate) + RateCurveConstant*(1000);
        } else {
            BorrowAPR= compoundSupplyRateWeights*(compoundSupplyRate) + compoundBorrowRateWeights*(compoundBorrowRate) + RateCurveConstant/(1-u);
        } 
    } else {
        if (u>0.999) {
            BorrowAPR = RateCurveConstant*(1000);
        } else {
            BorrowAPR = RateCurveConstant/(1-u);
        }
    }
}

Code:

Deposit Rate Model

DepositRate=CompoundSupplyRatio×CompoundSupplyRate+BorrowRate×uDeposit Rate= CompoundSupplyRatio\times CompoundSupplyRate +BorrowRate\times u

For assets that are not available on Compound or other money markets, Compound Supply Rate Weights=0, Compound Borrow Rate Weights=0

PseudoCode

Code:

Interest Accounting System

Definitions:

  • Deposit principle: the crypto assets that users deposited

  • Deposit interest: interest that the depositor earned

  • Deposit storage interest: the interest that depositor accrued

  • Deposit accrual interest: the deposit interest that has not accrued

  • Deposit Interest per block: interest that user earned for every block

  • BlocksPerYear: annual expected blocks of the blockchain

Formula:

DepositInterestRatePerBlock=BorrowAPR÷BlocksPerYearDeposit Interest Rate Per Block = BorrowAPR\div BlocksPerYear

DepositInterestPerBlock=(DepositPrinciple+DepositStorageInterest)×DepositInterestRatePerBlockDeposit Interest Per Block = (Deposit Principle+Deposit Storage Interest) \times Deposit Interest Rate Per Block

DepositInterest(blockt)=DepositInterest(blockt1))+DepositInterestPerBlockDepositInterest(block_t)=DepositInterest(block_t -_1))+DepositInterestPerBlock

BorrowAPR will be updated in the contract if there were any users who have deposits of the token performs a transaction

The interest earned between the last transaction block of the user and the latest transaction block will be accrued if the user performed a transaction and will be added to the Deposit Storage Interest.

Last updated