Build a swap
The instructions of the swap for userPublicKey, ready to assemble and sign, plus their
budget (transactionConfig) and what the transaction costs the wallet (costs). With
serialize: true the response also carries the whole unsigned v1 transaction
(swapTransaction) and lastValidBlockHeight.
Which route is built, in this order:
quoteResponse: the route of that quote, as quoted. No re-quote and no age check: build right after quoting, or the transaction may revert onminReturn. TheroutePlanis checked without I/O: each route must chain frominputMinttooutputMint, at most 4 steps per route and 2 routes, everylabela knowndex; otherwise400 bad_request.routeTicket: the signed route of a quote (only when the router setsROUTER_TICKET_SECRET; the public router does not).- Otherwise
inputMint+outputMint+amount(and the quote parameters): quoted now and built. The platform fee here isfeeBpswithfeeAccount;platformFeeBpsis a quote parameter and is ignored in a build body.
Types. amount takes a number or a decimal string and prioritizationFeeLamports its
own forms; every other numeric field (slippageBps, maxHops, reserveKeys, feeBps,
tipLamports, computeUnitPriceMicroLamports, transactionsFeeLamports, txVersion) must
be a JSON number: a string is 400 bad_request.
Assembling the transaction yourself: setupInstructions, then every entry of
swapInstructions (two for a split), then cleanupInstruction if present, then
otherInstructions, with transactionConfig in the v1 header (POST /tx/v1 does the
serialization). computeBudgetInstructions and addressLookupTableAddresses are always
empty: a v1 message carries its budget in the header and takes no lookup tables.
Differences from Jupiter: quoteResponse is optional; feeAccount is the fee
wallet (the router derives its token account); destinationTokenAccount is the
receiving wallet, not a token account; the transaction is v1 with no lookup tables;
extra fields swapInstructions, quoteId, buildId, shape, minReturn, maxAmountIn,
computeUnits, loadedAccountsDataSize, txVersion, transactionConfig, routePlan,
costs; no tokenLedgerInstruction, prioritizationType, simulationError or
dynamicSlippageReport; useSharedAccounts, dynamicComputeUnitLimit,
skipUserAccountsRpcCalls, dynamicSlippage, trackingAccount and blockhashSlotsToExpiry
are ignored.
Body
true: SOL input is wrapped from the wallet's lamports and its wSOL account closed after the swap; SOL output is unwrapped back to the wallet (not when destinationTokenAccount is another wallet). false: the route spends from and pays into the wallet's wSOL account. Alias unwrapSol
The fee in basis points. Pinned quote: must equal platformFee.feeBps when the quote priced one. On a quote that priced no fee it is added at build time and lowers the floor, so up to feeBps less than the quoted outAmount can arrive. Pair mode: priced like platformFeeBps, only with feeAccount
The priority fee, Jupiter style. A number is the total in lamports. "auto" takes the
75th percentile of recent prioritization fees, within 10,000 and 1,000,000 micro-lamports
per compute unit. priorityLevelWithMaxLamports is auto capped at maxLamports
(priorityLevel is ignored). jitoTipLamports adds a tip transfer to a Jito tip account
instead of a priority fee. Absent means no priority fee. The fee is charged on the declared
compute-unit limit, not on the units used.
The wallet that receives the output; the route delivers to its associated token account, created if missing. A token account here is 400 bad_recipient (an SPL multisig is accepted, as a wallet). When the last hop pays native SOL (a venue's native leg) the output can only go to userPublicKey: another wallet is 422 declined wire. Default userPublicKey. Alias recipient
Response
The instructions (and, with serialize, the unsigned transaction)
exact_out: one hop with a pinned output and an input cap. Any other ExactOut (several hops, or a venue without an exact-output instruction) is built as an exact-in shape that spends maxAmountIn with minReturn = the requested output. native_exact_in: one hop on a venue's native-SOL leg; token_exact_in_split: two routes
token_exact_in, native_exact_in, exact_out, token_exact_in_split