Skip to content

feat: add dexes volume command for DEX trading volume ranking#40

Closed
ggonzalez94 wants to merge 7 commits into
mainfrom
feat/dexes-volume
Closed

feat: add dexes volume command for DEX trading volume ranking#40
ggonzalez94 wants to merge 7 commits into
mainfrom
feat/dexes-volume

Conversation

@ggonzalez94
Copy link
Copy Markdown
Owner

@ggonzalez94 ggonzalez94 commented Mar 14, 2026

Summary

  • Adds dexes volume command to rank DEXes by 24h trading volume with 7d/30d totals and 1d/7d/1m percentage changes
  • Uses DefiLlama /overview/dexs API (no API key required)
  • Supports --chain filter for chain presence (e.g. --chain Arbitrum) and --limit
  • Follows the same pattern as protocols fees — consistent API, model types, and test coverage

Example usage

# Top 5 DEXes by 24h volume
defi dexes volume --limit 5 --results-only

# DEXes active on Arbitrum
defi dexes volume --chain Arbitrum --limit 5 --results-only

# With field selection
defi dexes volume --limit 10 --results-only --select rank,protocol,volume_24h_usd,change_1d_pct

Changes

  • internal/model/types.go: Added DexVolume model type
  • internal/providers/types.go: Added DexesVolume to MarketDataProvider interface
  • internal/providers/defillama/client.go: Implemented DexesVolume with chain filtering, null/zero volume exclusion, and descending sort
  • internal/app/runner.go: Added dexes volume command with 5m cache TTL
  • internal/providers/defillama/client_test.go: 3 httptest-based tests (sort+limit, chain filter, null/zero skip)
  • internal/app/runner_test.go: Updated fakeMarketProvider to implement new interface method
  • Updated CHANGELOG, README caveats, and Mintlify docs (market-commands reference, market-discovery guide, commands overview)

Test plan

  • go test ./... passes
  • go test -race ./... passes
  • go vet ./... passes
  • Smoke tested dexes volume with live DefiLlama API (unfiltered + chain filter)

🤖 Generated with Claude Code


Note

Medium Risk
Adds multiple new CLI commands and expands the DefiLlama market adapter plus EVM RPC gas querying; primary risk is contract/behavior changes in user-facing JSON outputs and new external dependency paths (DefiLlama endpoints + RPC calls).

Overview
Adds new market-discovery commands: dexes volume, protocols fees, and stablecoins top|chains, all backed by new DefiLlama API integrations with filtering (by --chain/--category/--peg-type), null/zero exclusion, ranking, and 5m caching.

Extends chains with chains list (enumerate supported chains + aliases) and chains gas (live EVM gas via RPC with optional --rpc-url and parallel multi-chain queries), and updates cache-bypass rules accordingly. Updates models/provider interfaces, adds comprehensive unit tests (runner + provider), and refreshes README/CHANGELOG/Mintlify docs to document the new commands and caveats.

Written by Cursor Bugbot for commit 1a2e101. This will update automatically on new commits. Configure here.

ggonzalez94 and others added 7 commits March 8, 2026 15:28
Agents and automation tools need to discover available chains before
using other commands. This adds `chains list` which enumerates all
supported chains with names, slugs, CAIP-2 identifiers, namespaces,
and accepted aliases. No API keys required; bypasses cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Agents planning execution need gas price context before deciding whether
to proceed with swaps, bridges, or other on-chain operations. This adds
`chains gas --chain <id>` which queries current base fee, priority fee,
and legacy gas price via RPC with EIP-1559 detection.

No API keys required, bypasses cache, supports --rpc-url override.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Allow --chain to accept comma-separated chain identifiers (e.g.
--chain 1,10,137,8453,42161) for parallel multi-chain gas price
queries. Single-chain usage preserves the existing scalar response
for backward compatibility. Multi-chain returns an array with
partial-result support and warnings for failed chains.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `stablecoins top` command using DefiLlama's free stablecoins API to
list stablecoins ranked by circulating market cap. Returns price, chain
count, peg type/mechanism, and day/week/month supply change deltas.
Supports `--peg-type` filter and `--limit`. No API key required.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…cap ranking

Surface stablecoin liquidity distribution across chains using DefiLlama's
stablecoinchains API. Returns chains ranked by total stablecoin supply with
CAIP-2 chain IDs and dominant peg type. No API key required.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `protocols fees` command that ranks protocols by 24h fee revenue
using the DefiLlama fees API. Includes 7d/30d totals, percentage
changes (1d/7d/1m), category filtering, and chain counts. No API key
required.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add `dexes volume` command to rank DEXes by 24h trading volume with
7d/30d totals and 1d/7d/1m percentage changes. Uses DefiLlama DEX
volume API (no API key required). Supports `--chain` filter for chain
presence and `--limit`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


type peggedAmount struct {
PeggedUSD float64 `json:"peggedUSD"`
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-USD stablecoins report zero circulating amounts

High Severity

The peggedAmount struct only has a PeggedUSD field (json:"peggedUSD"), but the DefiLlama API returns circulating amounts keyed by the actual peg type — e.g. {"peggedEUR": 100000000} for EUR-pegged stablecoins. This causes all non-USD pegged stablecoins to silently report zero CirculatingUSD and zero change deltas. The test fixtures mask this by incorrectly using "peggedUSD" as the key even for pegType: "peggedEUR" entries. Notably, StablecoinChains already handles this correctly by using map[string]float64 for the same kind of data.

Additional Locations (1)
Fix in Cursor Fix in Web

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a2e1014a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +376 to +377
if normChain != "" && !containsChain(p.Chains, normChain) {
continue
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize dexes chain filter inputs before matching

dexes volume --chain is matched as a raw lowercase string against DefiLlama chain names, so normalized chain forms used elsewhere in the CLI (e.g. --chain 1, --chain eip155:42161, or aliases that resolve via id.ParseChain) will never match and incorrectly return empty results. This makes the new command inconsistent with the CLI’s chain normalization contract and can silently break automation that passes canonical chain IDs.

Useful? React with 👍 / 👎.

@ggonzalez94
Copy link
Copy Markdown
Owner Author

Closing: superseded by #43 which contains all commits from this stacked branch chain (this PR's 7 commits are included in #43's 10).

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.

1 participant