Prerequisites
Before creating a vault, ensure you have:- Access to a deployed
VaultV2Factorycontract - The address of the ERC20 asset token for your vault
- Sufficient ETH for gas fees
- A wallet with signing capabilities
The asset token must be ERC20 compliant and should not:
- Have fees on transfer
- Revert on transfer to self
- Rebalance accounts on transfer
- Re-enter the vault during transfers
Deployment steps
Choose deployment parameters
Select the parameters for your vault deployment:The
owner will have full administrative control over the vault. Consider using a multisig or governance contract for production deployments.The salt can be any bytes32 value. Using a descriptive hash helps with address prediction and organization:Verify deployment
Confirm the vault was deployed correctly:The vault is deployed with default settings:
- All timelocks are zero (useful for initial setup)
- No name or symbol set
- No curator, allocators, or sentinels assigned
- No gates (anyone can interact)
- No adapters configured
- No fees set
Set vault metadata
Configure the vault’s name and symbol (optional but recommended):
These functions can only be called by the vault owner.
Configure initial roles
Set up the vault’s role structure. Since timelocks are initially zero, you can set these immediately:See the Configuration guide for detailed role descriptions.
Understanding vault initialization
When a vault is deployed, the constructor performs several critical setup steps:VaultV2.sol constructor
Key initialization details
- Immutable asset: The asset token address cannot be changed after deployment
- Decimal handling: Vault shares use the asset decimals plus an offset for inflation protection
- Virtual shares: Added to prevent inflation attacks (1 virtual share for tokens with 18 decimals)
- Last update timestamp: Set to deployment block timestamp for interest calculations
Decimal offset mechanism
The vault adds a decimal offset to protect against inflation attacks:| Asset decimals | Decimal offset | Vault decimals | Virtual shares |
|---|---|---|---|
| 18 (e.g., DAI) | 0 | 18 | 1 |
| 6 (e.g., USDC) | 12 | 18 | 10^12 |
| 8 (e.g., WBTC) | 10 | 18 | 10^10 |
The decimal offset ensures that for low-decimal tokens, small donations cannot significantly inflate the share price.
Post-deployment checklist
After deploying your vault, verify:- Owner address is correct (preferably a multisig)
- Asset address matches the intended token
- Name and symbol are set (if desired)
- Curator is assigned
- Initial allocators are configured
- Sentinels are set up (if using)
- Timelocks are configured for protection
- Gates are configured (if restricting access)
Common patterns
Pattern 1: Quick setup for testing
Pattern 2: Production deployment with governance
Pattern 3: Deterministic deployment
Next steps
Configuration
Configure roles, fees, adapters, and caps
Factory reference
Full VaultV2Factory contract documentation