feat(indexer): index community SKU and settings invoices on /api/v1/protocol/fees #1210
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic#1210
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
Index community-tax SKU unlock and settings-batch invoices (canonical 50 UST1 each, forwarded to CMM) on
GET /api/v1/protocol/fees. On-chain invoices and the community-token catalog already exist. The protocol fee API does not.This issue already bundles both invoice kinds (
sku_unlock+settings_fee). Do not split them. Do not mix factory pair-creation uluna (#1209). Design/home: #1213.Closed marketing tracker: cl8y-marketing#4. Do not reopen it.
Land after (or stacked on) the pair-creation
FeeSourcewidening pattern. Do not expand #1209’s MR.Given / When / Then
Given a paid EnableFeature, UpdateSettings batch, or launcher
create_tokenwithsku_count> 0 on pinned/catalogued emittersWhen the indexer ingests that success tx
Then it inserts one
protocol_fee_eventsrow per paid invoice (sku_unlockorsettings_fee) with amount from the canonical attr /sku_count × 50e6And launcher+token EnableFeature in the same tx is still one fee row
And migrate-adopt, tax skim, #595 swap/wrap legs, gas, and reverted invoices are not community fee rows
Not a duplicate / already implemented
pair_creationuluna. Prerequisite pattern; different source.unknownis OK until this stream exists.community_token_events— “which SKU,” not treasury USD.swap_amm/ wrap.Not implemented:
FeeSourcehas nosku_unlock/settings_fee. Catalog events are not read by/protocol/fees.Current codebase
On-chain invoices (already correct)
INVOICE_UST1 = 50_000_000(6 dp) incommunity-tax-token/ launcher:Sendto pinned launcher50 UST1 × NTransferUST1 → CMM (does not also send to the token)action=create_token+sku_count; replycreate_token_readyhas no invoice attrExecuteMsg::CreateToken(no UST1)Sends UST1 to the token; tokenTransfers to CMMenable_feature+sku+invoice(launcher often has noinvoice)Sendto tokenTransfer→ CMMupdate_settings+invoicePay-with-any-token (#595) only routes off-chain. Launcher/token still accept UST1
Sendonly. Swap/wrap legs on that path may already produceswap_amm/ wrap protocol fees. Those are not community invoices.Catalog ingest (exists; not the fee API)
community_tokens.rs(#594) parsesenable_feature/update_settings/create_token_readyintocommunity_token_events. Gaps vs treasury census:create_token_readystores no invoice amount (create-timeN × 50 UST1lives on launchercreate_token).enable_featuremay insert two catalog rows in one tx (launcher + token).GET /api/v1/protocol/feesdoes not read that table.Protocol fee API
Seven
FeeSources.COMMUNITY_TOKEN_LAUNCHERmay be unset — omit community invoice sources then (do not fake$0), same as wrap/window. GET is O(1) rollup / 60s cache.Frontend
ProtocolFeeSourceKeyhas no SKU/settings labels.Why the new implementation is needed
North-star ledgers should include project-team invoices, not only swap/book/wrap/window. Catalog
/community-tokensanswers “which token unlocked which SKU,” not “how much protocol invoice revenue in this window.”Idle volume (
event_count = 0) is not a reason to skip ingest. The first paid SKU must appear on the same API, with the same unpriced/idle/windowsemantics.Constraints / guardrails
pair_creation. SeparateFeeSourcestring(s). Do not count factorycreation_fee_ulunahere.campaign_idon fee rows.invoiceattr (canonical 50e6). Ignore the launcher’s same-txenable_featureas a second fee. Create with SKUs: count launchercreate_tokenonce (sku_count × 50e6). Do not also infer fromcreate_token_ready.amount_raw > 0. Do not infer50e6 × catalog SKU flags._contract_addressequals pinnedCOMMUNITY_TOKEN_LAUNCHER. Token wasm only for catalogued community tokens. Spoofenable_featurefrom a random CW20 is ignored.symbol=and never$1UST1."0".INVOICE_UST1; MM subscription (#597); invoice-payer adapter wasm; exact-out/route/solve; marketing fee tables.Relevant files
indexer/src/indexer/protocol_fees.rsFeeSource/ wrap-window patternindexer/src/indexer/parser.rsingest_protocol_feeindexer/src/indexer/community_tokens.rsindexer/src/db/queries/protocol_fees.rsindexer/src/config.rsCOMMUNITY_TOKEN_LAUNCHER, hub UST1indexer/src/api/protocol_fees.rs,protocol_fee_series.rs,api/defillama.rsindexer/tests/indexer_protocol_fees.rs,api_community_tokens.rsfrontend-dapp/src/types/index.ts,components/protocol/ProtocolFeeStats.tsxsmartcontracts/contracts/community-tax-token/src/invoice.rsinvoiceattr (read-only)smartcontracts/contracts/community-token-launcher/src/contract.rssku_count(read-only)skills/AGENTS_INDEXER_UST1_WINDOW_FEES.md,AGENTS_INDEXER_FEE_LEDGER_HOME.md,AGENTS_INDEXER_COMMUNITY_TOKENS.mdRecommended direction
FeeSourcewidening exists (or in a follow-up change set on that pattern), add two sources:sku_unlock— create-time paid SKUs and later EnableFeature (retail label SKU unlock).settings_fee— UpdateSettings batches (retail label Settings invoice).Prefer two keys. One combined
community_invoiceonly if Defillama/UI cannot take two._contract_address, same flattening as wrap #613):action=create_token+sku_count> 0 →sku_unlockamountsku_count × 50_000_000.sku_count=0→ no row.action=enable_feature+ positiveinvoice→sku_unlock. Drop launcherenable_featurein the same tx if the token segment is present.action=update_settings+ positiveinvoice→settings_fee.FeeSource::ALL, rollups, Defillama, frontend hide-idle.make verify-issue-1210. Catalog #594 tests stay green.Reject: folding invoices into
swap_ammorpair_creation; countingcreate_token_readyas a second fee.Acceptance criteria
FeeSourceincludes community invoice source(s); CHECK, rollups, Defillama, and UI labels updated.invoice=50000000) inserts onesku_unlockrow; launcher duplicate is not a second fee.settings_feerow of 50e6, not50 × field count.sku_unlockamountN × 50e6; create with 0 SKUs inserts none.contract_addressignored (#285). Unconfigured launcher pin omits the source(s).GET /api/v1/protocol/feesand/dailyexpose the new source(s) with idle/unpriced/windowsemantics. Frontend shows SKU unlock / Settings invoice whenevent_count > 0.(tx_hash, source, ordinal).Test plan (functional paths)
enable_feature+invoice=50000000(catalogued)sku_unlockrowenable_featureupdate_settings+invoice=50000000(multi-field)settings_feeof 50e6create_tokensku_count=2sku_unlock100e6;create_token_readynot a second feesku_count=0/ freeCreateTokenmigrate-adoptby_source; additive JSON"0"/ hide-idleamount_usdnull/community-tokensstill insertsmake verify-issue-586/#614(and #1209 verify if present)Test plan (attack, hack, and abuse)
enable_featureinvoice=50000000from random contract_contract_addresscontract_addresscreate_tokenandcreate_token_ready50e6 × enabled feature flagswithout a paid txinvoice=0/ missing invoice on token EnableFeature$1UST1 / vFDUSDpair_creationuluna into these sourcesinvoiceVerification criteria
by_sourcekeys, idle/unpriced, window allowlist.protocol_fee_events(sku_unlock, amount 50e6 UST1) and does not include swap/gas as that source.docs/indexer-invariants.mdprotocol-fees row updated.make verify-issue-1210plusmake verify-issue-586/make verify-issue-614/make verify-issue-594.Related ingest siblings: #1209 #1210 #1211. Pair-creation implement home is #1209 (not marketing #1). Design/home epic: #1213.
feat: index community SKU and settings invoices on /api/v1/protocol/feesto feat(indexer): index community SKU and settings invoices on /api/v1/protocol/feesRepair: DEX-native DoR. SKU unlock + settings invoices stay bundled here. Not implemented (catalog ≠ /protocol/fees). Stack after #1209; do not mix pair_creation.
Occupying-runner check: implement labels already present; no extra labels added.
/agent implement
/agent implement
/agent implement
Verification (2026-09-24): #1210 stays open.
origin/mainat54c4868estill has only sevenFeeSources; catalog events do not feed/protocol/fees. No newer issue replaces this ingest: #1213 is the home/docs epic; #1237/#1239 fix on-chain no-op charging; #1269 updates fee uniqueness.Remaining:
sku_unlock/settings_feefrom positive CMM UST1 invoices (launcher createsku_count × 50e6; token EnableFeature invoice; one flat UpdateSettings invoice), with dedupe, fail-closed parsing, and verified emitter/origin (#594, #1229)./fees+/daily, DeFiLlama, UI, and tests; preserve O(1)/60s, omitted-unconfigured, idle"0", and unpricednull. Exclude non-invoices; keep pair_creation #1209 and cohort #1211 separate.make verify-issue-1210and paid LocalTerra row evidence.Spec:
docs/qa/issue-1210/README.md; invariants L1210-1–L1210-8 inskills/AGENTS_INDEXER_FEE_LEDGER_HOME.md. Related: #1209 #1211 #1213 #1269 #594 #595 #597 #1229 #1237 #1239.