Morpho Vault V2 enables anyone to create non-custodial vaults that allocate assets into different markets. Depositors earn from underlying markets without actively managing their positions, while curation is handled by defined roles.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/morpho-org/vault-v2/llms.txt
Use this file to discover all available pages before exploring further.
ERC-4626 compliance
Vault V2 is fully compliant with ERC-4626 and ERC-2612 (permit extension).Virtual shares and decimal offset
The vault uses virtual shares to protect against inflation attacks:- Decimal offset =
max(0, 18 - assetDecimals) - Virtual shares =
10^decimalOffset - Vault decimals =
assetDecimals + decimalOffset
To protect against inflation attacks, the vault might need to be seeded with an initial deposit. See the OpenZeppelin ERC-4626 guide for more details.
Share calculation examples
Preview deposit (assets to shares):Share price dynamics
The vault’s share price is influenced by several factors:Interest accrual
Interest and losses are accounted only once per transaction at the first interaction with the vault. The vault loops through all adapters to calculate real assets:Max rate cap
The vault’s share price will not increase faster than the allocator-setmaxRate. This helps:
- Stabilize the distributed rate
- Build a buffer to absorb losses
- Prevent opportunistic depositors from diluting interest through donations
Donations and
forceDeallocate penalties increase the rate, which can attract opportunistic depositors. This can be mitigated by reducing the maxRate.Loss realization
Loss realization occurs inaccrueInterest and decreases total assets, causing shares to lose value:
Total assets tracking
The vault maintains multiple views of total assets:_totalAssets: Last recorded total assets (storage)totalAssets(): Updated total assets including accrued interestfirstTotalAssets: Total assets after first interest accrual in current transaction
firstTotalAssets variable:
- Tracks total assets after first interest accrual of the transaction
- Prevents bypassing relative caps with flashloans
- Ensures interest accrues only once per transaction
Deposit and withdrawal flow
Deposit
Users call
deposit(assets, onBehalf) or mint(shares, onBehalf):- Interest is accrued
- Shares are calculated and minted
- Assets are transferred from user to vault
- If liquidity adapter is set, assets are allocated to it
Entry implementation
Exit implementation
Immutability
All vault contracts are immutable. Vaults are deployed via the VaultV2Factory, which creates instances with fixed code that cannot be upgraded.While the vault code is immutable, configuration can be changed through the curator role (subject to timelocks and other restrictions).