feat: add chain analytics commands#6
Merged
Merged
Conversation
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]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
chaincommand group for EVM chain-level analytics, wired to real data sources (DefiLlama + growthepie). This complements the existingprotocolanalytics commands.What's included
chaincommand group (src/cli/chain.rs,src/commands/chain.rs) with subcommands for chain analytics.src/api/chain.rs,src/models/chain.rs):src/config/mod.rs).chainandprotocolanalytics subcommands (skills/chainpilot/SKILL.md).Notes
cargo checkpasses.🤖 Generated with Claude Code