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

# Swaps

> Bridge and swap in a single transaction using Warp's built-in solver liquidity.

Warp can bridge and swap in a single transaction. Specify the token you want on the destination chain, and if it differs from what the user holds, Warp routes through solver liquidity to swap and bridge automatically.

<Tabs>
  <Tab title="SDK">
    Request ETH on the target chain via `tokenRequests`. If the user only holds another token there (or on the source chain), Warp swaps and bridges to cover it:

    ```ts theme={null}
    import { baseSepolia, arbitrumSepolia } from 'viem/chains'

    const ethAmount = 2n
    const receiver = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045'

    const prepared = await rhinestoneAccount.prepareTransaction({
      sourceChains: [baseSepolia],
      targetChain: arbitrumSepolia,
      calls: [
        {
          to: receiver,
          value: ethAmount,
        },
      ],
      tokenRequests: [
        {
          address: 'ETH',
          amount: ethAmount,
        },
      ],
    })
    const signed = await rhinestoneAccount.signTransaction(prepared)
    const transaction = await rhinestoneAccount.submitTransaction(signed)
    ```

    If the user has USDC on Base Sepolia, Warp will swap it to ETH, bridge to Arbitrum Sepolia, and execute the transfer.

    <Note>The token address in `calls` and `tokenRequests` must correspond to the *target* chain.</Note>
  </Tab>

  <Tab title="API">
    When you request a token on the destination chain that differs from the user's source token, Warp routes through the solver market to bridge and swap in a single operation. No additional parameters are required — the quote response tells you what will be spent and what will be received.

    In a swap, `cost.input` and `cost.output` show different tokens:

    ```json theme={null}
    {
      "cost": {
        "input": [
          {
            "chainId": "eip155:8453",
            "tokenAddress": "0x4200000000000000000000000000000000000006",
            "symbol": "WETH",
            "decimals": 18,
            "price": { "usd": 2412.37 },
            "amount": "959454558006521"
          }
        ],
        "output": [
          {
            "chainId": "eip155:10",
            "tokenAddress": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
            "symbol": "USDC",
            "decimals": 6,
            "price": { "usd": 0.99 },
            "amount": "2000000"
          }
        ],
        "fees": {
          "total": { "usd": 0.31 },
          "breakdown": {
            "gas": { "usd": 0.30, "sponsored": false },
            "swap": { "usd": 0.01, "sponsored": false },
            "bridge": { "usd": 0.0004, "sponsored": false }
          }
        }
      }
    }
    ```

    Here the user spends WETH on Base (`eip155:8453`) to receive USDC on Optimism. `output.amount` matches the requested amount exactly — fees are paid in input tokens and surfaced via `cost.fees.breakdown`.

    For the full quote and submission flow, see the [API Quickstart](../../intents/quickstart).
  </Tab>
</Tabs>
