MorphoBlueSupplyVault
MorphoBlueSupplyVault
Minimal ERC-4626 wrapper over a single Morpho Blue supply-side position.
_One deployment per market. Deposits are supplied to Morpho; withdrawals pull directly to the receiver. Supply-only — no borrow or collateral positions.
Market parameters are stored as individual immutables rather than a storage struct so that every Morpho call avoids five SLOADs when copying them into memory._
MORPHO
contract IMorpho MORPHO
Morpho Blue singleton
MARKET_ID
Id MARKET_ID
Market id derived from the market parameters at construction
LOAN_TOKEN
address LOAN_TOKEN
Loan token of the Morpho market (= ERC-4626 underlying asset)
COLLATERAL_TOKEN
address COLLATERAL_TOKEN
Collateral token of the Morpho market
ORACLE
address ORACLE
Price oracle of the Morpho market
IRM
address IRM
Interest rate model of the Morpho market
LLTV
uint256 LLTV
Liquidation loan-to-value ratio of the Morpho market (scaled by 1e18)
constructor
constructor(address morpho_, struct MarketParams marketParams_, string name_, string symbol_) public
Constructor
Parameters
| Name | Type | Description |
|---|---|---|
| morpho_ | address | Morpho Blue singleton |
| marketParams_ | struct MarketParams | Market parameters (loanToken, collateralToken, oracle, irm, lltv) |
| name_ | string | ERC-20 name for vault shares |
| symbol_ | string | ERC-20 symbol for vault shares |
totalAssets
function totalAssets() public view returns (uint256)
maxWithdraw
function maxWithdraw(address owner) public view returns (uint256)
Caps the owner's withdrawable assets by Morpho market liquidity so this function never returns a value that would cause withdraw() to revert, as required by ERC-4626.
maxRedeem
function maxRedeem(address owner) public view returns (uint256)
Computed directly in shares to avoid the double floor rounding that would occur if derived from maxWithdraw: convertToShares(convertToAssets(shares)) can return shares - 1.
_deposit
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal
Supplies assets to Morpho and mints shares to receiver.
Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | Address that initiated the deposit |
| receiver | address | Address that receives the vault shares |
| assets | uint256 | Amount of loanToken to supply |
| shares | uint256 | Amount of vault shares to mint |
_withdraw
function _withdraw(address caller, address receiver, address owner, uint256 assets, uint256 shares) internal
Burns shares from owner and withdraws assets from Morpho directly to receiver.
Parameters
| Name | Type | Description |
|---|---|---|
| caller | address | Address that initiated the withdrawal |
| receiver | address | Address that receives the loanToken |
| owner | address | Address whose shares are burned |
| assets | uint256 | Amount of loanToken to withdraw from Morpho |
| shares | uint256 | Amount of vault shares to burn |