# How It Works (/onramp/earn/how-it-works)

> For the complete documentation index, see [llms.txt](/llms.txt)



<Callout type="warn" title="Beta">
  ZeroDev Earn is an experimental product offered in beta. It supports your
  integration with third-party protocols. ZeroDev does not provide these
  protocols or the services they offer, does not custody assets, and does not
  execute or control transactions; any transactions are solely between you (or
  your end users) and the applicable third-party protocol. Any APY, rewards,
  or other amounts are provided by such protocols, not ZeroDev, and all data
  is supplied by third parties for informational purposes only. Use involves
  significant risk, including smart contract failures, market volatility,
  illiquidity, lockup, and loss of principal. ZeroDev is not liable for any
  losses arising from use of the product or the third-party protocols it
  surfaces. You are responsible for ensuring your end users understand these
  risks and for any disclosures required by applicable law. Do your own
  independent research and proceed at your own risk.
</Callout>

Every Earn deposit uses a [Smart Routing Address](/onramp/smart-routing-address) (SRA), including same-chain deposits.

## Participants [#participants]

| Participant      | Responsibility                                                                          |
| ---------------- | --------------------------------------------------------------------------------------- |
| Your application | Requests a quote, submits source-chain calls, stores the SRA, and tracks status         |
| Owner            | Funds and signs the deposit, receives the vault position, and authorizes recovery       |
| Earn service     | Resolves the vault and route, validates the target, reads capacity, and creates the SRA |
| SRA              | Holds the route configuration and executes its stored destination actions               |
| Relayer          | Bridges funds when required and triggers destination execution                          |
| Vault protocol   | Accepts the deposit and issues the resulting position to the owner                      |

## Deposit sequence [#deposit-sequence]

```text
Application       request quote
Earn service      validate target and create SRA
Owner             fund SRA on source chain
Relayer           bridge funds, if cross-chain
Relayer           execute stored vault actions
Application       track SRA status
```

<div className="fd-steps">
  <div className="fd-step">
    ### Quote [#quote]

    The service:

    1. Resolves the funding token and destination vault.
    2. Selects the registered protocol adapter.
    3. Validates the target on-chain.
    4. Reads current deposit capacity.
    5. Creates an SRA containing the destination actions.
    6. Returns the source-chain calls and estimates.

    For ERC-4626 targets, validation reads `asset()` and capacity through `maxDeposit(owner)`. Aave validation checks the destination reserve and pool configuration.

    Stored SRA actions cannot be changed after creation.
  </div>

  <div className="fd-step">
    ### Funding [#funding]

    The owner submits every call in `quote.transaction.calls` or the equivalent `quote.userOp` batch. The final funding call transfers the source token to `quote.sra`.

    The SDK does not submit this transaction.
  </div>

  <div className="fd-step">
    ### Routing [#routing]

    For a cross-chain deposit, the relayer bridges funds to the SRA on the destination chain. A same-chain deposit skips the bridge but still waits for SRA execution.

    The route can deliver the funding token directly or use an SRA-supported cross-token route when the vault asset differs.
  </div>

  <div className="fd-step">
    ### Execution [#execution]

    The relayer executes the actions stored in the SRA:

    1. Approve the protocol target.
    2. Deposit or supply the amount received.
    3. Send the resulting vault shares or aTokens to the owner.

    The destination actions use the amount available at execution rather than the quote's original estimate.
  </div>

  <div className="fd-step">
    ### Status [#status]

    Status is scoped to the SRA, not to an individual quote. Quotes with the same owner and routing configuration can resolve to the same SRA and therefore share status.

    ```text
    PENDING -> BRIDGING -> EXECUTING -> COMPLETED
                                     -> FAILED
    PENDING (no funds within 1 hour) -> ABANDONED
    ```

    `getStatus` derives the state from observed deposits, bridge transactions, and executions associated with the SRA.
  </div>
</div>

## Where funds are held [#where-funds-are-held]

| Stage                        | Location                                               |
| ---------------------------- | ------------------------------------------------------ |
| Before funding               | Owner wallet                                           |
| Funded, before bridge        | SRA on the source chain                                |
| During bridge                | Bridge protocol route addressed to the destination SRA |
| Bridged, before execution    | SRA on the destination chain                           |
| After execution              | Vault position held by the owner                       |
| Failed destination execution | SRA, until owner-authorized recovery                   |

ZeroDev operates the relayer. The relayer does not own funds held by the SRA. SRA funds move through stored actions or an owner-authorized withdrawal.

## Quote expiry [#quote-expiry]

`expiresAt` is approximately 60 seconds after quote creation. It is an estimate-validity timestamp, not an SRA expiration.

Funding after `expiresAt` is not rejected solely because the timestamp passed, but fees, received amount, shares, APY, and deposit capacity may have changed. Request a new quote when deposit parameters change or before refreshing estimates.

## Slippage [#slippage]

`slippage` is set in basis points when requesting a quote. Default: 100 bps.

The SRA enforces the corresponding minimum output during execution. Cross-chain quotes also verify that the slippage budget covers route fees. If it does not, the request returns `SLIPPAGE_TOO_LOW` with `details.minSlippageBps`.

## Failure after funding [#failure-after-funding]

If vault capacity changes or a destination call reverts, funds remain in the SRA for [owner-authorized recovery](/onramp/earn/usage#recover-funds-from-an-sra). Tokens sent outside the configured route also require recovery.

If no funding arrives within one hour, status becomes `ABANDONED`. Late funds can still execute; start a new watcher to resume tracking. See [Errors](/onramp/earn/reference#errors) for quote and watcher failures.
