Agent Vault
Lets an agent manage liquidity under a mandate enforced onchain.
Overview#
A user deposits into a PDA vault and grants an agent key a mandate. The agent can only move funds between the vault and pools (up to 4 picked pools, or 1 to 3 pools it chooses for Autopilot), never to a wallet. It can add liquidity, remove liquidity, collect fees and swap, only within the mandate.
The mandate covers allowed tokens with a per-transaction and a rolling 24 hour limit, a reserve (the share of deposits the agent may never deploy), allowed pools (up to 4), an expiry, pause and instant revocation.
Every token the agent receives (LP tokens, swap output) must land in an account owned by the vault. Only the owner can withdraw, at any time, including while paused.
Instructions#
| Instruction | Who | What it does |
|---|---|---|
| create | Owner | Creates vault number id with its mandate. |
| update_policy | Owner | Replaces the mandate; accounting for kept tokens is preserved. |
| set_agent | Owner | Sets or revokes (all zeros) the agent key. |
| set_paused | Owner | Pauses or resumes the agent. |
| deposit | Owner | Deposits an allowed token into the vault. |
| withdraw | Owner | Withdraws any token the vault holds. Always allowed. |
| agent_add_liquidity | Agent | Deposits into an allowed VYLO pool within limits and reserve. |
| agent_remove_liquidity | Agent | Withdraws from an allowed pool back into the vault. |
| agent_swap | Agent | Swaps between allowed tokens in an allowed pool within limits. |
| agent_bin_pool | Agent | Bin pool: open, add, remove, collect fees (5% routed), close, swap, all owned by the vault. |
Accounts#
| Account | Seeds | Notes |
|---|---|---|
| Vault | ["vault", owner, id (u64 LE)] | 528 bytes: owner, agent, mandate, per-token deposited / deployed / spent today, allowed pools. |
Guarantees#
- The agent can never withdraw or transfer to an outside account.
- Pausing, revoking and expiry take effect immediately for the next agent action.
- The agent can only call VYLO classic pools, bin pools and swaps whose output stays in the vault, never a transfer to a wallet.
Events#
Events are emitted as program data logs and can be indexed from transaction logs.
- Agent: vault, action, pool, amounts
Source and client#
Source: programs/vylo-agent-vault. TypeScript builders and decoders: @vylo/solana/programs. See the SDK.