MorphoAdapter
Inherits: ERC4626, Ownable2Step
Title: MorphoAdapter
ERC4626-compliant wrapper for Morpho Blue lending.
Interchangeable with other yield adapters. Only accepts deposits from SyntheticSplitter.
State Variables
MORPHO
Morpho Blue protocol contract.
IMorpho public immutable MORPHO
marketParams
Morpho market parameters for this adapter.
MarketParams public marketParams
MARKET_ID
Computed market ID (keccak256 of marketParams).
bytes32 public immutable MARKET_ID
SPLITTER
SyntheticSplitter authorized to deposit/withdraw.
address public immutable SPLITTER
urd
Universal Rewards Distributor for Morpho incentives.
address public urd
Functions
constructor
Deploys adapter with Morpho market configuration.
constructor(
IERC20 _asset,
address _morpho,
MarketParams memory _marketParams,
address _owner,
address _splitter
) ERC4626(_asset) ERC20("Morpho Yield Wrapper", "myUSDC") Ownable(_owner);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | IERC20 | Underlying asset (USDC). |
_morpho | address | Morpho Blue protocol address. |
_marketParams | MarketParams | Market parameters (must have loanToken == _asset). |
_owner | address | Admin address for rewards and rescue. |
_splitter | address | SyntheticSplitter authorized to deposit. |
totalAssets
Returns total USDC value of this adapter’s Morpho position.
function totalAssets() public view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total assets including accrued interest. |
_deposit
Deposits assets to Morpho after ERC4626 share minting.
function _deposit(
address caller,
address receiver,
uint256 assets,
uint256 shares
) internal override;
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | Must be SPLITTER. |
receiver | address | Receiver of vault shares. |
assets | uint256 | Amount of USDC to deposit. |
shares | uint256 | Amount of vault shares minted. |
_withdraw
Withdraws assets from Morpho before ERC4626 share burning.
function _withdraw(
address caller,
address receiver,
address owner,
uint256 assets,
uint256 shares
) internal override;
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | Caller requesting withdrawal. |
receiver | address | Receiver of withdrawn assets. |
owner | address | Owner of vault shares being burned. |
assets | uint256 | Amount of USDC to withdraw. |
shares | uint256 | Amount of vault shares burned. |
_computeMarketId
Computes market ID from parameters (keccak256 hash).
function _computeMarketId(
MarketParams memory params
) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
params | MarketParams | Market parameters struct. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | Market identifier used by Morpho. |
_convertMorphoSharesToAssets
Converts Morpho supply shares to asset amount.
function _convertMorphoSharesToAssets(
uint256 shares
) internal view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
shares | uint256 | Morpho supply shares. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Equivalent asset amount. |
rescueToken
Recovers stuck tokens (excluding the underlying asset).
function rescueToken(
address token,
address to
) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Token to rescue. |
to | address | Recipient address. |
setUrd
Sets the Universal Rewards Distributor address.
function setUrd(
address _urd
) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
_urd | address | URD contract address (cannot be zero). |
claimRewards
Claims rewards and transfers to specified address.
function claimRewards(
address reward,
uint256 claimable,
bytes32[] calldata proof,
address to
) external onlyOwner returns (uint256 claimed);
Parameters
| Name | Type | Description |
|---|---|---|
reward | address | Reward token address. |
claimable | uint256 | Total claimable amount from merkle tree. |
proof | bytes32[] | Merkle proof for claim. |
to | address | Recipient of claimed rewards. |
Returns
| Name | Type | Description |
|---|---|---|
claimed | uint256 | Amount successfully claimed and transferred. |
claimRewardsToSelf
Claims rewards to this contract for compounding.
function claimRewardsToSelf(
address reward,
uint256 claimable,
bytes32[] calldata proof
) external onlyOwner returns (uint256 claimed);
Parameters
| Name | Type | Description |
|---|---|---|
reward | address | Reward token address. |
claimable | uint256 | Total claimable amount from merkle tree. |
proof | bytes32[] | Merkle proof for claim. |
Returns
| Name | Type | Description |
|---|---|---|
claimed | uint256 | Amount successfully claimed. |
Events
UrdUpdated
Emitted when URD address is updated.
event UrdUpdated(address indexed oldUrd, address indexed newUrd);
Errors
MorphoAdapter__OnlySplitter
Thrown when caller is not the SyntheticSplitter.
error MorphoAdapter__OnlySplitter();
MorphoAdapter__InvalidAddress
Thrown when a zero address is provided.
error MorphoAdapter__InvalidAddress();
MorphoAdapter__InvalidMarket
Thrown when market loan token doesn’t match asset.
error MorphoAdapter__InvalidMarket();
MorphoAdapter__CannotRescueUnderlying
Thrown when attempting to rescue the underlying asset.
error MorphoAdapter__CannotRescueUnderlying();