Add /protocol treasury fee tracking (24h/7d/30d USD) #1112

Merged
PlasticDigits merged 1 commit from feat/586-protocol-fee-tracking into main 2026-08-22 06:03:59 +00:00
PlasticDigits commented 2026-08-21 11:46:36 +00:00 (Migrated from gitlab.com)

Summary

  • Index treasury fees from AMM swap, book take, limit place, and pinned wrap/unwrap into protocol_fee_events, then materialize 24h/7d/30d USD + flow Δ% on global_stats_24h and capped source/token tables.
  • /protocol adds a Protocol fees panel after Global stats (source + token mix). Overview JSON is additive; GET /api/v1/protocol/fees is 60s-cached with an allowlisted window.
  • GET paths stay O(1) rollup. Book take uses fills only (L7, no double-count). Wrap requires exact WRAP_MAPPER_ADDRESS match; burn tax is ignored.

Closes #586

Test plan

  • make verify-issue-586 (docs, cargo lib + integration, vitest, Playwright e2e-smoke 5 workers, related 550/569)
  • cargo test --lib protocol_fees and --test indexer_protocol_fees --test api_overview
  • ProtocolPage + trailingWindowCopy vitest
  • Manual /protocol on LocalTerra or prod indexer: fee panel under Global stats; idle $0; Δ% — until 2× windows; wrap rows only after mapper pin
  • Confirm hybrid swap increases AMM + book once (not double book)
  • Confirm unwrap does not include InstantWithdraw burn tax
## Summary - Index treasury fees from AMM swap, book take, limit place, and pinned wrap/unwrap into `protocol_fee_events`, then materialize 24h/7d/30d USD + flow Δ% on `global_stats_24h` and capped source/token tables. - `/protocol` adds a **Protocol fees** panel after Global stats (source + token mix). Overview JSON is additive; `GET /api/v1/protocol/fees` is 60s-cached with an allowlisted `window`. - GET paths stay O(1) rollup. Book take uses fills only (L7, no double-count). Wrap requires exact `WRAP_MAPPER_ADDRESS` match; burn tax is ignored. Closes #586 ## Test plan - [x] `make verify-issue-586` (docs, cargo lib + integration, vitest, Playwright e2e-smoke 5 workers, related 550/569) - [x] `cargo test --lib protocol_fees` and `--test indexer_protocol_fees --test api_overview` - [x] ProtocolPage + trailingWindowCopy vitest - [ ] Manual `/protocol` on LocalTerra or prod indexer: fee panel under Global stats; idle `$0`; Δ% `—` until 2× windows; wrap rows only after mapper pin - [ ] Confirm hybrid swap increases AMM + book once (not double book) - [ ] Confirm unwrap does not include InstantWithdraw burn tax
PlasticDigits commented 2026-08-22 06:03:59 +00:00 (Migrated from gitlab.com)

mentioned in commit d1d2222ccc

mentioned in commit d1d2222ccca36a83c119d130246c6d7a669cacbb
PlasticDigits (Migrated from gitlab.com) merged commit d1d2222ccc into main 2026-08-22 06:04:00 +00:00
PlasticDigits commented 2026-08-22 06:09:45 +00:00 (Migrated from gitlab.com)

mentioned in commit 0fd7e3a323

mentioned in commit 0fd7e3a323b7dcba0e20430a2aeec5246eb6035f
PlasticDigits commented 2026-08-22 06:28:40 +00:00 (Migrated from gitlab.com)

mentioned in issue #586

mentioned in issue #586
PlasticDigits commented 2026-08-22 06:29:12 +00:00 (Migrated from gitlab.com)

mentioned in issue #590

mentioned in issue #590
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!1112
No description provided.