nansen-cli 1.10.0 → 1.10.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/src/trading.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Nansen CLI - Trading Commands
3
3
  * Quote and execute DEX swaps via the Nansen Trading API.
4
- * Supports Solana and EVM chains (Ethereum, Base, BSC).
4
+ * Supports Solana and Base.
5
5
  * Zero external dependencies — uses Node.js built-in crypto only.
6
6
  */
7
7
 
@@ -19,21 +19,17 @@ const TRADING_API_URL = process.env.NANSEN_TRADING_API_URL || 'https://trading-a
19
19
 
20
20
  const CHAIN_MAP = {
21
21
  solana: { index: '501', type: 'solana', chainId: 501, name: 'Solana', explorer: 'https://solscan.io/tx/' },
22
- ethereum: { index: '1', type: 'evm', chainId: 1, name: 'Ethereum', explorer: 'https://etherscan.io/tx/' },
23
22
  base: { index: '8453', type: 'evm', chainId: 8453, name: 'Base', explorer: 'https://basescan.org/tx/' },
24
- bsc: { index: '56', type: 'evm', chainId: 56, name: 'BSC', explorer: 'https://bscscan.com/tx/' },
25
23
  };
26
24
 
27
25
  // Extend when adding new EVM chains (e.g. arbitrum WETH, polygon WMATIC)
28
26
  const WRAPPED_NATIVE_TOKENS = {
29
- ethereum: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', symbol: 'WETH', nativeSymbol: 'ETH' },
30
27
  base: { address: '0x4200000000000000000000000000000000000006', symbol: 'WETH', nativeSymbol: 'ETH' },
31
- bsc: { address: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c', symbol: 'WBNB', nativeSymbol: 'BNB' },
32
28
  };
33
29
 
34
30
  // Common token symbol → address lookup per chain.
35
31
  // Native sentinels: Solana uses native mint, EVM uses 0xeee…eee.
36
- // Wrapped-native addresses (WETH, WBNB) are derived from WRAPPED_NATIVE_TOKENS
32
+ // Wrapped-native addresses (WETH) are derived from WRAPPED_NATIVE_TOKENS
37
33
  // to avoid duplication — keep that map as the single source of truth.
38
34
  const EVM_NATIVE = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
39
35
  const TOKEN_SYMBOLS = {
@@ -43,12 +39,6 @@ const TOKEN_SYMBOLS = {
43
39
  USDC: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
44
40
  USDT: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
45
41
  },
46
- ethereum: {
47
- ETH: EVM_NATIVE,
48
- WETH: WRAPPED_NATIVE_TOKENS.ethereum.address,
49
- USDC: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
50
- USDT: '0xdac17f958d2ee523a2206206994597c13d831ec7',
51
- },
52
42
  base: {
53
43
  ETH: EVM_NATIVE,
54
44
  WETH: WRAPPED_NATIVE_TOKENS.base.address,
@@ -57,12 +47,6 @@ const TOKEN_SYMBOLS = {
57
47
  // (like Circle did with USDC), this address will need updating.
58
48
  USDT: '0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2',
59
49
  },
60
- bsc: {
61
- BNB: EVM_NATIVE,
62
- WBNB: WRAPPED_NATIVE_TOKENS.bsc.address,
63
- USDC: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d',
64
- USDT: '0x55d398326f99059ff775485246999027b3197955',
65
- },
66
50
  };
67
51
 
68
52
  /**
@@ -80,9 +64,7 @@ export function resolveTokenAddress(symbolOrAddress, chainName) {
80
64
 
81
65
  // Default public RPC endpoints (used for nonce fetching)
82
66
  const EVM_RPC_URLS = {
83
- ethereum: process.env.NANSEN_RPC_ETHEREUM || 'https://eth.llamarpc.com',
84
67
  base: process.env.NANSEN_RPC_BASE || 'https://mainnet.base.org',
85
- bsc: process.env.NANSEN_RPC_BSC || 'https://bsc-dataseed.binance.org',
86
68
  };
87
69
 
88
70
  function getQuotesDir() {
@@ -321,7 +303,7 @@ export function signSolanaTransaction(transactionBase64, privateKeyHex) {
321
303
  *
322
304
  * @param {object} txData - Transaction fields from quote.transaction { to, data, value, gas, gasPrice }
323
305
  * @param {string} privateKeyHex - 64-char hex (32-byte secp256k1 private key)
324
- * @param {string} chain - Chain name (ethereum, base, bsc)
306
+ * @param {string} chain - Chain name
325
307
  * @param {number} nonce - Account nonce
326
308
  * @returns {string} 0x-prefixed signed transaction hex
327
309
  */
@@ -794,12 +776,17 @@ export function buildTradingCommands(deps = {}) {
794
776
  errorOutput(`
795
777
  Usage: nansen trade quote --chain <chain> --from <token> --to <token> --amount <baseUnits>
796
778
 
779
+ PREREQUISITE:
780
+ A wallet must be configured before using this command (the trading API builds
781
+ a transaction specific to your sender address).
782
+ Set one up with: nansen wallet create
783
+
797
784
  OPTIONS:
798
- --chain <chain> Chain: solana, ethereum, base, bsc
785
+ --chain <chain> Chain: solana, base
799
786
  --from <symbol|address> Input token (symbol like SOL, USDC or address)
800
787
  --to <symbol|address> Output token (symbol like USDC, ETH or address)
801
788
  --amount <units> Amount in BASE UNITS (e.g. lamports, wei)
802
- --wallet <name> Wallet name (default: default wallet)
789
+ --wallet <name> Wallet name (default: default wallet). Use "walletconnect" or "wc" for WalletConnect (EVM only).
803
790
  --slippage <pct> Slippage as decimal (e.g. 0.03 for 3%). Default: 0.03
804
791
  --auto-slippage Enable auto slippage calculation
805
792
  --max-auto-slippage <pct> Max auto slippage when auto-slippage enabled