(07)Technology

Vaults

An Vault holds one token for an agent and spends it only with a rotating one-time key. Anyone may submit a spend; only the signature decides what it does.

Chain Robinhood Chain · 4663Code 77da16aOrle Agent Swap 6d5a05cPad 61d8485

7.1What a vault is#

A vault is a small contract that holds a single ERC-20 token, fixed when it is created Vault.sol:462-469. It stores the root of its current one-time key and a nonce, the number of spends so far, which is also the index of the current key Vault.sol:362-365. It has no owner address and no admin function, and it moves nothing but its own token: a swap's output goes from Uniswap straight to the recipient the key signed Vault.sol:52-215.

Every spend follows the same steps Vault.sol:484-517:

  1. The parameters must have the exact length of their action, or the spend reverts Vault.sol:612-662.
  2. The vault rebuilds the signed message from the chain id, its own address, its nonce, the next key root, the action and the parameters, and recovers the key root from the WOTS signature.
  3. That root must be the current key root (or, during a recovery, the recovered one).
  4. The key rotates and the nonce advances before any external call.
  5. The action runs.

Because the signature binds everything that moves value, whoever submits it, the relayer or anyone else, can only send it as it is. A spend that did not land is sent again with the same bytes, never signed again: there is no expiry Vault.sol:212-215.

7.2The actions#

#ActionWhat it does
0TransferSends an amount of the vault’s token to an address.
1OpenChannelOpens a payment channel from the vault (how an agent pays the relayer).
2SetCrankKeySets or removes the key that may settle the vault’s payment channels. That key can only send escrow back to the vault or apply vouchers the payer signed.
3SwapAn exact-input Uniswap v4 swap of the vault’s token, with the vault itself as the swapper.
4ConfigurePoolCalls configure on a hook as this vault: how a creator vault changes its pool’s rules.
5ClaimDividendClaims the dividends a launched token owes this vault, to a recipient it signs.
6SetGuardianAdds or removes a recovery guardian.
7SetRecoveryPolicySets how many guardians must agree and how long a recovery then waits.
8SupportRecoveryAs a guardian, supports moving another vault to a new key root.
9DevBuyPays the dev buy of exactly one launch, which only DevBuy can send.

The action numbers are constants Vault.sol:235-244, and each one is documented with its parameters in the contract headerVault.sol:52-215. A DevBuy signature names the hash of every launch and dev buy parameter, so even once public it can only ever make the launch its owner signed Launchpad.fork.t.sol:2161-2199.

These ten came with the first version. Each version since added its own, 47 actions in all; those of versions 3 to 5 run in the vault modules (next section).

7.3The versions, and the agent key#

Every vault runs the same code, version 5, behind one beacon. Each version kept what came before and added:

VersionActionsWhat it added
210 to 13Profiles in Registry and the ERC-8004 identity of a creator vault
314 to 24The withdrawal lock, lending on Morpho and Borro, EIP-1271 approvals, and guardians’ protective powers
425 to 28Venues: Spark Savings USDG and Raeto’s vaults, with a breaker that brings a position home
529 to 46The agent key and its policy, the allowlists, standing orders and Priors credit

With version 5 the owner can give an agent a key of its own instead of the seed. The vault checks every spend that key signs against the owner's policy: the actions allowed, the most one spend may move, a budget that refills over 24 hours, and allowlists of who it may pay. The key lasts at most 90 days, and the owner can end it at once. A tighter setting is in force at once; a looser one waits the withdrawal lock's delay when the vault has a lock VaultV5.sol:12-15 Vault.sol:169-181. How an agent runs with such a key is on the agents page, and how Claude gets one on Orle Agent in Claude.

7.4Swaps from a vault#

A vault swaps by unlocking the Uniswap v4 PoolManager itself, so the swapper a pool's hook sees is the vault. The signed parameters fix the pool, the direction, the amount in, the minimum out, the recipient, an optional referrer and the exact gas the swap gets Vault.sol:747-791.

  • The gas is signed. The PoolManager call gets exactly swapGas, between 100,000 and 10,000,000, whatever gas the sender attached; if not enough is left, the whole spend reverts and the key is not used Vault.fork.t.sol:772-801.
  • A failed swap still uses the key. A swap sent on its own, as a transaction's own call, that fails inside the PoolManager, below its minimum, refused by a hook's circuit breaker or by a token, moves nothing, emits SwapFailed and rotates the key. A market that moved can never hold a signed key hostage. Since version 5, a failed swap inside another contract's call, where the failure could have been set up, reverts and keeps the key, as does an agent key's failed swap Vault.sol:66-83.
  • The output can go to another vault. A buy of a launched token sends it straight to the agent's vault for that token Launchpad.fork.t.sol:604-622.

7.5The vaults of one agent#

One master seed gives an agent several vaults, each with its own keychain keys.ts:85-95:

VaultTokenUsed for
Main vaultUSDGThe agent’s funds: buys, withdrawals, shielding, paying the relayer.
Token vaultsA launched tokenWhat the agent bought; sells go back to the main vault.
Creator vaultUSDGOwns the agent’s ERC-8004 identity and pays the relayer for publishing it and its Pad listing; owns the pools of the tokens the agent launched before and receives their creator payouts.
Private vaultsUSDGOne new vault per private unshield that asks for one (a shielded leaf, in the web app), so unshielded funds are not gathered in one place.

Keychain ids are public; the only secret is the master seed, so the seed alone recovers every vault, deposit and leaf of the agentkeys.ts:1-14.

7.6Creating a vault#

VaultFactory.createVault(token, initialKeyRoot, initialCrank) deploys a beacon proxy with CREATE2. The address depends only on the token, the first key root and the crank, so it is known before the vault exists, and calling the factory again for an existing vault returns it instead of failing. A front-runner can only create the very vault its owner asked for VaultFactory.sol:22-35.

7.7Recovery#

A one-time key scheme lives or dies with its seed. A vault can name guardians, any accounts, ideally other vaults, which keeps recovery post-quantum. The owner sets a threshold and a delay between 36 hours and 14 days Vault.sol:301-304.

  1. The owner's new device derives a new key root for the vault's current nonce and gives it to the guardians.
  2. Guardians support that root. The support that reaches the threshold starts the delay. One recovery per round: the first proposal to reach the threshold is the one that waits Vault.sol:1121-1153.
  3. After the delay anyone may finish it, or the new seed's first spend finishes it itself Vault.sol:1178-1190.

The owner always wins. Any spend signed by the current key starts a new round: the waiting recovery and every support gathered so far stop counting Vault.sol:217-221. Guardians cannot take a vault from an owner who still holds its key and spends within the delay.

Two more layers sit off chain: an encrypted backup of the seed, which the owner exports in a terminal with a passphrase the agent never sees (scrypt and AES-256-GCM) backup-cli.ts:1-15, and the relayer's signature escrow, which lets a restored machine finish what the old one signed.

7.8Upgrades: 72 hours of notice#

Every vault is a beacon proxy, so one change of the vault beacon's implementation changes the code of every vault at once. Whoever can do that could, in principle, take every vault's funds without a single WOTS signature. Orle Agent treats that power as the most important key of the system, and it is not an elliptic-curve key.

The vault beacon 0xE9F5…18a0 and the pool beacon are owned by UpgradeOwner 0x5553…6E5e, a contract that only acts on a WOTS signature from its own rotating key, and only 72 hours after the call was published on chain UpgradeOwner.sol:6-28. During those 72 hours the full calldata of the upgrade is public in its CallScheduled event, and every vault owner can withdraw before a change they do not accept. The security page describes it in full.

7.9Limits#

  • A vault holds one ERC-20 token and no native ETH. A swap that pays out ETH must name a recipient that accepts ETH, such as an ordinary wallet.
  • The MCP server reports a soft limit of 250 USDG per vault; the contract does not enforce it config.ts:8-13.
  • A signed spend that never lands blocks the vault until it is sent, by design: nothing else may be signed with that key vault.ts:18-20.
  • The contract does not refuse a zero next key root; the signer does. A vault rotated to zero could only be moved by recovery.
  • A guardian that is an ordinary wallet is an elliptic-curve key. Use vaults as guardians to keep recovery post-quantum.