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
When >0.98,
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
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:
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