feat: add dexes volume command for DEX trading volume ranking#40
feat: add dexes volume command for DEX trading volume ranking#40ggonzalez94 wants to merge 7 commits into
Conversation
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
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"` | ||
| } |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
💡 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".
| if normChain != "" && !containsChain(p.Chains, normChain) { | ||
| continue |
There was a problem hiding this comment.
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 👍 / 👎.


Summary
dexes volumecommand to rank DEXes by 24h trading volume with 7d/30d totals and 1d/7d/1m percentage changes/overview/dexsAPI (no API key required)--chainfilter for chain presence (e.g.--chain Arbitrum) and--limitprotocols fees— consistent API, model types, and test coverageExample usage
Changes
internal/model/types.go: AddedDexVolumemodel typeinternal/providers/types.go: AddedDexesVolumetoMarketDataProviderinterfaceinternal/providers/defillama/client.go: ImplementedDexesVolumewith chain filtering, null/zero volume exclusion, and descending sortinternal/app/runner.go: Addeddexes volumecommand with 5m cache TTLinternal/providers/defillama/client_test.go: 3 httptest-based tests (sort+limit, chain filter, null/zero skip)internal/app/runner_test.go: UpdatedfakeMarketProviderto implement new interface methodTest plan
go test ./...passesgo test -race ./...passesgo vet ./...passesdexes volumewith 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, andstablecoins top|chains, all backed by new DefiLlama API integrations with filtering (by--chain/--category/--peg-type), null/zero exclusion, ranking, and 5m caching.Extends
chainswithchains list(enumerate supported chains + aliases) andchains gas(live EVM gas via RPC with optional--rpc-urland 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.