design(indexer): fee-ledger home is #1209/#1210/#1211 with marketing trail #1213
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#1213
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
Home for fee-ledger ingest/API work is this repo’s indexer, not the marketing repository. This issue is the tracker epic + remaining trail. It does not implement new
FeeSourceparsers.Three implement tickets already exist and already hold the migrated engineering bodies:
GET /api/v1/protocol/fees(no instantiate-gas double-count)Marketing #1 / #4 / #5 are already closed as tracker dupes with comments that name the replacements above. Do not reopen them for implement work. Do not relabel #1209 / #1210 / #1211 in this ticket.
This ticket’s remaining job: make strategy/docs and cross-issue links use the dex issue numbers, so agents and humans cannot treat marketing as a second fee authority.
Related, not this ticket:
Bundle (do not split into a fourth ingest MR):
protocol_fee_eventsis the governed ledger; marketing stores pointers and labeled snapshots only.Current codebase
Indexer is seven
FeeSources; pair creation / invoices / cohort are missingindexer/src/indexer/protocol_fees.rsFeeSource::ALLis length 7:swap_amm,book_take,limit_place,wrap,unwrap,ust1_mint,ust1_redeem. Wrap/UST1 require pinned contracts and explicit positive fee attrs (fail closed). Rows land inprotocol_fee_eventswithUNIQUE (tx_hash, source, ordinal)andON CONFLICT DO NOTHING.fee_usdis stamped at ingest.indexer/src/indexer/parser.rsingest_protocol_feenever receives a wallet. There is nocreate_pair/creation_fee_ulunaparser, no community-invoice fee parser, and noby_cohortAPI.GET stays O(1) rollup / 60s cache — no live
SUM:GET /api/v1/protocol/fees?window=24h|7d|30d—indexer/src/api/protocol_fees.rsFrontend
ProtocolFeeSourceKeyandProtocolFeeStats.tsxSOURCE_LABEL/SOURCE_ORDERmatch those seven keys only.CHECK constraints in
indexer/migrations/20260821120000_protocol_fees.sql(later widened for UST1 window) still have nopair_creation/sku_unlock/settings_fee.Audit
docs/audits/factory-treasury-bank-send.mditem 11 still states the indexer has no pair-creation fee parser (pairs are discovered via instantiate / registry, which is not treasury census).On-chain fees already exist (ingest is the gap)
Pair creation — factory
execute_create_pair:config.pair_creation_fee_uluna(default100_000_000uluna)BankMsg::Sendtoconfig.treasury; wasmaction=create_pair+creation_fee_uluna. Instantiate gas is a Cosmos tx fee, not treasury revenue.reply_instantiate_pairis registration, not a fee. Overpay refunds to sender.SKU / settings invoices — community-tax token + launcher (
INVOICE_UST1 = 50_000_000). Catalog ingest already exists inindexer/src/indexer/community_tokens.rs(sku_unlock/settings_fee/createkinds intocommunity_token_events). That table answers “which token unlocked which SKU,” not “treasury USD on/protocol/fees.” Create-timeN × 50 UST1lives on launchercreate_token, not oncreate_token_ready.Cohort split —
protocol_fee_eventshas no actor column.traderstier_id SMALLINT NOT NULL DEFAULT 0plusfee_discount_registered. Unregistered retail is not Tier 0 MM. Livetradersis current state; a naive join would mis-label retail as MM and rewrite history on deregister.traders.total_fees_paidis mixed-unit and must not drive/protocolheadlines.Marketing repo is research/governance, not a fee service
PlasticDigits/cl8y-marketingREADME: evidence-led marketing; durable net realized protocol fees as the objective. Structure isresearch/,strategy/,content/. Issue bodies for the closed trackers name:strategy/fee-growth-model.mdstrategy/90-day-plan.mdstrategy/technical-architecture.mdstrategy/operating-system.mdresearch/snapshots/2026-09-03-protocol-fees.jsonresearch/source-register.mdThose files are the pointer surface. They must not grow a parallel fee indexer, notebook-as-truth, or implement-queue for wasm parsers.
Trail status (already done vs leftover)
Done
Leftover (this issue)
Why the work is needed
Phase 0 ledgers include pair creation, project-team invoices, and (later) a privacy-safe retail/MM split. The public API cannot report those yet. That ingest work belongs on #1209 / #1210 / #1211.
Without a single home map, two failure modes stay open:
protocol_fee_events. Campaign decisions then diverge from/protocol.Pointer retarget is cheap and prevents both. It is not optional “docs later”: it is the trail the three ingest tickets assumed when they were copied here.
Constraints and guardrails
FeeSource, migration CHECK, API field, or UI label here. That is #1209 then #1210 then #1211 (stack order: pair_creation → invoices → cohort). #1211 also depends on #1202 remaining on hold — do not expand #1202.community_token_events≠ protocol fees.reply_instantiate_pair, buy/sell tax, AutoLP, migrate-adopt, or pay-with-any-token swap legs as community invoices.campaign_idon fee rows. Split is aggregate (retail / MM / unjoined) as-of height. Do not treattraders.tier_id = 0as MM unlessfee_discount_registered(or equivalent as-of-height membership) is true.contract_addresswithout underscore is ignored (#285).$0). Idle configured →"0". Unpriced →null./protocol/feeson any other repo.Relevant files
This repo (implement ingest only via child issues)
indexer/src/indexer/protocol_fees.rsFeeSourceenum / wrap-window patternindexer/src/indexer/parser.rsingest_protocol_feewiring; no actor todayindexer/src/indexer/community_tokens.rsindexer/src/db/queries/protocol_fees.rsindexer/migrations/20260821120000_protocol_fees.sqlindexer/migrations/20260824120000_ust1_window_protocol_fees.sqlindexer/src/api/protocol_fees.rs,protocol_fee_series.rs,api/defillama.rsindexer/src/indexer/trader_tracker.rsfrontend-dapp/src/types/index.tsProtocolFeeSourceKeyfrontend-dapp/src/components/protocol/ProtocolFeeStats.tsxsmartcontracts/contracts/factory/src/contract.rscreation_fee_uluna(read-only for ingest)smartcontracts/contracts/community-tax-token/src/invoice.rsdocs/audits/factory-treasury-bank-send.mddocs/indexer-invariants.mdskills/AGENTS_INDEXER_UST1_WINDOW_FEES.md,AGENTS_INDEXER_WRAP_FEE_INGEST.mdMarketing repo (pointers / snapshots only)
strategy/fee-growth-model.mdstrategy/90-day-plan.mdstrategy/technical-architecture.mdstrategy/operating-system.mdstrategy/phase-0-status.mdresearch/snapshots/research/source-register.mdRecommended direction
cl8y-marketing#1,#4,#5, and prose like “open on marketing” / “implement here” instrategy/andresearch/. Replace with the table in the Summary. Keep historical snapshot JSON bytes stable unless a comment/header records “pair creation not in this extract; tracked on dex #1209.”Related ingest siblings: #1209 #1210 #1211is enough. No chat logs.Acceptance criteria
strategy/+research/markdown that referenced marketing #1 / #4 / #5 for implement now references the dex issue numbers in the Summary table. Historical “closed tracker” mentions may remain if they also name the dex replacement.Test plan (functional paths)
strategy/research/forcl8y-marketing/issues/1(and#1in fee-ledger context)fj issue viewmarketing 1 / 4 / 5pair_creation/protocol/feesingeststrategy/technical-architecture.md(or equivalent authority doc)Docs-only change: no indexer/frontend test suite required on this epic. Child ingest tickets keep
make verify-issue-586/make verify-issue-614plus their ownverify-issue-*bundles.Test plan (attack, hack, and abuse)
FeeSourceparsers insidePlasticDigits/cl8y-marketing/protocol/feesafter ingest shipsreply_instantiate_pairas pair_creationpair_creationorswap_ammenable_featuretraders.tier_id = 0⇒ MM/protocolcreate_pair/invoicefrom unpinned contractsconfig × countor50e6 × SKU flagswithout a paid tx$1UST1 / vFDUSD as USD$0(tx_hash, source, ordinal)uniqueness on childrenVerification criteria
code/cl8y-dex-terraclassic, three closed marketing trackers with replacement URLs.git grep -n 'cl8y-marketing#1\|issues/1' strategy research(and #4 / #5) is empty or every hit also names the dex replacement in the same paragraph.make verify-issue-586andmake verify-issue-614still green (no accidental ingest change in the pointer PR). This epic’s PR should be docs-only on marketing (plus optional issue-body related-link edits).Out of scope
pair_creation_fee_ulunaorINVOICE_UST1./route/solve.cl8y-agent-control: queued
implementjob0232cde9-375d-44f6-aeab-b503c12179fe(not executed; no Hetzner VM).Trail PRs (do not merge protected main from the agent):
Related ingest siblings: #1209 #1210 #1211. Verify:
make verify-issue-1213.Verified on
docs/1213-fee-ledger-home(updates existing PR, no new ingest):make verify-issue-1213— 4/4 PASS (before and after the pointer-map follow-up).FeeSource/ CHECK /pair_creation/sku_unlock/settings_feeon this epic.strategy/fee-ledger-home.md(companion PlasticDigits/cl8y-marketing#7).Do not merge protected
mainfrom this agent (Woodpecker + autoland).