# Rotate a key

> How to replace each kind of key on a vault, from operator keys behind multicalls to the VaultAdmin, the fee recipient and the NAV keys.

Source: https://docs.trusslabs.io/vaults/guides/rotate-a-key

Keys are replaced, not edited. An operator multicall's owner is fixed for its life, so a new operator key means a
new multicall and a new grant. Each kind of key has its own delay before the replacement can act, so start early
and revoke the old key last.

> **Key points**
>
> - Revoke the old key last, unless it has leaked; then revoke it first.
> - An operator key needs a new multicall, which the VaultAdmin or a vault manager grants.
> - Replacing the VaultAdmin takes two CRITICAL windows, so a multisig VaultAdmin usually changes its signers instead.
> - A NavAdmin cannot be changed in place; the attested account moves to a new NAV provider.

## How each key is replaced

| Key | How to rotate | When the new key can act |
|---|---|---|
| Settler, Donor | New multicall; the VaultAdmin or a vault manager grants its roles, then revokes the old | At once |
| Allocator | The same | After the HIGH grant delay |
| Trader | The same, on each sub-account it runs | Returns at once; executes after the HIGH grant delay |
| Vault manager | New multicall; the VaultAdmin grants the VaultManager profile and each sub-account's execute and return roles, then revokes the old | After the CRITICAL grant delay; its fee raises once their CRITICAL schedule runs |
| Sentry, NavGuardian | The VaultAdmin grants each of the profile's roles to the new address, then revokes the old | After the CRITICAL grant delay |
| VaultAdmin | See below | After two CRITICAL windows |
| Fee recipient | The VaultAdmin calls `setFeeRecipient(newRecipient)` (HIGH) | Once the change runs |
| NavManager | The NavAdmin calls `setNavManager(key, true)`, then `setNavManager(oldKey, false)` | At once |
| NavAdmin | A new NAV provider under the new NavAdmin, bound with `setNavProvider` on the attested account (CRITICAL, VaultAdmin) | Once the change runs |

Each grant takes effect at the moment `RoleGranted` gives. Keys added after launch are not in the vault's address
book, so track `RoleGranted` and `RoleRevoked`. Changing the fee recipient turns accrued fees into shares first, so
what accrued until then goes to the old recipient.

## Replacing the VaultAdmin

The VaultAdmin is the AccessManager's only admin, and its own admin changes wait the CRITICAL tier. To move to a new
key:

1. From the old key, schedule a grant of the admin role to the new key, and grants of every other role the
   VaultAdmin holds. Give each role its tier's delay as the execution delay, as the deployment did, or the new key
   would skip that role's timelock.
2. Wait the CRITICAL tier and run the grants. The admin role then waits its own CRITICAL grant delay before the
   new key is a member. Immediate roles take effect after the same grant delay.
3. Check the new key with `hasRole` for each role, then revoke the old key's roles.

In the first five days after deployment, grant delays are not yet in effect, so one CRITICAL window is enough.
Holders can watch every scheduled step, because each one is public before it runs.

## Where to read more

| Page | What it covers |
|---|---|
| [Profiles](https://docs.trusslabs.io/vaults/roles/profiles.md) | Each key and what it holds |
| [Operator multicalls](https://docs.trusslabs.io/vaults/roles/owned-multicall.md) | Why an operator key needs its own multicall |
| [A key has leaked](https://docs.trusslabs.io/vaults/guides/leaked-key.md) | Revoking first when a key is compromised |
| [Change curator](https://docs.trusslabs.io/vaults/guides/change-curator.md) | Replacing every key a curator holds |
