fix(swap): CL8Y to UST1 hits the gas-estimate under-run #1328

Open
opened 2026-09-23 11:05:55 +00:00 by PlasticDigits · 1 comment

Summary

Retail Swap of CL8Y → UST1 on dex.cl8y.com fails with the dApp out-of-gas toast: the transaction needed more gas than estimated. That string is the humanized under-estimate in frontend-dapp/src/utils/humanizeTerraTxError.ts. The dApp does not LCD-simulate execute gas; the envelope is the per-message fallback in frontend-dapp/src/services/terraclassic/terraClassicFeeEstimate.ts.

Expected / actual

  • Expected: CL8Y → UST1 Swap broadcasts with gas_wanted above measured gas_used and completes without that toast.
  • Actual: The swap is rejected because gas used exceeded the estimate.

Not duplicates

Closed gas tickets are other pairs or other message shapes. Keyword overlap on “gas” is not this bug.

Issue Why it is not this ticket
#1264 Native USTC → USTR wrap + 2-hop. Closed.
#587 / #599 LUNC ↔ USTR and USTR → USTC wrap/unwrap. Closed.
#1222 Closed research census of the gas envelope. This is a new CL8Y → UST1 repro.
#384 Fee-discount register/deregister. Closed.

Given / When / Then

Given a columbus-5 Swap of CL8Y to UST1 on / with the current fee envelope,

When the wallet signs the dApp Fee,

Then gas_used stays below gas_wanted, the humanized under-estimate toast does not appear, and the swap completes.

Acceptance criteria

  • Reproduce CL8Y → UST1 on columbus-5 and record gas_wanted vs gas_used and the route shape (direct pair vs hybrid hops).
  • Raise only the envelope for that shape from the measurement. Do not pay gas in a stablecoin and do not turn on a hybrid mode this path is documented to keep off.
  • A focused test locks the new limit above the measured use.

Test plan

  • Unit test the fee helper for the CL8Y → UST1 message shape.
  • Manual or scripted columbus-5 swap that asserts the under-estimate toast is absent.

Attack / abuse

  • A crafted quote must not lower gas_wanted below the measured floor for this shape.
  • The fix must not accept a user-supplied gas limit from the page query string.

Verification

  • One successful CL8Y → UST1 swap on columbus-5 with gas_used < gas_wanted and no under-estimate toast.
  • Neighbor routes (the closed USTC/USTR cases) stay on their existing limits.

First-pass model recommendation

Recommendation: grok-high

The failure can be the static envelope, a hybrid hop, or the wallet rewriting Fee. That is wallet and gas-estimate scope, not a single known local edit.

## Summary Retail Swap of **CL8Y → UST1** on `dex.cl8y.com` fails with the dApp out-of-gas toast: the transaction needed more gas than estimated. That string is the humanized under-estimate in `frontend-dapp/src/utils/humanizeTerraTxError.ts`. The dApp does not LCD-simulate execute gas; the envelope is the per-message fallback in `frontend-dapp/src/services/terraclassic/terraClassicFeeEstimate.ts`. ## Expected / actual - **Expected:** CL8Y → UST1 Swap broadcasts with `gas_wanted` above measured `gas_used` and completes without that toast. - **Actual:** The swap is rejected because gas used exceeded the estimate. ## Not duplicates Closed gas tickets are other pairs or other message shapes. Keyword overlap on “gas” is not this bug. | Issue | Why it is not this ticket | | --- | --- | | [#1264](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1264) | Native USTC → USTR wrap + 2-hop. Closed. | | [#587](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/587) / [#599](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/599) | LUNC ↔ USTR and USTR → USTC wrap/unwrap. Closed. | | [#1222](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1222) | Closed research census of the gas envelope. This is a new CL8Y → UST1 repro. | | [#384](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/384) | Fee-discount register/deregister. Closed. | ## Given / When / Then **Given** a columbus-5 Swap of CL8Y to UST1 on `/` with the current fee envelope, **When** the wallet signs the dApp `Fee`, **Then** `gas_used` stays below `gas_wanted`, the humanized under-estimate toast does not appear, and the swap completes. ## Acceptance criteria - Reproduce CL8Y → UST1 on columbus-5 and record `gas_wanted` vs `gas_used` and the route shape (direct pair vs hybrid hops). - Raise only the envelope for that shape from the measurement. Do not pay gas in a stablecoin and do not turn on a hybrid mode this path is documented to keep off. - A focused test locks the new limit above the measured use. ## Test plan - Unit test the fee helper for the CL8Y → UST1 message shape. - Manual or scripted columbus-5 swap that asserts the under-estimate toast is absent. ## Attack / abuse - A crafted quote must not lower `gas_wanted` below the measured floor for this shape. - The fix must not accept a user-supplied gas limit from the page query string. ## Verification - One successful CL8Y → UST1 swap on columbus-5 with `gas_used < gas_wanted` and no under-estimate toast. - Neighbor routes (the closed USTC/USTR cases) stay on their existing limits. ## First-pass model recommendation Recommendation: grok-high The failure can be the static envelope, a hybrid hop, or the wallet rewriting `Fee`. That is wallet and gas-estimate scope, not a single known local edit.
Author
Owner

PR #1332 is merged. make verify-issue-1328 passed: 95 tests across four files. This run skipped the optional live simulation because no funded simulation address was configured; PR #1332 records the Columbus-5 simulation evidence. The merged change documents invariants G1328-1–G1328-7 in ADR 0013 and skills/AGENTS_TERRACLASSIC_GAS.md, with links from the frontend and testing docs.

Remaining: complete the queued cl8y-pm inbox card, “Verify CL8Y to UST1 gas on Columbus-5” (49becf11-4b53-4441-9f01-07b99852f78e): sign one forward Columbus-5 swap, record route, tx hash, gas_wanted and gas_used, and confirm gas_used < gas_wanted with no under-estimate toast. Keep #1328 open until that operator check is complete.

Related but distinct: #1222 gas-envelope census; #1264 USTC→USTR wrap+2-hop gas; newer #1329 hybrid limit-order gas and #1330 route visibility/selection do not track this wallet check.

PR [#1332](https://git.cl8y.com/code/cl8y-dex-terraclassic/pulls/1332) is merged. `make verify-issue-1328` passed: 95 tests across four files. This run skipped the optional live simulation because no funded simulation address was configured; PR #1332 records the Columbus-5 simulation evidence. The merged change documents invariants G1328-1–G1328-7 in ADR 0013 and `skills/AGENTS_TERRACLASSIC_GAS.md`, with links from the frontend and testing docs. Remaining: complete the queued [cl8y-pm inbox card](https://pm.cl8y.com/inbox), “Verify CL8Y to UST1 gas on Columbus-5” (`49becf11-4b53-4441-9f01-07b99852f78e`): sign one forward Columbus-5 swap, record route, tx hash, `gas_wanted` and `gas_used`, and confirm `gas_used < gas_wanted` with no under-estimate toast. Keep #1328 open until that operator check is complete. Related but distinct: [#1222](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1222) gas-envelope census; [#1264](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1264) USTC→USTR wrap+2-hop gas; newer [#1329](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1329) hybrid limit-order gas and [#1330](https://git.cl8y.com/code/cl8y-dex-terraclassic/issues/1330) route visibility/selection do not track this wallet check.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic#1328
No description provided.