Skip to content

feat: add stablecoins top command#37

Closed
ggonzalez94 wants to merge 4 commits into
mainfrom
feat/stablecoins-top
Closed

feat: add stablecoins top command#37
ggonzalez94 wants to merge 4 commits into
mainfrom
feat/stablecoins-top

Conversation

@ggonzalez94
Copy link
Copy Markdown
Owner

@ggonzalez94 ggonzalez94 commented Mar 11, 2026

Summary

  • Adds stablecoins top command to list top stablecoins by circulating market cap using DefiLlama's free stablecoins API
  • Returns rank, name, symbol, peg type/mechanism, circulating USD, price, chain count, and day/week/month supply change deltas
  • Supports --peg-type filter (e.g. peggedUSD, peggedEUR) and --limit flag
  • No API key required; uses 5-minute cache TTL

Why

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, and protocols categories.

Example

defi stablecoins top --limit 5 --results-only --select rank,symbol,circulating_usd,price

Test plan

  • go test ./... passes
  • go test -race ./internal/providers/defillama/ ./internal/app/ passes
  • go vet ./... passes
  • Smoke tested stablecoins top with live DefiLlama API
  • Added 3 httptest-based unit tests (sort+limit, peg-type filter, null price)
  • Updated README, CHANGELOG, and Mintlify docs

🤖 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) plus chains list (enumerate supported chains/aliases) and chains gas (live EVM gas pricing via RPC with optional --rpc-url and 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.

ggonzalez94 and others added 4 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>
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.

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 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)
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: 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".

Comment thread internal/app/runner.go
if err != nil {
return err
}
return s.emitSuccess(trimRootPath(cmd.CommandPath()), result, nil, cacheMetaBypass(), nil, false)
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 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 👍 / 👎.

@ggonzalez94
Copy link
Copy Markdown
Owner Author

Closing: superseded by #43 which contains all commits from this stacked branch chain (this PR's 4 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