nansen-cli 1.25.0 → 1.25.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.25.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#367](https://github.com/nansen-ai/nansen-cli/pull/367) [`9fea10a`](https://github.com/nansen-ai/nansen-cli/commit/9fea10a844acbaccf37a348dfd4efd5c32f76a4a) Thanks [@kome12](https://github.com/kome12)! - add --premium-labels flag to tgm/holders, tgm/pnl-leaderboard, tgm/perp-pnl-leaderboard, and perp-leaderboard endpoints
8
+
3
9
  ## 1.25.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nansen-cli",
3
- "version": "1.25.0",
3
+ "version": "1.25.1",
4
4
  "description": "Command-line interface for Nansen API - designed for AI agents",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -85,13 +85,15 @@ nansen trade execute --quote "$quote_id"
85
85
 
86
86
  ## Amounts
87
87
 
88
- By default, `--amount` accepts **integer base units** (lamports, wei, etc). Use `--amount-unit token` to specify human-readable token amounts instead — the CLI resolves decimals locally and sends base units to the API.
88
+ 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.
89
89
 
90
90
  ```bash
91
91
  # Base units (default)
92
92
  nansen trade quote --chain solana --from SOL --to USDC --amount 1000000000
93
93
  # Token units (0.5 SOL = 500000000 lamports, resolved automatically)
94
94
  nansen trade quote --chain solana --from SOL --to USDC --amount 0.5 --amount-unit token
95
+ # USD amount ($50 worth of SOL, price resolved via Nansen search API)
96
+ nansen trade quote --chain solana --from SOL --to USDC --amount 50 --amount-unit usd
95
97
  ```
96
98
 
97
99
  | Token | Decimals | 1 token = |
@@ -100,25 +102,43 @@ nansen trade quote --chain solana --from SOL --to USDC --amount 0.5 --amount-uni
100
102
  | ETH | 18 | `1000000000000000000` |
101
103
  | USDC | 6 | `1000000` |
102
104
 
103
- If the user says "$20 worth of X", you must convert USD → token amount, then either pass base units or use `--amount-unit token`. For example, to buy $20 of SOL at $150/SOL: $20 ÷ $150 = 0.1333 SOL `--amount 0.1333 --amount-unit token`. Use a price lookup (e.g. `nansen research token info`) to get the current price first.
105
+ 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.
104
106
 
105
107
  ## Flags
106
108
 
109
+ ### `trade quote` flags
110
+
107
111
  | Flag | Purpose |
108
112
  |------|---------|
109
113
  | `--chain` | Source chain: `solana` or `base` |
110
114
  | `--to-chain` | Destination chain for cross-chain swap (omit for same-chain) |
111
115
  | `--from` | Source token (symbol or address) |
112
116
  | `--to` | Destination token (symbol or address, resolved against destination chain) |
113
- | `--amount` | Amount in base units (integer), or token units with `--amount-unit token` |
114
- | `--amount-unit` | Set to `token` to specify amount in token units (e.g. 0.5 SOL) |
117
+ | `--amount` | Amount in base units (integer), or token/USD units with `--amount-unit` |
118
+ | `--amount-unit` | `token` for token units (e.g. 0.5 SOL), `usd` for USD (e.g. 50), `base` = default |
115
119
  | `--wallet` | Wallet name (default: default wallet) |
116
120
  | `--to-wallet` | Destination wallet address (auto-derived for cross-chain if omitted) |
117
121
  | `--slippage` | Slippage tolerance as decimal (e.g. 0.03) |
118
- | `--quote` | Quote ID for execute |
122
+ | `--auto-slippage` | Enable auto slippage calculation |
123
+ | `--max-auto-slippage` | Max auto slippage when `--auto-slippage` is enabled |
124
+ | `--swap-mode` | `exactIn` (default) or `exactOut` |
125
+
126
+ ### `trade execute` flags
127
+
128
+ | Flag | Purpose |
129
+ |------|---------|
130
+ | `--quote` | Quote ID from `trade quote` |
131
+ | `--wallet` | Wallet name (default: default wallet) |
132
+ | `--quote-index` | Pin a specific quote by index (0-based) when multiple quotes were returned |
119
133
  | `--no-simulate` | Skip pre-broadcast simulation |
120
- | `--tx-hash` | Source tx hash (for bridge-status) |
134
+
135
+ ### `trade bridge-status` flags
136
+
137
+ | Flag | Purpose |
138
+ |------|---------|
139
+ | `--tx-hash` | Source tx hash |
121
140
  | `--from-chain` | Source chain (for bridge-status) |
141
+ | `--to-chain` | Destination chain (for bridge-status) |
122
142
 
123
143
  ## Environment Variables
124
144
 
package/src/api.js CHANGED
@@ -971,19 +971,21 @@ export class NansenAPI {
971
971
  }
972
972
 
973
973
  async tokenHolders(params = {}) {
974
- const { tokenAddress, chain = 'solana', labelType = 'all_holders', filters = {}, orderBy, pagination } = params;
974
+ const { tokenAddress, chain = 'solana', labelType = 'all_holders', filters = {}, orderBy, pagination, withLabels } = params;
975
975
  if (tokenAddress) {
976
976
  const validation = validateTokenAddress(tokenAddress, chain);
977
977
  if (!validation.valid) throw new NansenError(validation.error, validation.code);
978
978
  }
979
- return this.request('/api/v1/tgm/holders', {
979
+ const body = {
980
980
  token_address: tokenAddress,
981
981
  chain,
982
982
  label_type: labelType,
983
983
  filters,
984
984
  order_by: orderBy,
985
985
  pagination
986
- });
986
+ };
987
+ if (withLabels !== undefined) body.premium_labels = withLabels;
988
+ return this.request('/api/v1/tgm/holders', body);
987
989
  }
988
990
 
989
991
  async tokenFlows(params = {}) {
@@ -1027,19 +1029,21 @@ export class NansenAPI {
1027
1029
  }
1028
1030
 
1029
1031
  async tokenPnlLeaderboard(params = {}) {
1030
- const { tokenAddress, chain = 'solana', filters = {}, orderBy, pagination, days = 30 } = params;
1032
+ const { tokenAddress, chain = 'solana', filters = {}, orderBy, pagination, days = 30, withLabels } = params;
1031
1033
  if (tokenAddress) {
1032
1034
  const validation = validateTokenAddress(tokenAddress, chain);
1033
1035
  if (!validation.valid) throw new NansenError(validation.error, validation.code);
1034
1036
  }
1035
- return this.request('/api/v1/tgm/pnl-leaderboard', {
1037
+ const body = {
1036
1038
  token_address: tokenAddress,
1037
1039
  chain,
1038
1040
  date: buildDateRange(days),
1039
1041
  filters,
1040
1042
  order_by: orderBy,
1041
1043
  pagination
1042
- });
1044
+ };
1045
+ if (withLabels !== undefined) body.premium_labels = withLabels;
1046
+ return this.request('/api/v1/tgm/pnl-leaderboard', body);
1043
1047
  }
1044
1048
 
1045
1049
  async tokenWhoBoughtSold(params = {}) {
@@ -1126,14 +1130,16 @@ export class NansenAPI {
1126
1130
  }
1127
1131
 
1128
1132
  async tokenPerpPnlLeaderboard(params = {}) {
1129
- const { tokenSymbol, filters = {}, orderBy, pagination, days = 30 } = params;
1130
- return this.request('/api/v1/tgm/perp-pnl-leaderboard', {
1133
+ const { tokenSymbol, filters = {}, orderBy, pagination, days = 30, withLabels } = params;
1134
+ const body = {
1131
1135
  token_symbol: tokenSymbol,
1132
1136
  date: buildDateRange(days),
1133
1137
  filters,
1134
1138
  order_by: orderBy,
1135
1139
  pagination
1136
- });
1140
+ };
1141
+ if (withLabels !== undefined) body.premium_labels = withLabels;
1142
+ return this.request('/api/v1/tgm/perp-pnl-leaderboard', body);
1137
1143
  }
1138
1144
 
1139
1145
  async tokenIndicators(params = {}) {
@@ -1187,13 +1193,15 @@ export class NansenAPI {
1187
1193
  }
1188
1194
 
1189
1195
  async perpLeaderboard(params = {}) {
1190
- const { filters = {}, orderBy, pagination, days = 30 } = params;
1191
- return this.request('/api/v1/perp-leaderboard', {
1196
+ const { filters = {}, orderBy, pagination, days = 30, withLabels } = params;
1197
+ const body = {
1192
1198
  date: buildDateRange(days),
1193
1199
  filters,
1194
1200
  order_by: orderBy,
1195
1201
  pagination
1196
- });
1202
+ };
1203
+ if (withLabels !== undefined) body.premium_labels = withLabels;
1204
+ return this.request('/api/v1/perp-leaderboard', body);
1197
1205
  }
1198
1206
 
1199
1207
  // ============= Prediction Market Endpoints =============
package/src/cli.js CHANGED
@@ -30,6 +30,23 @@ export const SCHEMA = { version: VERSION, ...schemaDefinition };
30
30
 
31
31
  // ============= Pagination =============
32
32
 
33
+ /**
34
+ * Resolve a boolean CLI option that can be passed as either:
35
+ * --flag (flag=true, options key absent)
36
+ * --flag true (options key = 'true')
37
+ * --flag false (options key = 'false')
38
+ * Returns true/false/undefined (undefined = not supplied).
39
+ */
40
+ export function resolveBooleanOption(options, flags, key) {
41
+ if (options[key] !== undefined) {
42
+ const val = String(options[key]).toLowerCase();
43
+ if (val === 'true' || val === '1') return true;
44
+ if (val === 'false' || val === '0') return false;
45
+ }
46
+ if (flags[key] !== undefined) return Boolean(flags[key]);
47
+ return undefined;
48
+ }
49
+
33
50
  export function buildPagination(options) {
34
51
  if (!options.limit && !options.page) return undefined;
35
52
  return {
@@ -1237,14 +1254,17 @@ export function buildCommands(deps = {}) {
1237
1254
  }
1238
1255
  return result;
1239
1256
  },
1240
- 'holders': () => apiInstance.tokenHolders({ tokenAddress, chain, labelType: onlySmartMoney ? 'smart_money' : 'all_holders', filters, orderBy, pagination }),
1257
+ 'holders': () => apiInstance.tokenHolders({ tokenAddress, chain, labelType: onlySmartMoney ? 'smart_money' : 'all_holders', filters, orderBy, pagination, withLabels: resolveBooleanOption(options, flags, 'premium-labels') }),
1241
1258
  'flows': () => {
1242
1259
  const date = parseDateOption(options.date, days);
1243
1260
  const label = options.label;
1244
1261
  return apiInstance.tokenFlows({ tokenAddress, chain, label, filters, orderBy, pagination, days, date });
1245
1262
  },
1246
1263
  'dex-trades': () => apiInstance.tokenDexTrades({ tokenAddress, chain, onlySmartMoney, filters, orderBy, pagination, days }),
1247
- 'pnl': () => apiInstance.tokenPnlLeaderboard({ tokenAddress, chain, filters, orderBy, pagination, days }),
1264
+ 'pnl': () => {
1265
+ const withLabels = resolveBooleanOption(options, flags, 'premium-labels');
1266
+ return apiInstance.tokenPnlLeaderboard({ tokenAddress, chain, filters, orderBy, pagination, days, withLabels });
1267
+ },
1248
1268
  'who-bought-sold': () => {
1249
1269
  const date = parseDateOption(options.date, days);
1250
1270
  const buyOrSell = (options['buy-or-sell'] || 'BUY').toUpperCase();
@@ -1260,7 +1280,10 @@ export function buildCommands(deps = {}) {
1260
1280
  'jup-dca': () => apiInstance.tokenJupDca({ tokenAddress, filters, orderBy, pagination }),
1261
1281
  'perp-trades': () => apiInstance.tokenPerpTrades({ tokenSymbol, filters, orderBy, pagination, days }),
1262
1282
  'perp-positions': () => apiInstance.tokenPerpPositions({ tokenSymbol, filters, orderBy, pagination }),
1263
- 'perp-pnl-leaderboard': () => apiInstance.tokenPerpPnlLeaderboard({ tokenSymbol, filters, orderBy, pagination, days }),
1283
+ 'perp-pnl-leaderboard': () => {
1284
+ const withLabels = resolveBooleanOption(options, flags, 'premium-labels');
1285
+ return apiInstance.tokenPerpPnlLeaderboard({ tokenSymbol, filters, orderBy, pagination, days, withLabels });
1286
+ },
1264
1287
  'help': () => ({
1265
1288
  commands: ['info', 'ohlcv', 'screener', 'holders', 'flows', 'dex-trades', 'pnl', 'who-bought-sold', 'flow-intelligence', 'transfers', 'jup-dca', 'perp-trades', 'perp-positions', 'perp-pnl-leaderboard'],
1266
1289
  description: 'Token God Mode endpoints',
@@ -1334,7 +1357,10 @@ export function buildCommands(deps = {}) {
1334
1357
 
1335
1358
  const handlers = {
1336
1359
  'screener': () => apiInstance.perpScreener({ filters, orderBy, pagination, days }),
1337
- 'leaderboard': () => apiInstance.perpLeaderboard({ filters, orderBy, pagination, days }),
1360
+ 'leaderboard': () => {
1361
+ const withLabels = resolveBooleanOption(options, flags, 'premium-labels');
1362
+ return apiInstance.perpLeaderboard({ filters, orderBy, pagination, days, withLabels });
1363
+ },
1338
1364
  'help': () => ({
1339
1365
  commands: ['screener', 'leaderboard'],
1340
1366
  description: 'Perpetual futures analytics endpoints',
package/src/schema.json CHANGED
@@ -283,7 +283,13 @@
283
283
  },
284
284
  "label": {
285
285
  "description": "Holder segment to filter flows by",
286
- "enum": ["top_100_holders", "smart_money", "public_figure", "whale", "exchange"],
286
+ "enum": [
287
+ "top_100_holders",
288
+ "smart_money",
289
+ "public_figure",
290
+ "whale",
291
+ "exchange"
292
+ ],
287
293
  "default": "top_100_holders"
288
294
  }
289
295
  }
@@ -303,7 +309,10 @@
303
309
  },
304
310
  "buy-or-sell": {
305
311
  "description": "Filter by buy or sell side",
306
- "enum": ["BUY", "SELL"],
312
+ "enum": [
313
+ "BUY",
314
+ "SELL"
315
+ ],
307
316
  "default": "BUY"
308
317
  }
309
318
  }
@@ -347,6 +356,10 @@
347
356
  },
348
357
  "token": {
349
358
  "required": true
359
+ },
360
+ "premium-labels": {
361
+ "description": "Include premium Nansen labels in the response (true=premium, false=free-tier). When omitted, uses API default.",
362
+ "type": "boolean"
350
363
  }
351
364
  }
352
365
  },
@@ -362,6 +375,10 @@
362
375
  },
363
376
  "days": {
364
377
  "default": 30
378
+ },
379
+ "premium-labels": {
380
+ "description": "Include premium Nansen labels in the response (true=premium, false=free-tier). When omitted, uses API default.",
381
+ "type": "boolean"
365
382
  }
366
383
  }
367
384
  },
@@ -374,6 +391,10 @@
374
391
  },
375
392
  "days": {
376
393
  "default": 30
394
+ },
395
+ "premium-labels": {
396
+ "description": "Include premium Nansen labels in the response (true=premium, false=free-tier). When omitted, uses API default.",
397
+ "type": "boolean"
377
398
  }
378
399
  }
379
400
  },
@@ -515,6 +536,10 @@
515
536
  "options": {
516
537
  "days": {
517
538
  "default": 30
539
+ },
540
+ "premium-labels": {
541
+ "description": "Include premium Nansen labels in the response (true=premium, false=free-tier). When omitted, uses API default.",
542
+ "type": "boolean"
518
543
  }
519
544
  }
520
545
  }