IMorpho
Title: IMorpho
Minimal interface for Morpho Blue lending protocol.
See https://docs.morpho.org for full documentation.
Functions
setAuthorization
Set authorization for an address to act on behalf of the caller
function setAuthorization(
address authorized,
bool newIsAuthorized
) external;
isAuthorized
Check if an address is authorized to act on behalf of another
function isAuthorized(
address authorizer,
address authorized
) external view returns (bool);
createMarket
Create a new market
function createMarket(
MarketParams memory marketParams
) external;
idToMarketParams
Get market ID from params
function idToMarketParams(
bytes32 id
) external view returns (MarketParams memory);
supply
Supply loan assets to a Morpho market as a lender
function supply(
MarketParams memory marketParams,
uint256 assets,
uint256 shares,
address onBehalfOf,
bytes calldata data
) external returns (uint256 assetsSupplied, uint256 sharesSupplied);
withdraw
Withdraw loan assets from a Morpho market as a lender
function withdraw(
MarketParams memory marketParams,
uint256 assets,
uint256 shares,
address onBehalfOf,
address receiver
) external returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn);
supplyCollateral
Supply collateral to a Morpho market as a borrower
function supplyCollateral(
MarketParams memory marketParams,
uint256 assets,
address onBehalfOf,
bytes calldata data
) external;
withdrawCollateral
Withdraw collateral from a Morpho market as a borrower
function withdrawCollateral(
MarketParams memory marketParams,
uint256 assets,
address onBehalfOf,
address receiver
) external;
borrow
Borrow assets from a Morpho market
function borrow(
MarketParams memory marketParams,
uint256 assets,
uint256 shares,
address onBehalfOf,
address receiver
) external returns (uint256 assetsBorrowed, uint256 sharesIssued);
repay
Repay borrowed assets to a Morpho market
function repay(
MarketParams memory marketParams,
uint256 assets,
uint256 shares,
address onBehalfOf,
bytes calldata data
) external returns (uint256 assetsRepaid, uint256 sharesRepaid);
accrueInterest
Accrue interest for a market
function accrueInterest(
MarketParams memory marketParams
) external;
liquidate
Liquidate an unhealthy position
function liquidate(
MarketParams memory marketParams,
address borrower,
uint256 seizedAssets,
uint256 repaidShares,
bytes calldata data
) external returns (uint256 assetsSeized, uint256 assetsRepaid);
Parameters
| Name | Type | Description |
|---|---|---|
marketParams | MarketParams | The market parameters |
borrower | address | The address of the borrower to liquidate |
seizedAssets | uint256 | The amount of collateral to seize |
repaidShares | uint256 | The amount of debt shares to repay (alternative to seizedAssets) |
data | bytes | Callback data |
flashLoan
Execute a flash loan
Morpho flash loans are fee-free. Callback must repay exact amount.
function flashLoan(
address token,
uint256 assets,
bytes calldata data
) external;
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The token to flash loan |
assets | uint256 | The amount of tokens to flash loan |
data | bytes | Arbitrary data to pass to the callback |
position
Get position data for a user in a market
function position(
bytes32 id,
address user
) external view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral);
market
Get market data
function market(
bytes32 id
)
external
view
returns (
uint128 totalSupplyAssets,
uint128 totalSupplyShares,
uint128 totalBorrowAssets,
uint128 totalBorrowShares,
uint128 lastUpdate,
uint128 fee
);