JumpRateModelV4

Git Source

Inherits: IInterestRateModel, Ownable

Implementation of the IInterestRateModel interface for calculating interest rates

State Variables

blocksPerYear

The approximate number of blocks per year that is assumed by the interest rate model

uint256 public override blocksPerYear;

multiplierPerBlock

The multiplier of utilization rate that gives the slope of the interest rate

uint256 public override multiplierPerBlock;

baseRatePerBlock

The base interest rate which is the y-intercept when utilization rate is 0

uint256 public override baseRatePerBlock;

jumpMultiplierPerBlock

The multiplierPerBlock after hitting a specified utilization point

uint256 public override jumpMultiplierPerBlock;

kink

The utilization point at which the jump multiplier is applied

uint256 public override kink;

name

A name for user-friendliness, e.g. WBTC

string public override name;

Functions

constructor

Construct an interest rate model

constructor(
    uint256 blocksPerYear_,
    uint256 baseRatePerYear,
    uint256 multiplierPerYear,
    uint256 jumpMultiplierPerYear,
    uint256 kink_,
    address owner_,
    string memory name_
) Ownable(owner_);

Parameters

NameTypeDescription
blocksPerYear_uint256The estimated number of blocks per year
baseRatePerYearuint256The base APR, scaled by 1e18
multiplierPerYearuint256The rate increase in interest wrt utilization, scaled by 1e18
jumpMultiplierPerYearuint256The multiplier per block after utilization point
kink_uint256The utilization point where the jump multiplier applies
owner_addressThe owner of the contract
name_stringA user-friendly name for the contract

updateJumpRateModel

Update the parameters of the interest rate model (only callable by owner, i.e. Timelock)

function updateJumpRateModel(
    uint256 baseRatePerYear,
    uint256 multiplierPerYear,
    uint256 jumpMultiplierPerYear,
    uint256 kink_
) external onlyOwner;

Parameters

NameTypeDescription
baseRatePerYearuint256The approximate target base APR, as a mantissa (scaled by 1e18)
multiplierPerYearuint256The rate of increase in interest rate wrt utilization (scaled by 1e18)
jumpMultiplierPerYearuint256The multiplierPerBlock after hitting a specified utilization point
kink_uint256The utilization point at which the jump multiplier is applied

updateBlocksPerYear

Updates the blocksPerYear in order to make interest calculations simpler

function updateBlocksPerYear(uint256 blocksPerYear_) external onlyOwner;

Parameters

NameTypeDescription
blocksPerYear_uint256The new estimated eth blocks per year.

isInterestRateModel

Should return true

function isInterestRateModel() external pure override returns (bool);

utilizationRate

Calculates the utilization rate of the market

function utilizationRate(uint256 cash, uint256 borrows, uint256 reserves) public pure override returns (uint256);

Parameters

NameTypeDescription
cashuint256The total cash in the market
borrowsuint256The total borrows in the market
reservesuint256The total reserves in the market

Returns

NameTypeDescription
<none>uint256The utilization rate as a mantissa between [0, 1e18]

getBorrowRate

Returns the current borrow rate per block for the market

function getBorrowRate(uint256 cash, uint256 borrows, uint256 reserves) public view override returns (uint256);

Parameters

NameTypeDescription
cashuint256The total cash in the market
borrowsuint256The total borrows in the market
reservesuint256The total reserves in the market

Returns

NameTypeDescription
<none>uint256The current borrow rate per block, scaled by 1e18

getSupplyRate

Returns the current supply rate per block for the market

function getSupplyRate(uint256 cash, uint256 borrows, uint256 reserves, uint256 reserveFactorMantissa)
    external
    view
    override
    returns (uint256);

Parameters

NameTypeDescription
cashuint256The total cash in the market
borrowsuint256The total borrows in the market
reservesuint256The total reserves in the market
reserveFactorMantissauint256The current reserve factor for the market

Returns

NameTypeDescription
<none>uint256The current supply rate per block, scaled by 1e18

_updateJumpRateModel

Internal function to update the parameters of the interest rate model

function _updateJumpRateModel(
    uint256 baseRatePerYear,
    uint256 multiplierPerYear,
    uint256 jumpMultiplierPerYear,
    uint256 kink_
) private;

Parameters

NameTypeDescription
baseRatePerYearuint256The base APR, scaled by 1e18
multiplierPerYearuint256The rate increase wrt utilization, scaled by 1e18
jumpMultiplierPerYearuint256The multiplier per block after utilization point
kink_uint256The utilization point where the jump multiplier applies

Errors

JumpRateModelV4_MultiplierNotValid

error JumpRateModelV4_MultiplierNotValid();