> ## Documentation Index
> Fetch the complete documentation index at: https://zyfai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent Vaults

Agent Vault is a new automated vault primitive built by Zyfai. It exposes a standard ERC-4626 interface to integrators while running ERC-7540 asynchronous operations under the hood, with the full curation lifecycle (NAV updates, withdrawal processing, rebalancing execution) automated by Zyfai's infrastructure.

### The Problem with Vault Curation

Most production vaults use the ERC-7540 standard or similar async implementations. ERC-7540 solved a real technical constraint: synchronous ERC-4626 vaults cannot support complex multi-protocol strategies that need to unwind positions before settling. But in making operations asynchronous, it created a heavy manual operational loop that repeats daily:

1. **Request.** Users call `requestRedeem` to signal withdrawal intent. Shares are transferred to the vault.
2. **Settlement.** The curator manually reviews NAV from price oracles, unwinds positions across protocols, executes swaps, and approves all queued redemption requests at a single valuation point.
3. **Claim.** Users must return (typically 24+ hours later) to claim their assets. The curator cannot claim on behalf of users.

This workload scales linearly with the number of strategies a vault runs. It creates a distribution bottleneck: fintechs, neobanks, and wallets that want to offer DeFi yield must either build an in-house curation team or not offer yield at all.

### How Agent Vaults Work

Zyfai built a vault contract that automates the entire curation lifecycle. From the integrator's perspective, it behaves like a standard ERC-4626 vault: deposits go in, yield accrues, withdrawals come out. No async complexity exposed.

**Setup is three steps:**

1. Deploy the vault (ships with built-in multisig control via a Nested Safe).
2. Associate it with a [Zyfai Smart Account](/docs/product/infra/safe7579).
3. Done. The vault runs autonomously from this point.

The vault contract is open and permissionless. Anyone can deploy an instance and connect it to a Zyfai Smart Account. Source code is available on [GitHub](https://github.com/ondefy/erc7540-wrapper).

### Architecture

The Agent Vault architecture consists of four components, each responsible for a single layer of the system: ownership, accounting, execution, and automation.

```mermaid theme={null}
    flowchart TD
    subgraph high_trust["🔴 High Trust"]
        multisig["<b>Gnosis Safe Multisig</b>
        ───────────
        • forceTransmit*
        • setSmartAccount
        • allocateAssets
        • pause / unpause
        • upgrade beacon"]
    end

    subgraph no_trust["🟢 No Trust Required"]
        user["<b>User</b>
        ───────────
        • deposit / mint
        • requestRedeem / requestWithdraw
        • claim
        • setOperator"]

        operator["<b>ERC-7540 Operator</b>
        ───────────
        • Aggregators, routers
        • Acts on behalf of controller
        (requires explicit approval)"]

        user -- "approves" --> operator
    end

    subgraph medium_trust["🟡 Medium Trust"]
        indexer["<b>Indexer (Off-chain)</b>
        ───────────
        • Polls pendingWithdrawals
        • Fulfills withdrawals via SA
        • Syncs NAV (PnL)
        • Reallocates idle assets"]

        vault["<b>SmartAccountWrapper (Vault)</b>
        ───────────
        • ERC-4626 / ERC-7540
        • Manages shares & requests
        • Tracks allocatedAssets
        • ERC-1271 signature delegation"]

        smart_account["<b>Zyfai Smart Account</b>
        ───────────
        • Holds allocated assets
        • Executes DeFi strategies
        • transmitAllocatedAssets
        • transmitDeallocatedAssets"]

        indexer -- "monitors" --> vault
        indexer -- "calls transmit*" --> smart_account
        vault -- "owns" --> smart_account
        vault -- "assets flow" --> smart_account
    end

    multisig -. "controls" .-> medium_trust
    multisig -. "owns" .-> vault
    user -- "deposit / withdraw" --> vault
    operator -- "acts on behalf" --> vault

    style high_trust fill:#fde2e2,stroke:#e06666,color:#000
    style no_trust fill:#d9ead3,stroke:#6aa84f,color:#000
    style medium_trust fill:#e2d5f0,stroke:#8e7cc3,color:#000
    style vault fill:#cfe2f3,stroke:#6d9eeb,color:#000
    style smart_account fill:#fff2cc,stroke:#f6b26b,color:#000
    style multisig fill:#f4cccc,stroke:#cc0000,color:#000
    style user fill:#d9ead3,stroke:#6aa84f,color:#000
    style operator fill:#d9ead3,stroke:#6aa84f,color:#000
    style indexer fill:#d9d2e9,stroke:#8e7cc3,color:#000
```

**Safe Multisig (Owner)** has full control over the vault: upgrades, asset reallocation, parameter changes. No timelock on upgrades; the multisig threshold is the security boundary. Users opt into this trust model.

**SmartAccountWrapper (Vault)** is the accounting layer. This is the contract that integrators deploy and users interact with. It handles share minting and redemptions, tracks the value of capital deployed into DeFi via `allocatedAssets`, and exposes both ERC-4626 (synchronous) and ERC-7540 (asynchronous) interfaces. It also supports ERC-1271 signature delegation, allowing aggregators, routers, and other ERC-7540 operators to act on behalf of depositors.

**Zyfai Smart Account** is where allocated capital lives and DeFi strategies execute. It reports value back to the Vault via `transmitAllocatedAssets()` (capital deployed out) and `transmitDeallocatedAssets()` (capital returned).

**Indexer** is the automation engine. In a standard ERC-7540 vault, NAV updates require manual curator review and approval. In an Agent Vault, every 60 seconds, it polls `pendingWithdrawals()`, fulfills them through the Smart Account, syncs the NAV, and reallocates idle capital. **This single service replaces the curator's entire daily operational workflow**.

### Who This Is For

**Integrators.** A fintech, neobank, or wallet can plug in a single ERC-4626 vault and offer yield to their users without hiring a curation team, monitoring TVL, or processing settlements.

**Curators.** The operational burden that limits how many vaults a curator can manage disappears. Curators focus on strategy selection and risk parameters. Execution runs on its own.

**Agents.** The barrier to launching a vault drops from "build and operate a curation team" to "deploy a contract and configure."

### Resources

* Vault contract source: [github.com/ondefy/erc7540-wrapper](https://github.com/ondefy/erc7540-wrapper)
* Full architecture documentation: [ARCHITECTURE.md](https://github.com/ondefy/erc7540-wrapper/blob/main/ARCHITECTURE.md)
