Skip to content

feat: add profiler dex-trades command#451

Merged
kome12 merged 3 commits into
mainfrom
sonar/pug
Jun 3, 2026
Merged

feat: add profiler dex-trades command#451
kome12 merged 3 commits into
mainfrom
sonar/pug

Conversation

@kome12

@kome12 kome12 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds nansen research profiler dex-trades — a new subcommand that fetches DEX trade history for a wallet address on any supported chain via the POST /api/v1/profiler/dex-trades endpoint.

Files changed:

  • src/api.js — new addressDexTrades() method (follows the same pattern as addressPerpTrades, with chain-scoped address validation and date range support)
  • src/cli.js — wired into the profiler handler alongside existing subcommands; added to the help commands list
  • src/schema.json — documented the new endpoint with required options
  • src/__tests__/api.test.js — 6 unit tests covering endpoint URL, address/chain passthrough, orderBy, date range (default and custom days), filters, and Solana address support
  • src/__tests__/coverage.test.js — added to the profiler endpoint coverage array

Example usage:

nansen research profiler dex-trades --address 0x28c6c06298d514db089934071355e5743bf21d60 --chain ethereum
nansen research profiler dex-trades --address 0x28c6c06298d514db089934071355e5743bf21d60 --chain ethereum --days 7
nansen research profiler dex-trades --address 0x28c6c06298d514db089934071355e5743bf21d60 --chain ethereum --sort trade_value_usd:desc --limit 50
nansen research profiler dex-trades --address Gu29tjXrVr9v5n42sX1DNrMiF3BwbrTm379szgB9qXjc --chain solana

Test plan

  • All 27 test files pass (1486 tests, 2 skipped)
  • npm run lint passes clean
  • New addressDexTrades tests cover: endpoint, address/chain, orderBy, date range (default + custom), filters, and Solana address

🤖 Generated with Claude Code

Ko Miyatake (Openclaw Bot) and others added 2 commits June 2, 2026 08:22
Adds `nansen research profiler dex-trades` to surface DEX trade history
for a wallet address on any supported chain via POST /api/v1/profiler/dex-trades.

Supports --address, --chain, --days, --date, --sort, --page, --limit,
and --filter flags, consistent with other profiler subcommands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kome12 kome12 self-assigned this Jun 2, 2026
@kome12 kome12 requested a review from gulshngill June 2, 2026 10:31
@gulshngill

Copy link
Copy Markdown
Contributor

Code Review — feat: add profiler dex-trades command

Verdict: ✅ Approve — no blocking issues. Two-pass review: initial scan by Codex, cross-validated by Claude Code against exact line numbers. Tests: 1486 passed ✅ | Lint: clean ✅


🔵 Low — Default chain is inconsistent across three files (pre-existing codebase pattern)

  • cli.js:1115const chain = options.chain || 'all' is the shared default for all profiler subcommands; when --chain is omitted, chain="all" is always passed to the API method.
  • api.js:977chain = 'ethereum' default is effectively dead on the CLI path (always overridden by the CLI).
  • schema.json:214 — documents the default as "ethereum".

This three-way inconsistency already exists for every sibling profiler subcommand (transactions, pnl, counterparties, perp-trades, etc.) — the new code faithfully replicates the convention rather than introducing a new defect. Worth reconciling across the whole profiler family in a follow-up, but not blocking here.

One thing worth confirming: does /api/v1/profiler/dex-trades accept chain="all" (the effective CLI default)? That's the only concrete runtime risk, and it applies equally to the existing commands.


🔵 Low — No CLI dispatch test for dex-trades

The 6 new tests exercise api.addressDexTrades() directly, and coverage.test.js was correctly extended with the new endpoint. However there's no test calling the CLI handler with 'dex-trades' to verify arg wiring (--sort, --days, --filter passthrough). Not required — most profiler subcommands have no dispatch test either — but a single test mirroring the existing balance dispatch test would be a nice-to-have.


🔵 Low — orderBy shape in new test doesn't match --sort CLI output

api.test.js:1119 uses { column: 'block_timestamp', order: 'desc' }; the --sort shorthand in cli.js:438-451 produces { field, direction }. The test is asserting passthrough (valid), but using the shape that --sort actually generates would make intent clearer.


✅ Looks good

  • Endpoint string /api/v1/profiler/dex-trades is consistent across api.js, schema.json, and coverage.test.js
  • buildDateRange / parseDateOption / requireValidAddress wiring matches siblings exactly
  • Help text updated (cli.js:1193)
  • Changeset present, typed minor — correct for a new user-facing subcommand
  • ESM/style conventions followed throughout

🤖 Review assisted by Codex + Claude Code

@kome12 kome12 merged commit d8d92b7 into main Jun 3, 2026
7 checks passed
@kome12 kome12 deleted the sonar/pug branch June 3, 2026 11:43
@github-actions github-actions Bot mentioned this pull request Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants