User flows and examples / Swaps
Solana and Sui swaps
Two routes move a coin with no Bitcoin involved: between an EVM chain and Solana or Sui, and between two Solana coins. They are the routes the Maxy app takes for the same pairs, on the same code. The user's own wallet sends one checked transaction to the user's own address, and Maxy never holds the coins. A Sui pair is offered while its LI.FI leg answers; GET /pairs lists it under unavailable meanwhile.
| Route | Pairs | Carrier | What the wallet sends |
|---|---|---|---|
chain-swap | Any EVM token to a Solana or Sui coin, and back | One LI.FI route | An EVM transaction, a Solana transaction, or Sui transaction bytes |
sol-swap | Two Solana coins | Jupiter | A Solana transaction |
Place the order
The same four calls as Coin to coin: quote with both wallets, post the quote's order, send what comes back, then POST /orders/submit with its hash, signature or digest. The quote's signing.kind names the wallet that sends: evm_tx, solana_tx or sui_tx. In the sandbox, simulatedHash stands in for it.
curl -s -G "$BASE/quote" -H "x-maxy-key: $MAXY_API_KEY" --data-urlencode "from=USDC on base" --data-urlencode "to=SOL" \ -d amount=10 -d fromAddress="$WALLET" -d toAddress="$SOLANA_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)"
With the SDK, execute builds the route for each side's own signer (evm, solana, sui) and pays destAddress when one is named:
import { createMaxyClient, evmSignerFromPrivateKey, suiSignerFromKey, type SolanaSigner } from 'maxy-labs'; declare const solana: SolanaSigner; // the wallet's own Solana provider const maxy = createMaxyClient(); const evm = evmSignerFromPrivateKey(process.env.EVM_KEY!); const sui = suiSignerFromKey(process.env.SUI_KEY!); await maxy.swap.execute({ from: 'USDC on base', to: 'SOL', amount: '10', evm, solana }); await maxy.swap.execute({ from: 'SOL', to: 'BONK', amount: '0.1', solana }); // a coin written alone takes the other side's chain await maxy.swap.execute({ from: 'SUI', to: 'USDC on base', amount: '5', sui, evm });
From the command line, price and swap take the same words. A swap from Solana signs with MAXY_SOLANA_KEY, one from Sui with MAXY_SUI_KEY:
maxy price 10 usdc base to sol maxy swap 0.1 sol to bonk --yes
From an EVM token, an approve step may come first: it approves exactly the amount for the LI.FI Diamond. Follow steps in order.
What is checked before the wallet signs
- From an EVM chain. The transaction goes to the LI.FI Diamond, pays the user's own address on the other chain, and moves the coin and amount asked for, with no call after it.
POST /orderssimulates it from the wallet: ifsimulation.okis false, do not send it. - From Solana. The transaction is simulated against the wallet's own accounts: at most the amount sold and a bridge's own SOL fee may leave it. A Jupiter swap may call only Jupiter's programs, and the coin bought must arrive in the same wallet.
- From Sui. LI.FI builds the transaction from the wallet's own coins and names both wallets. One that names another wallet is refused.
Anything else is verification_failed, and nothing is sent. A sol-swap pays the wallet that sends it, so its toAddress is the same as fromAddress.
Track it
GET /status?orderId=<source transaction>&chainId=<source chain>&toChainId=<destination chain>&route=chain-swap. The chain ids are LI.FI's, as the order carries them: Solana is 1151111081099710, Sui 9270000000000000. The order is completed once the coin has arrived, and receiving.txHash names the transaction that delivered it. A sol-swap is one Solana transaction: GET /status?orderId=<signature>&route=sol-swap reads completed once it lands.
Parity with the Maxy app
Every pair the Maxy app swaps also trades through the API, the SDK and the command line on the same code path: Bitcoin to and from every listed chain, any EVM token to any other, and the two routes above. GET /pairs lists them in pairs, anyToken and coinToCoin. Limit orders, DCA, Grid and Multi stay in the Maxy app for now: the API, the SDK and the command line place market swaps.