User flows and examples / Swaps
Any token to BTC
Buy BTC with any token on Base, Arbitrum, BNB Chain, Avalanche, Robinhood Chain, Ethereum, Optimism, Polygon, Linea, zkSync Era, HyperEVM, Mantle, Berachain, Abstract, ApeChain or Monad, on route evm-btc-bridge. It is two legs, both from the user's own wallet: a swap or bridge into the own coin of a chain with a settler, then the escrow buy there, as on Buy BTC. Maxy never holds the coins between the legs. The Maxy app buys BTC with such a token the same way.
The two legs
| Leg | What happens | Where |
|---|---|---|
bridge | The solver's route picker swaps or bridges the token into the settler chain's own coin, paid to the same wallet. Before anything is signed, Maxy checks that the transaction pays that wallet, with a guaranteed minimum out. | The token's own chain |
escrow | The wallet opens the escrow with that coin, as on evm-btc-escrow. A solver pays the BTC and is paid from escrow on proof. | The token's chain when it has a settler (a same-chain swap), Base otherwise |
The BTC is sized from the leg's guaranteed minimum, less a little for the escrow transaction's gas. The signed intent fixes it, so toAmountMin equals toAmount. Each leg states its own minimum in legs.
Price it
Name the token by address, or by symbol when it has one on that chain. GET /tokens?chain=ethereum&search=PEPE finds the address. The samples use the setup from Get a quote.
curl -s -G "$BASE/price" -H "x-maxy-key: $MAXY_API_KEY" --data-urlencode "from=USDC on ethereum" -d to=BTC -d amount=50 \ | jq '{route, toAmount, toAmountMin, legs: [.legs[] | {leg, chainId, toChainId, toAmountMin}]}'
A live answer for 50 USDC on Ethereum: route evm-btc-bridge, toAmount 79,487 sats; the bridge leg into ETH on Base guarantees 0.0289 ETH, and the escrow takes at most 0.0286 ETH of it.
Place the order
GET /quote with fromAddress returns the steps in order: approve (the exact amount, only when the allowance is short), intent (signed before any coin moves), order, bridge, escrow, and partnerFee when you asked for one.
- 01 Send
approveand wait for it to confirm. Signintent. - 02
POST /orderswith the order and the signature. It answerstransaction, the swap leg, checked and simulated, andescrow.transaction, for later. - 03 Send
transactionbeforebridgeExpiresAt. ThenPOST /orders/submitwith{ order, signatures, bridgeTxHash }. - 04 Follow the
bridgepath that answer gives until it saysready: true: the coin is in the wallet on the settler chain. - 05 Send
escrow.transactionfrom the same wallet, thenPOST /orders/submitwith{ order, signatures, txHash }.
From there the order runs as any buy. GET /status reads the leg while the escrow is not open yet (rawStatus bridge:PENDING, then bridge:DONE), and the escrow after. The SDK's swap.execute and the REST flow buyBtcWithEvm run all five steps.
When a leg does not go through
| What happened | What the user has | What to do |
|---|---|---|
| The leg's carrier refunded or failed it | Their token back in the same wallet, from the carrier | Nothing was escrowed. The signed intent lapses unused |
| The leg landed and the escrow was never sent | The settler chain's coin in their wallet | Send the escrow, or keep the coin |
| No solver filled the escrow | Their coin in escrow | Take it back as on any buy: GET /orders/{id}/refund |
Tokens with no route
The route picker hands out only a transaction it can check against a price of the solver's own. For a token it has no price for (PEPE and LINK among them), GET /price still answers its number, and GET /quote answers routeAvailable: false, a message and no steps. Show the message, or offer the swap to the chain's own coin first.
Selling BTC for any token
The other way is btc-evm with two legs: the settler pays ETH on Base to the user's wallet, and that wallet bridges it to the token asked for (GET /orders/{id}/bridge). A quote whose bridge the route picker cannot prove has routeAvailable: false, so no BTC is paid for a coin that cannot be delivered.
In the sandbox
A test key runs this route with both legs simulated: the swap leg reads ready: true as soon as its simulatedHash is named, and the order walks to completed after the escrow's.