curl --request GET \
--url https://swap-v2.solanatracker.io/swap{
"txn": "BASE64_TX",
"rate": {
"amountIn": 1,
"amountOut": 81.631985,
"minAmountOut": 73.4687865,
"currentPrice": 0.012219167460548153,
"executionPrice": 0.010997250714493338,
"priceImpact": 0.002517,
"fee": 0.000005,
"baseCurrency": {
"mint": "<string>",
"decimals": 123
},
"quoteCurrency": {
"mint": "<string>",
"decimals": 123
},
"platformFee": 9000000,
"platformFeeUI": 0.009
},
"timeTaken": 0.016,
"type": "legacy"
}Build and execute token swap transactions
curl --request GET \
--url https://swap-v2.solanatracker.io/swap{
"txn": "BASE64_TX",
"rate": {
"amountIn": 1,
"amountOut": 81.631985,
"minAmountOut": 73.4687865,
"currentPrice": 0.012219167460548153,
"executionPrice": 0.010997250714493338,
"priceImpact": 0.002517,
"fee": 0.000005,
"baseCurrency": {
"mint": "<string>",
"decimals": 123
},
"quoteCurrency": {
"mint": "<string>",
"decimals": 123
},
"platformFee": 9000000,
"platformFeeUI": 0.009
},
"timeTaken": 0.016,
"type": "legacy"
}import { SolanaTracker } from 'solana-swap';
const tracker = new SolanaTracker('YOUR_API_KEY', 'YOUR_PRIVATE_KEY');
// Basic swap
const swap = await tracker.swap({
from: 'So11111111111111111111111111111111111111112', // SOL
to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
fromAmount: 0.1,
slippage: 10,
payer: 'YOUR_WALLET_ADDRESS',
priorityFee: 0.000005,
txVersion: 'v0'
});
console.log('Transaction:', swap.txn);
fromAmount parameter accepts:
1, 0.5 - Exact amount"auto" - Entire wallet balance"50%", "25%" - Percentage of balance// Manual fee
{ priorityFee: 0.000005 }
// Automatic with level
{
priorityFee: "auto",
priorityFeeLevel: "high" // min, low, medium, high, veryHigh, unsafeMax
}
{
fee: "YOUR_WALLET:0.1", // 0.1% to your wallet
feeType: "add" // or "deduct" (SOL only)
}
// Swap entire balance
const swap = await tracker.swap({
from: 'So11111111111111111111111111111111111111112',
to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
fromAmount: "auto",
slippage: 15,
payer: 'YOUR_WALLET_ADDRESS'
});
// Swap 50% of balance
const swap = await tracker.swap({
from: 'TOKEN_ADDRESS',
to: 'So11111111111111111111111111111111111111112',
fromAmount: "50%",
slippage: 10,
payer: 'YOUR_WALLET_ADDRESS'
});
// Add 0.1% fee
const swap = await tracker.swap({
from: 'So11111111111111111111111111111111111111112',
to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
fromAmount: 1,
slippage: 10,
payer: 'YOUR_WALLET_ADDRESS',
fee: 'YOUR_FEE_WALLET:0.1',
feeType: 'add'
});
{
"txn": "BASE64_ENCODED_TRANSACTION",
"rate": {
"amountIn": 0.1,
"amountOut": 81.631985,
"minAmountOut": 73.4687865,
"currentPrice": 0.012219167460548153,
"executionPrice": 0.010997250714493338,
"priceImpact": 0.002517,
"fee": 0.000005,
"platformFee": 9000000,
"platformFeeUI": 0.009
},
"timeTaken": 0.016,
"type": "v0"
}
platformFee (lamports) and platformFeeUI (SOL)| Error | Solution |
|---|---|
| Invalid token address | Verify addresses are valid |
| Invalid amount | Use number, “auto”, or percentage |
| Invalid slippage | Set between 0-100 |
| Token has no pools | Token may be delisted |
| Insufficient liquidity | Try smaller amount |
The base token address
"So11111111111111111111111111111111111111112"
The quote token address
"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"
The amount of the base token to swap. Accepts numeric value, 'auto' for full wallet balance, or percentage like '50%'
1
Maximum acceptable slippage percentage or 'auto' for dynamic slippage (Beta)
0 <= x <= 10010
Public key of the wallet sending the transaction
"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y"
Amount in SOL to increase transaction priority or 'auto'
0.000005
Priority level when priorityFee is set to 'auto'
min, low, medium, high, veryHigh, unsafeMax Transaction version
v0, legacy Custom fee for your users in format 'WALLET_ADDRESS:PERCENTAGE'
"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y:0.1"
Custom tip for Jito or similar services in format 'WALLET_ADDRESS:SOL_AMOUNT'
Fee application type. 'deduct' option is only used when the from address is SOL
add, deduct Disable multi-hop swaps
Successful swap transaction
Base64 encoded transaction
"BASE64_TX"
Show child attributes
Amount of input token
1
Amount of output token
81.631985
Minimum amount out after slippage
73.4687865
Current market price
0.012219167460548153
Actual execution price
0.010997250714493338
Price impact as a decimal
0.002517
Transaction fee
0.000005
Platform fee in lamports
9000000
Platform fee in SOL
0.009
Time taken for the operation in seconds
0.016
Transaction type
v0, legacy "legacy"
Was this page helpful?