VaultV2Factory
The VaultV2Factory contract is a factory for deploying new VaultV2 instances using the CREATE2 opcode, enabling deterministic vault addresses.Overview
VaultV2Factory provides a simple interface for creating VaultV2 vaults with predictable addresses based on the owner, asset, and salt parameters. It maintains a registry of all deployed vaults and their deployment parameters.State variables
Mapping that tracks whether an address is a VaultV2 created by this factory
Three-level mapping that stores vault addresses by owner, asset, and salt. Allows lookup of vault addresses given deployment parameters.
View functions
isVaultV2
The address to check
bool
True if the address is a VaultV2 created by this factory
vaultV2
The owner address used in vault creation
The asset address used in vault creation
The salt used in vault creation
address
The address of the deployed vault (address(0) if not deployed)
Public functions
createVaultV2
The initial owner of the vault
The underlying ERC-20 asset address for the vault
A unique salt for CREATE2 deployment (allows multiple vaults with same owner/asset)
address
The address of the newly deployed VaultV2
initCode is the concatenation of the VaultV2 creation code and the ABI-encoded constructor arguments (owner, asset).
Events
CreateVaultV2
The owner of the newly created vault
The underlying asset of the vault
The salt used for CREATE2 deployment
The address of the newly deployed VaultV2
Usage example
Notes
- The same combination of
owner,asset, andsaltwill always produce the same vault address - Attempting to create a vault with parameters that have already been used will revert (CREATE2 requirement)
- The factory does not have any special permissions over created vaults - the specified owner has full control
- Each vault is an independent contract with its own state and configuration