feat: emit fee_amount + UST1 token on deposit/withdraw wasm (DEX #614 ingest) #33
Labels
No labels
enhancement
governance
QA
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/ust1-window#33
Loading…
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
Emit an explicit treasury
fee_amount(raw UST1) plus token identity on deposit and withdraw wasm events so the DEX indexer can census CMM window fees on/protocol.DEX #614 / !444 already pins
UST1_WINDOW_ADDRESSand fail-closes unless those attrs exist. Columbus-5 window 11566 (terra1zxwpzpzpleatqn39r00grau4yt29sld8pw78s7ktvjafnj5nsaxq0h3rh2) does not emit them today, so live mint/redeem stays dropped.Related: DEX #586 (wrap-mapper already emits
fee_amount), #506 (/ust1UI), wrap-mapper ingest #613 (different contract — do not fold).Current codebase
contracts/ust1-window/src/contract.rsdeposit()action=deposit,ust1_out(net after fee),fee_total_bps,fee_chain_tax_bps,fee_cmm_protocol_bps,vfdusd_to_treasury(full vFDUSD input). Nofee_amount.withdraw()action=withdraw,vfdusd_out(net after fee), samefee_*_bps. Nofee_amount. No token identity key.applyFeeUst1). Deposit: less UST1 minted. Withdraw: fee applied to gross UST1 before rate division.effective_swapfee_bpsonly. Not a post-hoc treasury amount.parse_ust1_window_feesrequiresfee_amount+fee_asset/fee_denom/native_denom/denom/ust1_tokenon the reserved_contract_addresssegment. Neverust1_out × fee_total_bps/vfdusd_to_treasury × fee_cmm_protocol_bps.Why bps attrs are not enough: deposit
ust1_outis post-fee; reconstructing gross needs the oracle rate (not in wasm). Withdraw gross UST1 is the CW20send.amount, not on the window event. Splitfee_chain_tax_bps/fee_cmm_protocol_bpsare attribution, not transfers. Indexer must not invent the fee.Why this is needed
fee_amount./protocolundercounts until wasm names the amount.Constraints / guardrails
action(deposit/withdraw),ust1_out,vfdusd_out, orfee_*_bps._contract_addressCosmWasm already adds):fee_amount— positive raw integer of UST1 withheld (deposit: pre-fee UST1 −ust1_out; withdraw: gross UST1 − after-fee UST1). Zero-fee txs may omit or emit0(indexer already skips non-positive).fee_asset— UST1 CW20 bech32 (configust1_token). Prefer this name so DEXwindow_fee_tokenmatches wrap-mapper. Optional aliasust1_tokenis also accepted.fee_amount(DEX prices hub UST1; vFDUSD/FDUSD CEX is forbidden — PFee-7 / P550-11).fee_bps, chain-tax / CMM split, treasury forward, pause, oracle freshness, rolling limits,min_vfdusd_out).fee_usdat ingest from hub UST1.fee_bps; DEX parser;/mintfaucet; wrap-mapper (#613).Recommended direction
deposit()after INV-SWAP-001: computefee_amount = before_fee_ust1 - ust1_out(already implicit inapplyFeeUst1)..add_attribute("fee_amount", fee_amount)+.add_attribute("fee_asset", cfg.ust1_token).withdraw()after INV-SWAP-002:fee_amount = gross_ust1 - after_fee_ust1. Same two attrs.fee_amount+fee_assetmatching config; zero-fee (fee_bps=0) does not invent a fake amount.docs/DEPLOYMENT.mdand notify DEX ops so Coolify indexer pin stays the same address (migrate, do not instantiate a second window).Acceptance criteria
fee_amount(raw UST1 withheld) andfee_asset(UST1 CW20). Existing 11566 attrs still present.min_vfdusd_out/vfdusd_outare not the fee.DEPLOYMENT.md/ event table) listfee_amount+fee_assetfor both actions.protocol_fee_eventsust1_mint/ust1_redeemwhen indexerUST1_WINDOW_ADDRESSis pinned (closes remaining #614 live-tx criterion).Test plan
fee_bps=100fee_amount= 1% of pre-fee UST1;ust1_outstill netfee_bps=100fee_amount= 1% of gross UST1 sent;vfdusd_outstill netfee_bps=0fee_amount(omit or0)fee_assetis UST1, never vFDUSDmentioned in issue cl8y-dex-terraclassic#614
mentioned in commit
2ba41277e5mentioned in merge request !47
mentioned in merge request !48
Implementation is in !48 (
feat/issue-33-window-fee-events).Done in-repo:
fee_amount(raw UST1 withheld) +fee_asset(UST1 CW20). Existing attrs kept.docs/DEPLOYMENT.md; skillskills/window-fee-amount-events.Not done (ops / last AC):
terra1zxwp…address (do not instantiate a second window).protocol_fee_eventsust1_mint/ust1_redeem.!48 merge review (no automerge / not waiting on CI)
Merge conflicts: none.
feat/issue-33-window-fee-events(2ba41277) is one commit ahead ofmain(de0e8f01);git merge-treeis clean. GitLabdetailed_merge_status=mergeable.Sanity check (local, not CI):
cargo test -p ust1-common --lib inv_— 6 passed (INV-SWAP-001/002 +inv_fee_event_001_withheld_ust1_vectors)cargo test -p ust1-window --lib inv_fee_event_001— 3 passed (deposit 1% pre-fee UST1, withdraw 1% gross UST1,fee_bps=0→0,fee_assetis UST1)cargo test -p ust1-integration-tests --lib inv_fee_event_001— 1 passedAcceptance criteria vs !48:
fee_amount(raw UST1 withheld) +fee_asset(UST1 CW20). Existing 11566 attrs still asserted (action,ust1_out,fee_*_bps,vfdusd_to_treasury).min_vfdusd_out/vfdusd_outare not the fee.docs/DEPLOYMENT.mdlistsfee_amount+fee_assetfor both actions.terra1zxwp…address; one captured deposit + withdraw incrementing DEXprotocol_fee_eventsust1_mint/ust1_redeem. This issue stays open as the post-merge tracker — no duplicate issue created.Problems / gaps:
ci_quota_exceeded(rust+secret_detectionnever started). Not a code defect; merge proceeds without waiting on CI.Merging !48 now. Do not close this issue until the last AC is done.
mentioned in commit
e48311ff3d!48 is merged to
main(e48311f). Localmainmatchesorigin/main. Removed leftoverfeat/issue-33-window-fee-eventsworktree/branch and the empty GitLab issue branch33-feat-emit-fee-amount-…(no unique commits, no open MR). No stashes. Issue #30 left untouched.This issue remains the post-merge tracker for columbus-5 store+migrate of
terra1zxwp…+ live DEXprotocol_fee_eventscapture. No duplicate issue created.mentioned in issue cl8y-dex-terraclassic#616
Columbus-5 store + migrate done (same address)
Live window is now 11618 on the same
terra1zxwp…— do not instantiate a second window. DEXUST1_WINDOW_ADDRESSpin stays the address.F4D79240E8009740C63F3342A2AA655CE7015579FC376B765AC3821EF823C60A— height30085280,code=0, sendercl8y2_admin(terra1xsecn…) → code_id 11618009BD391E27AE8A6A7FCBA94443E2A257875A19603C51FAB1CC6C6B91E8E747D— height30085285,code=0, gas 276360/380379contract_infocode_id=11618, admin stillterra1xsecn4snv94ezcez0z3vq8an9j4h4kxxcydp8l, labelust1-windowfee_bps=100, per-tx1000000000, 24h10000000000,paused=false, treasury / oracle / tokens unchangedEmpty
MigrateMsg{}. No new instantiate.Still open (last AC): one captured deposit + one withdraw so Coolify
protocol_fee_eventsust1_mint/ust1_redeemincrement (DEX #614 live-tx criterion; ops #616). Record 11618 indocs/DEPLOYMENT.mdwhen that lands. Issue stays open.Not closing — last AC is still live DEX ingest
In-repo + columbus-5 store/migrate are done (LCD-confirmed just now):
terra1zxwp…h3rh2terra1xsecn…, labelust1-windowfee_bps=100,paused=false, UST1/vFDUSD tokens unchanged39D7DCCA…0CE509e48311f) —fee_amount+fee_asseton deposit/withdrawLast acceptance item is not done:
GET /api/v1/protocol/feesisust1_window_configured: false(noUST1_WINDOW_ADDRESSon the indexer service; Vite pin is not enough).ust1_mint/ust1_redeemrows yet.docs/DEPLOYMENT.mdonmainstill says live 11566 and the checklist box for recording 11618 is unchecked.After DEX sets
UST1_WINDOW_ADDRESS=terra1zxwpzpzpleatqn39r00grau4yt29sld8pw78s7ktvjafnj5nsaxq0h3rh2and one deposit + one withdraw incrementprotocol_fee_events, record 11618 inDEPLOYMENT.mdand close this + remaining DEX #614 live-tx line.