> For the complete documentation index, see [llms.txt](https://docs.enzyme.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.enzyme.finance/onyx-protocol/architecture/cross-chain-deposit-and-redeem.md).

# Cross-Chain Deposit and Redeem

Onyx supports deposits and redemptions from other chains via [**Chainlink CCIP**](https://docs.chain.link/ccip). Cross-chain support is a transport layer wrapped around the ordinary deposit and redeem flows on the vault's chain: the vault and its issuance components are unaware of cross-chain activity — from their perspective, they are dealing with an ordinary depositor on their own chain.

### Wallets Manager

The vault-chain side is coordinated by the **wallets manager** (the `WalletsManager`), a vault component that is the receiver of all incoming CCIP messages. For each message, it deploys the sender's depositor wallet if needed, forwards any bridged tokens to it, and executes the message's instructions through it. It is the only account authorized to operate the depositor wallets, and always on behalf of each wallet's one depositor.

### Depositor Wallets

Each (**source chain**, **depositor**) pair gets its own dedicated **depositor wallet** contract on the **vault chain** (the `DepositorWallet`), deployed by the wallets manager the first time a message arrives from that depositor.

The depositor wallet acts as the depositor's on-chain representative on the vault chain:

* It holds the depositor's bridged assets and shares.
* It is the account that the vault's deposit and redeem handlers see as their depositor and request controller.

Depositor wallet addresses are deterministic, so a depositor's wallet address can be computed in advance — before it is deployed — and used as a parameter in the instructions of the first message.

### Deposit Flow

A cross-chain deposit is a single CCIP message from the source chain, carrying the deposit asset together with instructions for what to do with it:

1. The depositor sends a CCIP message from the source chain, bridging the deposit asset and including instructions (e.g. approve and deposit).
2. On the vault chain, the wallets manager deploys the depositor wallet if it does not yet exist, and forwards the bridged asset to it.
3. The depositor wallet executes the instructions, performing the ordinary vault-chain deposit — either a sync deposit (shares minted immediately) or a request to the async deposit queue (executed later in a batch by an admin).
4. Shares are minted to the depositor wallet, where they remain held on the depositor's behalf.

```mermaid
sequenceDiagram
    participant Depositor as Depositor (source chain)
    participant Manager as Wallets manager (vault chain)
    participant Wallet as Depositor wallet (vault chain)
    participant Vault as Deposit handler + vault

    Depositor->>Manager: CCIP message (asset + instructions)
    Manager->>Wallet: deploy (first use) and forward asset
    Manager->>Wallet: execute instructions
    Wallet->>Vault: deposit (sync or request)
    Vault-->>Wallet: shares minted to wallet
```

### Getting Tokens Back

Shares minted on deposit remain in the depositor wallet on the vault chain — they do not need to be bridged, since the wallet holds them on the depositor's behalf and can use them for a later redemption.

Assets, on the other hand — after a redemption or a cancellation — are sent back to the depositor on the source chain via CCIP. There are two ways this happens:

* **Batched by a keeper**: an admin-authorized keeper triggers the return for many depositor wallets at once (typically right after executing a batch of queued requests), paying the CCIP fees.
* **Triggered by the depositor**: the depositor sends a follow-up CCIP message instructing their wallet to return specified tokens. The CCIP fee is deducted from the returned token amount (or paid from a fee token bridged along with the message).

The same return leg can carry any token held by the depositor wallet — including shares, though bridging shares to the source chain is not part of the standard flow.

### Redeem Flow

A cross-chain redemption reuses the same machinery, but with the token movement reversed: nothing is bridged in — the shares are already in the depositor wallet on the vault chain — and the redeemed assets are bridged out over the return leg:

1. The depositor sends a CCIP message from the source chain carrying only instructions (no tokens).
2. The wallets manager executes the instructions through the depositor wallet, which submits a redeem request to the vault's redeem handler.
3. An admin executes the queued request; the redeemed assets land in the depositor wallet.
4. The assets are sent back to the depositor on the source chain — batched by a keeper or triggered by the depositor, as described above.

```mermaid
sequenceDiagram
    participant Depositor as Depositor (source chain)
    participant Manager as Wallets manager (vault chain)
    participant Wallet as Depositor wallet (vault chain)
    participant Vault as Redeem handler + vault

    Depositor->>Manager: CCIP message (instructions only)
    Manager->>Wallet: execute instructions
    Wallet->>Vault: redeem request (shares)
    Note over Vault: admin executes queued requests
    Vault-->>Wallet: redeemed assets to wallet
    Wallet-->>Depositor: assets returned via CCIP
```

### Cancellation

While a queued deposit or redeem request is still pending, the depositor can cancel it with a follow-up cross-chain message. The refunded tokens land back in their depositor wallet and can be sent back to the source chain within the same message.

### Failure Safety

* **Failed instructions**: the token transfer and the instructions are decoupled. If the instructed action fails on arrival (e.g. a misconfigured deposit), the bridged tokens still land safely in the depositor wallet — nothing reverts back to the bridge. The depositor simply sends a follow-up message to retry the action or pull the tokens back.
* **Isolation**: each depositor's funds only ever touch their own depositor wallet, so a failure or pending state for one depositor never affects another.

```mermaid
sequenceDiagram
    participant Depositor as Depositor (source chain)
    participant Manager as Wallets manager (vault chain)
    participant Wallet as Depositor wallet (vault chain)

    Depositor->>Manager: CCIP message (asset + instructions)
    Manager->>Wallet: forward asset
    Manager--xWallet: instructions fail (asset stays in wallet)
    Depositor->>Manager: follow-up message (retry / return)
    Manager->>Wallet: execute follow-up instructions
    Wallet-->>Depositor: tokens returned via CCIP
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.enzyme.finance/onyx-protocol/architecture/cross-chain-deposit-and-redeem.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
