Skip to content

TwoKinksInterestRateModel

An interest rate model with two different slope increase or decrease each after a certain utilization threshold called kink is reached.

Approximate blocks per year used to convert annual constructor parameters to per-block rates.

int256 BLOCKS_PER_YEAR

The multiplier of utilization rate per block that gives the slope 1 of the interest rate scaled by EXP_SCALE

int256 MULTIPLIER_PER_BLOCK

The base interest rate per block which is the y-intercept when utilization rate is 0 scaled by EXP_SCALE

int256 BASE_RATE_PER_BLOCK

The utilization point at which the multiplier2 is applied

int256 KINK_1

The multiplier of utilization rate per block that gives the slope 2 of the interest rate scaled by EXP_SCALE

int256 MULTIPLIER_2_PER_BLOCK

The base interest rate per block which is the y-intercept when utilization rate hits KINK_1 scaled by EXP_SCALE

int256 BASE_RATE_2_PER_BLOCK

The maximum kink interest rate scaled by EXP_SCALE

int256 RATE_1

The utilization point at which the jump multiplier is applied

int256 KINK_2

The multiplier of utilization rate per block that gives the slope 3 of interest rate scaled by EXP_SCALE

int256 JUMP_MULTIPLIER_PER_BLOCK

The maximum kink interest rate scaled by EXP_SCALE

int256 RATE_2

Construct an interest rate model

constructor(int256 baseRatePerYear_, int256 multiplierPerYear_, int256 kink1_, int256 multiplier2PerYear_, int256 baseRate2PerYear_, int256 kink2_, int256 jumpMultiplierPerYear_, int256 blocksPerYear_) public
NameTypeDescription
baseRatePerYear_int256The approximate target base APR, as a mantissa (scaled by EXP_SCALE)
multiplierPerYear_int256The rate of increase or decrease in interest rate wrt utilization (scaled by EXP_SCALE)
kink1_int256The utilization point at which the multiplier2 is applied
multiplier2PerYear_int256The rate of increase or decrease in interest rate wrt utilization after hitting KINK_1 (scaled by EXP_SCALE)
baseRate2PerYear_int256The additional base APR after hitting KINK_1, as a mantissa (scaled by EXP_SCALE)
kink2_int256The utilization point at which the jump multiplier is applied
jumpMultiplierPerYear_int256The multiplier after hitting KINK_2
blocksPerYear_int256The approximate number of blocks per year assumed by this model

Calculates the current borrow rate per slot (block)

function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) external view returns (uint256)
NameTypeDescription
cashuint256The amount of cash in the market
borrowsuint256The amount of borrows in the market
reservesuint256The amount of reserves in the market
NameTypeDescription
[0]uint256The borrow rate percentage per slot (block) as a mantissa (scaled by EXP_SCALE)

Calculates the current supply rate per slot (block)

function getSupplyRate(uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveFactorMantissa) public view virtual returns (uint256)
NameTypeDescription
cashuint256The amount of cash in the market
borrowsuint256The amount of borrows in the market
reservesuint256The amount of reserves in the market
reserveFactorMantissauint256The current reserve factor for the market
NameTypeDescription
[0]uint256The supply rate percentage per slot (block) as a mantissa (scaled by EXP_SCALE)

Calculates the utilization rate of the market: borrows / (cash + borrows - reserves)

function utilizationRate(uint256 cash, uint256 borrows, uint256 reserves) public pure returns (uint256)
NameTypeDescription
cashuint256The amount of cash in the market
borrowsuint256The amount of borrows in the market
reservesuint256The amount of reserves in the market
NameTypeDescription
[0]uint256The utilization rate as a mantissa between [0, EXP_SCALE]