Morpho Blue
Code
Market Parameters
Market id
The market id is a bytes32
keccak256 hash of the 5 parameters of a market. It is used to identify a market in Morpho Blue.
type Id is bytes32;
To get the id from the parameters, a temporary solution is to execute this gist, or retrieve the id at market creation.
Market struct
The market struct is defined as follows:
struct Market {
uint128 totalSupplyAssets;
uint128 totalSupplyShares;
uint128 totalBorrowAssets;
uint128 totalBorrowShares;
uint128 lastUpdate;
uint128 fee;
}
It contains the state of a market.
totalBorrowAssets
& totalSupplyAssets
accrues the interest of the market only until last interest accrual, while totalBorrowShares
& totalSupplyShares
are representing the total shares distributed over lenders / borrowers.
MarketParams struct
The majority of the entrypoints accept a MarketParams
struct as parameter. This struct is defined as follows:
struct MarketParams {
address loanToken;
address collateralToken;
address oracle;
address irm;
uint256 lltv;
}
As an integrator, you need to recover these 5 parameters to interact with Morpho Blue. You can also use the idToMarketParams view function to recover the parameters of a given market from the bytes32 id.
Functions
setOwner
function setOwner(address newOwner) external;
Sets newOwner
as owner
of the contract.
- Warning: No two-step transfer ownership.
- Warning: The owner can be set to the zero address.
Parameters:
Name | Type | Description |
---|---|---|
newOwner | address | The new owner address. |
enableIrm
function enableIrm(address irm) external;
Enables irm
as a possible IRM for market creation.
- Warning: It is not possible to disable an IRM.
Parameters:
Name | Type | Description |
---|---|---|
irm | address | The irm address to enable. |
enableLltv
function enableLltv(uint256 lltv) external;
Enables lltv
as a possible LLTV for market creation.
- Warning: It is not possible to disable a LLTV.
Parameters:
Name | Type | Description |
---|---|---|
lltv | uint256 | The lltv value to enable (18 decimals). |
setFee
function setFee(MarketParams memory marketParams, uint256 newFee) external;
Sets the newFee
for the given market marketParams
.
- Warning: The recipient can be the zero address.
Parameters:
Name | Type | Description |
---|---|---|
marketParams | MarketParams | The market parameters. |
newFee | uint256 | The new fee value. |