nansen-cli 1.31.0 → 1.31.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.31.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#443](https://github.com/nansen-ai/nansen-cli/pull/443) [`0ee84db`](https://github.com/nansen-ai/nansen-cli/commit/0ee84db6cdab06054c6ae79c6d871bae0b4f3edb) Thanks [@araa47](https://github.com/araa47)! - Skip native gas pre-check for trades >= $10 USD, where gasless/solver-paid routes (e.g. Relay) are viable. When gas is insufficient on smaller trades, the error now also suggests increasing the trade value as an alternative to topping up gas.
8
+
3
9
  ## 1.31.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.31.0",
3
+ "version": "1.31.1",
4
4
  "description": "AI-agent CLI for Nansen API analytics, DEX swaps, and cross-chain trading",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -136,6 +136,10 @@ const FEE_BUFFER = { solana: 0.005, base: 0.00004 };
136
136
  const HIGH_PERCENTAGE_THRESHOLD = 95;
137
137
  const AUTO_ADJUST_THRESHOLD_PERCENT = 2;
138
138
 
139
+ // Trades at or above this USD value can use gasless/solver-paid routes (e.g. Relay),
140
+ // so the native gas pre-check is skipped for them.
141
+ export const GASLESS_MIN_TRADE_USD = 10;
142
+
139
143
  /**
140
144
  * Check if an address is USDC or the native token for a chain (case-insensitive for EVM).
141
145
  */
@@ -306,12 +310,19 @@ export async function resolvePercentAmount({ chain, from, walletAddress, percent
306
310
  *
307
311
  * Returns { hasSufficientNative } or throws on validation failure.
308
312
  * Best-effort: if RPC fails, returns passing result.
313
+ *
314
+ * Gasless bypass: trades >= $10 USD can use solver-paid options (e.g. Relay),
315
+ * so the gas check is skipped in that case.
309
316
  */
310
- export async function validateGasBalance({ chain, walletAddress }) {
317
+ export async function validateGasBalance({ chain, walletAddress, tradeValueUsd }) {
311
318
  const normalizedChain = chain.toLowerCase();
312
319
  const minGas = MIN_GAS_AMOUNTS[normalizedChain];
313
320
  if (minGas === undefined) return { hasSufficientNative: true };
314
321
 
322
+ // High-value trades can use gasless/solver-paid routes — skip the check.
323
+ const tradeUsd = parseFloat(tradeValueUsd) || 0;
324
+ if (tradeUsd >= GASLESS_MIN_TRADE_USD) return { hasSufficientNative: true };
325
+
315
326
  const balance = await fetchNativeBalance(normalizedChain, walletAddress);
316
327
 
317
328
  // RPC failure — proceed without validation.
@@ -323,7 +334,7 @@ export async function validateGasBalance({ chain, walletAddress }) {
323
334
 
324
335
  const symbol = NATIVE_SYMBOLS[normalizedChain] || 'native token';
325
336
  throw new Error(
326
- `Insufficient ${symbol} for gas fees. Wallet has ${balance} ${symbol} but needs at least ${minGas} ${symbol}. Fund the wallet before trading.`
337
+ `Insufficient ${symbol} for gas fees. Wallet has ${balance} ${symbol} but needs at least ${minGas} ${symbol}. Either fund the wallet with ${symbol} or trade a value of $${GASLESS_MIN_TRADE_USD}+ to use gasless options.`
327
338
  );
328
339
  }
329
340
 
package/src/trading.js CHANGED
@@ -1331,8 +1331,10 @@ CROSS-CHAIN NOTES (when using --to-chain):
1331
1331
  response.quotes.forEach((q, i) => log(formatQuote(q, i)));
1332
1332
 
1333
1333
  // Gas balance validation — check that the wallet has enough native token for gas.
1334
+ // High-value trades (>= $10) can use gasless/solver-paid routes and bypass this check.
1334
1335
  try {
1335
- await validateGasBalance({ chain, walletAddress });
1336
+ const tradeValueUsd = response.quotes[0]?.inUsdValue;
1337
+ await validateGasBalance({ chain, walletAddress, tradeValueUsd });
1336
1338
  } catch (gasErr) {
1337
1339
  throw new CommandError(`Error: ${gasErr.message}`, 'INSUFFICIENT_GAS');
1338
1340
  }