feat: add stablecoins top command#37
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>
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 pegged stablecoins always report zero circulating value
High Severity
The peggedAmount struct only defines a PeggedUSD field, but the DefiLlama API uses dynamic keys matching the peg type (e.g. peggedEUR, peggedJPY, peggedSGD). For any non-USD pegged stablecoin, the circulating, circulatingPrevDay, circulatingPrevWeek, and circulatingPrevMonth fields will all unmarshal as zero. This causes CirculatingUSD to be 0, all change deltas to be 0, and sorting by circulating market cap to place them last — completely breaking the --peg-type peggedEUR filter the PR explicitly advertises.
Additional Locations (1)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 140421c4e8
ℹ️ 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 err != nil { | ||
| return err | ||
| } | ||
| return s.emitSuccess(trimRootPath(cmd.CommandPath()), result, nil, cacheMetaBypass(), nil, false) |
There was a problem hiding this comment.
Align chains gas output shape with advertised schema
chains gas emits a scalar GasPrice for single-chain requests (emitSuccess(..., result, ...)), while the same command registers its schema as []model.GasPrice; this makes the JSON contract input-dependent and breaks schema-driven clients that deserialize based on defi schema. Keep one consistent response shape (or explicitly model both) so automation doesn't fail when switching between one vs multiple chains.
Useful? React with 👍 / 👎.


Summary
stablecoins topcommand to list top stablecoins by circulating market cap using DefiLlama's free stablecoins API--peg-typefilter (e.g.peggedUSD,peggedEUR) and--limitflagWhy
Stablecoin data is fundamental for DeFi agents — helps with capital allocation, stablecoin selection, liquidity assessment, and depeg monitoring. This was a notable gap in the CLI's market data commands alongside
chains top,protocols top, andprotocols categories.Example
Test plan
go test ./...passesgo test -race ./internal/providers/defillama/ ./internal/app/passesgo vet ./...passesstablecoins topwith live DefiLlama API🤖 Generated with Claude Code
Note
Medium Risk
Introduces new CLI commands that hit external services (DefiLlama stablecoins API and arbitrary RPC endpoints) and adds concurrent multi-chain RPC fetching, which can affect reliability and output compatibility despite being read-only.
Overview
Adds new market-discovery surfaces:
stablecoins top(DefiLlama stablecoins API,--peg-type/--limit, 5m cache) pluschains list(enumerate supported chains/aliases) andchains gas(live EVM gas pricing via RPC with optional--rpc-urland parallel multi-chain batch mode).Extends core types/provider interfaces and the DefiLlama client to support stablecoin data, implements chain enumeration in
internal/id, updates cache-bypass rules for the new metadata commands, and adds unit/runner tests and docs/README/CHANGELOG updates for the new commands and outputs.Written by Cursor Bugbot for commit 140421c. This will update automatically on new commits. Configure here.