Skip to content

Deployment And Initialization

This document outlines the end-to-end process of deploying, initializing, and registering King's Vault V2 core components.

Deployment Steps

  1. Deploy Controller implementation contract.
  2. Deploy ERC-1967 proxy pointing to the Controller implementation with initialize(owner, manager).
  3. Deploy one or more vaults:
  4. KingsVaultV2(name, symbol, asset, owner, controller)
  5. KingsVaultV2Async(name, symbol, asset, owner, controller)
  6. The Admin (owner) grants roles on the Controller:
  7. Roles.DEVELOPER to the deployment/operator address.
  8. Roles.KEEPER to the keeper automation address.
  9. Roles.GUARDIAN to the emergency operator or multisig.
  10. The Admin grants roles on the Vault:
  11. Roles.INVESTOR to allowlisted investors.
  12. Additional Roles.GUARDIAN if the guardian is separate from the owner.
  13. Roles.KEEPER on async vaults if using the executeRedeem() batch function.
  14. The Developer calls Controller.registerVault(vault).
  15. Deploy strategies and grant required Roles.KEEPER to the Controller proxy and any direct keeper relayers.
  16. The Developer calls Controller.strategyAdd(vault, strategy).
  17. 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.