When to use it
- Isolated markets: each pairs one loan asset with one collateral, its own oracle, interest
rate model and liquidation LTV (
lltv), named by those fiveMarketParams. One market’s bad debt does not reach another. - Choose it to lend or borrow in a specific pair with a specific oracle, or to build on a market someone created; for shared liquidity across many assets, Aave V3.
Pitfalls for a program
- A market exists only for exactly the
MarketParamsit was created with: pass all five. - Give exactly one of
assetsandshares, the other0. - Vet the market’s oracle: it alone decides liquidations there.
supplyCollateralearns nothing; onlysupplyof the loan asset earns interest.- Approve Morpho for the amount;
datais empty bytes unless you want its callback, which a Sauce program cannot receive.
In a Sauce program
Supply the loan asset to a market given asmain’s input, for onBehalf: the user’s wallet, or
the Pot (pot) to keep the position there. Morpho keeps the position in its own books, not
as a token, so it shows in no token balance:
Notes
- A market is identified by its id, the keccak256 of its abi-encoded
MarketParams, and is called with all five params. To supply by id, read them with Morpho’sidToMarketParams(id)(a read the registry’s ABI lacks, whichmorpho-borrowin this skill’s examples declares in the ABI file beside it), then callsupply(params, assets, 0, onBehalf, "")withonBehalfthe user’s wallet. A program takes the id as amainargument: the registry lists no markets, so the id comes from the user or from Morpho’s own app - Pass amount in
assetsparam and setsharesto 0 for standard operations - Each market is fully isolated — no cross-market risk contagion
lltvis the Liquidation Loan-to-Value ratio (e.g. 86% = 860000000000000000)- Supply collateral is separate from supplying loan tokens — collateral does not earn interest
- Bundler3 contract allows batching multiple Morpho operations in a single transaction
- Same Morpho address on both Ethereum and Base
Its names in a program
On Ethereum,MorphoBlue is a namespace: its contracts need no import.
Deployments
ABI
MorphoABI
import MorphoABI from "./protocols/morpho-blue/MorphoABI.json"; Speaks for: morpho.
supply((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsSupplied, uint256 sharesSupplied)withdraw((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn)borrow((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsBorrowed, uint256 sharesBorrowed)repay((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsRepaid, uint256 sharesRepaid)supplyCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, bytes data)withdrawCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, address receiver)
Next steps
- Protocols: the other protocols, by what they do.
- Protocols and tokens: calling a contract by its namespace, or through its ABI.
- Glossary: the words these pages use, in plain terms.
