Introduction
This guide explains how to retrieve transaction instruction data for executing swaps or price quotes on the Solana blockchain through our DEX Aggregator API.
API Endpoint
GET https://web3.okx.com/api/v5/dex/aggregator/swap-instructionRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
chainIndex | String | Yes | Chain identifier (e.g., 501 for Solana) |
chainId | String | Yes | Chain identifier (deprecated) |
amount | String | Yes | Token amount with decimals (e.g., 1000000 for 1.00 USDT) |
fromTokenAddress | String | Yes | Source token contract address |
toTokenAddress | String | Yes | Destination token contract address |
slippage | String | Yes | Maximum slippage tolerance (0 to <1 for Solana) |
autoSlippage | Boolean | No | Enable automatic slippage calculation |
maxAutoSlippage | String | No | Maximum auto-slippage limit when enabled |
userWalletAddress | String | Yes | User's wallet address |
swapReceiverAddress | String | No | Alternate recipient address for swapped tokens |
feePercent | String | No | Commission percentage (0-10%) |
fromTokenReferrerWalletAddress | String | No | Commission wallet for source token |
toTokenReferrerWalletAddress | String | No | Commission wallet for destination token |
positiveSlippagePercent | String | No | Positive slippage capture percentage (Solana only) |
positiveSlippageFeeAddress | String | No | Wallet for positive slippage fees |
dexIds | String | No | Comma-separated liquidity pool IDs |
directRoute | Boolean | No | Restrict to single liquidity pool routes |
priceImpactProtectionPercentage | String | No | Maximum allowed price impact (0-1.0) |
computeUnitPrice | String | No | Solana transaction priority fee |
computeUnitLimit | String | No | Solana computation resource limit |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
addressLookupTableAccount | Array | Solana address lookup table |
instructionLists | Array | Transaction instructions |
routerResult | Object | Price quote route data |
dexRouterList | Array | Exchange route percentages |
fromToken | Object | Source token details |
toToken | Object | Destination token details |
quoteCompareList | Array | Price comparison data |
tx | Object | Transaction information |
๐ Learn more about Solana transaction optimization
Key Features
- Multi-DEX Aggregation: Combines liquidity from multiple decentralized exchanges
- Slippage Protection: Customizable slippage tolerance levels
- Fee Optimization: Calculates optimal network fees
- Route Comparison: Shows best available swap paths
Best Practices
- Always verify token contract addresses
- Set appropriate slippage for volatile markets
- Monitor gas fees during network congestion
- Test with small amounts first
FAQ
What is the minimum slippage for Solana swaps?
The minimum slippage is 0%, but we recommend at least 0.1% for most transactions.
How do I calculate token amounts with decimals?
Multiply the desired token quantity by 10^decimals. For example, 1 USDC (6 decimals) = 1000000.
๐ Need help with Solana transactions?
What happens if my transaction exceeds the price impact protection?
The API will return an error if the estimated price impact exceeds your specified protection percentage.
Can I specify which DEXs to use?
Yes, use the dexIds parameter to limit liquidity sources.
Conclusion
This API provides comprehensive tools for executing efficient swaps on Solana, with features designed to optimize pricing, minimize fees, and protect against unfavorable market conditions. Always review the response data carefully before signing transactions.