Overview
The Swap Quoting endpoint provides swap quotes with optimized routing across multiple DEXs and liquidity sources. It returns the estimated output amount, slippage, and a serialized transaction ready to be signed.Private Beta Access OnlyThis endpoint is not yet available to the general public. Please contact the Mobula team to request access.
Query Parameters
chainId(required) — The blockchain identifier (e.g.,evm:1,solana,ethereum)tokenIn(required) — Address of the token to swap from (use0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEfor native tokens)tokenOut(required) — Address of the token to swap to (use0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEfor native tokens)amount(required) — Amount of tokenIn to swap (in token’s base units)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 routing. Can be any factory address.onlyProtocols(optional) — Comma-separated list of tradable pool types to restrict routing to (e.g.,uniswap-v2,uniswap-v3,raydium-amm). Only valid tradable pool types will be considered; non-tradable types will be filtered out.poolAddress(optional) — Specific pool address to use for the swap
Usage Examples
Basic Swap Quote
Swap with Excluded Protocols
Swap with Specific Pool Type
Response Format
Currently supports Solana blockchain. EVM chains support coming soon.Solana Response
Response Fields
Data Object
For Solana:solana(object, optional) — Solana transaction containertransaction(object) — Transaction detailsserialized(string) — Base64 encoded serialized transactionvariant(enum:legacy|versioned) — Transaction variant
estimatedAmountOut(string, optional) — Estimated output amount in tokenOut’s base unitsestimatedSlippage(number, optional) — Estimated slippage percentagerequestId(string) — Unique identifier for tracking this request. Keep this ID and provide it to the Mobula team if you encounter any issues.
Error Field
error(string, optional) — Error message if the quote failed. If you receive an error, please report it to the Mobula team along with therequestIdfor faster resolution.
Example Responses
Successful Solana Swap Quote
Quote with Error
Important Notes
- Native Token Address: Use
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeEfor native tokens on EVM chains, and the corresponding native token address on Solana (So11111111111111111111111111111111111111112for SOL) - Amount Format: Amounts should be provided in the token’s smallest unit (wei for ETH, lamports for SOL, etc.)
- Blockchain Support: Currently supports Solana. EVM chains support coming soon.
- Solana Transactions: Base64 encoded and ready to be deserialized, signed, and sent
- Slippage: Higher slippage increases success rate but may result in worse execution prices
- Request ID: Always keep the
requestIdfrom the response. In case of any issues or errors, provide this ID to the Mobula team for faster troubleshooting and resolution. - onlyProtocols Behavior: This parameter only restricts routing to a subset of tradable pool types. Non-tradable pool types will be automatically filtered out. You cannot extend beyond the base set of tradable protocols.
- excludedProtocols Behavior: You can specify any factory address to exclude from routing, regardless of whether it’s tradable or not.
Next Steps
For Solana Transactions
After receiving a quote:- Save the
requestIdfor troubleshooting purposes - Decode the base64 serialized transaction
- Deserialize based on the
variantfield (legacy or versioned) - Sign it with your Solana wallet
- Send to the network using your preferred RPC
EVM Support
EVM chains support is coming soon. The API will support Ethereum, BSC, Polygon, and other EVM-compatible chains.Use Cases
- DEX Aggregation: Get the best swap rates across multiple DEXs
- Trading Bots: Automated trading with optimal routing
- DeFi Applications: Integrate swap functionality into your dApp
- Price Comparison: Compare swap rates before execution