Skip to main content

Interest Rate Models

Interest rate models are defined as a list of governance-approved contracts. Each contract implements the IRM interface exposed below.

Function

borrowRate

function borrowRate(MarketParams memory marketParams, Market memory market) external returns (uint256);

Returns the borrow rate of the market marketParams.

Parameters:

NameTypeDescription
marketParamsMarketParamsThe MarketParams struct of the market.
marketMarketThe Market struct of the market.

Return values:

NameTypeDescription
borrowRateuint256The borrow rate of the market.

View Function

borrowRateView:

function borrowRateView(MarketParams memory marketParams, Market memory market) external view returns (uint256);

Returns the borrow rate of the market marketParams without modifying any storage.

Parameters:

NameTypeDescription
marketParamsMarketParamsThe MarketParams struct of the market.
marketMarketThe Market struct of the market.

Return values:

NameTypeDescription
borrowRateuint256The borrow rate of the market.

Make sure the input parameters correspond to the last time the market was updated (check lastUpdate) and apply the returned borrow rate as is applied in Morpho over the period between the market's lastUpdate and the query's block timestamp.

Calculations

The Annual Percentage Yields (APY) for both borrowing and supplying are key indicators of the returns for lenders and the cost for borrowers. The APY takes into account the compounding interest to provide a standardized measure of yields over a one-year period.

Borrow APY

The Borrow APY is calculated using the following formula:

borrowAPY=(e(borrowRate×secondsPerYear)1)\text{borrowAPY} = (e^{(\text{borrowRate} \times \text{secondsPerYear})} - 1)

Where:

  • borrowRate is the borrow rate per second, as determined by the Interest Rate Model (IRM),
  • secondsPerYear represents the total number of seconds in a year (31,536,000).

To obtain the borrowRate value, a simple call can be made to the borrowRateView or borrowRate functions defined in the upper sections.

Supply APY

The Supply APY is calculated considering the utilization and the fee. The formula is:

supplyAPY=borrowAPY×utilization×(1fee)\text{supplyAPY} = \text{borrowAPY} \times \text{utilization} \times (1 - \text{fee})

Where:

  • fee is the fee of the market, to be activated by the DAO, on a per-market basis,
  • utilization is calculated as:
utilization=totalBorrowAssetstotalSupplyAssets\text{utilization} = \frac{\text{totalBorrowAssets}}{\text{totalSupplyAssets}}