TrussDocs

Policies

Building a policy

What a new policy must satisfy to be bound, how its refusals and failures behave, and what no policy can do.

A policy is asked questions inside the flows people depend on, so a mistake in one can stop those flows. This page sets out what a policy must satisfy before a vault accepts it, how a refusal and a failure differ in each slot, and what no policy can do however it is written.

Key points

  • A policy must implement its slot's hook, name the vault it serves, and answer to that vault's AccessManager.
  • A policy that reverts behaves differently by slot: a broken withdrawal policy refuses everyone, and a broken holder policy stops every share transfer.
  • No policy can stop a holder sending shares away, block the fee mint, or move the vault's funds.
  • A custom policy's own restricted functions have no rows in the roles table today.

What a policy must satisfy

  1. It implements the slot's interface: IVaultDepositPolicy, IVaultHolderPolicy, IVaultWithdrawalPolicy, ISubAccountAllocationPolicy or ISubAccountExecutionPolicy.
  2. Its vault() returns the vault it serves. A policy serves one vault.
  3. Its authority() returns that vault's AccessManager. Binding refuses a policy that fails either check.
  4. An execution policy's moduleType() matches its module's family, and a module cannot be added without one.

A policy bound on a live vault waits the CRITICAL tier, and unbinding it waits the same. A holder or withdrawal policy named at deployment is bound by the factory with no wait. It must exist before the vault does, so it is built against the vault's predicted address and AccessManager. Each binding emits an event: VaultDepositPolicySet, VaultHolderPolicySet, VaultWithdrawalPolicySet, SubAccountAllocationPolicySet or ModuleAdded.

A policy's own settings, such as an allowlist, answer to the vault's AccessManager. The roles table maps the functions of the policies that exist today. A custom policy's own restricted functions have no rows in it.

Refusals and failures

SlotA refusalA revert
Deposit, request hookRefuses the requestRefuses the request
Deposit, settlementHeadroomA low answer fills less, or nothingStops every deposit settlement and the depositCapacity() view
HolderReverts the arrival with HolderNotAllowedReverts every arrival: share transfers, deposit claims and new deposits stop
WithdrawalRefuses with WithdrawalNotAllowedCounts as a refusal of everyone; the views read zero
AllocationRefuses the pushRefuses the push
ExecutionReverts the executionReverts the execution, including an instant withdrawal's venue leg

Hooks run inside user flows, so keep them cheap. The holder policy runs on every share transfer, and the withdrawal policy on every redemption request and claim.

What no policy can do

  • It cannot stop a holder sending shares away. The sender is never asked about, and pausing the vault does not stop transfers either.
  • It cannot block the fee mint, because the holder policy is never asked about the fee recipient.
  • It cannot stop a settlement batch because of one address. Settlement asks neither the holder nor the withdrawal policy.
  • It cannot move the vault's funds. The vault and its sub-accounts only ask a policy questions, and none sends it tokens or an approval.

Before binding one

  • Test it against a fork of the vault, through every function on Vault policies that asks it.
  • Decide who can change its settings, and how fast. A list that must be quick to update cannot sit behind a long delay.
  • Watch for the binding events. On a vault with timelocks, a binding is scheduled in public, so holders can see it before it runs.

Where to read more

PageWhat it covers
PoliciesEvery slot, and what exists today
Vault policiesEvery function that asks a vault policy
Sub-account policiesEvery function that calls a sub-account policy
Bind a policyThe steps to bind, replace or remove one
Tiers and timelocksHow the CRITICAL wait is scheduled and cancelled