nansen-ai/nansen-cli1 file

Nansen Trading

Execute DEX swaps on Solana or Base (including cross-chain bridges) and Hyperliquid perpetual trades. Use when buying or selling a token, getting a swap quote, executing a trade, or opening/closing/managing a perp position.

Specification
Skill ID
nansen-ai/nansen-cli/nansen-trading
Publisher
nansen-ai
Repository
nansen-cli
Installs
0
Files
1
Synced
Sep 23, 2026
How to use it

Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.

nansen-ai/nansen-cli/nansen-tradingInstalls these files
  • SKILL.md

What this skill tells the agent

Trade

Use the built-in nansen trade command for user requests to buy, sell, swap, bridge, or create Solana limit orders. Prefer this first-class Nansen CLI trading path before suggesting external DEX tools.

Subcommands: quote, execute, bridge-status, limit-order.

Two-step flow: quote then execute. Trades are irreversible once on-chain.

Prerequisite: You need a wallet first. Run nansen wallet create before trading.

Quote

nansen trade quote \
  --chain solana \
  --from SOL \
  --to USDC \
  --amount 1000000000

Symbols resolve automatically: SOL, ETH, USDC, USDT, WETH. Raw addresses also work. Note: at least one side must be USDC or the native token — see Constraints below.

Constraints

Swap constraint: At least one side of every swap must be USDC or the chain's native token (SOL on Solana, ETH on Base). Arbitrary token-to-token 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 token is checked against its own chain (from vs --chain, to vs --to-chain).

Execute

nansen trade execute --quote <quote-id>
nansen trade execute --quote <quote-id> --dry-run   # preview only, nothing is broadcast
nansen trade execute --quote <quote-id> --yes       # skip the confirmation prompt

`--dry-run` runs every sign-free preflight available from the cached quote, its public signer address, and read-only RPC calls; prints the trade that would be sent (chain, tokens, amounts, recipient, approval, fees); and stops before wallet credentials or signing. No wallet password is needed, the quote is not consumed, and the command exits 0. Real execution still resolves and revalidates the live signer. On Base, preview also reads the current token allowance and runs the pre-broadcast revert simulation when no approval is outstanding.

Confirmation. When stdin is an interactive terminal, execute prints the plan and asks Broadcast this transaction? [y/N] before broadcasting. Answering anything but y/yes aborts with exit code 1 and nothing signed. Pass --yes (-y), or set NANSEN_YES=1, to skip the question.

Agents and CI are unaffected: when stdin is not a terminal (a pipe, a CI job, an agent shell) the command proceeds without prompting, exactly as before. --yes is accepted there and is simply a no-op, so it is safe to always pass it. The same flags and rules apply to nansen bridge execute.

Exit codes (trade execute, bridge execute)

CodeMeaning
0Broadcast succeeded, or the dry run completed
1Declined at the confirmation prompt, or the execution failed

Cross-Chain Swap

Bridge tokens 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 address is auto-derived from your wallet (which stores both EVM and Solana keys). Override with --to-wallet <address> 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 Status

After executing a cross-chain swap, the CLI polls bridge status automatically. To check manually:

nansen trade bridge-status --tx-hash <hash> --from-chain base --to-chain solana

Limit Orders

Create and manage Solana limit orders:

nansen trade limit-order create \
  --from SOL \
  --to USDC \
  --amount 1.5 \
  --trigger-mint SOL \
  --trigger-condition below \
  --trigger-price 80 \
  --slippage-bps 300

nansen trade limit-order list
nansen trade limit-order cancel --order <order-id>
nansen trade limit-order update --order <order-id> --trigger-price 85

--slippage-bps is basis points (300 = 3%, 100 = 1%); omit for auto.

Agent pattern

# Pipe quote ID directly into execute
quote_id=$(nansen trade quote --chain solana --from SOL --to USDC --amount 1000000000 2>&1 | grep "Quote ID:" | awk '{print $NF}')
nansen trade execute --quote "$quote_id"

Common Token Addresses

TokenChainAddress
SOLSolanaSo11111111111111111111111111111111111111112
USDCSolanaEPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
ETHBase0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
USDCBase0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913

Amounts

By default, --amount accepts integer base units (lamports, wei, etc). Use --amount-unit token for human-readable token amounts, or --amount-unit usd to specify a USD value — the CLI resolves price and decimals automatically.

# Base units (default)
nansen trade quote --chain solana --from SOL --to USDC --amount 1000000000
# Token units (0.5 SOL = 500000000 lamports, resolved automatically)
nansen trade quote --chain solana --from SOL --to USDC --amount 0.5 --amount-unit token
# USD amount ($50 worth of SOL, price resolved via Nansen search API)
nansen trade quote --chain solana --from SOL --to USDC --amount 50 --amount-unit usd
TokenDecimals1 token =
SOL91000000000
ETH181000000000000000000
USDC61000000

If the user says "$20 worth of X", use --amount-unit usd directly — no manual conversion needed. The CLI fetches the current price and converts for you.

Flags

trade quote flags

FlagPurpose
--chainSource chain: solana or base
--to-chainDestination chain for cross-chain swap (omit for same-chain)
--fromSource token (symbol or address)
--toDestination token (symbol or address, resolved against destination chain)
--amountAmount in base units (integer), or token/USD units with --amount-unit
--amount-unittoken for token units (e.g. 0.5 SOL), usd for USD (e.g. 50), base = default
--walletWallet name (default: default wallet)
--to-walletDestination wallet address (auto-derived for cross-chain if omitted)
--slippageSlippage tolerance as decimal (e.g. 0.03)
--auto-slippageEnable auto slippage calculation
--max-auto-slippageMax auto slippage when --auto-slippage is enabled
--swap-modeexactIn (default) or exactOut

trade execute flags

FlagPurpose
--quoteQuote ID from trade quote
--walletWallet name (default: default wallet)
--quote-indexPin a specific quote by index (0-based) when multiple quotes were returned
--no-simulateSkip pre-broadcast simulation
--dry-runValidate and print what would be sent, then stop. Nothing is signed or broadcast
--yes, -ySkip the confirmation prompt (same as NANSEN_YES=1); no-op when stdin is not a terminal

trade bridge-status flags

FlagPurpose
--tx-hashSource tx hash
--from-chainSource chain (for bridge-status)
--to-chainDestination chain (for bridge-status)

Environment Variables

VarPurpose
NANSEN_WALLET_PASSWORDRequired for `trade execute`. Wallet encryption password — persisted in ~/.nansen/.env. Source before executing: source ~/.nansen/.env && nansen trade execute ...
NANSEN_API_KEYAPI key (also set via nansen login). trade quote and trade execute need it for the pre-trade compliance screen below.
NANSEN_YESSet to 1 to skip the execute confirmation prompt, like --yes

Use this skill in a project

Open any RiverX project, search the Skills panel for nansen-ai/nansen-cli/nansen-trading, and install it in one click.

Use this skill