Find something... ⌘K

Swaps / Routes

Other coins

The same order with a different coin. USDC signs without gas, SOL pays from a Solana wallet, and coin to coin moves between EVM chains with no Bitcoin. The samples use the setup from Get a quote.

Pay with USDC

USDC on Base and Arbitrum needs no gas. The wallet signs once or twice and sends nothing: the solver opens the escrow.

curlTypeScriptPython
Copy
curl -s -G "$BASE/quote" -H "x-maxy-key: $MAXY_API_KEY" --data-urlencode "from=USDC on base" -d to=BTC -d amount=20 \ -d fromAddress="$WALLET" -d toAddress="$MY_BTC_ADDRESS" > quote.json SIGS='{}' for ID in $(jq -r '.steps[] | select(.kind == "signature") | .id' quote.json); do SIG=$(cast wallet sign --private-key "$TEST_WALLET_KEY" --data "$(jq -c --arg id "$ID" '.steps[] | select(.id == $id) | .typedData' quote.json)") SIGS=$(echo "$SIGS" | jq -c --arg id "$ID" --arg sig "$SIG" '. + {($id): $sig}') done curl -s -X POST "$BASE/orders" -H "x-maxy-key: $MAXY_API_KEY" -H "content-type: application/json" \ -d "$(jq -c --argjson sigs "$SIGS" '{order: .order, signatures: $sigs}' quote.json)"

The quote's route is evm-btc-gasless. The wallet signs a USDC permit, when the allowance is short, and a transfer bound to this order. Steps appear only for a wallet that holds the USDC; otherwise issues.balance says what is missing. The sandbox reads no balances, so any wallet works there. After that, the states, webhook and refund rule are the same.

If the solver never opens the escrow, the USDC never left the wallet: the signature lapses 2 hours after signing, the order reads refundable, and there is nothing to refund.

Pay with SOL

The wallet signs a readable request, then the deposit. The SOL goes into the settlement program's escrow, never to a Maxy address. The sample runs with a test key once wallet is yours: your wallet adapter, in the shape below.

TypeScript Copy
import { createMaxyClient } from '@maxy-labs/sdk/core'; import { buyBtcWithSolana } from '@maxy-labs/sdk/solana'; const wallet = { address: publicKey.toBase58(), // the connected wallet signMessage: (text) => adapter.signMessage(new TextEncoder().encode(text)), // a readable request signTransaction: (base64) => signWithYourAdapter(base64), // signs, does not send; answers base64 }; const done = await buyBtcWithSolana({ client: createMaxyClient(), // reads MAXY_API_KEY wallet, amount: '1', // whole SOL recipient: 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4', onProgress: (state) => console.log(state), }); console.log(done.order.state, done.bitcoinTxid);
  1. 01 The solver opens its offer on chain.
  2. 02 The SOL locks in the program's escrow.
  3. 03 The solver pays the BTC to the user's address.
  4. 04 The payment is proven on Solana after one Bitcoin confirmation, and the SOL goes to the solver.

An offer the user never funds expires after 10 minutes (quote_expired: quote again). An escrow whose BTC is never proven refunds the user's wallet when it expires. The smallest order is about $2. Live, the BTC can go to a bc1q… or a bc1p… address; the sandbox takes bc1q… only.

Over HTTP: GET /quote with from=SOL, sign the quote step's message, POST /orders, sign the deposit it returns, then post it to POST /orders/{id}/steps. Track with GET /status?orderId=…&route=sol-btc.

The other way, BTC to SOL: GET /quote with from=BTC&to=SOL, then follow steps, or use swap.createBtcToSolOrder and swap.settleBtcToSol. If the fresh price is over 0.1% below the quote, the answer is quote_mismatch: quote again.

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.

curlTypeScriptPython
Copy
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) # live: send .transaction from the wallet, use its hash 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)"

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.