# Who can call what

> Every restricted function on every contract of a Truss vault, its tier, and which profiles can call it.

Source: https://docs.trusslabs.io/vaults/roles/function-permissions

This page lists every restricted function in a vault, the tier it waits, and the profiles that hold it. The
tables are generated from the roles table, the contract that fixes these facts for every vault in an environment.
They are never edited by hand.

> **Key points**
>
> - The VaultAdmin holds every role on this page. The tables show who else does.
> - Every function that lowers risk is Immediate, so it can act at once.
> - Each sub-account's execute and return roles are separate roles, so a trader on one sub-account has nothing on
>   another.
> - A few functions sit outside the table: the contracts check their callers themselves, or anyone may call them.

## How to read the tables

There is one table per contract type. A role covers its function on every contract of that type in the vault,
except the roles under "On each sub-account", which are one role per sub-account.

| Column | What it means |
|---|---|
| Tier | How long a holder waits before the call runs. Immediate means no wait. See [Tiers and timelocks](https://docs.trusslabs.io/vaults/roles/tiers-and-timelocks.md) |
| Risk | Whether the function can raise risk, only lower it, or neither |
| Can move or revalue funds | Whether the function can move, redirect or change the value of what the vault holds |
| Also held by | The profiles other than the VaultAdmin that hold the role |

Risk also decides who may cancel a scheduled call. The admin canceller cancels one that raises risk, and the
operational canceller any other. The VaultAdmin holds both.

## The functions, contract by contract

Generated from `RolesTable` version 1: 71 roles that cover every instance of a contract type,
and 2 roles on each sub-account. The VaultAdmin holds every role in these tables.

### TrussVault

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `addSubAccount` | CRITICAL | Raises | Yes | VaultAdmin only |
| `initiateSubAccountRemoval` | Immediate | Lowers | No | VaultAdmin only |
| `finalizeSubAccountRemoval` | Immediate | Neither | No | VaultAdmin only |
| `setDepositPolicy` | CRITICAL | Raises | Yes | VaultAdmin only |
| `setHolderPolicy` | CRITICAL | Raises | Yes | VaultAdmin only |
| `pushToSubAccount` | Immediate | Neither | No | VaultManager, Allocator |
| `requestAssetsFromSubAccount` | Immediate | Neither | No | VaultManager |
| `settleDeposit` | Immediate | Neither | No | VaultManager, Settler |
| `settleRedeem` | Immediate | Neither | No | VaultManager, Settler |
| `crystalliseFees` | Immediate | Neither | No | VaultManager |
| `donate` | Immediate | Neither | No | VaultManager, Donor |
| `pause` | Immediate | Lowers | No | Sentry |
| `unpause` | HIGH | Raises | No | VaultAdmin only |
| `raiseEntryFee` | MEDIUM | Raises | No | VaultManager |
| `lowerEntryFee` | Immediate | Lowers | No | VaultManager |
| `raiseExitFee` | MEDIUM | Raises | No | VaultManager |
| `lowerExitFee` | Immediate | Lowers | No | VaultManager |
| `raiseManagementRate` | MEDIUM | Raises | No | VaultManager |
| `lowerManagementRate` | Immediate | Lowers | No | VaultManager |
| `raisePerformanceRate` | MEDIUM | Raises | No | VaultManager |
| `lowerPerformanceRate` | Immediate | Lowers | No | VaultManager |
| `setFeeRecipient` | HIGH | Raises | Yes | VaultAdmin only |
| `resetHighWaterMark` | HIGH | Raises | Yes | VaultAdmin only |
| `rescueTokens` | Immediate | Raises | Yes | VaultAdmin only |
| `rescueNative` | Immediate | Raises | Yes | VaultAdmin only |
| `setWithdrawalPolicy` | CRITICAL | Raises | Yes | VaultAdmin only |
| `raiseInstantRedeemFee` | LOW | Raises | No | VaultManager |
| `lowerInstantRedeemFee` | Immediate | Lowers | No | VaultManager |
| `forceTransfer` | Immediate | Raises | Yes | VaultManager |

### Sub-accounts

| Function | On | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|---|
| `pause` | both | Immediate | Lowers | No | Sentry |
| `unpause` | both | HIGH | Raises | No | VaultAdmin only |
| `setSubAccountAllocationPolicy` | both | CRITICAL | Raises | No | VaultAdmin only |
| `addModule` | tracked | CRITICAL | Raises | Yes | VaultAdmin only |
| `removeModule` | tracked | Immediate | Neither | No | VaultAdmin only |
| `rescueTokens` | tracked | Immediate | Raises | Yes | VaultAdmin only |
| `setNavProvider` | attested | CRITICAL | Raises | Yes | VaultAdmin only |
| `invalidateNav` | attested | Immediate | Lowers | No | NavGuardian |
| `anchorDeviationToLatestAttestation` | attested | Immediate | Raises | Yes | NavGuardian |

### BitmaskVerifier

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `allowCallShape` | CRITICAL | Raises | Yes | VaultAdmin only |
| `revokeCallShape` | Immediate | Lowers | No | VaultAdmin only |

### AssetRegistry

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `registerAsset` | CRITICAL | Raises | Yes | VaultAdmin only |
| `initiateDeregistration` | Immediate | Lowers | No | VaultManager |
| `finalizeDeregistration` | Immediate | Neither | No | VaultManager |

### PriceOracle

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `setOracleAdapterForAsset` | CRITICAL | Raises | Yes | VaultAdmin only |
| `removeOracleAdapterForAsset` | Immediate | Raises | Yes | VaultAdmin only |

### SubAccountSwapPolicy

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `raiseRateLimitCapacity` | HIGH | Raises | No | VaultAdmin only |
| `lowerRateLimitCapacity` | Immediate | Lowers | No | Sentry |
| `raiseRateLimitRefillRate` | HIGH | Raises | No | VaultAdmin only |
| `lowerRateLimitRefillRate` | Immediate | Lowers | No | Sentry |

### SubAccountLendPolicy

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `raiseRateLimitCapacity` | HIGH | Raises | No | VaultAdmin only |
| `lowerRateLimitCapacity` | Immediate | Lowers | No | Sentry |
| `raiseRateLimitRefillRate` | HIGH | Raises | No | VaultAdmin only |
| `lowerRateLimitRefillRate` | Immediate | Lowers | No | Sentry |

### SubAccountAllocationPolicy

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `raiseRateLimitCapacity` | HIGH | Raises | No | VaultAdmin only |
| `lowerRateLimitCapacity` | Immediate | Lowers | No | Sentry |
| `raiseRateLimitRefillRate` | HIGH | Raises | No | VaultAdmin only |
| `lowerRateLimitRefillRate` | Immediate | Lowers | No | Sentry |
| `raiseSubAccountCap` | HIGH | Raises | No | VaultAdmin only |
| `lowerSubAccountCap` | Immediate | Lowers | No | Sentry |

### DepositCapPolicy

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `raiseDepositCap` | HIGH | Raises | No | VaultAdmin only |
| `lowerDepositCap` | Immediate | Lowers | No | VaultManager, Sentry |

### InstantRedemptionPolicy

| Function | Tier | Risk | Can move or revalue funds | Also held by |
|---|---|---|---|---|
| `setDefaultSource` | CRITICAL | Raises | Yes | VaultAdmin only |
| `clearDefaultSource` | Immediate | Lowers | No | VaultManager, Sentry |
| `raiseWindowCapacity` | HIGH | Raises | No | VaultAdmin only |
| `lowerWindowCapacity` | Immediate | Lowers | No | VaultManager, Sentry |
| `raiseWindowRefillRate` | HIGH | Raises | No | VaultAdmin only |
| `lowerWindowRefillRate` | Immediate | Lowers | No | VaultManager, Sentry |
| `loosenFreshnessGate` | HIGH | Raises | No | VaultAdmin only |
| `tightenFreshnessGate` | Immediate | Lowers | No | VaultManager, Sentry |
| `pauseInstant` | Immediate | Lowers | No | VaultManager, Sentry |
| `unpauseInstant` | HIGH | Raises | No | VaultAdmin only |

### On each sub-account

Each of these is a separate role on every sub-account, so holding it on one sub-account gives nothing on another.

| Function | On | Tier | Risk | Can move or revalue funds | Held by |
|---|---|---|---|---|---|
| `executeModule` | tracked | Immediate | Neither | No | VaultAdmin, VaultManager, Trader |
| `returnAssetsToVault` | both | Immediate | Lowers | No | VaultAdmin, VaultManager, Trader |
| `executeCalls` | attested | Immediate | Neither | No | VaultAdmin, VaultManager, Trader |

### AccessManager

The manager's own roles guard no vault function. The VaultAdmin holds all five.

| Role | What it does | Tier | Also held by |
|---|---|---|---|
| Admin | Administers the manager: grants and revokes every delayed role, maps functions to roles, closes targets | CRITICAL | VaultAdmin only |
| Admin canceller | Cancels a scheduled call against a role that raises risk | Immediate | VaultAdmin only |
| Operational canceller | Cancels a scheduled call against any other role | Immediate | VaultAdmin only |
| Operational admin | Grants and revokes the immediate roles the delegation admin does not | Immediate | VaultAdmin only |
| Delegation admin | Grants and revokes the Settler, Allocator and Donor roles and each sub-account's execute and return roles | Immediate | VaultManager |

## Functions outside the table

These functions answer to no role on the access manager:

| Function | Contract | Who may call it |
|---|---|---|
| `crystalliseFees` | The vault | The fee recipient, always, with no role. Anyone else needs its role, which the VaultManager holds |
| `setNavManager` | An attested NAV provider | The NavAdmin |
| `attest` | An attested NAV provider | The NavManagers |
| `syncNav` | An attested sub-account | Anyone. It only takes up an attestation the account would use anyway |
| `multicall(bytes[])` | The vault and each sub-account | Anyone. Each inner call is checked against the original caller |
| `sweep` | A module | Anyone. It sends a stray token to the module's sub-account |

Requests, cancellations, request transfers and claims are the holder's own. The vault checks each against the
request's controller or an operator it has approved. Anyone may claim a fill for its controller, who is then paid.

## Checking it on chain

Every fact on this page can be read from the vault's access manager, the factory and the roles table:

- `getTargetFunctionRole(target, selector)` gives the role a function answers to.
- `hasRole(roleId, account)` gives membership and the holder's delay. A grant still waiting its grant delay reads
  as not a member.
- `canCall(caller, target, selector)` says whether a call runs now or after a delay.
- `getRoleAdmin(roleId)` and `getRoleGrantDelay(roleId)` give who grants a role and how long a new holder waits.
- On the factory, `delaysOf(vault)` gives the vault's tiers in seconds.
- On the roles table, `allTypeScoped()`, `allSubAccountScoped(subAccount)` and one view per profile list every
  role with its tier and risk. `rolesVersion()` gives the table's version.

## Where to read more

| Page | What it covers |
|---|---|
| [Profiles](https://docs.trusslabs.io/vaults/roles/profiles.md) | What each profile is for, and what a leaked key could do |
| [Tiers and timelocks](https://docs.trusslabs.io/vaults/roles/tiers-and-timelocks.md) | How long each tier waits, and how a delayed call is scheduled |
| [Reading vault state](https://docs.trusslabs.io/vaults/developers/reading-state.md) | The views an integration reads |
