SubvaultModule
Purpose
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 protocol based on the
Verifier
setup for this specific subvaultRespond to
pullAssets
calls from the parent vault only
Storage Layout (SubvaultModuleStorage
)
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_)
View Functions
vault() → address
vault() → address
Returns the address of the parent vault that instantiated this subvault.
Mutable Functions
pullAssets(asset: address, value: uint256)
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()
addressReverts: With
NotVault()
if the caller is not the vaultTransfer Behavior: Uses
TransferLibrary.sendAssets()
to forward tokens or native ETH to theVault.sol
addressEmits:
AssetsPulled(asset, vault, value)
Internal Initialization
__SubvaultModule_init(address vault_)
__SubvaultModule_init(address vault_)
Internal setup method to be called during construction or proxy initialization.
Events
event AssetsPulled(address indexed asset, address indexed to, uint256 value)
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 ETHto
: Always equals thevault()
addressvalue
: Amount of the asset transferred
Error Handling
NotVault()
: Raised when a non-vault caller attempts to callpullAssets()