# Deposits

> How a deposit request is opened, settled at a fresh NAV by a settler, claimed as shares, cancelled or transferred, and which contract and caller each step needs.

Source: https://docs.trusslabs.io/vaults/flow-of-funds/deposits

A deposit into a Truss vault is a request. The holder's USDC waits in a separate contract, the deposit silo, outside
the vault's NAV, until a settler fills the request at the price of that moment. The holder then claims the shares.
Every deposit goes through this queue; there is no instant deposit.

> **Key points**
>
> - The owner of the USDC, or its operator, opens the request. A Settler, a VaultManager or the VaultAdmin settles it.
> - Settlement prices every request in the batch at one fresh NAV. While the NAV is stale, the request waits.
> - When demand is above the deposit cap's headroom, every request in the batch fills by the same fraction.
> - A pending deposit can be cancelled for its full amount at any time, or transferred to a new controller.

| Step | Function on `TrussVault` | Who must call it | Fresh NAV | Event |
|---|---|---|---|---|
| Request | `requestDeposit(assets, controller, owner)` | The owner or its operator | No | `DepositRequest` |
| Settle | `settleDeposit(requestIds)` | A Settler or VaultManager through its multicall, or the VaultAdmin | Yes | `RequestFilled`, `Settled` |
| Claim | `deposit` or `mint` with a controller, or `claimDepositFor(controller)` | The controller or its operator; anyone for `claimDepositFor` | No | `Deposit` |

## 1. Opening a request

The owner approves the vault to take its USDC, then calls `requestDeposit`. The vault moves the USDC into the deposit
silo and gives the request an id, which the named controller owns from then on.

The vault refuses the request when:

- the amount is below the vault's minimum deposit, a limit fixed at deployment;
- the vault is paused;
- a holder policy is bound and refuses the controller;
- a deposit policy is bound and refuses it. The deposit-cap policy admits every request and applies the cap at settlement instead.

The minimum is the deployer's choice, within the factory's maximum. The committed preprod configs set 0.01 USDC, under
a factory maximum of 100,000 USDC.

## 2. Settling

A settler calls `settleDeposit` with a list of request ids. It chooses which requests fill and when, so it also
chooses the moment of the price. In one call the vault:

1. turns the fees accrued so far into shares for the fee recipient, at a fresh NAV;
2. prices every request in the batch at that NAV, per share;
3. fills each request, pro rata when the batch asks for more than the deposit cap's headroom (the cap less the net
   principal already settled). What does not fill stays pending;
4. moves the USDC from the silo into the vault, takes the entry fee as shares for the fee recipient, and holds the
   rest of the new shares for the controller.

A batch names at most the vault's settlement batch maximum, 40 in the committed preprod configs. An id that is no
longer pending is skipped with `RequestSkipped`. A fill too small to mint one unit of share stays pending.
Settlement works while the vault is paused, and reverts while the NAV is stale.

## 3. Claiming the shares

Filled shares wait in the vault until claimed. The controller, or its operator, claims with `deposit(assets,
receiver, controller)` or `mint(shares, receiver, controller)`, and may claim in parts. Anyone may call
`claimDepositFor(controller)`, which sends everything claimable to the controller. When a holder policy is bound,
the address receiving the shares must pass it.

## Cancelling and transferring

The controller or its operator can cancel with `cancelDepositRequest(requestId)`. Every unfilled USDC goes back to
the controller from the silo, at any age, for free. Cancelling works while paused or stale, and emits
`RequestCancelled`.

`transferDepositRequest(requestId, oldController, newController)` hands the whole pending balance to a new
controller, who must pass the holder policy when one is bound. Shares already filled stay with the old controller.
See [Selling a pending request](https://docs.trusslabs.io/vaults/flow-of-funds/selling-a-pending-request.md).

What can stop or delay a deposit: the minimum, a bound policy, the cap, a pause, a stale NAV at settlement, and a
settler that does not settle.

## Where to read more

| Page | What it covers |
|---|---|
| [Flow of funds](https://docs.trusslabs.io/vaults/flow-of-funds.md) | Who is who, and which steps need a fresh NAV |
| [Fees in the flow of funds](https://docs.trusslabs.io/vaults/flow-of-funds/fees.md) | When the entry fee and accrued fees are taken |
| [Vault policies](https://docs.trusslabs.io/vaults/policies/vault-policies.md) | The deposit and holder policies, and where each is asked |
| [Deposits and redemptions](https://docs.trusslabs.io/vaults/developers/deposits-and-redemptions.md) | The calls for an integration |
