Skip to main content
GET
/
swap
Build Swap Transaction
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"
}

Overview

The swap endpoint builds token swap transactions on Solana. You receive a serialized transaction that you sign and broadcast using your wallet.
This endpoint builds the transaction but does not execute it. You must sign and send the transaction yourself.

Supported Platforms

  • Pump.fun - Launch platform tokens
  • PumpSwap - Pump.fun liquidity pools
  • Orca - Concentrated liquidity
  • Meteora - Dynamic pools
  • Moonshot - New launches
  • Raydium - V4 AMM, CPMM, Launchpad
  • Jupiter - Aggregated routing

SDK Examples

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);

Key Parameters

Amount Formats

The fromAmount parameter accepts:
  • Numeric: 1, 0.5 - Exact amount
  • Auto: "auto" - Entire wallet balance
  • Percentage: "50%", "25%" - Percentage of balance

Priority Fees

// Manual fee
{ priorityFee: 0.000005 }

// Automatic with level
{ 
  priorityFee: "auto",
  priorityFeeLevel: "high" // min, low, medium, high, veryHigh, unsafeMax
}

Custom Fees

Add your own fees for monetization:
{
  fee: "YOUR_WALLET:0.1", // 0.1% to your wallet
  feeType: "add" // or "deduct" (SOL only)
}

Examples

Swap with Auto Amount

// Swap entire balance
const swap = await tracker.swap({
  from: 'So11111111111111111111111111111111111111112',
  to: '4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R',
  fromAmount: "auto",
  slippage: 15,
  payer: 'YOUR_WALLET_ADDRESS'
});

Swap with Percentage

// Swap 50% of balance
const swap = await tracker.swap({
  from: 'TOKEN_ADDRESS',
  to: 'So11111111111111111111111111111111111111112',
  fromAmount: "50%",
  slippage: 10,
  payer: 'YOUR_WALLET_ADDRESS'
});

Swap with Custom Fee

// 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'
});

Response Structure

{
  "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"
}

Platform Fees

Standard fee: 0.5% of transaction value
  • Deducted from output
  • Shown in platformFee (lamports) and platformFeeUI (SOL)
  • Volume discounts available
Contact [email protected] for volume pricing

Common Errors

ErrorSolution
Invalid token addressVerify addresses are valid
Invalid amountUse number, “auto”, or percentage
Invalid slippageSet between 0-100
Token has no poolsToken may be delisted
Insufficient liquidityTry smaller amount

Next Steps

Query Parameters

from
string
required

The base token address

Example:

"So11111111111111111111111111111111111111112"

to
string
required

The quote token address

Example:

"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"

fromAmount
required

The amount of the base token to swap. Accepts numeric value, 'auto' for full wallet balance, or percentage like '50%'

Example:

1

slippage
required

Maximum acceptable slippage percentage or 'auto' for dynamic slippage (Beta)

Required range: 0 <= x <= 100
Example:

10

payer
string
required

Public key of the wallet sending the transaction

Example:

"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y"

priorityFee

Amount in SOL to increase transaction priority or 'auto'

Example:

0.000005

priorityFeeLevel
enum<string>
default:medium

Priority level when priorityFee is set to 'auto'

Available options:
min,
low,
medium,
high,
veryHigh,
unsafeMax
txVersion
enum<string>
default:v0

Transaction version

Available options:
v0,
legacy
fee
string

Custom fee for your users in format 'WALLET_ADDRESS:PERCENTAGE'

Example:

"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y:0.1"

customTip
string

Custom tip for Jito or similar services in format 'WALLET_ADDRESS:SOL_AMOUNT'

feeType
enum<string>
default:add

Fee application type. 'deduct' option is only used when the from address is SOL

Available options:
add,
deduct
onlyDirectRoutes
boolean
default:false

Disable multi-hop swaps

Response

Successful swap transaction

txn
string

Base64 encoded transaction

Example:

"BASE64_TX"

rate
object
timeTaken
number

Time taken for the operation in seconds

Example:

0.016

type
enum<string>

Transaction type

Available options:
v0,
legacy
Example:

"legacy"

I