πŸ›οΈVault Integration

This guide walks through integrating with Moonwell's Morpho Vaults. These vaults accept single-asset deposits and allocate funds across multiple Morpho Blue markets, optimizing yield automatically. They implement the standard ERC-4626 interface.

Deployed Vaults

Base

OP Mainnet

Step 1: Deposit

Deposit underlying tokens into the vault and receive vault shares.

IERC4626 vault = IERC4626(0xc1256Ae5FF1cf2719D4937adb3bbCCab2E00A2Ca); // mwUSDC on Base
IERC20 underlying = IERC20(vault.asset());
uint depositAmount = 1000e6; // 1,000 USDC

// Approve the vault to pull underlying
underlying.approve(address(vault), depositAmount);

// Deposit and receive shares
uint shares = vault.deposit(depositAmount, address(this));

You can also specify exactly how many shares you want with mint():

Step 2: Query Balances

circle-info

maxWithdraw reflects available liquidity. If all deposited funds are currently lent out in Morpho markets, withdrawals may be limited until borrowers repay or new deposits come in.

Step 3: Withdraw

Withdraw underlying tokens by specifying either an asset amount or a share amount.

The receiver parameter lets you send withdrawn assets directly to another address. The owner parameter specifies whose shares to burn - if it's not msg.sender, the caller needs an ERC-20 allowance on the vault shares.

Building on Top

Your contract can accept user deposits, route them into a Moonwell vault, and issue its own token on top. Since Morpho vaults are ERC-4626, this works with any standard vault integration.

Product tokens map 1:1 to vault shares. As the vault accrues yield, each share becomes redeemable for more underlying over time.

Last updated