nansen-cli 2.5.0 → 2.6.0

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.
@@ -49,7 +49,7 @@ function parseTimeframeDays(value) {
49
49
  if (value === undefined || value === null) return undefined;
50
50
  const trimmed = String(value).trim();
51
51
  if (!/^[1-9]\d*$/.test(trimmed)) {
52
- throw new NansenError('--timeframe-days must be a positive integer', ErrorCode.INVALID_PARAMS);
52
+ throw new NansenError('--days must be a positive integer', ErrorCode.INVALID_PARAMS);
53
53
  }
54
54
  return parseInt(trimmed, 10);
55
55
  }
@@ -114,7 +114,7 @@ const SUB_HELP = {
114
114
  'chain-rank': `nansen research chain-rank — Rank chains by growth metrics
115
115
 
116
116
  USAGE:
117
- nansen research chain-rank [--timeframe-days 7|30|365] [--chain-type all|evm]`,
117
+ nansen research chain-rank [--days 7|30|365] [--chain-type all|evm]`,
118
118
  'token-sectors': `nansen research token-sectors — List token sectors available for filtering
119
119
 
120
120
  USAGE:
@@ -126,13 +126,13 @@ USAGE:
126
126
  'smart-money-pnl-leaderboard': `nansen research smart-money-pnl-leaderboard — Rank smart money wallets by PnL
127
127
 
128
128
  USAGE:
129
- nansen research smart-money-pnl-leaderboard [--chains c1,c2] [--timeframe-days 1|7|30|90|180] [--filters '<json>'] [--sort <field[:asc|desc]>] [--page <n>] [--limit <n>]`,
129
+ nansen research smart-money-pnl-leaderboard [--chains c1,c2] [--days 1|7|30|90|180] [--filters '<json>'] [--sort <field[:asc|desc]>] [--page <n>] [--limit <n>]`,
130
130
  'position-intelligence': `nansen research position-intelligence — Aggregate Hyperliquid positions by trader cohort
131
131
 
132
132
  USAGE:
133
133
  nansen research position-intelligence --symbol <symbol>
134
134
 
135
- NOTE: --token-address is accepted as an alias for --symbol (the API request field is token_address).`,
135
+ NOTE: --coin, --token and --token-address are accepted as aliases for --symbol (the API request field is token_address).`,
136
136
  'perp-pnl-summary': `nansen research perp-pnl-summary — Summarize realized Hyperliquid PnL for an address
137
137
 
138
138
  USAGE:
@@ -146,30 +146,30 @@ NOTE: --block-timestamp is required for bitcoin, tron, ton, starknet, and sui.`,
146
146
  'historical-dex-trades': `nansen research historical-dex-trades — Historical DEX trades for a token
147
147
 
148
148
  USAGE:
149
- nansen research historical-dex-trades --token-address <addr> --from-date <YYYY-MM-DD> --to-date <YYYY-MM-DD> [--chain <chain>]`,
149
+ nansen research historical-dex-trades --token <addr> --from-date <YYYY-MM-DD> --to-date <YYYY-MM-DD> [--chain <chain>]`,
150
150
  'historical-pnl-leaderboard': `nansen research historical-pnl-leaderboard — Historical PnL leaderboard for a token
151
151
 
152
152
  USAGE:
153
- nansen research historical-pnl-leaderboard --token-address <addr> --from-date <YYYY-MM-DD> --to-date <YYYY-MM-DD> [--chain <chain>]`,
153
+ nansen research historical-pnl-leaderboard --token <addr> --from-date <YYYY-MM-DD> --to-date <YYYY-MM-DD> [--chain <chain>]`,
154
154
  'historical-token-flow-summary': `nansen research historical-token-flow-summary — Historical token flow summary
155
155
 
156
156
  USAGE:
157
- nansen research historical-token-flow-summary --token-address <addr> --from-date <YYYY-MM-DD> --to-date <YYYY-MM-DD> [--chain <chain>]
157
+ nansen research historical-token-flow-summary --token <addr> --from-date <YYYY-MM-DD> --to-date <YYYY-MM-DD> [--chain <chain>]
158
158
 
159
159
  NOTE: This endpoint does not support pagination.
160
160
  Whale, public figure, top PnL and exchange label history starts 2025-03-11, so those fields are null for an earlier --to-date.`,
161
161
  'historical-token-quant-scores': `nansen research historical-token-quant-scores — Historical token quantitative scores
162
162
 
163
163
  USAGE:
164
- nansen research historical-token-quant-scores --token-address <addr> --as-of-date <YYYY-MM-DD> [--chain <chain>]`,
164
+ nansen research historical-token-quant-scores --token <addr> --as-of-date <YYYY-MM-DD> [--chain <chain>]`,
165
165
  'historical-top-holders': `nansen research historical-top-holders — Historical top holders of a token
166
166
 
167
167
  USAGE:
168
- nansen research historical-top-holders --token-address <addr> --as-of-date <YYYY-MM-DD> [--chain <chain>]`,
168
+ nansen research historical-top-holders --token <addr> --as-of-date <YYYY-MM-DD> [--chain <chain>]`,
169
169
  'historical-who-bought-sold': `nansen research historical-who-bought-sold — Historical buyers/sellers of a token
170
170
 
171
171
  USAGE:
172
- nansen research historical-who-bought-sold --token-address <addr> --from-date <YYYY-MM-DD> --to-date <YYYY-MM-DD> [--buy-or-sell BUY|SELL] [--chain <chain>]`,
172
+ nansen research historical-who-bought-sold --token <addr> --from-date <YYYY-MM-DD> --to-date <YYYY-MM-DD> [--buy-or-sell BUY|SELL] [--chain <chain>]`,
173
173
  'historical-smart-money-balances': `nansen research historical-smart-money-balances — Historical smart money token balances
174
174
 
175
175
  USAGE:
@@ -179,7 +179,7 @@ NOTE: This endpoint does not support order_by.`,
179
179
  'historical-token-screener': `nansen research historical-token-screener — Historical token screener
180
180
 
181
181
  USAGE:
182
- nansen research historical-token-screener --timeframe-days <n> --to-date <YYYY-MM-DD> [--chains c1,c2]`,
182
+ nansen research historical-token-screener --days <n> --to-date <YYYY-MM-DD> [--chains c1,c2]`,
183
183
  'historical-wallet-balances': `nansen research historical-wallet-balances — Historical token balances for a wallet
184
184
 
185
185
  USAGE:
@@ -198,7 +198,7 @@ USAGE:
198
198
  'historical-token-ohlcv': `nansen research historical-token-ohlcv — Historical token OHLCV candles
199
199
 
200
200
  USAGE:
201
- nansen research historical-token-ohlcv --token-address <addr> --from-date <date> --timeframe <5m|15m|30m|1h|4h|1d|1w> (--as-of-date <date> | --as-of-ts <timestamp>) [--chain <chain>] [--apply-blacklist-filter <true|false>]`,
201
+ nansen research historical-token-ohlcv --token <addr|symbol> --from-date <date> --interval <5m|15m|30m|1h|4h|1d|1w> (--as-of-date <date> | --as-of-ts <timestamp>) [--chain <chain>] [--apply-blacklist-filter <true|false>]`,
202
202
  };
203
203
 
204
204
  export function buildResearchCommands(deps = {}) {
@@ -226,7 +226,7 @@ export function buildResearchCommands(deps = {}) {
226
226
 
227
227
  for (const [name, example] of [
228
228
  ['chain', 'solana'], ['chains', 'solana'], ['chain-type', 'all'],
229
- ['timeframe', '1d'], ['timeframe-days', '7'],
229
+ ['interval', '1d'], ['days', '7'],
230
230
  ]) {
231
231
  rejectBlankOption(options[name], name, example);
232
232
  }
@@ -238,10 +238,10 @@ export function buildResearchCommands(deps = {}) {
238
238
  const asOfDate = options['as-of-date'];
239
239
 
240
240
  if (sub === 'chain-rank') {
241
- const timeFrame = parseTimeframeDays(options['timeframe-days']) ?? 7;
241
+ const timeFrame = parseTimeframeDays(options.days) ?? 7;
242
242
  if (!CHAIN_RANK_TIMEFRAMES.has(timeFrame)) {
243
243
  throw new NansenError(
244
- `--timeframe-days must be one of: ${[...CHAIN_RANK_TIMEFRAMES].join(', ')}`,
244
+ `--days must be one of: ${[...CHAIN_RANK_TIMEFRAMES].join(', ')}`,
245
245
  ErrorCode.INVALID_PARAMS,
246
246
  );
247
247
  }
@@ -265,10 +265,10 @@ export function buildResearchCommands(deps = {}) {
265
265
  }
266
266
 
267
267
  if (sub === 'smart-money-pnl-leaderboard') {
268
- const timeframe = parseTimeframeDays(options['timeframe-days']) ?? 7;
268
+ const timeframe = parseTimeframeDays(options.days) ?? 7;
269
269
  if (!SM_PNL_TIMEFRAME_DAYS.includes(timeframe)) {
270
270
  throw new NansenError(
271
- `--timeframe-days must be one of: ${SM_PNL_TIMEFRAME_DAYS.join(', ')}`,
271
+ `--days must be one of: ${SM_PNL_TIMEFRAME_DAYS.join(', ')}`,
272
272
  ErrorCode.INVALID_PARAMS,
273
273
  );
274
274
  }
@@ -280,10 +280,10 @@ export function buildResearchCommands(deps = {}) {
280
280
  }
281
281
 
282
282
  if (sub === 'position-intelligence') {
283
- const symbol = String(options.symbol || options['token-address'] || options.token || '').trim();
283
+ const symbol = String(options.symbol || '').trim();
284
284
  if (!symbol) {
285
285
  throw new NansenError(
286
- 'Required: --symbol (or --token-address)',
286
+ 'Required: --symbol',
287
287
  ErrorCode.MISSING_PARAM,
288
288
  );
289
289
  }
@@ -299,11 +299,11 @@ export function buildResearchCommands(deps = {}) {
299
299
  }
300
300
 
301
301
  if (sub === 'historical-token-ohlcv') {
302
- const tokenAddress = options['token-address'] || options.token;
302
+ const tokenAddress = options.token;
303
303
  const asOfTs = options['as-of-ts'];
304
304
  requireOptions(
305
- { 'token-address': tokenAddress, 'from-date': fromDate, timeframe: options.timeframe },
306
- ['token-address', 'from-date', 'timeframe'],
305
+ { token: tokenAddress, 'from-date': fromDate, interval: options.interval },
306
+ ['token', 'from-date', 'interval'],
307
307
  );
308
308
  if (!asOfDate && !asOfTs) {
309
309
  throw new NansenError(
@@ -323,7 +323,7 @@ export function buildResearchCommands(deps = {}) {
323
323
  fromDate,
324
324
  asOfDate,
325
325
  asOfTs,
326
- timeframe: options.timeframe,
326
+ timeframe: options.interval,
327
327
  applyBlacklistFilter: parseBooleanOption(options, flags, 'apply-blacklist-filter'),
328
328
  });
329
329
  }
@@ -347,22 +347,22 @@ export function buildResearchCommands(deps = {}) {
347
347
  // Range-based token endpoints (require --from-date + --to-date)
348
348
  const rangeTokenHandlers = {
349
349
  'historical-dex-trades': () => apiInstance.researchDexTrades({
350
- tokenAddress: options['token-address'] || options.token,
350
+ tokenAddress: options.token,
351
351
  chain: options.chain,
352
352
  fromDate, toDate, filters, orderBy, pagination,
353
353
  }),
354
354
  'historical-pnl-leaderboard': () => apiInstance.researchPnlLeaderboard({
355
- tokenAddress: options['token-address'] || options.token,
355
+ tokenAddress: options.token,
356
356
  chain: options.chain,
357
357
  fromDate, toDate, filters, orderBy, pagination,
358
358
  }),
359
359
  'historical-token-flow-summary': () => apiInstance.researchTokenFlowSummary({
360
- tokenAddress: options['token-address'] || options.token,
360
+ tokenAddress: options.token,
361
361
  chain: options.chain,
362
362
  fromDate, toDate,
363
363
  }),
364
364
  'historical-who-bought-sold': () => apiInstance.researchWhoBoughtSold({
365
- tokenAddress: options['token-address'] || options.token,
365
+ tokenAddress: options.token,
366
366
  chain: options.chain,
367
367
  buyOrSell: options['buy-or-sell'],
368
368
  fromDate, toDate, filters, orderBy, pagination,
@@ -371,8 +371,8 @@ export function buildResearchCommands(deps = {}) {
371
371
 
372
372
  if (rangeTokenHandlers[sub]) {
373
373
  requireOptions(
374
- { 'token-address': options['token-address'] || options.token, 'from-date': fromDate, 'to-date': toDate },
375
- ['token-address', 'from-date', 'to-date'],
374
+ { token: options.token, 'from-date': fromDate, 'to-date': toDate },
375
+ ['token', 'from-date', 'to-date'],
376
376
  );
377
377
  if (sub === 'historical-token-flow-summary' && (options.page || options.limit)) {
378
378
  throw new NansenError(
@@ -386,12 +386,12 @@ export function buildResearchCommands(deps = {}) {
386
386
  // As-of-date token endpoints (require --as-of-date)
387
387
  const asOfTokenHandlers = {
388
388
  'historical-token-quant-scores': () => apiInstance.researchTokenQuantScores({
389
- tokenAddress: options['token-address'] || options.token,
389
+ tokenAddress: options.token,
390
390
  chain: options.chain,
391
391
  asOfDate, filters, orderBy, pagination,
392
392
  }),
393
393
  'historical-top-holders': () => apiInstance.researchTopHolders({
394
- tokenAddress: options['token-address'] || options.token,
394
+ tokenAddress: options.token,
395
395
  chain: options.chain,
396
396
  asOfDate, filters, orderBy, pagination,
397
397
  }),
@@ -399,8 +399,8 @@ export function buildResearchCommands(deps = {}) {
399
399
 
400
400
  if (asOfTokenHandlers[sub]) {
401
401
  requireOptions(
402
- { 'token-address': options['token-address'] || options.token, 'as-of-date': asOfDate },
403
- ['token-address', 'as-of-date'],
402
+ { token: options.token, 'as-of-date': asOfDate },
403
+ ['token', 'as-of-date'],
404
404
  );
405
405
  return asOfTokenHandlers[sub]();
406
406
  }
@@ -420,8 +420,8 @@ export function buildResearchCommands(deps = {}) {
420
420
  }
421
421
 
422
422
  if (sub === 'historical-token-screener') {
423
- const timeframeDays = parseTimeframeDays(options['timeframe-days']);
424
- requireOptions({ 'timeframe-days': timeframeDays, 'to-date': options['to-date'] }, ['timeframe-days', 'to-date']);
423
+ const timeframeDays = parseTimeframeDays(options.days);
424
+ requireOptions({ days: timeframeDays, 'to-date': options['to-date'] }, ['days', 'to-date']);
425
425
  return apiInstance.researchTokenScreener({
426
426
  chains: parseChains(options),
427
427
  timeframeDays,
@@ -166,6 +166,7 @@ export const ERROR_CODES = {
166
166
  RPC_JSON_ERROR: { group: 'trade', description: 'The RPC answered with a body that is not JSON.' },
167
167
  RPC_NETWORK_ERROR: { group: 'trade', description: 'The CLI could not reach the RPC.', retry: true },
168
168
  CONFIRMATION_DECLINED: { group: 'trade', description: 'The confirmation prompt was declined; nothing was signed.' },
169
+ CONFIRMATION_REQUIRED: { group: 'trade', description: 'NANSEN_REQUIRE_CONFIRM is set and stdin is not a terminal; nothing was signed. Pass --yes to proceed or --dry-run to preview.' },
169
170
  CONFIRMATION_UNAVAILABLE: { group: 'trade', description: 'Confirmation is required but no terminal is available. Pass --yes to confirm.' },
170
171
 
171
172
  // ── Bridge ──
@@ -15,6 +15,11 @@
15
15
  * the command proceeds without asking, so no automated workflow can hang on a
16
16
  * question nobody is there to answer. `--yes` is still accepted there and is
17
17
  * simply a no-op. Declining the prompt exits 1 with nothing signed.
18
+ *
19
+ * Opt-in stop point: an operator who wants their agent to pause before moving
20
+ * funds sets `NANSEN_REQUIRE_CONFIRM=1`. With it set and stdin not a terminal,
21
+ * a run without --yes / NANSEN_YES fails with CONFIRMATION_REQUIRED before the
22
+ * command does anything else; --dry-run still previews. Unset, nothing changes.
18
23
  */
19
24
 
20
25
  import { CommandError } from './api.js';
@@ -23,21 +28,49 @@ import { CommandError } from './api.js';
23
28
  // empty string) leaves the confirmation in place.
24
29
  const TRUTHY_ENV_VALUES = new Set(['1', 'true', 'yes', 'on']);
25
30
 
26
- export function isYesEnvSet(env = process.env) {
27
- const raw = env?.NANSEN_YES;
31
+ function isTruthyEnv(raw) {
28
32
  return typeof raw === 'string' && TRUTHY_ENV_VALUES.has(raw.trim().toLowerCase());
29
33
  }
30
34
 
35
+ export function isYesEnvSet(env = process.env) {
36
+ return isTruthyEnv(env?.NANSEN_YES);
37
+ }
38
+
39
+ // Same spellings as NANSEN_YES. Anything else keeps today's behaviour.
40
+ export function isRequireConfirmEnvSet(env = process.env) {
41
+ return isTruthyEnv(env?.NANSEN_REQUIRE_CONFIRM);
42
+ }
43
+
44
+ function confirmationRequiredError() {
45
+ return new CommandError(
46
+ 'Confirmation required: NANSEN_REQUIRE_CONFIRM is set and stdin is not a terminal, so nothing was signed or broadcast. '
47
+ + 'Pass --yes (or set NANSEN_YES=1) to proceed, or --dry-run to preview.',
48
+ 'CONFIRMATION_REQUIRED',
49
+ );
50
+ }
51
+
31
52
  /**
32
53
  * Read the guard's inputs off the parsed flags. `-y` arrives as `flags.y`
33
54
  * because single-dash tokens are always parsed as valueless flags.
55
+ *
56
+ * Every guarded command calls this first, so the NANSEN_REQUIRE_CONFIRM refusal
57
+ * is thrown here, before any API request. Those requests can sign an x402
58
+ * payment on a 402 response, so refusing only at guardExecution could spend
59
+ * funds and then claim nothing was signed.
34
60
  */
35
61
  export function resolveExecuteGuard(flags = {}, { env = process.env, isTTY = false } = {}) {
36
- return {
62
+ const guard = {
37
63
  dryRun: Boolean(flags['dry-run']),
38
64
  assumeYes: Boolean(flags.yes || flags.y) || isYesEnvSet(env),
39
65
  isTTY: Boolean(isTTY),
66
+ requireConfirm: isRequireConfirmEnvSet(env),
40
67
  };
68
+ if (needsConfirmationOffTerminal(guard)) throw confirmationRequiredError();
69
+ return guard;
70
+ }
71
+
72
+ function needsConfirmationOffTerminal({ dryRun, assumeYes, isTTY, requireConfirm }) {
73
+ return Boolean(requireConfirm) && !dryRun && !assumeYes && !isTTY;
41
74
  }
42
75
 
43
76
  /**
@@ -70,6 +103,7 @@ export async function guardExecution({
70
103
  dryRun = false,
71
104
  assumeYes = false,
72
105
  isTTY = false,
106
+ requireConfirm = false,
73
107
  promptFn,
74
108
  log = () => {},
75
109
  confirmationLog = log,
@@ -85,6 +119,12 @@ export async function guardExecution({
85
119
  return false;
86
120
  }
87
121
 
122
+ // Backstop for callers that build the guard themselves; resolveExecuteGuard
123
+ // normally refuses this case before the command makes any request.
124
+ if (needsConfirmationOffTerminal({ dryRun, assumeYes, isTTY, requireConfirm })) {
125
+ throw confirmationRequiredError();
126
+ }
127
+
88
128
  // Non-interactive stdin (agents, CI, pipes): unchanged, deterministic, never
89
129
  // blocked on a prompt. --yes is accepted here and does nothing.
90
130
  if (!isTTY || assumeYes) return true;
@@ -381,8 +381,8 @@ function valueErrors(name, spec, value) {
381
381
 
382
382
  /**
383
383
  * Check a research command's options before it runs. Throws one NansenError
384
- * listing every problem (see validationError). On success it rewrites
385
- * --chain/--chains in `options` to their canonical spelling (lowercase, REST
384
+ * listing every problem (see validationError). On success it renames aliases
385
+ * to their schema name, and rewrites --chain/--chains in `options` to their canonical spelling (lowercase, REST
386
386
  * aliases such as bsc -> bnb applied), as the API itself would, and turns
387
387
  * --chains into an array.
388
388
  */
@@ -399,9 +399,18 @@ export function validateResearchInput(resolved, { flags = {}, options = {}, endp
399
399
  ...Object.entries(options).map(([name, value]) => [name, value]),
400
400
  ...Object.entries(flags).filter(([name, value]) => value && !(name in options)).map(([name, value]) => [name, value]),
401
401
  ];
402
+ const spelled = new Map(); // schema name -> the spelling that was given
402
403
  for (const [raw, value] of supplied) {
403
404
  const canonical = names.get(raw);
404
405
  if (canonical) {
406
+ // `--token A --token-address B` names one input twice; the handler
407
+ // would silently use one of them.
408
+ if (spelled.has(canonical)) {
409
+ errors.push(fieldError(`--${canonical}`, 'invalid_field_value',
410
+ `Options '--${spelled.get(canonical)}' and '--${raw}' are the same input (--${canonical}); pass one.`));
411
+ continue;
412
+ }
413
+ spelled.set(canonical, raw);
405
414
  given.set(canonical, value);
406
415
  continue;
407
416
  }
@@ -415,8 +424,12 @@ export function validateResearchInput(resolved, { flags = {}, options = {}, endp
415
424
  continue;
416
425
  }
417
426
  const field = raw.length === 1 ? `-${raw}` : `--${raw}`;
427
+ // --days is the lookback flag elsewhere; here the window is text (24h, 7d).
428
+ const hint = raw === 'days' && leaf.options?.timeframe && !names.has('days')
429
+ ? ' Use --timeframe instead (for example --timeframe 7d); this command takes a time window, not a number of days.'
430
+ : '';
418
431
  errors.push(fieldError(field, 'unknown_field',
419
- `Option '${field}' is not recognized by ${path}. Command-specific options: ${visible.join(', ') || 'none'}. Common options also apply; see: nansen schema.`));
432
+ `Option '${field}' is not recognized by ${path}.${hint} Command-specific options: ${visible.join(', ') || 'none'}. Common options also apply; see: nansen schema.`));
420
433
  }
421
434
 
422
435
  for (const [name, value] of given) {
@@ -447,9 +460,25 @@ export function validateResearchInput(resolved, { flags = {}, options = {}, endp
447
460
  }
448
461
 
449
462
  if (errors.length) throw validationError(errors);
463
+ canonicalizeOptionNames(options, flags, names);
450
464
  normalizeChainOptions(options, names);
451
465
  }
452
466
 
467
+ /**
468
+ * Move every alias to its schema name (--token-address -> --token), so a
469
+ * handler reads one name per input and an alias needs only a schema entry.
470
+ */
471
+ function canonicalizeOptionNames(options, flags, names) {
472
+ for (const [raw, canonical] of names) {
473
+ if (raw === canonical) continue;
474
+ for (const bag of [options, flags]) {
475
+ if (!Object.hasOwn(bag, raw)) continue;
476
+ bag[canonical] = bag[raw];
477
+ delete bag[raw];
478
+ }
479
+ }
480
+ }
481
+
453
482
  /** Reject an output format the CLI cannot write. */
454
483
  export function validateOutputOptions({ flags = {}, options = {} } = {}) {
455
484
  // --fields is applied after the response arrives; check its shape here so
@@ -937,7 +937,7 @@ EXAMPLES:
937
937
  log('');
938
938
 
939
939
  } catch (err) {
940
- if (err.reported) throw err;
940
+ if (err.reported || err.code === 'CONFIRMATION_REQUIRED') throw err;
941
941
  log(`Error: ${err.message}`);
942
942
  if (err.details) log(` Details: ${JSON.stringify(err.details)}`);
943
943
  if (err.cause) log(` Cause: ${err.cause.message || err.cause}`);
@@ -946,6 +946,7 @@ EXAMPLES:
946
946
  },
947
947
 
948
948
  'list': async (args, apiInstance, flags, options) => {
949
+ rejectBlankOption(options.token, 'token', 'SOL');
949
950
  rejectBlankOption(options.mint, 'mint', 'SOL');
950
951
  rejectBlankOption(options.limit, 'limit', '20');
951
952
  rejectBlankOption(options.offset, 'offset', '0');
@@ -953,7 +954,14 @@ EXAMPLES:
953
954
  rejectBlankOption(options.wallet, 'wallet', '<name>');
954
955
  const walletName = options.wallet;
955
956
  const state = options.state;
956
- const mint = options.mint ? resolveTokenAddress(options.mint, 'solana') : undefined;
957
+ // --mint is the old name of --token.
958
+ if (options.token !== undefined && options.mint !== undefined) {
959
+ log(`Error: --token ${options.token} and --mint ${options.mint} are the same input; pass one.`);
960
+ exit(1);
961
+ return;
962
+ }
963
+ const tokenArg = options.token ?? options.mint;
964
+ const mint = tokenArg ? resolveTokenAddress(tokenArg, 'solana') : undefined;
957
965
  const limit = options.limit || 20;
958
966
  // parseArgs keeps numbers as strings; the footer below adds to offset.
959
967
  const offset = options.offset == null ? 0 : Number(options.offset);
@@ -969,7 +977,7 @@ EXAMPLES:
969
977
  if (mint) {
970
978
  const mintValidation = validateTokenAddress(mint, 'solana');
971
979
  if (!mintValidation.valid) {
972
- log(`Error: Invalid --mint address: ${mintValidation.error}`);
980
+ log(`Error: Invalid --token address: ${mintValidation.error}`);
973
981
  exit(1);
974
982
  return;
975
983
  }
@@ -1159,7 +1167,7 @@ EXAMPLES:
1159
1167
  log('');
1160
1168
 
1161
1169
  } catch (err) {
1162
- if (err.reported) throw err;
1170
+ if (err.reported || err.code === 'CONFIRMATION_REQUIRED') throw err;
1163
1171
  log(`Error: ${err.message}`);
1164
1172
  if (err.details) log(` Details: ${JSON.stringify(err.details)}`);
1165
1173
  exit(1);
package/src/perp.js CHANGED
@@ -429,7 +429,7 @@ async function buildScreenSignSubmit(apiInstance, prepared, ctx) {
429
429
  log(` Filled${tag}: ${o.totalSz} @ ${o.avgPx} (${oidText})`);
430
430
  } else {
431
431
  log(` Resting order${tag}: ${oidText}`);
432
- if (coin && o.oidSafe) log(` Cancel: nansen perp cancel --coin ${coin} --oid ${o.oid}`);
432
+ if (coin && o.oidSafe) log(` Cancel: nansen perp cancel --symbol ${coin} --oid ${o.oid}`);
433
433
  }
434
434
  }
435
435
  } else if (result.response) {
@@ -652,11 +652,16 @@ function assertOrderType(raw) {
652
652
  return type;
653
653
  }
654
654
 
655
- // Resolve the asset symbol from --coin (or its --symbol alias), rejecting a
655
+ // Resolve the asset symbol from --symbol (or its --coin alias), rejecting a
656
656
  // duplicated flag. Returns the upper-cased symbol, or '' when neither is set.
657
657
  function resolveCoin(options) {
658
- const raw = scalar(options.coin, 'coin') ?? scalar(options.symbol, 'symbol');
659
- return String(raw ?? '').toUpperCase();
658
+ const symbol = scalar(options.symbol, 'symbol');
659
+ const coin = scalar(options.coin, 'coin');
660
+ // `--symbol ETH --coin BTC` names the market twice; never pick one silently.
661
+ if (symbol !== undefined && coin !== undefined) {
662
+ throw invalid(`--symbol ${symbol} and --coin ${coin} are the same input (--coin is an alias of --symbol); pass one.`);
663
+ }
664
+ return String(symbol ?? coin ?? '').toUpperCase();
660
665
  }
661
666
 
662
667
  // ── Preview + confirmation (--dry-run / --yes) ───────────────────────
@@ -876,10 +881,10 @@ export function buildPerpCommands(deps = {}) {
876
881
 
877
882
  if (!coin || !options.side || options.size === undefined || options.price === undefined) {
878
883
  throw new CommandError(
879
- `Usage: nansen perp order --coin <symbol> --side <buy|sell> --size <amount> --price <price> [options]
884
+ `Usage: nansen perp order --symbol <symbol> --side <buy|sell> --size <amount> --price <price> [options]
880
885
 
881
886
  OPTIONS:
882
- --coin Asset symbol (BTC, ETH, etc.)
887
+ --symbol Asset symbol (BTC, ETH, etc.; alias --coin)
883
888
  --side buy (long) or sell (short)
884
889
  --size Position size in base asset units
885
890
  --price Limit price (or mark price for market orders)
@@ -1011,7 +1016,7 @@ OPTIONS:
1011
1016
  const walletName = scalar(options.wallet, 'wallet');
1012
1017
 
1013
1018
  if (!coin || options.oid === undefined) {
1014
- throw new CommandError('Usage: nansen perp cancel --coin <symbol> --oid <orderId> [--wallet <name>] [--dry-run] [--yes]', 'MISSING_PARAM');
1019
+ throw new CommandError('Usage: nansen perp cancel --symbol <symbol> --oid <orderId> [--wallet <name>] [--dry-run] [--yes]', 'MISSING_PARAM');
1015
1020
  }
1016
1021
 
1017
1022
  const oid = parsePositiveInt(options.oid, 'oid');
@@ -1067,7 +1072,7 @@ OPTIONS:
1067
1072
 
1068
1073
  if (!coin || options.size === undefined || options.price === undefined || !options.side) {
1069
1074
  throw new CommandError(
1070
- `Usage: nansen perp close --coin <symbol> --size <amount> --price <markPrice> --side <buy|sell> [options]
1075
+ `Usage: nansen perp close --symbol <symbol> --size <amount> --price <markPrice> --side <buy|sell> [options]
1071
1076
 
1072
1077
  --side buy (closing a short) or sell (closing a long)
1073
1078
  --slippage Slippage tolerance (default 0.03 = 3%)
@@ -1186,7 +1191,7 @@ OPTIONS:
1186
1191
  const walletName = scalar(options.wallet, 'wallet');
1187
1192
 
1188
1193
  if (!coin || options.leverage === undefined) {
1189
- throw new CommandError('Usage: nansen perp leverage --coin <symbol> --leverage <n> [--margin-type cross|isolated] [--wallet <name>] [--dry-run] [--yes]', 'MISSING_PARAM');
1194
+ throw new CommandError('Usage: nansen perp leverage --symbol <symbol> --leverage <n> [--margin-type cross|isolated] [--wallet <name>] [--dry-run] [--yes]', 'MISSING_PARAM');
1190
1195
  }
1191
1196
 
1192
1197
  const marginType = assertMarginType(options['margin-type']);