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

# Swaps inside your app

> Wallet helpers for swaps, multi-swaps and pool deposits.

<Info>The preview SDK supports swaps and sequential multi-swaps. Zaps are not enabled yet; `capabilities().zap.available` is false.</Info>

Install the versioned preview package:

```bash theme={null}
npm install https://build.route.fun/downloads/route-fun-sdk-0.2.0-preview.2.tgz viem
```

This is a downloadable preview, not a published npm-registry package.

Keep your API key on your backend. Users review and sign with their wallet in your app.

Route selects Robinhood Chain automatically; you do not need to pass `chainId`. Wallet helpers still verify the connected network.

| Flow       | Call                              | What happens                                    |
| ---------- | --------------------------------- | ----------------------------------------------- |
| Swap       | `wallet.swap({ id, input })`      | Approve if needed, refresh, sign, track receipt |
| Multi-swap | `wallet.multiSwap({ id, input })` | Trade each allocation sequentially              |
| Pool zap   | `zapWallet.zap({ id, input })`    | Swap and deposit in one atomic wallet batch     |

Supply your connected wallet, authenticated backend callbacks, durable store and review UI. The swap helper also checks the reviewed builder deployment. No redirect is needed.

```js theme={null}
await wallet.multiSwap({
  id: crypto.randomUUID(),
  input: {
    execution: 'sequential', payer,
    inputs: [{ token: usdg, amount: '100000000' }],
    outputs: [
      { token: eth, weightBps: 5000 },
      { token: ai, weightBps: 5000 },
    ],
    builderCode, builderFeeBps: 25, slippageBps: 50,
  },
});
```

Weights divide each input, not final portfolio dollar values. Each trade uses normal builder fees and preparation limits. Completed trades remain completed if a later trade stops. The helper records settlements and resumes from the next leg.

Zaps require an enabled backend and an atomic-capable wallet. They count workspace usage but collect no extra builder fee. Wallet account upgrades may be required and must be disclosed; upgraded accounts cannot use the current EOA-only builder swap path. The backend restricts deposits to supported pools.

```js theme={null}
await wallet.resume(id);   // Check without signing
await wallet.continue(id); // Continue after user action
```

Keep the operation ID across reloads. Recover an uncertain swap with its transaction hash, or a zap with its wallet batch ID. Never create another operation to bypass a pending submission.

[Capabilities](/api-reference/v2-builders-capabilities) · [Integration API](/api-reference/v2-builders-integration)
