curl --request GET \
--url https://swap-v2.solanatracker.io/rate{
"amountIn": 1,
"amountOut": 9181.330823048,
"minAmountOut": 9089.517514818,
"currentPrice": 9181.330823048,
"executionPrice": 9089.517514818,
"priceImpact": 0.0334641736518774,
"fee": 0.01,
"baseCurrency": {
"decimals": 9,
"mint": "So11111111111111111111111111111111111111112"
},
"quoteCurrency": {
"decimals": 9,
"mint": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
},
"platformFee": 9000000,
"platformFeeUI": 0.009
}Get swap quotes before executing transactions
curl --request GET \
--url https://swap-v2.solanatracker.io/rate{
"amountIn": 1,
"amountOut": 9181.330823048,
"minAmountOut": 9089.517514818,
"currentPrice": 9181.330823048,
"executionPrice": 9089.517514818,
"priceImpact": 0.0334641736518774,
"fee": 0.01,
"baseCurrency": {
"decimals": 9,
"mint": "So11111111111111111111111111111111111111112"
},
"quoteCurrency": {
"decimals": 9,
"mint": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
},
"platformFee": 9000000,
"platformFeeUI": 0.009
}import { SolanaTracker } from 'solana-swap';
const tracker = new SolanaTracker('YOUR_API_KEY');
// Get rate quote before swap
const quote = await tracker.getRate({
from: 'So11111111111111111111111111111111111111112', // SOL
to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
amount: 1,
slippage: 10
});
console.log(`Expected: ${quote.amountOut} tokens`);
console.log(`Minimum: ${quote.minAmountOut} tokens`);
console.log(`Price impact: ${(quote.priceImpact * 100).toFixed(2)}%`);
| Field | Type | Description |
|---|---|---|
amountIn | number | Input token amount |
amountOut | number | Expected output token amount |
minAmountOut | number | Minimum output after slippage |
currentPrice | number | Current market price |
executionPrice | number | Actual execution price |
priceImpact | number | Price impact as decimal (0.05 = 5%) |
fee | number | Trading fee |
platformFee | number | Platform fee in lamports |
platformFeeUI | number | Platform fee in SOL |
{
"amountIn": 1,
"amountOut": 9181.330823048,
"minAmountOut": 9089.517514818,
"currentPrice": 9181.330823048,
"executionPrice": 9089.517514818,
"priceImpact": 0.0334641736518774,
"fee": 0.01,
"baseCurrency": {
"decimals": 9,
"mint": "So11111111111111111111111111111111111111112"
},
"quoteCurrency": {
"decimals": 9,
"mint": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
},
"platformFee": 9000000,
"platformFeeUI": 0.009
}
// Check rate before executing swap
async function validateAndSwap(swapParams) {
// Get quote first
const quote = await tracker.getRate({
from: swapParams.from,
to: swapParams.to,
amount: swapParams.amount,
slippage: swapParams.slippage
});
// Check price impact
if (quote.priceImpact > 0.05) {
throw new Error('Price impact too high');
}
// Execute swap
return await tracker.swap(swapParams);
}
| Error | Description | Solution |
|---|---|---|
Invalid or missing token address | Token address is invalid | Verify token addresses |
Invalid amount | Amount is not valid | Ensure amount is positive |
Invalid slippage tolerance | Slippage not between 0-100 | Set slippage 0-100 |
Unable to fetch pools | Cannot find liquidity | Token may lack active pools |
The base token address
"So11111111111111111111111111111111111111112"
The quote token address
"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
The amount of the base token to convert (in native units, not lamports)
1
The maximum acceptable slippage percentage
0 <= x <= 10010
Successful rate quote
The amount of the source token used for the conversion
1
The amount of the destination token that would be received
9181.330823048
The minimum amount of the destination token after applying slippage
9089.517514818
The current market price for the token pair
9181.330823048
The actual price at which the trade would be executed
9089.517514818
The difference between market price and execution price as a fraction
0.0334641736518774
The trading fee charged for the transaction
0.01
Show child attributes
Show child attributes
The fee charged by the platform in lamports
9000000
The platform fee in SOL
0.009
Was this page helpful?