# Coin to coin

Move a coin between EVM chains, with no Bitcoin involved, on route `cross-evm`. The wallet sends one checked transaction to a bridge. Maxy's settler takes no part, and Maxy never holds the coins. Maxy uses a settler route whenever one exists. Use this one to get a coin onto a chain and token a Bitcoin swap accepts, such as ETH on Base to ETH on Arbitrum. Solana and Sui have their own: [Solana and Sui swaps](https://maxy.co/docs/solana-and-sui-swaps).

## Place the order

Quote, post the quote's `order`, send the transaction that comes back, then tell Maxy its hash. There is nothing to sign first. In the sandbox, `simulatedHash` stands in for the hash; live, send `transaction` from the wallet and use its hash. The samples use the setup from [Get a quote](https://maxy.co/docs/buy-btc#get-a-quote).

```sh
curl -s -G "$BASE/quote" -H "x-maxy-key: $MAXY_API_KEY" --data-urlencode "from=ETH on base" --data-urlencode "to=ETH on arbitrum" \
  -d amount=0.005 -d fromAddress="$WALLET" -d toAddress="$WALLET" > quote.json
curl -s -X POST "$BASE/orders" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \
  -d "$(jq -c '{order: .order}' quote.json)" > placed.json
TX_HASH=$(jq -r .transaction.simulatedHash placed.json)
curl -s -X POST "$BASE/orders/submit" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \
  -d "$(jq -c --arg tx "$TX_HASH" '.next.body + {txHash: $tx}' placed.json)"
```

```ts
const headers = { 'x-maxy-key': KEY, 'content-type': 'application/json' };
const q = new URLSearchParams({ from: 'ETH on base', to: 'ETH on arbitrum', amount: '0.005', fromAddress: account.address, toAddress: account.address });
const quote = await fetch(`${BASE}/quote?${q}`, { headers }).then((r) => r.json());
const placed = await fetch(`${BASE}/orders`, { method: 'POST', headers, body: JSON.stringify({ order: quote.order }) }).then((r) => r.json());

const tx = placed.transaction;
const txHash = tx.simulated ? tx.simulatedHash : await walletClient.sendTransaction({ to: tx.to, data: tx.data, value: BigInt(tx.value) });
await fetch(`${BASE}/orders/submit`, { method: 'POST', headers, body: JSON.stringify({ ...placed.next.body, txHash }) });
```

```python
headers = {"x-maxy-key": KEY}
quote = requests.get(f"{BASE}/quote", headers=headers, params={
    "from": "ETH on base", "to": "ETH on arbitrum", "amount": "0.005", "fromAddress": account.address, "toAddress": account.address,
}).json()
placed = requests.post(f"{BASE}/orders", headers=headers, json={"order": quote["order"]}).json()

tx = placed["transaction"]
tx_hash = tx["simulatedHash"] if tx.get("simulated") else your_wallet_sends(tx)
requests.post(f"{BASE}/orders/submit", headers=headers, json={**placed["next"]["body"], "txHash": tx_hash})
```

A token, unlike ETH, can add an `approve` step first: follow `steps` in order. Track with `GET /status?orderId=…&chainId=8453&toChainId=42161&route=cross-evm`. The states are the same, and `failed` can happen here. A pair with no route answers `unsupported_route`: pick from `GET /pairs`.

## How the route is chosen

Each quote is the solver's route picker's: of Mayan, deBridge, Across and LI.FI, the one that pays out most after every fee, with a transaction that pays the user's own address. The number shown is that route's, so its fees are already out of `toAmount`.

For routers that are bridges themselves, LI.FI among them: the routes that end in one settler step (`evm-btc-escrow`, `evm-btc-gasless`, `btc-evm` paid by a settler, `sol-btc`, `btc-sol`) call no bridge, LI.FI included, so a route through them cannot loop back. The two-leg routes (`evm-btc-bridge`, a `btc-evm` sale paid out through a bridge) and coin to coin use this route picker. Every route works for every key, a bridge's own included. A bridge that wants no route looping back through it can leave out the two-leg routes and coin to coin: each carries a bridge leg of Maxy's own. Where the SDK asks LI.FI itself (the Tron and Sui legs, a leg's status), it goes through Maxy's host and sends only the route's fields and Maxy's integrator name, `maxy`, so LI.FI records these calls as Maxy's. [Router intake](https://maxy.co/docs/router-intake) has the rest of a router's form.

Before sending, the SDK checks the transaction by the rules of the provider that carries it:

- the provider's own contract, and the user's address as the receiver;
- the coin and amount asked for, and the quoted minimum where the calldata states one;
- native value of the amount plus at most the provider's own fee;
- a token approval for exactly the amount, to that contract.

Another provider, or calldata that does not decode, is `verification_failed`, and nothing is sent. Over HTTP, `POST /orders` answers the transaction checked and simulated: if `simulation.ok` is false, do not send it.

## Approvals and expiry

| Step | What the wallet does |
| --- | --- |
| `approve-reset` | Only for a token that refuses a new allowance over an old one: sets it to 0. Wait for it to confirm |
| `approve` | Approves exactly this amount for the bridge. Wait for it to confirm |
| `send` | Sends the bridge transaction from `POST /orders`, then `POST /orders/submit` with its hash |

A route's transaction carries its own expiry, and a quote is valid no longer than that. An order from a stale quote is `409 quote_expired` with `details.freshQuote`: quote again, nothing was sent. More on allowances: [Approvals and permits](https://maxy.co/docs/approvals-and-permits).

---
Source: https://maxy.co/docs/coin-to-coin (Maxy Docs › User flows and examples › Swaps)
