> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yield.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart contract reference

> The Meta Vault contract at function level: user functions, privileged functions by role, limits, events, errors and the guarantees that hold across them.

This page describes the Meta Vault contract for engineers and reviewers. For the product view, see the [Meta Vaults overview](https://docs.yield.xyz/documentation/earn/oavs/meta-vaults/index.md).

## Components

| Component | What it does |
| - | - |
| Vault | ERC-4626 contract that holds custody, the strategy list, fees and access settings. Runs behind an upgradeable beacon proxy |
| Strategies | Up to 10 ERC-4626 vaults that accept the deposit asset. Lending markets that are not ERC-4626 are wrapped in a Yield.xyz ERC-4626 adapter |
| Reinvester | Receives claimed reward tokens, swaps them into the deposit asset and returns them to the vault |
| Allocation service | Offchain. Computes target weights and prepares or executes `allocate` and `deallocate` |

## User functions

| Function | Behavior |
| - | - |
| `deposit`, `mint` | Harvest fees owed, then take the deposit asset and mint shares. A deposit fee mints fee shares in the same call. Assets stay idle until allocated |
| `withdraw`, `redeem` | Harvest fees owed, burn shares and pay from idle, then from strategies in queue order. Exact-out: pays the full amount or reverts |
| `maxDeposit`, `maxMint` | Return 0 when the vault is paused, deposits are disabled, or the whitelist is on and the receiver is not whitelisted |
| `maxWithdraw`, `maxRedeem` | Return 0 when paused. Otherwise a best-effort estimate of what strategies can pay now; a `withdraw` within it can still revert if a strategy cannot pay |
| `preview*` | Include fees owed but not yet minted |
| `totalAssets` | Idle balance plus each strategy position at the strategy's own `convertToAssets` |

`maxWithdraw` is the one deviation from ERC-4626 to note. Some strategies report 0 from their `max*` functions while their `withdraw` works. The vault treats a 0 or a revert as no information and values that position from its own accounting, so the estimate can be higher than what a strategy can pay at that moment.

## Privileged functions

| Function | Role | What it does |
| - | - | - |
| `setMetaAssets` | Admin | Sets the strategy list and withdrawal queue order. Harvests first. Reverts if a dropped strategy holds more than the dust limit |
| `forceRemoveMetaAsset` | Admin | Drops a strategy whose valuation reverts. Reverts on a strategy that can still be valued |
| `configureVault` | Admin | Sets fee rates and the fee recipient. Harvests at the old rates first |
| `setDustLimit` | Admin | Sets the dust limit, up to a ceiling fixed at deployment |
| `setReinvestor` | Admin | Sets where claimed reward tokens are sent |
| `setWhitelistedTargets` | Admin | Allowlists reward claim calls by contract and function selector. Rejects the deposit asset, the vault and any strategy |
| `setWhitelistEnabled` | Admin | Turns the share holder whitelist on or off |
| `allocate` | Keeper | Deposits idle assets into a listed strategy, with a minimum shares out |
| `deallocate` | Keeper | Redeems strategy shares to idle, with a minimum assets out |
| `harvest` | Keeper | Mints fees owed and records a checkpoint |
| `claimAndSweep` | Reinvester | Runs allowlisted claim calls, then sends the named reward tokens to the reinvester. Reverts if total assets fall or share supply changes |
| `setPaused` | Pauser | Pauses or unpauses deposits, mints, withdrawals, redemptions and reward claims |
| `setDepositsDisabled` | Pauser | Stops or reopens new deposits and mints. Withdrawals stay open |
| `setWhitelisted` | Whitelist manager | Approves or removes addresses that may receive shares |

## Limits

| Limit | Value |
| - | - |
| Strategies per vault | 10 |
| Deposit fee | Up to 500 bps (5%) |
| Performance fee | Up to 5,000 bps (50%) |
| Management fee | Up to 2,000 bps (20%) a year |
| Dust limit | Set per vault, never above a ceiling fixed at deployment |
| Share decimals | Deposit asset decimals plus 6 |

## Events

| Event | Emitted when |
| - | - |
| `Deposit`, `Withdraw` | A customer deposits or withdraws (standard ERC-4626) |
| `DepositFeeCollected` | Deposit fee shares are minted |
| `HarvestFeeCollected` | Management and performance fee shares are minted |
| `VaultConfigured` | Fees or the fee recipient change |
| `MetaAssetsSet`, `MetaAssetForceRemoved` | The strategy list changes |
| `PausedSet`, `DepositsDisabledSet` | The vault is paused or unpaused, or deposits are stopped or reopened |
| `RewardsClaimed`, `Swept` | Rewards are claimed and sent to the reinvester |
| `WhitelistEnabledSet`, `WhitelistedSet` | The whitelist is turned on or off, or an address is approved or removed |

## Errors you may see

| Error | Cause |
| - | - |
| `Paused` | The vault is paused |
| `ERC4626ExceededMaxDeposit`, `ERC4626ExceededMaxMint` | Deposits are disabled, or the receiver is not whitelisted |
| `NotWhitelisted` | A share transfer to an address that is not whitelisted |
| `ERC4626ExceededMaxWithdraw`, `ERC4626ExceededMaxRedeem` | The amount is more than the holder's balance or the vault's estimated liquidity |
| `InsufficientLiquidity` | Idle and strategies together could not pay the full amount |

## Guarantees

* **Funds move only between the vault and its listed strategies.** `allocate` and `deallocate` take only listed strategies, and no privileged function sends the deposit asset or strategy shares anywhere else.
* **Reward claims cannot touch principal.** Claim calls are allowlisted per contract and selector, can never target the deposit asset, the vault or a strategy, and revert if total assets fall or share supply changes. The deposit asset and strategy shares can never be swept.
* **Fees dilute, they never withdraw.** Every fee is minted as shares to the fee recipient.
* **A funded strategy cannot be dropped.** Removal reverts above the dust limit, and the dust limit cannot be raised past its fixed ceiling.
* **Holders can always exit a permissioned vault.** The whitelist gates who receives shares, never withdrawals or redemptions.
* **Roles cannot escalate.** Only the admin grants roles.

These hold for the deployed implementation. An upgrade through the beacon proxy can change contract behavior, which is why upgrades are signed by the vault's admin.

## Next steps

> [card] [How it works](https://docs.yield.xyz/documentation/earn/oavs/meta-vaults/architecture.md)
>
> The operational view of the same components.

> [card] [Roles & signing](https://docs.yield.xyz/documentation/earn/oavs/meta-vaults/vault-mechanics/roles-signing-models.md)
>
> Who typically holds each role.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.