Skip to content

feat: add chain analytics commands#6

Merged
junjieit merged 14 commits into
mainfrom
feat/chain-command
Jun 10, 2026
Merged

feat: add chain analytics commands#6
junjieit merged 14 commits into
mainfrom
feat/chain-command

Conversation

@junjieit

@junjieit junjieit commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a new chain command group for EVM chain-level analytics, wired to real data sources (DefiLlama + growthepie). This complements the existing protocol analytics commands.

What's included

  • chain command group (src/cli/chain.rs, src/commands/chain.rs) with subcommands for chain analytics.
  • Data layer (src/api/chain.rs, src/models/chain.rs):
    • TVL and per-chain protocol TVL via DefiLlama
    • Fees endpoint (corrected) and chain activity fields via growthepie
    • Dropped fields that had no reliable data source rather than surfacing empty values
  • Config plumbing for the new endpoints (src/config/mod.rs).
  • Docs: chainpilot skill updated to document the chain and protocol analytics subcommands (skills/chainpilot/SKILL.md).

Notes

  • growthepie chain-activity URLs use the dict-key (underscore) form.
  • cargo check passes.

🤖 Generated with Claude Code

junjieit and others added 14 commits June 9, 2026 10:23
Previously several chain fields were hardcoded to None or fetched from
wrong/empty endpoints. Wire up free DefiLlama/CoinGecko sources:

- stablecoins: fix 404 by using the stablecoins.llama.fi host
- stablecoin_flow_24h + flows net/inflow/outflow + per-coin breakdown,
  derived from per-chain chainCirculating current vs prevDay
- protocols.revenue from overview/fees/{chain} dailyRevenue
- native_price coverage via DefiLlama per-chain gecko_id (authoritative,
  all chains) with local chain_config and name-map fallbacks; drop the
  native_token guard so chains like Base (no symbol) still resolve
- fix BSC resolution: DefiLlama names it "Binance" in /chains but "BSC"
  in stablecoins chainCirculating; add stablecoin_chain_name remap

Fields without a free source (bridge_flow, cex_flow, active_addresses,
tx_count_24h, throughput, protocols.users) remain N/A pending paid APIs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- fees_24h used /summary/fees/{chain} (a protocol endpoint) which returned
  wrong values for Ethereum and N/A for most chains. Switch to the chain
  endpoint /overview/fees/{chain} (Ethereum 24h fees now ~8.8M vs bogus ~0.3M)
- DefiLlamaProtocol.chain_tvls was missing #[serde(rename = "chainTvls")] so
  it never deserialized; per-chain TVL silently fell back to the protocol's
  global TVL (e.g. Binance CEX showed 140B on every chain). Add the rename and
  drop the global fallback so a protocol's TVL is chain-specific, or null when
  the chain has no breakdown

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
active_addresses, tx_count_24h, and throughput were hardcoded to None
with no data source. Wire them to growthepie's free per-chain API
(chains/{url_key}.json), mapping EVM chain ID to growthepie's url_key.

- daa -> active_addresses, txcount -> tx_count_24h, throughput -> throughput
- replaces the dead /overview/activeUsers fetch (always 404'd)
- only covers chains growthepie tracks (Ethereum + L2s); chains like BSC
  and Avalanche keep these fields N/A, which is honest given no source

Still unsourced: bridge_flow (needs DefiLlama Pro key), cex_flow and
protocols.users (no usable public source).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Remove bridge_flow, cex_flow (ChainFlows) and users (ChainProtocolEntry)
along with their renderers. These had no usable data source (bridge needs
a paid DefiLlama Pro key; CEX flows and per-protocol users have no public
API) and only ever rendered as empty/N/A, which was misleading.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
chain_id_to_growthepie returned the dashed url_key (e.g. "polygon-pos"),
but growthepie's chains/{key}.json endpoint keys files by the master dict
key (underscored, "polygon_pos") and 403s on the dashed form. Single-word
chains were unaffected; polygon, zksync_era and arbitrum_nova returned no
activity data. Use the underscore form.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add a `chain` Subcommands section (info/flows/stablecoins/protocols) with
each command's fields, data sources, and coverage caveats (growthepie
activity only for Ethereum-ecosystem chains; flows are stablecoin-scope
only; protocol TVL is chain-specific or N/A). Also surface chain-level
analytics in the skill description for trigger accuracy.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`chain flows` --help still advertised "(bridge, CEX, stablecoin flows)"
after bridge/CEX were removed, and `chain info` omitted the fees and 24h
activity fields. Align the help summaries with actual behavior.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The protocol command (info/tvl/revenue/chains) had no skill documentation.
Add a section covering each subcommand, its flags, and output fields.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
CEX, bridge and canonical-bridge/chain entries report a per-chain TVL
in DefiLlama's /protocols response (e.g. Binance CEX has
chainTvls["Ethereum"]), so they dominated the chain protocols list with
large, misleading TVLs. Filter them out by category, and additionally
require a chainTvls[chain] value so every row shows a real per-chain TVL.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@junjieit junjieit merged commit fcb73d9 into main Jun 10, 2026
3 checks passed
@junjieit junjieit deleted the feat/chain-command branch June 10, 2026 02:13
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