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. |
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:
Manual retrieval of the borrow rate:
To manually retrieve the borrowRate
for a market, you can use the borrowRateView
function of the IRM contract. This section guides you through the process of obtaining the necessary parameters and executing the function call.
Jump into the Addresses section to get the contract addresses.
- Querying the Morpho Blue Contract
First, obtain the marketParams
by querying the idToMarketParams
function. For example, for the wstETH/WETH (94.5%) market, use the following ID: 0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41.
Next, acquire the market
values by querying the market
function.
- Querying the AdaptiveCurveIRM Contract
Use the retrieved marketParams
and market
in the following format to query the contract:
Input:
marketParams
(tuple)
["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0","0x2a01EB9496094dA03c4E364Def50f5aD1280AD72","0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC","945000000000000000"]
market
(tuple)
["10004929554680902814569", "9991371195121664602574716119", "8810921364321507255452", "8796441127786542454899358360","1707318023",0]