nansen-agent-guide
Routing guide -- when to use `nansen agent` (AI research) vs direct CLI data commands. Use when deciding how to answer a user's…
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.
$ npx -y skills add nansen-ai/nansen-cli --skill nansen-trading --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/nansen-tradingContext preview
The summary Claude sees to decide when to auto-load this skill.
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.
name: nansen-trading
description: 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.
metadata:
openclaw:
requires:
env:
- NANSEN_WALLET_PASSWORD
bins:
- nansen
primaryEnv: NANSEN_API_KEY
install:
- kind: node
package: nansen-cli
bins: [nansen]
allowed-tools: Bash(nansen:*)Nansen account API calls accept a selected `nansen:api` browser session or conventional API key with the same permissions. `NANSEN_API_KEY` takes precedence; optional `primaryEnv` preserves configured-key injection. Run `nansen auth status` for offline selection. Cached access expiry alone permits automatic renewal during an authorized task. Stop on anonymous selection, invalid state, blocked/uncertain renewal or actual auth failure; never drop a credential or fall back to anonymous x402 payment. Browser login does not grant wallet signing, privileged service identity or a persistent MCP integration key. Preserve all confirmation, signing, sanctions and geographic checks below. Browser login is available in CLI 2.0.0 within the [macOS arm64 preview scope](https://github.com/nansen-ai/nansen-cli/blob/main/docs/browser-login.md#preview-platform-scope).
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.
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.
**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.
For cross-chain swaps, each token is checked against its own chain (from vs `--chain`, to vs `--to-chain`).
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`.
| Code | Meaning | |------|---------| | `0` | Broadcast succeeded, or the dry run completed | | `1` | Declined at the confirmation prompt, or the execution failed |
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).
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
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.
# 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"| Token | Chain | Address | |-------|-------|---------| | SOL | Solana | `So11111111111111111111111111111111111111112` | | USDC | Solana | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` | | ETH | Base | `0xeeeeeeeeeeeeeeeeeee
Built by agents, for agents. Command-line interface for the Nansen API, designed for AI agents to research on-chain data, manage wallets, and trade through nansen trade. Use it for both analytics and execution: nansen research ...
Routing guide -- when to use `nansen agent` (AI research) vs direct CLI data commands. Use when deciding how to answer a user's…
Set up a local webhook server to receive Nansen smart alerts in real-time with HMAC signature verification and public tunneling.…
What tokens are whales dollar-cost averaging into? Jupiter DCA strategies by smart money and target token fundamentals.
What DeFi positions does a wallet hold? Protocol-by-protocol breakdown of assets, debts, and rewards across chains.
Is smart money exiting a token I hold? Net flow direction, seller breakdown by label, and recent SM trades.
What are crypto funds and VCs holding right now? Cross-chain fund portfolios and net accumulation signals.