Contracts
9
3 contracts · 6 libraries · 4 outside
Flows
7
Supply · Borrow · Repay · Liquidation · Vault deposit · Curate a vault · Create a market
Source
8/9
Source for 8 of 9 · BUSL-1.1 (Morpho.sol) and GPL-2.0-or-later (libraries), GPL-2.0-or-later
Pinned
v1.0.0
2 repos · commit 55d2d99
Isolated lending markets in one immutable contract, each defined by loan token, collateral token, oracle, rate model and LLTV; MetaMorpho vaults allocate deposits across them.
Morpho Blue is a single contract with no upgrade path and no governance over existing markets. Anyone creates a market from five parameters (loanToken, collateralToken, oracle, irm, lltv) whose hash is the market id; the owner only chooses which rate models and LLTVs may be used, and a fee of up to 25% of interest. Supply and borrow positions are shares; interest accrues on each interaction. The oracle and the rate model are external contracts chosen per market. MetaMorpho is an ERC-4626 vault on top: a curator sets caps per market (increases behind a timelock), an allocator orders the queues and moves liquidity, and deposits are supplied to markets in queue order.
LendingEthereum and EVM L2s
Vaults
Core
Libraries
Chosen per market
MetaMorphocontract
ERC-4626 vault. Pools deposits of one asset and supplies them to Morpho markets in supply-queue order, up to each market's cap. Roles: owner, curator (caps, market removal), allocator (queues, reallocate), guardian (can revoke pending changes). Cap increases and other risk-raising changes wait for a timelock; it takes a performance fee as new shares.
57 entry points104 functions24 storage7 eventsMetaMorpho.sol:43
Inherits IMetaMorphoStaticTyping, IMetaMorphoBase, Multicall, Ownable2Step, Ownable, ERC20Permit, Nonces, EIP712, IERC5267, IERC20Permit, ERC4626, IERC4626, ERC20, IERC20Errors, IERC20Metadata, IERC20, Context
Lend the loan token to one market and receive supply shares.
Lender starts
Approves Morpho, then calls supply(marketParams, assets, shares, onBehalf, data) with exactly one of assets or shares.
Morpho.supply
The market must exist, exactly one of assets / shares is non-zero, onBehalf is not zero.
Morpho.sol:169 on GitHubMorpho._accrueInterest
Brings the market up to now: interest since lastUpdate is added to both total borrow and total supply; the fee part is minted as supply shares to the fee recipient.
Morpho.sol:483 on GitHubIIrm.borrowRate
The market's rate model returns the borrow rate used for that accrual.
SharesMathLib.toSharesDown
Assets to shares, rounded down (for a shares input, assets are rounded up).
SharesMathLib.sol:27 on GitHubMorpho back in supply()
Credits the shares to onBehalf, raises the market totals, emits Supply.
Morpho.sol:169 on GitHubIMorphoLiquidateCallback.onMorphoSupply
Only with data: onMorphoSupply is called on msg.sender before payment.
IERC20.transferFrom
Last, the loan token moves from msg.sender into Morpho.
0/23 checked
Mapped: Morpho Blue core and its libraries, MetaMorpho v1.0 and its factory. Not mapped: oracles (morpho-blue-oracles), AdaptiveCurveIrm (morpho-blue-irm), bundlers, public allocator, MetaMorpho v1.1 and Vaults V2.
forge Version: 1.5.1-stable