Deployment And Initialization
This document outlines the end-to-end process of deploying, initializing, and registering King's Vault V2 core components.
Deployment Steps
- Deploy
Controllerimplementation contract. - Deploy ERC-1967 proxy pointing to the
Controllerimplementation withinitialize(owner, manager). - Deploy one or more vaults:
KingsVaultV2(name, symbol, asset, owner, controller)KingsVaultV2Async(name, symbol, asset, owner, controller)- The Admin (
owner) grants roles on the Controller: Roles.DEVELOPERto the deployment/operator address.Roles.KEEPERto the keeper automation address.Roles.GUARDIANto the emergency operator or multisig.- The Admin grants roles on the Vault:
Roles.INVESTORto allowlisted investors.- Additional
Roles.GUARDIANif the guardian is separate from the owner. Roles.KEEPERon async vaults if using theexecuteRedeem()batch function.- The Developer calls
Controller.registerVault(vault). - Deploy strategies and grant required
Roles.KEEPERto the Controller proxy and any direct keeper relayers. - The Developer calls
Controller.strategyAdd(vault, strategy). - The Guardian unpauses the vault when deposits are ready to open.
Vault Registration Flow
Before a vault can be used or have strategies attached, it must be registered with the Controller.
sequenceDiagram
participant Dev as Developer
participant Controller
participant Vault
Dev->>Controller: registerVault(vault)
Controller->>Vault: totalAssets()
Controller->>Vault: totalSupply()
Controller->>Controller: _initialValues(vault)
Controller->>Controller: mark vault registered
Validation
During registration, the Controller enforces the following checks:
| Check | Failure |
|---|---|
Caller has Roles.DEVELOPER |
AccessControl revert |
vault != address(0) |
ZeroAddress() |
| Vault is not already registered | VaultAlreadyRegistered(vault) |
Upon successful registration, the Controller snapshots the initial assets and supply into the confirmed values, setting the baseline for NAV tracking.