feat(#507): fee-aware wrap UX and cLUNC/cUSTC mainnet enablement #1044
No reviewers
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!1044
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/507-mainnet-wrap-ux"
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
fee_bpsinto Swap/Pool simulate + execute nets (netCw20AfterNativeWrap/netAfterWrapMapperFee) so previews and CW20 send amounts match on-chain mint/unwrap skims (no false 1:1).VITE_LUNC_C_*); prefer registry symbols over on-chainLUNC-Clabels.wrap-enablement.env.example,AGENTS_MAINNET_WRAP_ENABLEMENT.md) without silently adding wrap to soft-launch defaults (SL5).Closes #507 for in-repo work. Ops still must set Coolify env + rebuild + mainnet smoke txs.
Test plan
make lint-frontend(warnings only, pre-existing)simulateNativeSwapfee_bps, tokenRegistry cLUNC/cUSTC, pool counterpart fee, SwapPage SEC-A02make test-mainnet-soft-launch-defaultsVITE_*fromdeployments/mainnet-soft-launch/wrap-enablement.env.exampleand rebuildfee_bps=100; pause/rate-limit CTAse2e/wrap-swap.spec.tsafter redeployIssue AC checkoff
Closes #507
marked this merge request as ready
mentioned in issue #507
RECOMMEND: FIX
Thorough review of !1044 (
3681e8b,feat/507-mainnet-wrap-ux→main) against #507, including security/DeFi attack surface, gap analysis, and verification of fee math vs router invariants. Scope is client/docs/tokenlist only — nosmartcontracts/changes. No critical fund-drain, prompt-injection, or DB-leak findings; do not merge until Medium items below are addressed (or explicitly accepted as post-merge enablement gates with Coolify still dark).Issue #507 acceptance criteria
VITE_*on columbus-5test-mainnet-soft-launch-defaultsasserts commented-only wrap keysIn-repo #507 work is largely delivered; closing the issue still requires ops Coolify + smoke. Treat “Closes #507” as in-repo complete only if that matches project practice — otherwise keep issue open until ops ACs land.
Security / DeFi audit
Smart contracts / oracle / DB / indexer
minimum_receiveremain chain-enforced.Config.fee_bps, not an external price feed.route_slippage.rsonly adds cLUNC/cUSTC symbol aliases — no auth, query, or PII surface change. No DB leak vector in this MR.Attack table from #507
fee_bps=100minimum_receiveonunwrap_outputFindings to fix
M1 — Fail-open
fee_bps = 0when wrap-mapper config is unavailablequeryWrapMapperFeeBps/wrapMapperFeeBps ?? 0+wrapUnwrapFeeNote(..., 0)→ “Wrap (1:1)” and optimistic sim.frontend-dapp/src/services/terraclassic/wrapMapper.ts(queryWrapMapperConfigcatch → null; fee helper → 0),SwapPage.tsx(~382),PoolPagefee default.Fix: treat unknown fee as blocking for wrap/native-wrap paths (disable submit + “Wrap fee unavailable”); never show 1:1 unless config successfully returned
fee_bps === 0. Includefee_bps/ config success in sim query key.M2 — Pause / rate-limit queries fail-open on LCD error
queryPausedState/checkRateLimitExceededcatch →false.Fix: if wrap mapper is configured and safety queries fail, disable wrap submit (same gate as M1).
M3 — No runtime treasury cross-check
Build-time
VITE_TREASURY_ADDRESSis trusted forwrap_deposit. Wrong Coolify value misroutes user funds. Docs warn; UI does not.Fix: after config load, compare
config.treasurytoTREASURY_CONTRACT_ADDRESS; banner + block wrap on mismatch.L1 — E2E E4 still weakly asserts
/1:1/(wrap-swap.spec.ts) withtoBeGreaterThanOrEqual(0)— no regression guard for fee note.L2 — Multihop native routes only say “wrap/unwrap your tokens” (no fee %).
L3 —
amountForTargetNetAfterWrapMapperFeereturnstargetNetwhenbps >= 10000(edge; unlikely on-chain).L4 — Trade market panel still has no native wrap path (
isWrapOrUnwrap: false) — document as intentional out-of-scope for #507.Fee math correctness (when config loads)
Verified aligned with router
net_after_wrap_mapper_unwrap_fee:net = A − floor(A × fee_bps / 10_000)netCw20AfterNativeWrap)minimum_receiveuses post-unwrap netGap analysis (non-security)
Testing performed in review
wrapMapper,router,poolProvideCounterpart,tokenRegistry— 54 passedmake test-mainnet-soft-launch-defaults— ALL PASSCI
Pipeline 2743565178 failed on
cargo-audit-indexer(event-listener,scc,spinadvisories) — unrelated to this diff, but may block merge under green-pipeline policy. Frontend jobs were skipped after security stage failure.Recommended before merge
fee_bps=100; assert submit disabled on config null; drop useless/1:1/soft assert.cargo-audit-indexerfor pipeline green.docs/qa-templates/wrap-unwrap-test-pass.mdand record smoke txs.Bottom line: Strong in-repo progress on fee-honest wrap UX and SL5-safe enablement docs, but optimistic fee/safety defaults under LCD failure are inconsistent with #507’s attack table and should be fixed before production wrap enablement.
added 1 commit
a2f57478- fix(#507): fail-closed wrap config, pause, and treasury gatesCompare with previous version
mentioned in commit
8fa03d6f06mentioned in issue #506
mentioned in issue #508