Swap Instructions
Get swap instructions for Solana that allow you to build custom transactions with your own instructions (e.g., Jito tips, fee transfers).
Documentation Index
Fetch the complete documentation index at: https://docs.mobula.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Swap Instructions endpoint returns individual Solana instructions instead of a serialized transaction. This allows you to:- Add your own instructions (e.g., Jito tips, custom fee transfers)
- Combine multiple swaps in a single transaction
- Have full control over transaction construction
- Avoid deserializing/re-serializing transactions which adds latency
Query Parameters
chainId(required) — The blockchain identifier. Must besolanaorsolana:solanatokenIn(required) — Address of the token to swap from (useSo11111111111111111111111111111111111111111for native SOL)tokenOut(required) — Address of the token to swap to (useSo11111111111111111111111111111111111111111for native SOL)amount(required ifamountRawnot provided) — Human-readable amount of tokenIn to swap (e.g.,"1.5"for 1.5 tokens)amountRaw(required ifamountnot provided) — Raw amount as a string (e.g.,"1500000000"for 1.5 SOL with 9 decimals)walletAddress(required) — Wallet address that will execute the swapslippage(optional) — Maximum acceptable slippage percentage (0-100). Default:1excludedProtocols(optional) — Comma-separated list of factory addresses to exclude from routingonlyProtocols(optional) — Comma-separated list of tradable pool types to restrict routingpoolAddress(optional) — Specific pool address to use for the swaponlyVerifiedTokens(optional) — When set to"true", rejects quotes wheretokenOutis an unverified launchpad token (e.g., Pump.fun, Pumpswap, Raydium Launchlab). Default:"false".priorityFee(optional) — Priority fee configuration. Can beauto, a preset (low,medium,high,veryHigh), or a number in microLamports per CUcomputeUnitLimit(optional) — Compute unit limit. Can betruefor dynamic or a specific number. Default:400,000jitoTipLamports(optional) — Jito tip amount in lamports for block engine priorityfeePercentage(optional) — Fee percentage to charge on the swap (0.01 to 99). Fee is always taken from native SOL (deducted from the swap amount). At least one side of the swap must be native SOL. Must be used together withfeeWallet.feeWallet(optional) — Wallet address to receive fees. Required whenfeePercentageis set.
Usage Examples
Basic Swap Instructions
With Priority Fee
With Jito Tip
With Integration Fee
feeWallet via a SystemProgram.transfer instruction.
Response Format
Response Fields
Data Object
amountOutTokens(string, optional) — Estimated output amount in tokensslippagePercentage(number, optional) — Slippage percentagetokenIn(object, optional) — Input token metadataaddress(string) — Token contract addressname(string, optional) — Token namesymbol(string, optional) — Token symboldecimals(number) — Token decimalslogo(string | null, optional) — Token logo URL
tokenOut(object, optional) — Output token metadatarequestId(string) — Unique identifier for tracking this requestsolana(object) — Solana instructions containerinstructions(object) — All instructions needed for the swapcomputeBudgetInstructions(array, optional) — Instructions to set compute budgetsetupInstructions(array, optional) — Setup instructions (e.g., create token accounts)swapInstructions(array) — The swap instructions (can be multiple for multi-hop routes)cleanupInstructions(array, optional) — Cleanup instructions (e.g., close token accounts)addressLookupTableAddresses(array, optional) — ALT addresses for versioned transactions
lastValidBlockHeight(number) — The last block height at which the blockhash is validrecentBlockhash(string) — Recent blockhash to use when building the transaction
Instruction Format
Each instruction contains:programId(string) — The program that will process this instructionaccounts(array) — Account keys involved in the instructionpubkey(string) — Account public keyisSigner(boolean) — Whether the account must signisWritable(boolean) — Whether the account is writable
data(string) — Instruction data as base64 encoded string
Building a Transaction
After receiving instructions, you need to build and sign the transaction yourself:Important Notes
- Solana Only: This endpoint only works with Solana chains
- Mobula Execution Engine: Instructions are generated by Mobula’s internal execution engine, which routes through multiple DEXs (Raydium, Orca, Pumpfun, etc.) for optimal pricing
- Blockhash Expiry: The
recentBlockhashandlastValidBlockHeighthave a limited validity window (~150 blocks / ~1 minute). Build and send your transaction quickly. - ALT Required: For complex swaps, Address Lookup Tables are required. Always fetch and include them if
addressLookupTableAddressesis provided. - Request ID: Keep the
requestIdfor troubleshooting with Mobula support
Comparison with /swap/quoting
| Feature | /swap/quoting | /swap/quoting-instructions |
|---|---|---|
| Returns | Serialized transaction | Individual instructions |
| Custom instructions | Need to deserialize | Direct insertion |
| Latency | Lower (ready to sign) | Slightly higher (need to build) |
| Flexibility | Limited | Full control |
| Chain support | Solana + EVM | Solana only |
| Use case | Simple swaps | Advanced integrations |
Query Parameters
Mobula chain id. EVM: evm:<integer> (e.g. evm:1, evm:8453, evm:42161). Solana: solana:solana. TON: ton:mainnet or ton:testnet.
Sell token address. Native sentinels — EVM: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE (EIP-7528). Solana: So11111111111111111111111111111111111111112 (wSOL). TON: EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c.
1Buy token address. Same sentinel rules as tokenIn.
1Human-readable amount (e.g. "1.5" for 1.5 tokens). Converted server-side: raw = amount × 10^decimals. Mutually exclusive with amountRaw.
Raw amount as a digit-only string (e.g. "1500000" for 1.5 USDC at 6 decimals). Use this when you already have the bigint to avoid float precision loss. Mutually exclusive with amount.
Slippage tolerance in % (0-100, default 1). Quote rejects if expected output drops below this threshold.
User wallet address — recipient of tokenOut, signer for the broadcast tx, fee context.
1DEX-level deny list (CSV). Example: pump-amm,raydium.
DEX-level allow list (CSV). Example: uniswap-v3,uniswap-v4.
Pin routing to a single pool (e.g. when you want a specific Uniswap V3 fee tier).
Aggregator filter (CSV) — jupiter, kyberswap, lifi, naos. Omit to let the API pick.
Solana only. auto, low, medium, high, veryHigh, or microLamports per CU as a number string.
Solana only. true for dynamic CU limit, or a fixed integer (default 400 000).
Solana only. Jito tip in lamports — adds a transfer to one of the Jito tip accounts for fast landing.
Caller referral fee in % (0-99). Mobula skims a 20% platform cut off the top. Requires feeWallet.
Wallet that receives the caller referral fee. Required when feePercentage > 0.
Minimum caller referral fee in native-token units. Currently honored on TON native-input swaps; requires feeWallet.
Solana only. Fee abstraction — wallet that signs/pays for the tx (separate from walletAddress).
Solana only. true returns N candidate transactions over a durable nonce — race them across landers (Jito, Nozomi, 0slot). Only one commits.
Per-lander tip when multiLander=true. Defaults to each lander's minimum.