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:
Name | Type | Description |
---|---|---|
marketParams | MarketParams | The MarketParams struct of the market. |
market | Market | The Market struct of the market. |
Return values:
Name | Type | Description |
---|---|---|
borrowRate | uint256 | The 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:
Name | Type | Description |
---|---|---|
marketParams | MarketParams | The MarketParams struct of the market. |
market | Market | The Market struct of the market. |
Return values:
Name | Type | Description |
---|---|---|
borrowRate | uint256 | The 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:
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:
Where:
fee
is the fee of the market, to be activated by the DAO, on a per-market basis,utilization
is calculated as: