JumpRateModelV3

Overview

License: MIT

contract JumpRateModelV3 is Initializable, InterestRateModel, AccessControlUpgradeable

V3 interest rate Model.

Structs info

BlendingTokenInfo

struct BlendingTokenInfo {
	uint256 gainPerBlock;
	uint256 jumGainPerBlock;
	uint256 targetUtil;
}

RateInfo

struct RateInfo {
	uint256 lastInterestRate;
	uint256 lastAccrualBlockNumber;
	uint256 maxBorrowRate;
}

Events info

NewInterestParams

event NewInterestParams(uint256 gainPerBlock, uint256 jumGainPerBlock, uint256 targetUtil)

Emitted when the owner of the interest rate model is updated.

Parameters:

NewOwner

event NewOwner(address newOwner)

Emitted when the owner of the contract is updated.

Parameters:

NewInterest

event NewInterest(uint256 appliedBlock, uint256 interestRate)

Emitted when a new interest rate is set.

Parameters:

Constants info

MODERATOR_ROLE (0x797669c9)

bytes32 constant MODERATOR_ROLE = keccak256("MODERATOR_ROLE")

State variables info

blocksPerYear (0xa385fb96)

uint256 blocksPerYear

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

blendingTokenInfo (0x582d785a)

mapping(address => struct JumpRateModelV3.BlendingTokenInfo) blendingTokenInfo

rateInfo (0x3a86fb41)

mapping(address => struct JumpRateModelV3.RateInfo) rateInfo

isBlendingTokenSupport (0xb7979487)

mapping(address => bool) isBlendingTokenSupport

Modifiers info

onlyBlendingToken

modifier onlyBlendingToken()

Modifier to restrict access to only the blending token contract.

onlyAdmin

modifier onlyAdmin()

Modifier to check if the caller is the default admin role.

onlyModerator

modifier onlyModerator()

Modifier to check if the caller has the moderator role.

Functions info

initialize (0xfe4b84df)

function initialize(uint256 blocksPerYear_) public initializer

Constructs an interest rate model.

Parameters:

grantModerator (0x6981c7ae)

function grantModerator(address newModerator) public onlyAdmin

Grants the MODERATOR_ROLE to a new address. The caller must have the ADMIN_ROLE.

Parameters:

revokeModerator (0x36445636)

function revokeModerator(address moderator) public onlyAdmin

Revokes the moderator role from the specified address. The caller must have the admin role.

Parameters:

updateJumpRateModel (0x10b86276)

function updateJumpRateModel(
    uint256 gainPerYear,
    uint256 jumGainPerYear,
    uint256 targetUtil_,
    address blendingToken
) external onlyModerator

Updates the parameters of the interest rate model (only callable by owner, i.e. Timelock). Only the contract moderator can call this function.

Parameters:

setBlockPerYear (0x03700d6b)

function setBlockPerYear(uint256 blocksPerYear_) external onlyModerator

Sets the number of blocks per year for the JumpRateModelV3 contract. Only the contract moderator can call this function.

Parameters:

addBLendingTokenSupport (0xf9828944)

function addBLendingTokenSupport(
    address blendingToken,
    uint256 gainPerYear,
    uint256 jumGainPerYear,
    uint256 targetUtil_,
    uint256 newMaxBorrow
) external onlyModerator

Adds support for a new blending token to the JumpRateModelV3 contract.

Requirements:

  • blendingToken cannot be the zero address.

  • Only the contract moderator can call this function.

Parameters:

removeBLendingTokenSupport (0xff60fb68)

function removeBLendingTokenSupport(address _blending) external onlyModerator

Removes blending token support for the specified blending token address.

Requirements:

  • _blending cannot be the zero address.

  • _blending must be a supported blending token.

Parameters:

setMaxBorrowRate (0xa8801029)

function setMaxBorrowRate(
    address blendingToken,
    uint256 newMaxBorrow
) external onlyModerator

Sets the maximum borrow rate for a blending token.

Requirements:

  • The caller must have the onlyModerator modifier.

  • The blending token must be supported by the contract.

Parameters:

updateBlockNumber (0x938c9cf6)

function updateBlockNumber(address blendingToken) public onlyModerator

Updates the block number for a given blending token.

Requirements:

  • The caller must have the onlyModerator modifier.

  • The blending token must be supported.

Parameters:

utilizationRate (0x6e71e2d8)

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

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

Parameters:

Return values:

getInterestRateChange (0x86959d81)

function getInterestRateChange(
    uint256 cash,
    uint256 borrows,
    uint256 reserves,
    address blendingToken
) public view returns (int256)

Calculates the change in the interest rate per block per block.

Parameters:

Return values:

getBlockNumber (0x42cbb15c)

function getBlockNumber() public view returns (uint256)

Function to simply retrieve block number. This exists mainly for inheriting test contracts to stub this result.

storeBorrowRate (0x5eeaafea)

function storeBorrowRate(
    uint256 cash,
    uint256 borrows,
    uint256 reserves
) public override onlyBlendingToken returns (uint256)

Calculates and stores the current borrow interest rate per block for the specified blending token.

Parameters:

Return values:

getSupplyRate (0x32dc9b1c)

function getSupplyRate(
    uint256 cash,
    uint256 borrows,
    uint256 reserves,
    uint256 reserveFactorMantissa,
    address blendingToken
) public view override returns (uint256)

Calculates the current supply rate per block.

Parameters:

Return values:

getBorrowRate (0x89469df9)

function getBorrowRate(
    uint256 cash,
    uint256 borrows,
    uint256 reserves,
    address blendingToken
) external view override returns (uint256)

Calculates the current borrow rate per block.

Parameters:

Return values:

Last updated