Skip to main content

Vault

The Vault is the only contract that holds user funds. Every token deposited, settled, or withdrawn flows through it. It is intentionally minimal: a pure pass-through custodian with no per-asset ledger — the protocol's authoritative ledger is the Orchestrator's commitment tree and nullifier set, not the Vault's bookkeeping.

ORCHESTRATOR and FEE_COLLECTOR are immutables set at construction; onlyOrchestrator guards every state-changing function. The Vault never calls untrusted contracts — only SafeTransferLib on the token address decoded from the EncodedAsset.

Interface

pull(asset, from, amount) → net

Used on deposit. Moves amount from from into the Vault with safeTransferFrom, enforces exact delivery via a balance-delta check, skims the protocol fee, and returns the net:

push(asset, to, amount)

Used on withdrawal (netPublicValue > 0). Sends amount to to with safeTransfer. No fee — the deposit fee already applied.

refundCredit(asset, amount)

Re-banks tokens fee-free during refund shielding: pulls amount from msg.sender (the Orchestrator) with exact-delivery enforcement. Used so re-shielding a leftover does not pay the deposit fee a second time.

balanceOf(asset) → uint256

The Vault's current balance for an asset — useful for auditing solvency. (The Orchestrator also reads raw balances directly via Assets.balanceOf for its transient-balance snapshots.)