# Vault policies

> The deposit, holder and withdrawal policies, the hook each one exposes, and every function that asks it.

Source: https://docs.trusslabs.io/vaults/policies/vault-policies

A vault asks up to three policies about the people using it. The deposit policy decides what may come in, the holder
policy who may receive shares, and the withdrawal policy who may take USDC out. This page lists each hook and every
function that asks it, so you can see exactly where a rule applies and where it does not.

> **Key points**
>
> - The deposit policy is asked when a deposit request opens, and once per deposit settlement for how much may fill.
> - The holder policy is asked wherever shares or a pending request arrive, and never about the address they leave.
> - The withdrawal policy is asked about whoever controls or is paid by a redemption, never about the owner whose shares it takes.
> - Settlement never asks the holder or withdrawal policy, so one refused address cannot stop a batch.

## The deposit policy

`applyDepositPolicyOnRequest(intent)` sees the caller, the owner the USDC comes from, the controller and the amount.
It reverts to refuse, and may update its own state, such as using up a limit. `settlementHeadroom()` returns the
most one deposit settlement may fill across its batch.

| Function | Hook | When |
|---|---|---|
| `requestDeposit` | `applyDepositPolicyOnRequest` | After the minimum and the holder check, before the USDC moves |
| `settleDeposit` | `settlementHeadroom` | Once per batch. Below demand, every request fills pro rata |
| `depositCapacity()` | `settlementHeadroom` | A view |

Claims, cancellations and deposit request transfers never ask it. `DepositCapPolicy` admits every request. Its
headroom is the cap less the net principal already settled.

## The holder policy

`canHold(account)` says whether `account` may receive shares or a pending request. A `false` reverts the action with
`HolderNotAllowed`. A policy that reverts reverts the action too.

| Function | Who is asked about |
|---|---|
| `requestDeposit` | The controller |
| `requestRedeem`, `requestRedeemAndExecute` | The controller, only when it is not the owner |
| `deposit`, `mint`, `claimDepositFor` | The address the shares go to |
| `transfer`, `transferFrom` | The recipient |
| `transferDepositRequest`, `transferRedeemRequest` | The new controller |
| `cancelRedeemRequest` | The controller, whom the shares return to |
| `forceTransfer` | The address the position moves to |

It is never asked about the sender, a burn, the vault itself, which holds escrowed shares, or the fee recipient. A
refused address keeps its shares and can send them on. It cannot cancel a redemption, because the shares would
return to it.

## The withdrawal policy

`canWithdraw(account)` says whether `account` may redeem shares for USDC or be paid by a redemption. Anything but a
clean `true`, a revert included, counts as a refusal, and the action reverts with `WithdrawalNotAllowed`.

| Function | Who is asked about |
|---|---|
| `requestRedeem` | The controller |
| `requestRedeemAndExecute`, `executeRedeemRequest` | The controller and the receiver |
| `redeem`, `withdraw` | The controller and the receiver |
| `claimRedeemFor` | The controller, who is paid |
| `transferRedeemRequest` | The new controller |
| `forceTransfer` | The address moved to, when a redemption or its fills move |
| `maxRedeem`, `maxWithdraw`, `previewInstantRedeem`, `maxInstantRedeem` | Read zero for a refused controller |

It is never asked about the owner whose shares go into escrow, or about the caller. A refused owner can therefore
open a redemption that names an allowed controller. Settlement never asks it: a refused controller's request still
fills, and the USDC waits until the policy allows a claim. Cancelling a request does not ask it either.

## Where to read more

| Page | What it covers |
|---|---|
| [Policies](https://docs.trusslabs.io/vaults/policies.md) | Every slot, and what exists today |
| [Building a policy](https://docs.trusslabs.io/vaults/policies/building-a-policy.md) | What happens when a hook refuses or reverts |
| [Using policies for compliance](https://docs.trusslabs.io/vaults/compliance/using-policies.md) | Which hook fits which compliance need |
| [Deposits](https://docs.trusslabs.io/vaults/flow-of-funds/deposits.md) | The deposit flow these hooks sit in |
| [Withdrawals](https://docs.trusslabs.io/vaults/flow-of-funds/withdrawals.md) | The redemption flow these hooks sit in |
