✔️Interest Rate Model
Overview
The Bank contract allows for the use of custom Interest Rate Models (IRMs) to calculate borrow rates for different markets. This feature enables flexible and dynamic interest rate calculations tailored to specific market conditions.
InterestRateModel Interface
Custom IRMs must implement the IInterestRateModel
interface:
Key Functions
isIrm()
: Validates that the contract is a legitimate IRM.borrowRate()
: Calculates and returns the current borrow rate. This function may modify the contract state.borrowRateView()
: Similar toborrowRate()
, but doesn't modify the contract state.
Creating a Custom IRM
To create a custom IRM:
Implement the
IInterestRateModel
interface.Define your interest rate calculation logic in the
borrowRate()
andborrowRateView()
functions.Ensure
isIrm()
returnstrue
.
Example:
Registering and Using a Custom IRM
Deploy your custom IRM contract.
The DAO must register the IRM with the Bank contract using the
registerIrm()
function:Once registered, you can use the IRM when creating a new market:
Include the address of your registered IRM in the
marketConfigs.irm
field.
Important Notes
Only IRMs registered by the DAO can be used in market creation.
Ensure your IRM calculations are accurate and gas-efficient.
Test your IRM thoroughly before deployment to avoid potential issues in live markets.
The Bank contract will call the IRM's
borrowRate()
function during interest accrual, so make sure it handles all possible market states correctly.
By following these guidelines, you can create and integrate custom Interest Rate Models to suit various market strategies and conditions within the Bank ecosystem.
Last updated