fix(indexer/listings): reconcile DeFiLlama volume, fees, and TVL with live data #1354
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#1354
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On 2026-09-25 around 05:25–05:35 UTC, CL8Y DEX's DeFiLlama volume, fee history, and TVL diverged from the live indexer and pool inventory for different reasons. This is a reconciliation issue; keep the already completed listing/adapter tickets #631 and #687 closed.
The three current causes are: (1) one unpriced swap makes an entire UTC day's otherwise priced volume JSON
null, and the upstream DEX adapter throws; (2) historical fee corrections do not propagate through both the eight-day indexer Llama rollup and Llama's stored daily chart; (3) Llama prices only LUNC and USTC in the TVL adapter's reserve basket, omitting material CW20 pool legs. There are also missing fee sources and a pair-scoping risk described below.Reproducible evidence
Compare completed UTC days 2026-08-26 through 2026-09-24, inclusive for flows. Do not compare a UTC-day flow with
/overviewtrailing 24h/30d.null; their already priced swaps sum to $22,011.24 in the indexer's UTC protocol series. That accounts for the gap (rounding aside)./defillama/daily; $897.47 in/protocol/fees/daily/overviewaround $157–160k about 1–2 hours laterPublic evidence: Llama DEX volume, Llama fees, Llama TVL with
tokensInUsd, indexer UTC volume series, indexer UTC fee series, indexer overview, 2026-09-24 Llama feed. For the exact 30-day volume window, add the 2026-08-26 daily feed to the protocol series' 2026-08-27–09-24 points and exclude its in-progress 09-25 point.1. Volume: a single unpriced hop erases the day's priced total
The 2026-09-24 daily response has
trade_count: 28andvolume_usd: null. The same UTC day in the protocol series has $558.461005 of priced swaps and 28 trades. A CL8Y-cb/ALPHA trade at 16:56:49 UTC, tx37A8F6FAB565F532382C1EA1EC349624BB1D0E2316409AF95EBAB53EF294EAAF, has no USD price; it is one hop in a route through UST1/ALPHA. Both CL8Y and ALPHA are outside the swap-volume USD catalog for that pair. The source query inindexer/src/db/queries/defillama.rsstores a positive pricedSUM(volume_usd)andunpriced_trade_count;indexer/src/api/defillama.rsthen callsdaily_usd_field_fail_closed, which makes the whole daynullif the count is nonzero. Upstreamdexs/cl8y-dexthrows on thatnull. Its arithmetic and start pin otherwise match the feed.The ten null dates in the 30-day sample are 08-27, 09-01, 09-05, 09-09, 09-11, 09-12, 09-13, 09-17, 09-18, and 09-24. Llama's chart contains the other twenty days and reports their approximately $31,166 sum. This is a lower bound problem as well: the $53,177.23 comparison includes only priced swaps, not a guessed USD value for the unpriced hops.
2. Fees: two stale history layers, plus omitted fee sources
Examples on matching UTC days: 09-10 is $69 stored by Llama, $69.23 on today's Llama daily feed, $92.10 on today's protocol fee series; 09-17 is $115 stored versus $166.95 on both live indexer series. 09-24 agrees at about $2.01. Upstream
fees/cl8y-dexmaps the current endpoint's seven sources into labeled groups and a residual; the present-day value agrees. The issue is historical state, not an observed double-add in that adapter.indexer/src/indexer/defillama.rssetsDAILY_LOOKBACK_DAYS = 8, andrefresh_defillama_dailyonly reaggregates today and those eight prior days.protocol_fee_seriesreaggregates 90 prior days. The completed #1269 multihop fee repair backfills historicalprotocol_fee_events, and the NULL-only USD backfill can fill older rows later. Old Llama daily fee rollups therefore have a concrete route to remaining stale; Llama's already stored daily chart can lag the corrected endpoint again. Public gem-pair swap tapes show no gem swaps during this 30-day sample, but a production DB comparison by fee source and pair is needed to distinguish every dollar of the $80.73 indexer-series gap from intentional gem exclusions or other differences.FeeSource::ALLand the live/protocol/feesAPI still contain only seven sources. Pair-creation treasury fees and community SKU/settings invoices are absent from both the fee ledger and DeFiLlama feed; existing #1209 and #1210 specify that work.fjcurrently shows both closed, while their latest comments andmainstill say implementation is outstanding after docs-only auto-close. Their amounts are not included in the $150.60 measured gap because the underlying events have not been reconciled here.Source-level additional risk:
indexer/src/db/queries/defillama.rsexcludes aswap_ammfee when any gem-pair swap has the sametx_hash, even though #1269 now storesprotocol_fee_events.pair_id. A mixed gem/non-gem router transaction would lose the non-gem fee too. Current 30-day impact is unmeasured; this is not an explanation for the volume nulls.3. TVL: token price coverage, not a bad factory pin
The upstream TVL adapter queries the configured factory's listed
Pool {}reserves, maps cLUNC/cUSTC 1:1 to nativeuluna/uusd, and adds other CW20s by address. The factory matches the deployment registry. Llama's current token breakdown values only LUNC and USTC. A Llama coins price request likewise returns only the two native prices. Material omitted legs include the UST1/USTR pool (about $42.3k at probe time) and UST1's leg of the UST1/cUSTC pool (pool about $53.1k). Llama has no verified UST1, USTR, or CL8Y CW20 prices./overviewvalues some pools by a priced leg times two, so its ~$157–160k is an illustrative coverage comparison, not an exact expected Llama TVL.Recommended fixes and acceptance
"0", all-unpriced activity stays JSONnull. Addunpriced_trade_count/ priced-trade count or completeness metadata to the daily API and document that the headline is a priced lower bound. Keep gem exclusion, one row per swap hop, and no wrap/window or limit-fill double count. Investigate the CL8Y/ALPHA hop's missing USD mark separately using a verified, time-appropriate price; do not invent a peg. Recompute from adapter start 2026-08-17 and request Llama to reload the affected daily dates. Acceptance: 2026-09-24 publishes at least its existing $558.46 priced sum, and the anchored 30-day chart includes the ten missing dates without reporting unpriced activity as$0.protocol_fee_events,defillama_daily_fees, andprotocol_daily_feesfor 2026-08-17 onward, with the same gem rules. Then reaggregatedefillama_daily_*for all affected historical days after #1269/NULL-USD backfills, and ask Llama to reingest those dates. Add a dirty-day queue or explicit backfill command when old fee rows change; the ordinary eight-day loop can remain bounded. Acceptance: every historical day matches the priced ledger after intentional exclusions, and Llama's stored fee chart matches the corrected daily endpoint within display rounding; document any excluded amounts./protocol/feesand DeFiLlama. Do not infer gas, spread, tax, or unverified invoices as fees. Add a mixed gem/non-gem same-tx case and scope pair-linked fee exclusion to its ownpair_id/event rather than any matching tx hash.$1, and do not invent USTR or gem pegs. Compare factory reserve amounts, valued versus unvalued token balances, and the Llama token breakdown at the same block/time before declaring a TVL target. Keep raw on-chain pool reserves as the TVL source.Related: #631 listing, #687 fee adapter/start repair, #688 post-merge operations, #1269 multihop fee backfill, #1209 and #1210 missing fee sources, #629 price coverage context. In-repo source:
scripts/defillama/,indexer/src/api/defillama.rs,indexer/src/db/queries/defillama.rs,indexer/src/indexer/defillama.rs,indexer/src/db/queries/protocol_fee_series.rs.