跳转到主要内容
GET
Build Swap Transaction
本页介绍的是较早的 Solana Tracker Swap API(swap-v2.solanatracker.io)。它仍在运行,每笔兑换收取平台费。Raptor 是另一款独立的兑换 API(raptor.solanatracker.io),目前免费,无需 API 密钥。

概览

swap 端点在 Solana 上构建代币兑换交易。您会收到一个序列化交易,您需要使用钱包签名并广播。
此端点构建交易但不执行。您必须自行签名并发送交易。

支持的平台

  • Pump.fun - 上线平台代币
  • PumpSwap - Pump.fun 流动性池
  • Orca - 集中流动性
  • Meteora - 动态池
  • Moonshot - 新上线
  • Raydium - V4 AMM、CPMM、Launchpad
  • Jupiter - 聚合路由

SDK 示例

关键参数

金额格式

fromAmount 参数接受:
  • 数值: 1、0.5 - 精确金额
  • 自动: "auto" - 整个钱包余额
  • 百分比: "50%"、"25%" - 余额的百分比

优先费

合作伙伴 / 推荐费

添加您自己的合作伙伴或推荐费用以实现盈利:

示例

使用自动金额的兑换

使用百分比的兑换

自定义费用的兑换

响应结构

Solana Tracker 平台费

标准费用:交易金额的 0.5%
  • 从输出中扣除
  • 在 platformFee(lamports)和 platformFeeUI(SOL)中显示
  • 提供成交量折扣
联系 swap-api@solanatracker.io 了解成交量定价

常见错误

下一步

Rate 端点

在兑换前获取报价

JavaScript SDK

安装 SDK

查询参数

from
string
必填

The base token address

示例:

"So11111111111111111111111111111111111111112"

to
string
必填

The quote token address

示例:

"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"

fromAmount
必填

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

示例:

1

slippage
必填

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

必填范围: 0 <= x <= 100
示例:

10

payer
string
必填

Public key of the wallet sending the transaction

示例:

"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y"

priorityFee

Amount in SOL to increase transaction priority or 'auto'

示例:

0.000005

priorityFeeLevel
enum<string>
默认值:medium

Priority level when priorityFee is set to 'auto'

可用选项:
min,
low,
medium,
high,
veryHigh,
unsafeMax
txVersion
enum<string>
默认值:v0

Transaction version

可用选项:
v0,
legacy
fee
string

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

Pattern: ^[a-zA-Z0-9]+:[0-9]+(\.[0-9]+)?$
示例:

"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y:0.1"

customTip
string

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

Pattern: ^[a-zA-Z0-9]+:[0-9]+(\.[0-9]+)?$
feeType
enum<string>
默认值:add

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

可用选项:
add,
deduct
onlyDirectRoutes
boolean
默认值:false

Disable multi-hop swaps

响应

Successful swap transaction

txn
string

Base64 encoded transaction

示例:

"BASE64_TX"

rate
object
timeTaken
number

Time taken for the operation in seconds

示例:

0.016

type
enum<string>

Transaction type

可用选项:
v0,
legacy
示例:

"legacy"