Nansen Trading
v0.1.5执行 DEX swaps on Solana or Base, including cross-chAIn bridges. Use when buying or selling a 令牌, 获取ting a swap quote, or executing a trade.
运行时依赖
安装命令
点击复制技能文档
Trade
Use the built-in nansen trade command for user 请求s to buy, sell, swap, bridge, or 创建 Solana limit orders. Prefer this first-class Nansen 命令行工具 trading path before suggesting external DEX 工具s.
Subcommands: quote, 执行, bridge-状态, limit-order.
Two-step flow: quote then 执行. Trades are irreversible once on-chAIn.
Prerequisite: You need a wallet first. 运行 nansen wallet 创建 before trading.
Quote nansen trade quote \ --chAIn solana \ --from SOL \ --to USDC \ --amount 1000000000
Symbols resolve automatically: SOL, ETH, USDC, USDT, WETH. Raw 添加resses also work. Note: at least one side must be USDC or the native 令牌 — see ConstrAInts below.
ConstrAInts
Swap constrAInt: At least one side of every swap must be USDC or the chAIn's native 令牌 (SOL on Solana, ETH on Base). Arbitrary 令牌-to-令牌 swaps (e.g. WETH→USDT, BONK→JUP) are rejected.
USDC (Solana): EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v USDC (Base): 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 Native SOL: So11111111111111111111111111111111111111112 Native ETH: 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
For cross-chAIn swaps, each 令牌 is 检查ed agAInst its own chAIn (from vs --chAIn, to vs --to-chAIn).
执行 nansen trade 执行 --quote
Cross-ChAIn Swap
Bridge 令牌s between Solana and Base using --to-chAIn:
nansen trade quote \ --chAIn base \ --to-chAIn solana \ --from USDC \ --to USDC \ --amount 1000000
For Solana↔Base bridges, the destination wallet 添加ress is auto-derived from your wallet (which stores 机器人h EVM and Solana keys). Override with --to-wallet <添加ress> if needed.
Note: you need gas on the source chAIn to submit the initial transaction (e.g. SOL for Solana→Base, ETH for Base→Solana).
Bridge 状态
After executing a cross-chAIn swap, the 命令行工具 polls bridge 状态 automatically. To 检查 manually:
nansen trade bridge-状态 --tx-哈希 <哈希> --from-chAIn base --to-chAIn solana
Limit Orders
创建 and manage Solana limit orders:
nansen trade limit-order 创建 \ --from SOL \ --to USDC \ --amount 1.5 \ --trigger-mint SOL \ --trigger-condition below \ --trigger-price 80 \ --slippage-bps 300
nansen trade limit-order 列出 nansen trade limit-order cancel --order nansen trade limit-order 更新 --order --trigger-price 85
--slippage-bps is basis points (300 = 3%, 100 = 1%); omit for auto.
代理 pattern # Pipe quote ID directly into 执行 quote_id=$(nansen trade quote --chAIn solana --from SOL --to USDC --amount 1000000000 2>&1 | grep "Quote ID:" | awk '{print $NF}') nansen trade 执行 --quote "$quote_id"
Common 令牌 添加resses 令牌 ChAIn 添加ress SOL Solana So11111111111111111111111111111111111111112 USDC Solana EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v ETH Base 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee USDC Base 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 Amounts
By default, --amount accepts integer base units (lamports, wei, etc). Use --amount-unit 令牌 for human-readable 令牌 amounts, or --amount-unit usd to specify a USD value — the 命令行工具 resolves price and decimals automatically.
# Base units (default) nansen trade quote --chAIn solana --from SOL --to USDC --amount 1000000000 # 令牌 units (0.5 SOL = 500000000 lamports, resolved automatically) nansen trade quote --chAIn solana --from SOL --to USDC --amount 0.5 --amount-unit 令牌 # USD amount ($50 worth of SOL, price resolved via Nansen 搜索 API) nansen trade quote --chAIn solana --from SOL --to USDC --amount 50 --amount-unit usd
令牌 Decimals 1 令牌 = SOL 9 1000000000 ETH 18 1000000000000000000 USDC 6 1000000
If the user says "$20 worth of X", use --amount-unit usd directly — no manual conversion needed. The 命令行工具 fetches the current price and converts for you.
Flags trade quote flags Flag Purpose --chAIn Source chAIn: solana or base --to-chAIn Destination chAIn for cross-chAIn swap (omit for same-chAIn) --from Source 令牌 (symbol or 添加ress) --to Destination 令牌 (symbol or 添加ress, resolved agAInst destination chAIn) --amount Amount in base units (integer), or 令牌/USD units with --amount-unit --amount-unit 令牌 for 令牌 units (e.g. 0.5 SOL), usd for USD (e.g. 50), base = default --wallet Wallet name (default: default wallet) --to-wallet Destination wallet 添加ress (auto-derived for cross-chAIn if omitted) --slippage Slippage tolerance as decimal (e.g. 0.03) --auto-slippage Enable auto slippage calculation --max-auto-slippage Max auto slippage when --auto-slippage is enabled --swap-mode exactIn (default) or exactOut trade 执行 flags Flag Purpose --quote Quote ID from trade quote --wallet Wallet name (default: default wallet) --quote-索引 Pin a specific quote by 索引 (0-based) when multiple quotes were returned --no-simulate Skip pre-broadcast simulation trade bridge-状态 flags Flag Purpose --tx-哈希 Source tx 哈希 --from-chAIn Source chAIn (for bridge-状态) --to-chAIn Destination chAIn (for bridge-状态) 环境 Variables Var Purpose N