fix(swap): USTC→USTR wrap+2hop gas fails on Swap #1264
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#1264
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
Retail Swap of native USTC (
uusd) → USTR ondex.cl8y.com/is reporting a gas problem (failed or unusable fee). This is the wrap + 2-hop hub path, not a direct pair and not the reverse unwrap.Bundle into one issue (do not split OOG vs hint vs wallet rewrite vs wrap-fee netting):
/with Route chrome showing wrap + hub hops.gas_used ≥ gas_wanted/ humanized out-of-gas toast), (B) wallet auto-gas rewrite (Station/WalletConnect thousands of LUNC while dApp Fee is tens of LUNC), or (C) Network-fee hint vs signedFeemismatch with a succeeding tx.WRAP_ROUTER_COMBO_OVERHEAD_GAS(or the wrap+N-hop combined envelope) from measuredgas_used, or align hint/submit so the wallet honors the dAppFee. Do not turn hybrid on for native wrap+multihop (H596-7). Do not pay gas inuusd.Related, not duplicates (keyword overlap on “gas” / USTR is not enough):
WRAP_ROUTER_COMBO_OVERHEAD_GAS400k. Different native (uluna), and the follow-up bake succeeded for USTC → USTR.unwrap_output+ InstantWithdraw of taxed USTC). #599 explicitly recorded USTC → USTR as succeeding on that bake.gas_usedis still unmeasured. Do not reopen that research ticket; this is a concrete USTC → USTR execute failure.getGasLimitForTxinventory. Background only.Current codebase
Native USTC is
uusd; wrap CW20 is cUSTC. USTR is CW20. There is no factory pair USTR/cUSTC. Hub graph (unchanged from #599):Client BFS therefore routes USTC → USTR as
wrap_deposit(uusd → cUSTC) then cUSTC → UST1 → USTR (2 pool-only hops) in one multi-msg tx.SwapPagenative wrap branch →executeNativeSwap. Comment: “Pool-only hops from client BFSfindRoute— never copy hybrid / book_input (#587 / #599).”wrap_deposit+ CW20send→ routerexecute_swap_operations(unwrap_outputfalse). CW20 send amount is post–wrap-fee mint (netCw20AfterNativeWrap).totalGasLimitForExecuteMsgs:WRAP_GAS_LIMIT400,000 +gasLimitForRouterExecuteSwapOperations(2) 1,910,000 +WRAP_ROUTER_COMBO_OVERHEAD_GAS400,000 = 2,710,000 (~76.76 LUNC ateffectiveGasPriceUluna()28.325). Combo overhead applies only when wrap and router send share one tx and hops ≥ 2./simulateon the execute path (skills/AGENTS_TERRACLASSIC_GAS.md). ExplicitFeeinulunaonly. Station / WalletConnect may replace that envelope.Do not treat #1222 Stay as “gas is fine.” That ADR forbade constant retune from the research MR; a new measured OOG or 4k-LUNC wallet rewrite on this path is in-scope here.
Repro (Given / When / Then)
Given a columbus-5 wallet with native USTC, enough LUNC for a tens-of-LUNC network fee, and USTR as the ask on Swap
/When the trader quotes and submits USTC → USTR (Route shows wrap + UST1 hub hops; one SWAP)
Then the tx is
code = 0,gas_used < gas_wanted, the Swap Network-fee hint is the same class as the signedFee(tens of LUNC at 28.325, not thousands), and the UI does not show the humanized out-of-gas toast.Expected vs actual
gas_usedFeeor is documented as rewrite with a working manual pathAcceptance criteria
/: one USTC → USTR Swap. Record hash,gas_wanted,gas_used, feeuluna, Route hops, and whether the wallet rewrote the fee. Classify A / B / C above.WRAP_ROUTER_COMBO_OVERHEAD_GASor documented successor) sogas_wanted> measuredgas_usedwith the same margin discipline as #587 (not a silentBASE_GAS_LIMITfallthrough; not a blanket 15M). Inventory fixture + unit test for wrap+2hop = new ceiling.estimateSwapNetworkFee/preferNoSetFee/ Station amino so the confirm screen matches the dApp envelope, or document the wallet class + working manual gas with UI copy. Mainnet fee-guard (#429) stays off.totalGasLimitForExecuteMsgsmsgs as execute (wrap + router send). No hint that shows ~200 LUNC while the wallet sees ~4k, or the reverse.uusd) → USTR: one submit, no OOG toast,gas_used < gas_wanted.skills/AGENTS_TERRACLASSIC_GAS.md/ frontend gas section with the measured hash and the named constant. Do not spawn a second census ADR.Test plan
totalGasLimitForExecuteMsgsfixture stays 2,710,000 until AC2 changes it; after a raise, the fixture equals the new named sum (400k wrap + 1,910,000 hops + combo).UNWRAP_ROUTER_COMBO_OVERHEAD_GAS, not the wrap combo.hybrid/book_inputon USTC → USTR ops.BASE_GAS_LIMIT(existing #587 throw path).Attack / abuse tests
gas_used ≈ gas_wanted(the #353 1,810,000-exact failure mode).uluna. A 0-USTC-after-swap wallet with remaining LUNC must still be able to pay network fee; do not suggestuusdfees.send.msgmust fail closed on gas estimation, not under-grant.Verification criteria
code = 0andgas_used < gas_wantedfor USTC → USTR.makeunit/inventory targets that coverterraGas.tswrap combo + native swap tests pass.MIN_GAS_PRICE_ULUNA, or mainnet fee-guard.Out of scope
SetDiscountRegistryAll(#123), indexer pair-creation protocol fees (#1209).GET /route/solvehybrid.First-pass model recommendation
Recommendation: grok-high
Rationale: Founder-required surface (wasm execute envelope, wallet
Fee/ Station rewrite, wrap mapper + router). Not a known local one-file edit: expected touch isfrontend-dapp/src/utils/constants.ts,frontend-dapp/src/services/terraclassic/terraGas.ts, possiblyswapNetworkFee.ts/router.ts/ Swap native path, plus inventory fixtures and the gas playbook. Columbus-5 wrap+2hop is still unmeasured (ADR 0004); first pass must classify OOG vs wallet rewrite before retuning. Comparable closed work (#587 / #599 / #679) spanned hop math, combo overhead, and wallet behavior — not the three-file Composer bar. Verify with wrap+2hop inventory tests plus a recorded USTC → USTRgas_usedvsgas_wanted.cl8y-agent-control: queued
design_authorjoba888b0ce-900f-4421-b0e1-2024c469b707(not executed; no Hetzner VM)./agent implement
/agent implement
PR #1281 merged (hop-0-only hybrid). This ticket is not closed.
Shipped with #1281: wrap+2hop USTC→USTR stays pool-only (H596-7) at the existing 2,710,000 envelope. Combo gas was not raised. Inventory fixture
wrap_plus_send_2hop_ustc+ wrap-swap E10 docs/tests.Still open: AC1 columbus-5 execute (hash /
gas_wanted/gas_used/ fee / wallet rewrite A/B/C).VERIFY_ISSUE_1264_CHAIN=1LocalTerra wrap-swap E10 not run here. Do not retuneWRAP_ROUTER_COMBO_OVERHEAD_GASwithout that measurement.Implementation is in #1293 (
issue/1264-ustc-wrap-gas).Shipped: 2.71M wrap+2hop envelope (no combo raise), pool-only hops (H596-7 / H1280-6), G1264-4 LUNC gas-gate for USTC Max/submit, docs/skills G1264-1–G1264-8,
make verify-issue-1264.Still open: AC1 columbus-5
gas_used(no funded wallet in operator KV). LocalTerra E10 showed Network fee ~76.76 LUNC then wasmSwap hop produced zero outputon stale gem hops, not OOG. Do not close until AC1.Merged as PR #1293. Origin branch had been force-updated to main (empty PR); restored commit
86b4e690from the local worktree then merged.Product: USTC wrap gas-gate uses bank LUNC; wrap+2hop envelope stays 2.71M. Do not close: AC1 columbus-5
gas_usedis still unmeasured. AC2/AC3 blocked on AC1. LocalTerra E10 last noted empty hop, not OOG.Leftover ops: #1300
Post-merge sanity after #1297 landed on top of this fix: G1264-4 is intact on origin/main.
SwapPagestill usesisNativeUlunaDenom(fromToken)(notisNativeDenom) for Max / Network-fee, and the gas gate readsulunaBalanceQuerywhen pay is USTC. No restore of USTC-as-LUNC fee gating. AC1 columbus-5gas_usedremains unmeasured.AC1 still unmeasured. Keep the 2.71M USTC→USTR wrap+2hop envelope until columbus-5
gas_usedis recorded.Inbox card filed (phone): small native USTC→USTR on dex.cl8y.com; paste the tx hash in the card Complete note.
Do not close this issue from leftover ops.
AC1 measured. Envelope stays 2,710,000. Do not raise
WRAP_ROUTER_COMBO_OVERHEAD_GAS.columbus-5 wrap+2hop USTC→USTR (operator inbox card):
code=0gas_wanted=2710000gas_used=2630228(margin 79,772)VERIFY1264_COLUMBUS_TX+make verify-issue-1264PASS (5/5)Residual copy (not this ticket): Swap still shows “This size moves the pool” / confirm 6.42% when wrap+tax fees dominate hop spread 0%. That is the #678 5% high-impact threshold, not an OOG.
Closing.