nansen-cli 1.31.1 → 1.32.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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.32.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#455](https://github.com/nansen-ai/nansen-cli/pull/455) [`875fabb`](https://github.com/nansen-ai/nansen-cli/commit/875fabb3f86736b03c874904e27a898315ef4bfa) Thanks [@gulshngill](https://github.com/gulshngill)! - Support x402 payments with USDT on BNB Smart Chain (`eip155:56`), which the Nansen API now advertises as a payment option. Payment signing already handled any EVM network generically; this adds BSC to the post-payment balance check with the correct token contract and 18-decimal precision (Base USDC and X Layer USDT0 use 6), plus a `bsc` entry in the shared RPC registry with a `NANSEN_BSC_RPC` override.
8
+
9
+ ## 1.32.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#451](https://github.com/nansen-ai/nansen-cli/pull/451) [`73600d9`](https://github.com/nansen-ai/nansen-cli/commit/73600d9cd13248a265332ec0728c602b16f44868) Thanks [@kome12](https://github.com/kome12)! - Add `nansen research profiler dex-trades` command for DEX trade history
14
+
3
15
  ## 1.31.1
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nansen-cli",
3
- "version": "1.31.1",
3
+ "version": "1.32.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",
package/src/api.js CHANGED
@@ -973,6 +973,20 @@ export class NansenAPI {
973
973
  });
974
974
  }
975
975
 
976
+ async addressDexTrades(params = {}) {
977
+ const { address, chain = 'ethereum', filters = {}, orderBy, pagination, days = 30, date } = params;
978
+ if (address) requireValidAddress(address, chain);
979
+ const dateRange = date || buildDateRange(days);
980
+ return this.request('/api/v1/profiler/dex-trades', {
981
+ address,
982
+ chain,
983
+ date: dateRange,
984
+ filters,
985
+ order_by: orderBy,
986
+ pagination
987
+ });
988
+ }
989
+
976
990
  // ============= Token God Mode Endpoints =============
977
991
 
978
992
  async tokenScreener(params = {}) {
package/src/cli.js CHANGED
@@ -1148,6 +1148,10 @@ export function buildCommands(deps = {}) {
1148
1148
  'pnl-summary': () => apiInstance.addressPnlSummary({ address, chain, orderBy, pagination, days }),
1149
1149
  'perp-positions': () => apiInstance.addressPerpPositions({ address, filters, orderBy, pagination }),
1150
1150
  'perp-trades': () => apiInstance.addressPerpTrades({ address, filters, orderBy, pagination, days }),
1151
+ 'dex-trades': () => {
1152
+ const date = parseDateOption(options.date, days);
1153
+ return apiInstance.addressDexTrades({ address, chain, filters, orderBy, pagination, days, date });
1154
+ },
1151
1155
  'batch': () => {
1152
1156
  let addresses = [];
1153
1157
  if (options.addresses) {
@@ -1186,7 +1190,7 @@ export function buildCommands(deps = {}) {
1186
1190
  return compareWallets(apiInstance, { addresses: addrs, chain, days });
1187
1191
  },
1188
1192
  'help': () => ({
1189
- commands: ['balance', 'labels', 'transactions', 'pnl', 'search', 'historical-balances', 'related-wallets', 'counterparties', 'pnl-summary', 'perp-positions', 'perp-trades', 'batch', 'trace', 'compare'],
1193
+ commands: ['balance', 'labels', 'transactions', 'pnl', 'search', 'historical-balances', 'related-wallets', 'counterparties', 'pnl-summary', 'perp-positions', 'perp-trades', 'dex-trades', 'batch', 'trace', 'compare'],
1190
1194
  description: 'Wallet profiling endpoints',
1191
1195
  example: 'nansen research profiler compare --addresses "0xABC...,0xDEF..." --chain ethereum'
1192
1196
  })
package/src/rpc-urls.js CHANGED
@@ -8,6 +8,7 @@
8
8
  * Override env vars:
9
9
  * NANSEN_EVM_RPC Custom Ethereum RPC (also used as generic EVM fallback)
10
10
  * NANSEN_BASE_RPC Custom Base RPC
11
+ * NANSEN_BSC_RPC Custom BNB Smart Chain RPC
11
12
  * NANSEN_XLAYER_RPC Custom X Layer RPC
12
13
  * NANSEN_SOLANA_RPC Custom Solana RPC
13
14
  *
@@ -20,6 +21,7 @@
20
21
 
21
22
  const DEFAULT_EVM_RPC = 'https://eth.public-rpc.com';
22
23
  const DEFAULT_BASE_RPC = 'https://mainnet.base.org';
24
+ const DEFAULT_BSC_RPC = 'https://bsc-dataseed.binance.org';
23
25
  const DEFAULT_XLAYER_RPC = 'https://rpc.xlayer.tech';
24
26
  const DEFAULT_SOLANA_RPC = 'https://api.mainnet-beta.solana.com';
25
27
 
@@ -27,6 +29,7 @@ export const CHAIN_RPCS = {
27
29
  ethereum: process.env.NANSEN_EVM_RPC || DEFAULT_EVM_RPC,
28
30
  evm: process.env.NANSEN_EVM_RPC || DEFAULT_EVM_RPC, // generic EVM fallback
29
31
  base: process.env.NANSEN_BASE_RPC || process.env.NANSEN_RPC_BASE || DEFAULT_BASE_RPC,
32
+ bsc: process.env.NANSEN_BSC_RPC || DEFAULT_BSC_RPC,
30
33
  xlayer: process.env.NANSEN_XLAYER_RPC || DEFAULT_XLAYER_RPC,
31
34
  solana: process.env.NANSEN_SOLANA_RPC || DEFAULT_SOLANA_RPC,
32
35
  };
package/src/schema.json CHANGED
@@ -203,6 +203,21 @@
203
203
  }
204
204
  }
205
205
  },
206
+ "dex-trades": {
207
+ "endpoint": "/api/v1/profiler/dex-trades",
208
+ "description": "DEX trade history for a wallet",
209
+ "options": {
210
+ "address": {
211
+ "required": true
212
+ },
213
+ "chain": {
214
+ "default": "ethereum"
215
+ },
216
+ "days": {
217
+ "default": 30
218
+ }
219
+ }
220
+ },
206
221
  "search": {
207
222
  "endpoint": "/api/v1/search/entity-name",
208
223
  "description": "Search for entities by name",
package/src/x402.js CHANGED
@@ -156,6 +156,17 @@ export async function createPaymentSignature(response, url, options = {}) {
156
156
  return null;
157
157
  }
158
158
 
159
+ /**
160
+ * x402 payment tokens per EVM network, matching the stablecoins the API
161
+ * advertises in 402 `accepts` entries. `decimals` matters: USDT on BNB Smart
162
+ * Chain uses 18 decimals, unlike the 6-decimal tokens on Base and X Layer.
163
+ */
164
+ export const EVM_X402_TOKENS = {
165
+ 'eip155:8453': { token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', rpc: CHAIN_RPCS.base, symbol: 'USDC', decimals: 6 }, // Base USDC
166
+ 'eip155:196': { token: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736', rpc: CHAIN_RPCS.xlayer, symbol: 'USDT0', decimals: 6 }, // X Layer USDT0
167
+ 'eip155:56': { token: '0x55d398326f99059fF775485246999027B3197955', rpc: CHAIN_RPCS.bsc, symbol: 'USDT', decimals: 18 }, // BSC USDT
168
+ };
169
+
159
170
  /**
160
171
  * Check stablecoin balance for x402 payment wallet on the given network.
161
172
  * Returns `{ balance, symbol }` (USD amount + token symbol) or null if check fails.
@@ -192,13 +203,9 @@ export async function checkX402Balance(network) {
192
203
  }
193
204
 
194
205
  if (network.startsWith('eip155:')) {
195
- // Per-network token + RPC. Both tokens are 6-decimals.
196
206
  // Default to Base USDC if the network is unknown so existing wallets keep working.
197
- const EVM_NETWORKS = {
198
- 'eip155:8453': { token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', rpc: CHAIN_RPCS.base, symbol: 'USDC' }, // Base USDC
199
- 'eip155:196': { token: '0x779Ded0c9e1022225f8E0630b35a9b54bE713736', rpc: CHAIN_RPCS.xlayer, symbol: 'USDT0' }, // X Layer USDT0
200
- };
201
- const { token, rpc, symbol } = EVM_NETWORKS[network] || EVM_NETWORKS['eip155:8453'];
207
+ const { token, rpc, symbol, decimals } =
208
+ EVM_X402_TOKENS[network] || EVM_X402_TOKENS['eip155:8453'];
202
209
  const addr = walletInfo.evm.replace('0x', '').toLowerCase().padStart(64, '0');
203
210
  const resp = await fetch(rpc, {
204
211
  method: 'POST',
@@ -210,7 +217,7 @@ export async function checkX402Balance(network) {
210
217
  }),
211
218
  });
212
219
  const data = await resp.json();
213
- return { balance: parseInt(data.result, 16) / 1e6, symbol };
220
+ return { balance: parseInt(data.result, 16) / 10 ** decimals, symbol };
214
221
  }
215
222
 
216
223
  return null;