Skip to main content

IVaultV2Factory

Interface for the VaultV2Factory contract, which handles deterministic deployment of VaultV2 instances using CREATE2.

Events

CreateVaultV2

event CreateVaultV2(
    address indexed owner,
    address indexed asset,
    bytes32 salt,
    address indexed newVaultV2
)
Emitted when a new VaultV2 is deployed.
owner
address
The initial owner of the vault
asset
address
The ERC20 asset token address
salt
bytes32
The salt used for CREATE2 deployment
newVaultV2
address
The address of the newly deployed vault

Functions

isVaultV2

function isVaultV2(address account) external view returns (bool)
Checks if an address is a VaultV2 deployed by this factory.
account
address
required
The address to check
return
bool
true if the address is a VaultV2 from this factory, false otherwise

vaultV2

function vaultV2(address owner, address asset, bytes32 salt) external view returns (address)
Computes the deterministic address of a VaultV2 for given parameters without deploying it.
owner
address
required
The owner parameter for the vault
asset
address
required
The asset token address
salt
bytes32
required
The salt for CREATE2 deployment
return
address
The predicted address where the vault would be deployed

createVaultV2

function createVaultV2(address owner, address asset, bytes32 salt) external returns (address newVaultV2)
Deploys a new VaultV2 instance using CREATE2.
owner
address
required
The initial owner of the vault
asset
address
required
The ERC20 asset token address for the vault
salt
bytes32
required
The salt for deterministic addressing. Using the same parameters and salt will revert.
newVaultV2
address
The address of the newly deployed VaultV2
Calling this function with the same owner, asset, and salt combination twice will revert because CREATE2 cannot deploy to the same address twice.

Usage example

IVaultV2Factory factory = IVaultV2Factory(factoryAddress);

// Predict vault address before deployment
bytes32 salt = keccak256("my-vault-v1");
address predictedAddress = factory.vaultV2(owner, assetToken, salt);

// Deploy the vault
address vault = factory.createVaultV2(owner, assetToken, salt);
assert(vault == predictedAddress);

// Verify deployment
bool isValid = factory.isVaultV2(vault);
assert(isValid == true);

Implementation

See VaultV2Factory for the implementation details.