nansen-cli 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/README.md +1 -1
- package/package.json +5 -1
- package/.changeset/README.md +0 -8
- package/AGENTS.md +0 -176
- package/CLAUDE.md +0 -217
- package/SKILL.md +0 -230
- package/TODO.md +0 -42
- package/scripts/check-changeset.js +0 -28
- package/vitest.e2e.config.js +0 -10
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#110](https://github.com/nansen-ai/nansen-cli/pull/110) [`82aa780`](https://github.com/nansen-ai/nansen-cli/commit/82aa78022bdcd62987b0949e090f19f563699d9a) Thanks [@TimNooren](https://github.com/TimNooren)! - Fix `nansen changelog` always showing "CHANGELOG.md not found". Added a `files` field to `package.json` to explicitly bundle `CHANGELOG.md` with the published package. Also excludes `src/__tests__/` from the package, reducing package size from ~537 kB to ~269 kB.
|
|
8
|
+
|
|
9
|
+
## 1.9.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#98](https://github.com/nansen-ai/nansen-cli/pull/98) [`2f3f556`](https://github.com/nansen-ai/nansen-cli/commit/2f3f556d008a1f8ec40d57a8a2822bedbc6b60cb) Thanks [@Codier](https://github.com/Codier)! - Add symbol shortcuts for common tokens (SOL, ETH, USDC, USDT, etc.) that resolve to canonical addresses per chain. Users can now use `--from SOL --to USDC` instead of raw contract addresses.
|
|
14
|
+
|
|
15
|
+
- [#32](https://github.com/nansen-ai/nansen-cli/pull/32) [`08a8d21`](https://github.com/nansen-ai/nansen-cli/commit/08a8d21be6e9196661be737545e790af180aebc3) Thanks [@arein](https://github.com/arein)! - Add WalletConnect support for trading, transfers, and x402 auto-payment (EVM only)
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#99](https://github.com/nansen-ai/nansen-cli/pull/99) [`9144cba`](https://github.com/nansen-ai/nansen-cli/commit/9144cba38b06c90d462df97ea6cbcdeaed26fa36) Thanks [@Codier](https://github.com/Codier)! - Show clear error when `--amount` contains a decimal (e.g. `0.005`) instead of base units (lamports, wei). Detected client-side before hitting the API.
|
|
20
|
+
|
|
21
|
+
- [#100](https://github.com/nansen-ai/nansen-cli/pull/100) [`19559bf`](https://github.com/nansen-ai/nansen-cli/commit/19559bfea6c22f6bd6b8c278ed5e6ae6d64866d5) Thanks [@Codier](https://github.com/Codier)! - Fix `nansen trade help` returning blank output. Now prints subcommands, usage, and examples. Also fixes `errorOutput` ReferenceError in `buildCommands` scope (affected `trade` and `changelog` commands).
|
|
22
|
+
|
|
23
|
+
- [#93](https://github.com/nansen-ai/nansen-cli/pull/93) [`342c91f`](https://github.com/nansen-ai/nansen-cli/commit/342c91fdeb6d98d6b5c10a58cb9702eb5afe096f) Thanks [@Codier](https://github.com/Codier)! - Warn when `--from` is a wrapped native token (WETH/WBNB) or native sentinel, so AI agents can correct the token before execution fails
|
|
24
|
+
|
|
25
|
+
## 1.8.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- [#56](https://github.com/nansen-ai/nansen-cli/pull/56) [`d10998a`](https://github.com/nansen-ai/nansen-cli/commit/d10998aa2be19f80e8476d19bfd46029757a7335) Thanks [@askeluv](https://github.com/askeluv)! - Add CHANGELOG.md, `nansen changelog` command, and post-update "what's new" notice
|
|
30
|
+
|
|
31
|
+
- Added CHANGELOG.md following Keep a Changelog format with history back to v1.5.0
|
|
32
|
+
- Added `nansen changelog` command with `--since <version>` filtering
|
|
33
|
+
- Added one-time upgrade notice on first run after version update (prints to stderr)
|
|
34
|
+
|
|
35
|
+
- [#77](https://github.com/nansen-ai/nansen-cli/pull/77) [`46e4660`](https://github.com/nansen-ai/nansen-cli/commit/46e4660034d9681405d09a5184f78525c300b8a5) Thanks [@0xlaveen](https://github.com/0xlaveen)! - Add token-ohlcv endpoint for OHLCV candle data
|
|
36
|
+
|
|
37
|
+
- [#75](https://github.com/nansen-ai/nansen-cli/pull/75) [`287937e`](https://github.com/nansen-ai/nansen-cli/commit/287937e1d307e0b3f25648863d0c5b4a54d215ff) Thanks [@TimNooren](https://github.com/TimNooren)! - Restructure CLI into research/trade/wallet namespaces
|
|
38
|
+
|
|
39
|
+
- Commands reorganized: `smart-money`, `profiler`, `token`, `portfolio` now live under `nansen research`
|
|
40
|
+
- New `nansen trade` namespace for `quote` and `execute`
|
|
41
|
+
- New `nansen wallet` namespace for wallet management
|
|
42
|
+
- Old top-level commands still work with deprecation warnings
|
|
43
|
+
|
|
44
|
+
- [#61](https://github.com/nansen-ai/nansen-cli/pull/61) [`9af0192`](https://github.com/nansen-ai/nansen-cli/commit/9af01921871be1d0537047cb4ad9733e01876646) Thanks [@askeluv](https://github.com/askeluv)! - Add ENS name resolution for profiler commands. Use `.eth` names directly in `--address` flags — resolved automatically via ensideas API with onchain RPC fallback. Works across all profiler subcommands, batch, and trace operations.
|
|
45
|
+
|
|
46
|
+
All notable changes to the Nansen CLI will be documented in this file.
|
|
47
|
+
|
|
48
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
49
|
+
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
50
|
+
|
|
51
|
+
## [1.7.0] - 2026-02-24
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
|
|
55
|
+
- **Trading commands** — `quote` and `execute` for DEX swaps (EVM + Solana)
|
|
56
|
+
- **Wallet management** — `wallet create`, `list`, `show`, `export`, `default`, `delete`
|
|
57
|
+
- **Wallet send** — transfer tokens on EVM and Solana (`wallet send`)
|
|
58
|
+
- **x402 auto-payment** — automatic payment via Base USDC or Solana SPL USDC
|
|
59
|
+
- Explorer links in transaction output
|
|
60
|
+
- `--dry-run` flag for `wallet send`
|
|
61
|
+
- x402 low balance warning
|
|
62
|
+
- AI Agent Access setup docs and improved onboarding flow
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- Solana execute crash with OKX quotes
|
|
67
|
+
- x402 auto-pay retry path (3 reference errors)
|
|
68
|
+
- Gas estimation — use API `quote.gas` as floor
|
|
69
|
+
- Pre-flight simulation moved after approval (industry standard)
|
|
70
|
+
- EVM signing edge cases with pure JS ECDSA
|
|
71
|
+
- Wallet send crashes on amount parsing and silent success
|
|
72
|
+
- Solana confirmation and SPL token transfer account ordering
|
|
73
|
+
- Suppress duplicate JSON output from quote/execute
|
|
74
|
+
- Suppress approval warning for native ETH swaps
|
|
75
|
+
|
|
76
|
+
### Changed
|
|
77
|
+
|
|
78
|
+
- Pricing clarity — from $0.01/call, min $0.05 balance
|
|
79
|
+
- Consolidated crypto primitives into shared module
|
|
80
|
+
|
|
81
|
+
## [1.6.0] - 2026-02-14
|
|
82
|
+
|
|
83
|
+
### Added
|
|
84
|
+
|
|
85
|
+
- `token indicators` endpoint
|
|
86
|
+
- `profiler search` — general entity search command
|
|
87
|
+
- `--x402-payment-signature` flag for pre-signed payment headers
|
|
88
|
+
- `X-Client-Type` and `X-Client-Version` tracking headers on all API requests
|
|
89
|
+
|
|
90
|
+
### Fixed
|
|
91
|
+
|
|
92
|
+
- Error JSON now outputs to stdout (not stderr) for consistent agent parsing
|
|
93
|
+
- Config loading — environment variables correctly override file config
|
|
94
|
+
|
|
95
|
+
## [1.5.1] - 2026-02-07
|
|
96
|
+
|
|
97
|
+
### Added
|
|
98
|
+
|
|
99
|
+
- Allow API requests without API key when using x402 payment flow
|
|
100
|
+
|
|
101
|
+
## [1.5.0] - 2026-01-31
|
|
102
|
+
|
|
103
|
+
_Baseline version. Changes above are relative to this release._
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/nansen-cli)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
-
[](https://github.com/nansen-ai/nansen-cli/actions/workflows/ci.yml)
|
|
6
6
|
|
|
7
7
|
> **Built by agents, for agents.** We prioritize the best possible AI agent experience.
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nansen-cli",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Command-line interface for Nansen API - designed for AI agents",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"nansen": "./src/index.js"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src/*.js",
|
|
12
|
+
"CHANGELOG.md"
|
|
13
|
+
],
|
|
10
14
|
"scripts": {
|
|
11
15
|
"start": "node src/index.js",
|
|
12
16
|
"pretest": "node scripts/check-changeset.js",
|
package/.changeset/README.md
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Changesets
|
|
2
|
-
|
|
3
|
-
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
|
|
4
|
-
with multi-package repos, or single-package repos to help you version and publish your code. You can
|
|
5
|
-
find the full documentation for it [in the repository](https://github.com/changesets/changesets)
|
|
6
|
-
|
|
7
|
-
We have a quick list of common questions to get you started engaging with this project in
|
|
8
|
-
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
|
package/AGENTS.md
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# AGENTS.md — Contributor Guide
|
|
2
|
-
|
|
3
|
-
Guidance for AI coding agents (Claude Code, Codex, Copilot, etc.) working on this repository. If you're an agent **using** the CLI, see [README.md](README.md).
|
|
4
|
-
|
|
5
|
-
## Architecture
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
src/
|
|
9
|
-
├── index.js # Entry point (shebang, calls runCLI)
|
|
10
|
-
├── cli.js # Command router, arg parsing, schema, help text
|
|
11
|
-
├── api.js # NansenAPI client (REST, retry, cache, x402 auto-pay)
|
|
12
|
-
├── wallet.js # Wallet CRUD (create/list/show/export/delete/send)
|
|
13
|
-
├── trading.js # Quote + execute swaps (OKX router via API)
|
|
14
|
-
├── transfer.js # Token/native transfers (EVM + Solana)
|
|
15
|
-
├── x402.js # x402 payment orchestration (picks network, signs)
|
|
16
|
-
├── x402-evm.js # EVM payment signing (EIP-3009 transferWithAuthorization)
|
|
17
|
-
├── x402-svm.js # Solana payment signing (SPL transfer)
|
|
18
|
-
├── crypto.js # Key encryption/decryption (AES-256-GCM or plaintext)
|
|
19
|
-
└── update-check.js # Version upgrade notice
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
### Command routing
|
|
23
|
-
|
|
24
|
-
`src/index.js` → `runCLI()` in `src/cli.js`
|
|
25
|
-
|
|
26
|
-
Commands are built by three functions, merged in `runCLI()`:
|
|
27
|
-
- `buildCommands()` in cli.js — analytics commands (smart-money, profiler, token, etc.)
|
|
28
|
-
- `buildWalletCommands()` in wallet.js — wallet subcommands
|
|
29
|
-
- `buildTradingCommands()` in trading.js — quote/execute
|
|
30
|
-
|
|
31
|
-
Commands listed in `NO_AUTH_COMMANDS` skip API initialization. Everything else instantiates `NansenAPI` with retry, cache, and x402 config.
|
|
32
|
-
|
|
33
|
-
### Data flow: trade
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
CLI args → api.js GET /defi/quote → quote response
|
|
37
|
-
→ wallet.js decrypt key → trading.js sign tx → api.js POST /defi/execute → broadcast
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Data flow: x402 auto-pay
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
api.js (any call) → 402 response with payment requirements
|
|
44
|
-
→ x402.js rankRequirements() → picks cheapest network (EVM first)
|
|
45
|
-
→ x402-evm.js or x402-svm.js → sign USDC payment
|
|
46
|
-
→ api.js retries original request with Payment-Signature header
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
If EVM payment fails (insufficient funds), the async generator yields a Solana signature as fallback.
|
|
50
|
-
|
|
51
|
-
### Output convention
|
|
52
|
-
|
|
53
|
-
Core functions return data objects. The CLI layer formats via `formatOutput()`. Never `console.log` in core functions — use the `log` dependency injection for CLI output.
|
|
54
|
-
|
|
55
|
-
## Development
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
npm install # Install dependencies
|
|
59
|
-
npm test # Run tests (vitest)
|
|
60
|
-
npm run test:watch # Watch mode
|
|
61
|
-
npm run test:coverage # With coverage
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Running locally
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
node src/index.js <command> [options]
|
|
68
|
-
|
|
69
|
-
# Examples
|
|
70
|
-
node src/index.js wallet create my-wallet
|
|
71
|
-
node src/index.js smart-money --chain solana --limit 5
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Testing
|
|
75
|
-
|
|
76
|
-
- **Framework:** Vitest
|
|
77
|
-
- **Test files:** `src/__tests__/*.test.js`
|
|
78
|
-
- **Current:** 577 tests across 13 test files
|
|
79
|
-
- **All new code must have tests**
|
|
80
|
-
- **Mock all RPC/API calls** — never hit real networks in tests
|
|
81
|
-
|
|
82
|
-
### Test structure
|
|
83
|
-
|
|
84
|
-
```js
|
|
85
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
86
|
-
|
|
87
|
-
global.fetch = vi.fn();
|
|
88
|
-
|
|
89
|
-
describe('featureName', () => {
|
|
90
|
-
beforeEach(() => {
|
|
91
|
-
fetch.mockReset();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should do the thing', async () => {
|
|
95
|
-
fetch.mockResolvedValueOnce({
|
|
96
|
-
ok: true,
|
|
97
|
-
json: async () => ({ jsonrpc: '2.0', result: '0x...', id: 1 })
|
|
98
|
-
});
|
|
99
|
-
// test logic
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Required RPC mocks by code path
|
|
105
|
-
|
|
106
|
-
**EVM transfers:** `eth_getBalance`, `eth_gasPrice`, `eth_maxPriorityFeePerGas`, `eth_getTransactionCount`, `eth_estimateGas`, `eth_getCode`, `eth_sendRawTransaction`, `eth_getTransactionReceipt`
|
|
107
|
-
|
|
108
|
-
**Solana transfers:** `getBalance`, `getLatestBlockhash`, `sendTransaction`, `getSignatureStatuses`
|
|
109
|
-
|
|
110
|
-
**SPL token transfers** (additionally): `getTokenAccountsByOwner`, `getAccountInfo`
|
|
111
|
-
|
|
112
|
-
**Wallet operations:** No RPC mocks needed (file I/O only). Mock `fs` if testing file paths.
|
|
113
|
-
|
|
114
|
-
**API calls:** Mock `fetch` to return `{ ok: true, json: () => ({...}) }` or `{ ok: false, status: 402, headers: new Headers({...}) }` for x402 paths.
|
|
115
|
-
|
|
116
|
-
## Style Guide
|
|
117
|
-
|
|
118
|
-
- **ESM only** (`import`/`export`). No TypeScript, no transpilation.
|
|
119
|
-
- **No interactive prompts in core functions.** Use env vars: `NANSEN_WALLET_PASSWORD`, `NANSEN_API_KEY`.
|
|
120
|
-
- **Error handling:** `throw new Error('descriptive message')` in core. CLI catches and formats.
|
|
121
|
-
- **Actionable error messages** — tell the user what to do:
|
|
122
|
-
- ❌ `"Authentication failed"`
|
|
123
|
-
- ✅ `"Not logged in. Run: nansen login"`
|
|
124
|
-
- **BigInt for token amounts.** Never use floating point. Parse to BigInt with decimals.
|
|
125
|
-
- **Chain branching:** Use `chain === 'solana'` checks, not inheritance/polymorphism.
|
|
126
|
-
- **Minimal dependencies.** Prefer Node.js built-in APIs (crypto, fs, path, http).
|
|
127
|
-
|
|
128
|
-
## PR Checklist
|
|
129
|
-
|
|
130
|
-
- [ ] `npm test` passes (all tests)
|
|
131
|
-
- [ ] New code paths have test coverage
|
|
132
|
-
- [ ] No hardcoded secrets, API keys, or private keys
|
|
133
|
-
- [ ] No `console.log` in core functions (use `log` dep injection)
|
|
134
|
-
- [ ] Error messages are actionable (tell user what to do)
|
|
135
|
-
- [ ] CLI help text updated if adding/changing commands
|
|
136
|
-
- [ ] RPC mocks cover all methods in the code path
|
|
137
|
-
- [ ] Wallet flows work both with and without `NANSEN_WALLET_PASSWORD`
|
|
138
|
-
- [ ] Changeset added if changing user-facing behavior (add a `.changeset/<name>.md` file — `npm test` will warn if missing)
|
|
139
|
-
|
|
140
|
-
## Chains & Networks
|
|
141
|
-
|
|
142
|
-
**EVM:** Ethereum (chain ID 1), Base (8453). `CHAIN_IDS` in transfer.js only maps these two — other EVM chains will fail for transfers.
|
|
143
|
-
|
|
144
|
-
**Solana:** mainnet-beta. Supports native SOL, standard SPL tokens, and Token-2022 (Token Extensions).
|
|
145
|
-
|
|
146
|
-
**RPC endpoints:** Hardcoded in `CHAIN_RPCS` (transfer.js). Nansen API handles RPC for trading.
|
|
147
|
-
|
|
148
|
-
## Key Constants
|
|
149
|
-
|
|
150
|
-
| Constant | Value |
|
|
151
|
-
|----------|-------|
|
|
152
|
-
| USDC (Base) | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` |
|
|
153
|
-
| USDC (Solana) | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |
|
|
154
|
-
| x402 payment | $0.05 USDC per API call |
|
|
155
|
-
| Gas buffer | API provides `quote.gas` with 1.5x multiplier — use directly |
|
|
156
|
-
|
|
157
|
-
## Endpoint Quirks
|
|
158
|
-
|
|
159
|
-
These are internal details agents should know when writing or debugging tests:
|
|
160
|
-
|
|
161
|
-
- **`token holders --smart-money`** — Returns `UNSUPPORTED_FILTER` for tokens without smart money tracking. Not all tokens have this data.
|
|
162
|
-
- **`token flow-intelligence`** — May return all-zero flows for illiquid tokens. Normal, not an error.
|
|
163
|
-
- **`token screener --search`** — Client-side filtering. The CLI fetches up to 500 results, then filters locally.
|
|
164
|
-
- **`--fields`** — Applies to the entire response tree, including the `success`/`data` wrapper.
|
|
165
|
-
- **Profiler beta endpoints** use `recordsPerPage` instead of `per_page`. The CLI handles this automatically.
|
|
166
|
-
- **`profiler perp-positions`** — No pagination support; the API ignores the pagination parameter.
|
|
167
|
-
|
|
168
|
-
## Known Gotchas
|
|
169
|
-
|
|
170
|
-
1. **EIP-7702 delegated accounts** on Base have contract code. Always use `eth_estimateGas`, never hardcode 21000 gas.
|
|
171
|
-
2. **Solana SPL account ordering:** Writable accounts (destATA) must precede readonly (mint) in the transaction message.
|
|
172
|
-
3. **`getSignatureStatuses`** over `confirmTransaction` — the latter is deprecated and unreliable on public RPCs.
|
|
173
|
-
4. **`--max` native SOL:** Reserve 5000 lamports for fee. On EVM L2s, reserve 3x estimated gas for L1 data posting fees.
|
|
174
|
-
5. **Token-2022:** Use `TOKEN_2022_PROGRAM_ID` and `TransferCheckedInstruction` (not plain `Transfer`).
|
|
175
|
-
6. **CreateATA path:** When recipient doesn't have a token account, the sender creates it. This path in transfer.js has limited test coverage — add tests if modifying.
|
|
176
|
-
7. **`CHAIN_IDS` is incomplete:** Only ethereum and base are mapped. Adding new EVM chain support requires updating this map.
|
package/CLAUDE.md
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
AI assistant guide for contributing to nansen-cli.
|
|
4
|
-
|
|
5
|
-
## What This Is
|
|
6
|
-
|
|
7
|
-
A CLI for the [Nansen API](https://docs.nansen.ai), designed specifically for AI agents. All output is structured JSON. 30 endpoints across Smart Money, Profiler, Token God Mode, and Portfolio.
|
|
8
|
-
|
|
9
|
-
## Quick Start
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm install
|
|
13
|
-
npm test # Run mocked tests (no API key needed)
|
|
14
|
-
npm run test:live # Run against live API (needs NANSEN_API_KEY)
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Project Structure
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
src/
|
|
21
|
-
├── index.js # Thin CLI entry point (imports cli.js)
|
|
22
|
-
├── cli.js # CLI logic: parsing, routing, formatting, schema
|
|
23
|
-
├── api.js # NansenAPI class, all HTTP calls, validation
|
|
24
|
-
└── __tests__/
|
|
25
|
-
├── unit.test.js # Core logic tests (validation, parsing, formatting)
|
|
26
|
-
├── api.test.js # API method tests with mocked fetch
|
|
27
|
-
├── cli.test.js # CLI integration tests (subprocess)
|
|
28
|
-
├── cli.internal.test.js # CLI unit tests (direct imports for coverage)
|
|
29
|
-
└── coverage.test.js # Endpoint coverage verification
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
**Three files, clear separation:**
|
|
33
|
-
- `index.js` = Entry point (thin wrapper)
|
|
34
|
-
- `cli.js` = CLI layer (parsing, routing, output formatting, schema)
|
|
35
|
-
- `api.js` = API layer (HTTP, validation, config)
|
|
36
|
-
|
|
37
|
-
## Code Conventions
|
|
38
|
-
|
|
39
|
-
- **ES modules** (`import`/`export`, not `require`)
|
|
40
|
-
- **Async/await** for all API calls
|
|
41
|
-
- **All output is JSON** (for AI agent consumption)
|
|
42
|
-
- **No external dependencies** (just Node.js built-ins + vitest for tests)
|
|
43
|
-
|
|
44
|
-
## Adding a New Endpoint
|
|
45
|
-
|
|
46
|
-
1. **Add API method in `src/api.js`:**
|
|
47
|
-
```javascript
|
|
48
|
-
async newEndpoint(params = {}) {
|
|
49
|
-
const { chain = 'solana', filters = {}, orderBy, pagination } = params;
|
|
50
|
-
return this.request('/api/v1/endpoint-path', {
|
|
51
|
-
chain,
|
|
52
|
-
filters,
|
|
53
|
-
order_by: orderBy,
|
|
54
|
-
pagination
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
2. **Add CLI handler in `src/index.js`:**
|
|
60
|
-
```javascript
|
|
61
|
-
// In the appropriate command handler (smart-money, profiler, token, portfolio)
|
|
62
|
-
'new-subcommand': () => api.newEndpoint({ chains, filters, orderBy, pagination }),
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
3. **Add tests:**
|
|
66
|
-
- `api.test.js` — Mock the fetch, verify request body
|
|
67
|
-
- `cli.test.js` — Test CLI invocation
|
|
68
|
-
- `coverage.test.js` — Add to `DOCUMENTED_ENDPOINTS`
|
|
69
|
-
|
|
70
|
-
4. **Update `README.md`** with docs
|
|
71
|
-
|
|
72
|
-
## Testing
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
npm test # All tests, mocked
|
|
76
|
-
npm run test:watch # Watch mode
|
|
77
|
-
npm run test:coverage # With coverage report
|
|
78
|
-
NANSEN_API_KEY=xxx npm run test:live # Live API tests
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**Test philosophy:**
|
|
82
|
-
- Unit tests don't need API key (use mocked fetch)
|
|
83
|
-
- Live tests are opt-in via `NANSEN_LIVE_TEST=1`
|
|
84
|
-
- Coverage test ensures all documented endpoints have implementations
|
|
85
|
-
|
|
86
|
-
## Common Patterns
|
|
87
|
-
|
|
88
|
-
### Address Validation
|
|
89
|
-
```javascript
|
|
90
|
-
// Validates EVM (0x...) or Solana (Base58) addresses
|
|
91
|
-
const validation = validateAddress(address, chain);
|
|
92
|
-
if (!validation.valid) throw new Error(validation.error);
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Date Ranges
|
|
96
|
-
```javascript
|
|
97
|
-
// Most endpoints accept days param, converted to date range
|
|
98
|
-
const to = new Date().toISOString().split('T')[0];
|
|
99
|
-
const from = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Retry Behavior
|
|
103
|
-
- **Enabled by default** with 3 attempts
|
|
104
|
-
- Retries on: 429, 500, 502, 503, 504, network errors
|
|
105
|
-
- Exponential backoff with jitter (1s base, 30s max)
|
|
106
|
-
- Respects `retry-after` headers
|
|
107
|
-
- Disable with `--no-retry` or `options.retry = false`
|
|
108
|
-
- Success responses include `_meta.retriedAttempts` if retried
|
|
109
|
-
|
|
110
|
-
### Response Format
|
|
111
|
-
```javascript
|
|
112
|
-
// Success
|
|
113
|
-
{ "success": true, "data": { ... } }
|
|
114
|
-
|
|
115
|
-
// Error
|
|
116
|
-
{ "success": false, "error": "message", "code": "ERROR_CODE", "status": 401, "details": { ... } }
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Schema Discovery
|
|
120
|
-
```bash
|
|
121
|
-
nansen schema # Full schema (commands, options, types)
|
|
122
|
-
nansen schema smart-money # Schema for specific command
|
|
123
|
-
```
|
|
124
|
-
Returns JSON with all commands, subcommands, option types/defaults, return fields, supported chains, and smart money labels. No API key required.
|
|
125
|
-
|
|
126
|
-
### Field Filtering
|
|
127
|
-
```bash
|
|
128
|
-
nansen research smart-money netflow --fields token_symbol,net_flow_usd,chain
|
|
129
|
-
```
|
|
130
|
-
Reduces response size by including only specified fields. Works with nested data structures.
|
|
131
|
-
|
|
132
|
-
### Error Codes
|
|
133
|
-
Structured error codes for programmatic handling:
|
|
134
|
-
|
|
135
|
-
| Code | Description |
|
|
136
|
-
|------|-------------|
|
|
137
|
-
| `UNAUTHORIZED` | Invalid or missing API key (401) |
|
|
138
|
-
| `FORBIDDEN` | Valid key but insufficient permissions (403) |
|
|
139
|
-
| `CREDITS_EXHAUSTED` | Insufficient API credits (403) — do not retry |
|
|
140
|
-
| `RATE_LIMITED` | Too many requests (429) |
|
|
141
|
-
| `INVALID_ADDRESS` | Address format validation failed |
|
|
142
|
-
| `INVALID_TOKEN` | Token address validation failed |
|
|
143
|
-
| `INVALID_CHAIN` | Unsupported or invalid chain |
|
|
144
|
-
| `INVALID_PARAMS` | Generic parameter validation error |
|
|
145
|
-
| `MISSING_PARAM` | Required parameter not provided |
|
|
146
|
-
| `UNSUPPORTED_FILTER` | Filter not supported for this token/chain (400) |
|
|
147
|
-
| `NOT_FOUND` | Resource not found (404) |
|
|
148
|
-
| `TOKEN_NOT_FOUND` | Token doesn't exist |
|
|
149
|
-
| `ADDRESS_NOT_FOUND` | Address has no data |
|
|
150
|
-
| `SERVER_ERROR` | Nansen API internal error (500+) |
|
|
151
|
-
| `SERVICE_UNAVAILABLE` | API temporarily down (503) |
|
|
152
|
-
| `NETWORK_ERROR` | Connection failed |
|
|
153
|
-
| `TIMEOUT` | Request timed out |
|
|
154
|
-
| `UNKNOWN` | Unclassified error |
|
|
155
|
-
|
|
156
|
-
## API Reference
|
|
157
|
-
|
|
158
|
-
### Chains
|
|
159
|
-
`ethereum`, `solana`, `base`, `bnb`, `arbitrum`, `polygon`, `optimism`, `avalanche`, `linea`, `scroll`, `zksync`, `mantle`, `ronin`, `sei`, `plasma`, `sonic`, `unichain`, `monad`, `hyperevm`, `iotaevm`
|
|
160
|
-
|
|
161
|
-
### Smart Money Labels
|
|
162
|
-
`Fund`, `Smart Trader`, `30D Smart Trader`, `90D Smart Trader`, `180D Smart Trader`, `Smart HL Perps Trader`
|
|
163
|
-
|
|
164
|
-
### Endpoints by Category
|
|
165
|
-
|
|
166
|
-
**Smart Money (6):** netflow, dex-trades, perp-trades, holdings, dcas, historical-holdings
|
|
167
|
-
|
|
168
|
-
**Profiler (11):** balance, labels, transactions, pnl, search, historical-balances, related-wallets, counterparties, pnl-summary, perp-positions, perp-trades
|
|
169
|
-
|
|
170
|
-
**Token God Mode (12):** screener, holders, flows, dex-trades, pnl, who-bought-sold, flow-intelligence, transfers, jup-dca, perp-trades, perp-positions, perp-pnl-leaderboard
|
|
171
|
-
|
|
172
|
-
**Portfolio (1):** defi-holdings
|
|
173
|
-
|
|
174
|
-
## Gotchas
|
|
175
|
-
|
|
176
|
-
- **Perp endpoints** work with Hyperliquid (use `--symbol BTC` not `--token`)
|
|
177
|
-
- **JUP DCA** is Solana-only
|
|
178
|
-
- **Beta endpoints** (`/api/beta/...`) may have different pagination
|
|
179
|
-
- **EVM vs Solana addresses** — validation auto-detects based on chain param
|
|
180
|
-
|
|
181
|
-
## Publishing (npm)
|
|
182
|
-
|
|
183
|
-
**DO NOT manually run `npm version` or `npm publish`. CI handles everything.**
|
|
184
|
-
|
|
185
|
-
1. **Push to main** — CI runs tests
|
|
186
|
-
2. **CI creates a "Version Packages" PR** — bumps version + updates CHANGELOG
|
|
187
|
-
3. **Merge the Version PR** — CI auto-publishes to npm
|
|
188
|
-
|
|
189
|
-
If you mess up: accidentally bumped version manually? `git revert` and add a changeset instead. CI publish failed? Check GitHub Actions logs, likely needs `NPM_TOKEN` secret refresh.
|
|
190
|
-
|
|
191
|
-
## Changesets
|
|
192
|
-
|
|
193
|
-
Every PR that changes user-facing behavior **must** include a changeset file. `npm test` will warn if one is missing. The changeset description ends up in CHANGELOG.md (auto-generated by CI), so write it as a user-facing changelog entry.
|
|
194
|
-
|
|
195
|
-
**Needs a changeset:** new features, bug fixes, breaking changes, changed CLI output, new/modified commands.
|
|
196
|
-
|
|
197
|
-
**Does NOT need a changeset:** docs-only, test-only, refactors with no behavior change, CI/tooling.
|
|
198
|
-
|
|
199
|
-
Add a file to `.changeset/` with a descriptive kebab-case name:
|
|
200
|
-
|
|
201
|
-
```markdown
|
|
202
|
-
---
|
|
203
|
-
"nansen-cli": minor
|
|
204
|
-
---
|
|
205
|
-
|
|
206
|
-
Short description of the change (appears in CHANGELOG)
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
Use `patch` for bug fixes, `minor` for new features, `major` for breaking changes.
|
|
210
|
-
|
|
211
|
-
## PR Checklist
|
|
212
|
-
|
|
213
|
-
- [ ] Tests pass (`npm test`)
|
|
214
|
-
- [ ] New endpoints have tests in all 3 test files
|
|
215
|
-
- [ ] README.md updated if adding user-facing features
|
|
216
|
-
- [ ] Changeset added for user-facing changes (see above)
|
|
217
|
-
- [ ] No new dependencies (keep it lightweight)
|
package/SKILL.md
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: nansen-cli
|
|
3
|
-
description: Nansen CLI for onchain analytics, smart money tracking, DEX trading, and perp markets.
|
|
4
|
-
license: MIT
|
|
5
|
-
metadata:
|
|
6
|
-
author: nansen-ai
|
|
7
|
-
version: "1.8.0"
|
|
8
|
-
repository: https://github.com/nansen-ai/nansen-cli
|
|
9
|
-
compatibility: Node.js 18+. Works with Claude Code, Codex, Cursor, Windsurf, and any terminal-native agent.
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Nansen CLI
|
|
13
|
-
|
|
14
|
-
Onchain analytics and DEX trading for AI agents.
|
|
15
|
-
|
|
16
|
-
## Quick Reference
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
# Search for any token, wallet, or entity
|
|
20
|
-
nansen research search "jupiter" --type token
|
|
21
|
-
|
|
22
|
-
# Token price (OHLCV)
|
|
23
|
-
nansen research token ohlcv --token <addr> --chain solana --timeframe 1h --limit 24
|
|
24
|
-
|
|
25
|
-
# Smart Money — what are the pros buying?
|
|
26
|
-
nansen research smart-money netflow --chain solana --limit 10
|
|
27
|
-
|
|
28
|
-
# Token screener — trending tokens
|
|
29
|
-
nansen research token screener --chain solana --timeframe 24h --smart-money --limit 20
|
|
30
|
-
|
|
31
|
-
# Trade — quote then execute
|
|
32
|
-
nansen trade quote --chain solana --from <from_token_address> --to <to_token_address> --amount <base_units>
|
|
33
|
-
nansen trade execute --quote <quote-id>
|
|
34
|
-
|
|
35
|
-
# Create a wallet
|
|
36
|
-
nansen wallet create # interactive
|
|
37
|
-
NANSEN_WALLET_PASSWORD="pass" nansen wallet create # non-interactive
|
|
38
|
-
|
|
39
|
-
# Discover all commands, options, and return fields
|
|
40
|
-
nansen schema
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Setup
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm install -g nansen-cli
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Auth (pick one)
|
|
50
|
-
|
|
51
|
-
**x402 Pay-Per-Call (no API key needed):**
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
nansen wallet create # Generates EVM + Solana keypair
|
|
55
|
-
# Fund the EVM address with USDC on Base (~$0.50 minimum)
|
|
56
|
-
export NANSEN_WALLET_PASSWORD="your-password" # Skip interactive prompt
|
|
57
|
-
# Done — CLI auto-pays $0.01-$0.05 per call
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**API Key:**
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
export NANSEN_API_KEY=your-api-key
|
|
64
|
-
# Or: nansen login --api-key YOUR_KEY
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Get a key at [app.nansen.ai/api](https://app.nansen.ai/api).
|
|
68
|
-
|
|
69
|
-
## Smart Money
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
nansen research smart-money netflow --chain solana --limit 10
|
|
73
|
-
nansen research smart-money dex-trades --chain solana --labels "Smart Trader" --limit 20
|
|
74
|
-
nansen research smart-money holdings --chain solana --limit 10
|
|
75
|
-
nansen research smart-money perp-trades --limit 10 # no --chain (Hyperliquid only)
|
|
76
|
-
nansen research smart-money dcas --limit 10 # no --chain (Jupiter/Solana only)
|
|
77
|
-
nansen research smart-money historical-holdings --chain solana --token-address <addr>
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Labels: `Fund`, `Smart Trader`, `30D Smart Trader`, `90D Smart Trader`, `180D Smart Trader`, `Smart HL Perps Trader`
|
|
81
|
-
|
|
82
|
-
## Token Analytics
|
|
83
|
-
|
|
84
|
-
`--chain` required. Use `--token` for the token address.
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
nansen research token screener --chain solana --timeframe 24h --smart-money --limit 20
|
|
88
|
-
nansen research token info --token <addr> --chain solana
|
|
89
|
-
nansen research token indicators --token <addr> --chain solana
|
|
90
|
-
nansen research token ohlcv --token <addr> --chain solana --timeframe 1h --limit 24
|
|
91
|
-
nansen research token holders --token <addr> --chain solana --smart-money
|
|
92
|
-
nansen research token flows --token <addr> --chain solana --days 7
|
|
93
|
-
nansen research token flow-intelligence --token <addr> --chain solana
|
|
94
|
-
nansen research token who-bought-sold --token <addr> --chain solana
|
|
95
|
-
nansen research token dex-trades --token <addr> --chain solana --limit 20
|
|
96
|
-
nansen research token pnl --token <addr> --chain solana --sort total_pnl_usd:desc
|
|
97
|
-
nansen research token transfers --token <addr> --chain solana --enrich
|
|
98
|
-
nansen research token jup-dca --token <addr> # no --chain
|
|
99
|
-
nansen research token perp-trades --symbol ETH --days 7 # no --chain, uses --symbol
|
|
100
|
-
nansen research token perp-positions --symbol BTC # no --chain
|
|
101
|
-
nansen research token perp-pnl-leaderboard --symbol SOL # no --chain
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Native tokens (SOL, ETH) are not supported on most token endpoints — use specific token addresses.
|
|
105
|
-
|
|
106
|
-
## Wallet Profiler
|
|
107
|
-
|
|
108
|
-
`--chain` and `--address` required for most commands.
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
nansen research profiler balance --address <addr> --chain solana
|
|
112
|
-
nansen research profiler labels --address <addr> --chain ethereum
|
|
113
|
-
nansen research profiler pnl --address <addr> --chain ethereum --days 30
|
|
114
|
-
nansen research profiler pnl-summary --address <addr> --chain ethereum
|
|
115
|
-
nansen research profiler transactions --address <addr> --chain ethereum --limit 20
|
|
116
|
-
nansen research profiler historical-balances --address <addr> --chain solana --days 30
|
|
117
|
-
nansen research profiler related-wallets --address <addr> --chain ethereum
|
|
118
|
-
nansen research profiler counterparties --address <addr> --chain ethereum
|
|
119
|
-
nansen research profiler perp-positions --address <addr> # no --chain
|
|
120
|
-
nansen research profiler perp-trades --address <addr> # no --chain
|
|
121
|
-
nansen research profiler search --query "Vitalik" # no --chain
|
|
122
|
-
nansen research profiler batch --addresses "0xabc,0xdef" --chain ethereum --include labels,balance,pnl
|
|
123
|
-
nansen research profiler trace --address <addr> --chain ethereum --depth 2 --width 10 # ⚠️ makes N×width API calls
|
|
124
|
-
nansen research profiler compare --addresses "0xabc,0xdef" --chain ethereum
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Search
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
nansen research search "jupiter" --type token
|
|
131
|
-
nansen research search "Vitalik" --type entity --limit 5
|
|
132
|
-
nansen research search "0xd8dA..." # by address
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Perps (Hyperliquid)
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
nansen research perp screener --sort volume_usd:desc --limit 20
|
|
139
|
-
nansen research perp leaderboard --days 7 --limit 20
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Portfolio
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
nansen research portfolio defi --wallet <addr>
|
|
146
|
-
nansen research points leaderboard --tier green --limit 20
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## Trading
|
|
150
|
-
|
|
151
|
-
Two-step: quote then execute.
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
# Get quotes from multiple aggregators (Jupiter, OKX, LiFi)
|
|
155
|
-
nansen trade quote --chain solana \
|
|
156
|
-
--from <from_token_address> \
|
|
157
|
-
--to <to_token_address> \
|
|
158
|
-
--amount <base_units>
|
|
159
|
-
|
|
160
|
-
# Execute the best quote
|
|
161
|
-
nansen trade execute --quote <quote-id>
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
> ⚠️ Always inspect the quote response (price, slippage, expiry) before executing.
|
|
165
|
-
> Quotes expire — if you wait too long, execute will fail. Get a fresh quote and retry.
|
|
166
|
-
> Trades are irreversible once executed on-chain.
|
|
167
|
-
|
|
168
|
-
**⚠️ Amounts are in base units (not human-readable):**
|
|
169
|
-
|
|
170
|
-
| Token | Decimals | 1 unit = |
|
|
171
|
-
|-------|----------|----------|
|
|
172
|
-
| SOL | 9 | 1000000000 lamports |
|
|
173
|
-
| ETH | 18 | 1000000000000000000 wei |
|
|
174
|
-
| USDC | 6 | 1000000 |
|
|
175
|
-
|
|
176
|
-
Symbol shortcuts (SOL, ETH) don't work yet — use full addresses.
|
|
177
|
-
|
|
178
|
-
### Common Addresses
|
|
179
|
-
|
|
180
|
-
**Solana:** SOL `So11111111111111111111111111111111111111112` · USDC `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` · JUP `JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN`
|
|
181
|
-
|
|
182
|
-
**Base:** ETH `0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee` · USDC `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` · DEGEN `0x4ed4e862860bed51a9570b96d89af5e1b0efefed`
|
|
183
|
-
|
|
184
|
-
## Wallet Management
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
nansen wallet create # Create EVM + Solana keypair
|
|
188
|
-
nansen wallet list # List wallets
|
|
189
|
-
nansen wallet send --to <addr> --amount 1.5 --chain evm # Send native
|
|
190
|
-
nansen wallet send --to <addr> --chain evm --max # Send entire balance
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## Common Options
|
|
194
|
-
|
|
195
|
-
| Option | Description |
|
|
196
|
-
|--------|-------------|
|
|
197
|
-
| `--chain` | Required for most commands. See [Supported Chains](#supported-chains) |
|
|
198
|
-
| `--token` | Token address (aliases: `--mint`, `--token-address`) |
|
|
199
|
-
| `--address` | Wallet address |
|
|
200
|
-
| `--limit` | Results per page (default 10) |
|
|
201
|
-
| `--days` | Lookback period in days (default 30) |
|
|
202
|
-
| `--sort` | Sort field:direction (e.g. `value_usd:desc`) |
|
|
203
|
-
| `--smart-money` | Filter to smart money wallets only |
|
|
204
|
-
| `--pretty` | Formatted JSON output |
|
|
205
|
-
| `--table` | ASCII table output |
|
|
206
|
-
| `--stream` | NDJSON (one record per line) |
|
|
207
|
-
| `--fields a,b` | Return only specific fields |
|
|
208
|
-
| `--cache` | Cache responses (300s TTL). **Do not use with `trade` commands** — stale prices/quotes can cause bad trades |
|
|
209
|
-
|
|
210
|
-
## Schema Introspection
|
|
211
|
-
|
|
212
|
-
> **Stuck?** Run `nansen schema` or `nansen schema <command>` to discover all available commands, options, and return fields.
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
nansen schema # Full JSON schema — all commands, options, return fields
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## Supported Chains
|
|
219
|
-
|
|
220
|
-
**Research:** `solana`, `ethereum`, `base`, `bnb`, `arbitrum`, `polygon`, `optimism`, `avalanche`, `linea`, `scroll`, `mantle`, `ronin`, `sei`, `plasma`, `sonic`, `monad`, `hyperevm`, `iotaevm`
|
|
221
|
-
|
|
222
|
-
**Trading & x402:** `solana`, `base`
|
|
223
|
-
|
|
224
|
-
## Gotchas
|
|
225
|
-
|
|
226
|
-
- Native tokens (SOL, ETH) don't work on most token endpoints — use wrapped addresses
|
|
227
|
-
- Perp commands don't take `--chain` (Hyperliquid only)
|
|
228
|
-
- `--amount` is always in base units, not human-readable
|
|
229
|
-
- Profiler `trace` makes N×width API calls — can burn credits fast
|
|
230
|
-
- x402 auth needs USDC on Base, not Solana
|
package/TODO.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# TODO
|
|
2
|
-
|
|
3
|
-
> **Built by agents, for agents.** We prioritize improvements that create the best possible AI agent experience.
|
|
4
|
-
|
|
5
|
-
## P0 - Trading Agent Support
|
|
6
|
-
|
|
7
|
-
### Wallet Management
|
|
8
|
-
- [ ] `nansen wallet create` — generate a local wallet (per chain), store key securely on disk
|
|
9
|
-
- [ ] `nansen wallet address` — print the wallet address for funding
|
|
10
|
-
- [ ] `nansen wallet balance` — check wallet balance
|
|
11
|
-
|
|
12
|
-
### Trading Execution
|
|
13
|
-
- [x] `nansen quote` — get a quote for a DEX swap (chain, tokens, amount)
|
|
14
|
-
- [x] `nansen execute` — sign and submit a trade via Nansen API (takes quote-id)
|
|
15
|
-
- [ ] ⚠️ EVM transaction signing — requires thorough security review before production use
|
|
16
|
-
|
|
17
|
-
> These commands are required for `nansen-trading-agent` — the autonomous trading sub-agent.
|
|
18
|
-
> Wallet commands should keep the agent self-contained with zero external dependencies.
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## P2 - Nice to Have
|
|
23
|
-
|
|
24
|
-
### Test Coverage Gaps
|
|
25
|
-
- [ ] Test config priority chain (ENV > ~/.nansen > local) — needs `loadConfig()` exported
|
|
26
|
-
- [ ] Add snapshot tests for `--help` output
|
|
27
|
-
- [ ] Document magic test addresses (e.g. Binance hot wallet)
|
|
28
|
-
- [ ] Test Bitcoin address validation
|
|
29
|
-
- [ ] Test stdin pipe mode for API key input
|
|
30
|
-
|
|
31
|
-
### Shell Completions
|
|
32
|
-
- [ ] Bash completions
|
|
33
|
-
- [ ] Zsh completions
|
|
34
|
-
- [ ] Fish completions
|
|
35
|
-
|
|
36
|
-
### Distribution
|
|
37
|
-
- [ ] Homebrew formula (`brew install nansen-cli`)
|
|
38
|
-
- [ ] Docker image
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
*Last updated: 2026-02-06*
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Non-blocking check: warns if the current branch has no new changeset file
|
|
5
|
-
* compared to main. Runs as a pretest hook so agents and humans see a reminder.
|
|
6
|
-
* Always exits 0 — this is a nudge, not a gate.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { execSync } from "child_process";
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
const branch = execSync("git rev-parse --abbrev-ref HEAD", { encoding: "utf8" }).trim();
|
|
13
|
-
if (branch === "main") process.exit(0);
|
|
14
|
-
|
|
15
|
-
const newChangesets = execSync(
|
|
16
|
-
"git diff main --name-only --diff-filter=A -- .changeset/*.md",
|
|
17
|
-
{ encoding: "utf8" }
|
|
18
|
-
).trim();
|
|
19
|
-
|
|
20
|
-
if (!newChangesets) {
|
|
21
|
-
console.error(
|
|
22
|
-
"\x1b[33m[changeset] No new changeset file found on this branch. " +
|
|
23
|
-
"If this PR changes user-facing behavior, add one: npx changeset\x1b[0m"
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
} catch {
|
|
27
|
-
// Not a git repo, main doesn't exist, etc. — skip silently.
|
|
28
|
-
}
|