Find something... ⌘K

User flows and examples / Swaps

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.

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.

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) 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.

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 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

StepWhat the wallet does
approve-resetOnly for a token that refuses a new allowance over an old one: sets it to 0. Wait for it to confirm
approveApproves exactly this amount for the bridge. Wait for it to confirm
sendSends 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.