How to get a quote
In this section, you'll learn how to request quotes for token swaps on Solana. This will help you understand the expected output amount and available routes before executing a swap.
Overview
Getting a quote is the first step before executing a swap. The quote will provide:
Expected output amount
Price impact
Available routes through different AMM protocols
Current market prices
Estimated transaction fees
A) Protocol-Specific Approach (Explicit)
Use this when you want to work with a specific Solana AMM protocol.
Request Quote Fetch specific protocol information using:
GET /strategies/:id
Required Parameters:
ParameterDescriptionExampleaction
Type of operation
swap
protocol
Protocol name
raydium
fromToken
Token mint to swap from
So11111111111111111111111111111111111111112
(Wrapped SOL)toToken
Token mint to swap to
EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
(USDC)amountIn
Input amount in lamports
1000000000
(1 SOL)slippage
Maximum price slippage
0.5
(0.5% slippage tolerance)Example Request:
GET /strategies/raydium-sol-usdc?action=swap&protocol=raydium&fromToken=So11111111111111111111111111111111111111112&toToken=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amountIn=1000000000&slippage=0.5
Response:
{ "quote": { "protocol": "Raydium", "fromToken": { "mint": "So11111111111111111111111111111111111111112", "symbol": "SOL", "decimals": 9 }, "toToken": { "mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "symbol": "USDC", "decimals": 6 }, "amountIn": "1000000000", "expectedAmountOut": "25123456", "minAmountOut": "25000000", "priceImpact": 0.12, "fee": { "amount": "0.000005", "currency": "SOL" }, "route": ["SOL", "USDC"], "poolAddress": "58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2" } }
B) Protocol-Agnostic Approach (Less Explicit)
Let our system find the best route across all available AMM protocols.
Use the Generic Endpoint
GET /strategies/0x0
Use the same parameters as above, excluding
protocol
.Example Request:
GET /strategies/0x0?action=swap&fromToken=So11111111111111111111111111111111111111112&toToken=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amountIn=1000000000&slippage=0.5
Response:
{ "routes": [ { "protocol": "Raydium", "expectedAmountOut": "25123456", "minAmountOut": "25000000", "priceImpact": 0.12, "route": ["SOL", "USDC"], "poolAddress": "58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2" }, { "protocol": "Orca", "expectedAmountOut": "25120000", "minAmountOut": "24996800", "priceImpact": 0.15, "route": ["SOL", "USDC"], "poolAddress": "6UmmUiYoBjSrhakAobJw8BvkmJtDVxaeBtbt7rxWo1mg" } ], "bestRoute": { "protocol": "Raydium", "expectedAmountOut": "25123456", "minAmountOut": "25000000", "priceImpact": 0.12 } }
Important Notes
All amounts should include the proper number of decimals for the token
SOL amounts are in lamports (1 SOL = 1,000,000,000 lamports)
Price impact shows how much the swap will affect market price
The API automatically handles wrapped SOL conversions
Multiple routes may be available through different AMM protocols
Transaction fees are paid in SOL
Slippage protection is important due to Solana's fast block times
Next Steps
After getting a quote, you can proceed to:
Last updated