SubvaultModule
Overview
The SubvaultModule represents an isolated child vault within a modular vault system. It is tightly controlled by its parent vault (typically a VaultModule) and is responsible for securely holding and releasing assets upon authenticated requests.
Responsibilities
- Store and isolate a portion of vault assets.
- Allow trusted actor (curator) to delegate liquidity from the subvault to external protocols based on the
Verifiersetup for this specific subvault. - Respond to
pullAssetscalls from the parent vault only.
Configuration and State
Storage Layout (SubvaultModuleStorage)
struct SubvaultModuleStorage {
address vault;
}
vault: Address of the root vault that controls this subvault. Only this address can request asset withdrawals.
The layout is stored in a deterministic custom slot derived using:
SlotLibrary.getSlot("SubvaultModule", name_, version_)
Internal Initialization
__SubvaultModule_init(address vault_)
An onlyInitializing setup method that stores the parent vault address. It does not register this subvault in the parent; createSubvault or reconnectSubvault performs that step.
Functions
View Functions
vault() -> address
Returns the address of the parent vault that instantiated this subvault.
State-Changing Functions
pullAssets(asset: address, value: uint256)
Allows the parent vault to withdraw a specified amount of an asset.
- Access control: Can only be called by the
vault()address. - Reverts with
NotVault()if the caller is not the vault. - Transfer behavior: Uses
TransferLibrary.sendAssets()to forward tokens or native ETH to theVault.soladdress. - Emits
AssetsPulled(address indexed asset, address indexed to, uint256 value).
Events
event AssetsPulled(address indexed asset, address indexed to, uint256 value)
Triggered when assets are withdrawn by the parent vault.
asset: Address of the ERC20 token or native ETH.to: Always equals thevault()address.value: Amount of the asset transferred.
Errors
NotVault(): Raised when a non-vault caller attempts to callpullAssets().