Swap build
swap_buildBuild an UNSIGNED swap transaction on X1 at the best price across XDEX and APEX AMM — direct, or two hops through XNT or APEX in ONE transaction, simulated against your wallet before it is returned. Returns base64 you sign with your own key and broadcast yourself; this server never holds your keys and never signs for you. Use mint addresses, or the string "native" for XNT. APEX mint is Du6Z596DwGnfUcMSyRHSBQzNybiQKu8GESVfruEv9Jqr. Check priceImpact before signing — thin pools move hard. Building is free. When you spend XNT (more than 0.01), the transaction includes a 0.1% platform fee to the APEX buyback wallet, shown as platformFee in the answer; otherwise you pay only the network fee.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"tokenIn": "<tokenIn>",
"tokenOut": "<tokenOut>",
"amount": "<amount>",
"wallet": "<wallet>"
},
"name": "swap_build"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount of tokenIn, in whole tokens (not raw units). | |
| wallet | Yes | Your X1 wallet public key — it will be the fee payer and signer. | |
| tokenIn | Yes | Mint address to spend, or "native" for XNT. | |
| slippage | No | Slippage tolerance as a fraction. Default 0.01 (1%). | |
| tokenOut | Yes | Mint address to receive, or "native" for XNT. |