Documentation Index
Fetch the complete documentation index at: https://mintlify.com/morpho-org/vault-v2/llms.txt
Use this file to discover all available pages before exploring further.
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.
The initial owner of the vault
The ERC20 asset token address
The salt used for CREATE2 deployment
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.
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.
The owner parameter for the vault
The salt for CREATE2 deployment
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.
The initial owner of the vault
The ERC20 asset token address for the vault
The salt for deterministic addressing. Using the same parameters and salt will revert.
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.