nansen-trading
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTrade
交易
Two-step flow: quote then execute. Trades are irreversible once on-chain.
Prerequisite: You need a wallet first. Run before trading.
nansen wallet create两步流程:先获取报价,再执行交易。交易上链后不可撤销。
前置条件: 你需要先拥有一个钱包。在交易前运行命令。
nansen wallet createQuote
获取报价
bash
nansen trade quote \
--chain solana \
--from SOL \
--to USDC \
--amount 1000000000Symbols resolve automatically: , , , , . Raw addresses also work.
SOLETHUSDCUSDTWETHbash
nansen trade quote \
--chain solana \
--from SOL \
--to USDC \
--amount 1000000000代币符号会自动解析:、、、、。直接使用代币地址也可以。
SOLETHUSDCUSDTWETHExecute
执行交易
bash
nansen trade execute --quote <quote-id>bash
nansen trade execute --quote <quote-id>Agent pattern
Agent模式
bash
undefinedbash
undefinedPipe quote ID directly into execute
直接将报价ID传入执行命令
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"
undefinedquote_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"
undefinedCommon Token Addresses
常用代币地址
| Token | Chain | Address |
|---|---|---|
| SOL | Solana | |
| USDC | Solana | |
| ETH | Base | |
| USDC | Base | |
| 代币 | 链 | 地址 |
|---|---|---|
| SOL | Solana | |
| USDC | Solana | |
| ETH | Base | |
| USDC | Base | |
Amounts are in base units
金额以基础单位计算
| Token | Decimals | 1 token = |
|---|---|---|
| SOL | 9 | |
| ETH | 18 | |
| USDC | 6 | |
| 代币 | 小数位数 | 1代币 = |
|---|---|---|
| SOL | 9 | |
| ETH | 18 | |
| USDC | 6 | |
Flags
参数选项
| Flag | Purpose |
|---|---|
| |
| Source token (symbol or address) |
| Destination token (symbol or address) |
| Amount in base units (integer) |
| Wallet name (default: default wallet) |
| Slippage tolerance as decimal (e.g. 0.03) |
| Quote ID for execute |
| Skip pre-broadcast simulation |
| 选项 | 用途 |
|---|---|
| 指定链: |
| 源代币(符号或地址) |
| 目标代币(符号或地址) |
| 金额(基础单位,整数) |
| 钱包名称(默认:默认钱包) |
| 滑点容忍度(小数形式,例如0.03) |
| 执行交易所需的报价ID |
| 跳过广播前的模拟步骤 |
Environment Variables
环境变量
| Var | Purpose |
|---|---|
| Required for |
| API key (also set via |
Agents: Never hold a wallet password only in session memory. Ifis not inNANSEN_WALLET_PASSWORD, follow the setup flow in the nansen-wallet-manager skill Password Policy to generate and persist one before proceeding.~/.nansen/.env
| 变量 | 用途 |
|---|---|
| 执行 |
| API密钥(也可通过 |
Agent提示: 切勿仅在会话内存中存储钱包密码。如果未保存在NANSEN_WALLET_PASSWORD中,请遵循nansen-wallet-manager技能的密码策略中的设置流程,生成并持久化存储密码后再继续操作。~/.nansen/.env
Notes
注意事项
- Quotes expire after ~1 hour. If execute fails, get a fresh quote.
- A wallet is required even for quotes (the API builds sender-specific transactions).
- ERC-20 swaps may require an approval step — execute handles this automatically.
- 报价约1小时后过期。如果执行交易失败,请获取新的报价。
- 即使是获取报价也需要钱包(API会构建与发送方相关的交易)。
- ERC-20代币兑换可能需要授权步骤 — 执行命令会自动处理此操作。