Guides
Add a sub-account
How to add a tracked or attested sub-account to a live vault, from building it with an expansion kit to granting its roles and opening its limits.
A vault can take a new sub-account after launch, up to the most sub-accounts fixed at deployment. An expansion kit builds the new account, and the VaultAdmin then wires its roles and adds it at the CRITICAL tier. It takes no capital until its limits are raised.
Key points
- Check there is room: the most sub-accounts a vault may hold is fixed at deployment.
- An expansion kit creates and sets up the new contracts in one transaction, and holds no power afterwards.
- Adding the account, its modules and its assets each wait the CRITICAL tier.
- The account receives nothing until its cap and push limit are raised, which waits HIGH.
Steps
All steps after the first are the VaultAdmin's. With timelocks on, schedule them for the same moment, at least the CRITICAL tier away, and execute them as one batch in this order.
- Build the account with an expansion kit. Deploying the kit creates and initializes everything in its
constructor, so no one can initialize a contract in between. The kit holds no role.
SubAccountExpansionKitbuilds a tracked account, with a swap module and its policy and a lend module, as wanted.AttestedSubAccountExpansionKitbuilds an attested account, with its call verifier and a NAV provider under the vault's NavAdmin. The account starts at an accepted value of zero.
- Wire its roles on the AccessManager. Map the account's functions, and its new swap policy's, to the vault's existing roles. Then grant
its own execute and return roles, from
allSubAccountScoped(subAccount)on the roles table, to the VaultAdmin, each vault manager's multicall and any trader the account should have. Put both roles under the delegation admin, with the HIGH tier as the execute role's grant delay and none on the return role. - Bind its allocation policy with
setSubAccountAllocationPolicyand, on a tracked account, each module withaddModule(module, policy)(both CRITICAL). - Add it to the vault with
addSubAccount(subAccount)(CRITICAL). The vault refuses an account that answers to another AccessManager or NAV oracle, or a tracked one with another price oracle or asset registry. - Register each of a tracked account's assets with
registerAsset(CRITICAL). See Onboard an asset. - Open it by raising its cap with
raiseSubAccountCap, then its push, swap and lend limits (HIGH).
An attested account's extra steps
- Allow its calls. The VaultAdmin admits each permitted call with
allowCallShapeon the account's verifier (CRITICAL). Without one, the account can make no call. - Set up its attesters. The NavAdmin appoints and removes the provider's NavManagers, the keys that post its
value, with
setNavManager. - For a permissioned token, have the issuer allow the account's address before its first call. The address is known once the kit is deployed.
Traders added later
A trader granted an execute role after launch waits the HIGH grant delay before it can trade, as RoleGranted
shows. Its return role acts at once. The VaultAdmin or a vault manager grants both.
Events
SubAccountAdded, ModuleAdded, SubAccountAllocationPolicySet, AssetRegistered, CallShapeSet and the policy
raises, with the AccessManager's TargetFunctionRoleUpdated and RoleGranted.
Where to read more
| Page | What it covers |
|---|---|
| Extending a vault | What can be added to a live vault |
| Tracked sub-accounts | How a tracked account works |
| Attested sub-accounts | How an attested account works |
| Rate limits | Caps and push limits |