This is the Malda developer documentation, for product documentation visit docs.malda.xyz
Switch to Product Docs
LogoLogo
  • Introduction
  • Malda ZK Coprocessor
    • Introduction
  • Architecture
  • Technical Details
  • Development
  • Malda Lending
    • Introduction
    • Operator
    • Interest
    • Interfaces
Powered by GitBook
On this page
  • JumpRateModelV4
  • State Variables
  • Functions
  • Errors
  1. Malda Lending

Interest

PreviousOperatorNextInterfaces

Last updated 7 days ago

Inherits: , Ownable

Implementation of the IInterestRateModel interface for calculating interest rates

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

uint256 public override blocksPerYear;

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

uint256 public override multiplierPerBlock;

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

uint256 public override baseRatePerBlock;

The multiplierPerBlock after hitting a specified utilization point

uint256 public override jumpMultiplierPerBlock;

The utilization point at which the jump multiplier is applied

uint256 public override kink;

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

string public override name;

Construct an interest rate model

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

Parameters

Name
Type
Description

blocksPerYear_

uint256

The estimated number of blocks per year

baseRatePerYear

uint256

The base APR, scaled by 1e18

multiplierPerYear

uint256

The rate increase in interest wrt utilization, scaled by 1e18

jumpMultiplierPerYear

uint256

The multiplier per block after utilization point

kink_

uint256

The utilization point where the jump multiplier applies

owner_

address

The owner of the contract

name_

string

A user-friendly name for the contract

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

Name
Type
Description

baseRatePerYear

uint256

The approximate target base APR, as a mantissa (scaled by 1e18)

multiplierPerYear

uint256

The rate of increase in interest rate wrt utilization (scaled by 1e18)

jumpMultiplierPerYear

uint256

The multiplierPerBlock after hitting a specified utilization point

kink_

uint256

The utilization point at which the jump multiplier is applied

Updates the blocksPerYear in order to make interest calculations simpler

function updateBlocksPerYear(uint256 blocksPerYear_) external onlyOwner;

Parameters

Name
Type
Description

blocksPerYear_

uint256

The new estimated eth blocks per year.

Should return true

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

Calculates the utilization rate of the market

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

Parameters

Name
Type
Description

cash

uint256

The total cash in the market

borrows

uint256

The total borrows in the market

reserves

uint256

The total reserves in the market

Returns

Name
Type
Description

<none>

uint256

The utilization rate as a mantissa between [0, 1e18]

Returns the current borrow rate per block for the market

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

Parameters

Name
Type
Description

cash

uint256

The total cash in the market

borrows

uint256

The total borrows in the market

reserves

uint256

The total reserves in the market

Returns

Name
Type
Description

<none>

uint256

The current borrow rate per block, scaled by 1e18

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

Name
Type
Description

cash

uint256

The total cash in the market

borrows

uint256

The total borrows in the market

reserves

uint256

The total reserves in the market

reserveFactorMantissa

uint256

The current reserve factor for the market

Returns

Name
Type
Description

<none>

uint256

The current supply rate per block, scaled by 1e18

Internal function to update the parameters of the interest rate model

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

Parameters

Name
Type
Description

baseRatePerYear

uint256

The base APR, scaled by 1e18

multiplierPerYear

uint256

The rate increase wrt utilization, scaled by 1e18

jumpMultiplierPerYear

uint256

The multiplier per block after utilization point

kink_

uint256

The utilization point where the jump multiplier applies

error JumpRateModelV4_MultiplierNotValid();

JumpRateModelV4
Git Source
IInterestRateModel
State Variables
blocksPerYear
multiplierPerBlock
baseRatePerBlock
jumpMultiplierPerBlock
kink
name
Functions
constructor
updateJumpRateModel
updateBlocksPerYear
isInterestRateModel
utilizationRate
getBorrowRate
getSupplyRate
_updateJumpRateModel
Errors
JumpRateModelV4_MultiplierNotValid