Skip to content

Controller

Source: src/controllers/Controller.sol

The Controller is the central UUPS-upgradeable coordinator of the King's Vault V2 ecosystem. It manages vault registration, strategy registries, fund routing, NAV (Net Asset Value) proposals and confirmations, and configurable performance fee share minting. The current performance fee rate for Ethereum Network Lending, AAVE GHO Saving, and Hyperliquidity Provider (HLP)—the V2 portals documented here—is 0%, so fee-share minting is inactive for those portals.

This Controller serves V2 shared vaults, not per-user GHO Staking. See Aave GHO Saving for Saving-specific routing and accounting.

Before integration or administration, verify the listed signatures and permissions against the deployed implementation and its verified source. See Documentation scope and verification.

State Structures

Struct Fields Purpose
Values timestamp, assets, supply, feeRate, pnl, isProfit A vault NAV snapshot.
VaultValues feeRate, activeBookValue, recalledYield, epochs, pending/confirmed values Per-vault NAV and PnL accounting.
VaultStrategies registered, strategies Per-vault strategy registry.
ControllerStorage manager, vaults, vaultValues, vaultStrategies ERC-7201 namespaced storage.

Public And External Functions

Function Access Description
initialize(address owner, address manager_) initializer Initializes Controller proxy, grants admin to owner, stores fee manager.
manager() public view Returns fee receiver address.
feeRate(address vault_) public view Returns the configured vault performance fee rate where 1_000_000 = 100%. The current V2 portal value is 0 (0%).
pnlBasis(address vault_) public view Returns activeBookValue + recalledYield.
isVaultRegistered(address vault) public view Returns whether vault is registered.
totalStrategyAssets(address vault) public view Sums totalAssets() of all registered strategies for a vault.
strategies(address vault) public view Returns registered strategy list.
markedElapsedTime(address vault) public view Returns seconds between confirmed and previous confirmed snapshots.
markedValues(address vault) public view Returns current confirmed NAV assets and supply.
prevMarkedValues(address vault) public view Returns previous confirmed NAV assets and supply.
setManager(address manager_) Admin Updates fee receiver. Emits FeeReceiverSet.
setFeeRate(address vault_, uint256 feeRate_) Keeper, registered vault Sets the configurable performance fee rate. Reverts if feeRate_ >= 1_000_000. Emits FeeRateSet. The current V2 portal configuration is 0 (0%).
registerVault(address vault) Developer Registers a vault and initializes confirmed values. Emits VaultRegistered.
vaultExit(address vault) Guardian, registered vault Invokes each strategy's exit procedure and returns the recovered amount; does not guarantee recovery of remote or unavailable assets.
vaultHarvest(address vault, address token) Keeper, registered vault Tells vault to sweep token to manager if manager is set.
strategyAdd(address vault, address strategy_) Developer, registered vault Adds compatible strategy to vault registry. Emits StrategyAdded.
strategyRevoke(address vault, address strategy_, bool force) Developer, registered vault, registered strategy Invokes the strategy's exit procedure and removes it from the registry. Registry removal is not proof that all assets were recovered. Emits StrategyRevoked.
fundInvest(address vault, address strategy_, uint256 amount) Keeper, registered vault, registered strategy Moves vault idle assets into strategy and increases book value.
fundDivest(address vault, address strategy_, uint256 amount) Keeper, registered vault, registered strategy Initiates strategy divestment and decreases book value by the amount returned by that call. Asynchronous divestment may return 0 while remote recovery remains in progress.
fundReplenishOnlyForVault(address vault, uint256 shortage) Registered vault only; msg.sender must equal vault Pro-rata liquidity waterfall across strategies.
fundExitOnlyForVault(address vault) Registered vault only; msg.sender must equal vault Invokes each strategy's exit procedure for shutdown; remote positions may require separate recovery.
proposeValues(address vault) Keeper, registered vault Creates pending NAV epoch. Emits ValuesProposed.
confirmValues(address vault, uint256 epoch) Admin, registered vault Confirms the latest pending epoch and may mint fee shares only when profitable and feeRate > 0. With the current 0% V2 portal rate, no fee shares are minted. Emits ValuesConfirmed and possibly FeeSharesMinted.

Internal Functions

Function Description
_getControllerStorage() Returns Controller's ERC-7201 namespaced storage pointer.
_onlyRegisteredVault(address vault) Reverts if vault is not registered.
_onlyRegisteredStrategy(address vault, address strategy_) Reverts if strategy is not registered for the vault.
_onlyNoneRegisteredStrategy(address vault, address strategy_) Reverts if strategy is already registered for the vault.
_authorizeUpgrade(address) UUPS authorization, Admin only.
_initialValues(address vault) Writes initial confirmed NAV snapshot.
_confirmValues(address vault, uint256 epoch) Validates freshness/epoch and promotes pending to confirmed.
_exitAllStrategies(address vault) Calls exit(true) on every strategy and decreases book value.
_increaseBookValue(address vault, uint256 amount) Adds invested capital to active book value, first offsetting recalled yield.
_decreaseBookValue(address vault, uint256 amount) Reduces active book value; excess becomes recalled yield.