fix(frontend): CW20-to-native unwrap gas (#343) #845

Merged
PlasticDigits merged 2 commits from local1/343-unwrap-gas into main 2026-06-09 07:07:16 +00:00
PlasticDigits commented 2026-06-09 06:53:21 +00:00 (Migrated from gitlab.com)

Summary

  • Add UNWRAP_GAS_LIMIT when router unwrap_output: true
  • Extend estimateNativeSwapUlunaFeesTotal for native output paths

Test plan

  • npm test -- transactions.test.ts
  • EMBER→LUNC swap confirms on LocalTerra

Docs

Merge after !844 (#345) — stacked on same gas-limit work.


Note

Medium Risk
Changes affect broadcast fee math and native Max reserves for swaps, plus mandatory uluna on create_pair when governance sets a fee—wrong estimates cause failed txs or user confusion, but scope is localized to gas/fee helpers and factory create flow.

Overview
CW20→native unwrap (#343): Gas estimation now adds UNWRAP_GAS_LIMIT when router execute_swap_operations sets unwrap_output: true, including nested CW20 send hooks and estimateNativeSwapUlunaFeesTotal. Swap Max for native pay passes needsUnwrapOutput into computeMaxSpendableHumanAmount so LUNC reserves match the unwrap path. Tests lock the higher gas limit for unwrap sends.

Create pair (#345): CREATE_PAIR_GAS_LIMIT rises from 800k to 1M (LocalTerra instantiate benchmark). createPair loads factory config and attaches uluna coins when pair_creation_fee_uluna > 0; Create Pair lists the fee when configured. FactoryConfigResponse gains pair_creation_fee_uluna.

Also allows null on indexer trader best_trade_pnl / worst_trade_pnl, and documents #343/#345 in AGENTS_TERRACLASSIC_GAS.md.

Reviewed by Cursor Bugbot for commit 8f2971ae3a. Bugbot is set up for automated code reviews on this repo. Configure here.

## Summary - Add `UNWRAP_GAS_LIMIT` when router `unwrap_output: true` - Extend `estimateNativeSwapUlunaFeesTotal` for native output paths ## Test plan - [ ] `npm test -- transactions.test.ts` - [ ] EMBER→LUNC swap confirms on LocalTerra ## Docs - [skills/AGENTS_TERRACLASSIC_GAS.md](skills/AGENTS_TERRACLASSIC_GAS.md) **Merge after !844 (#345)** — stacked on same gas-limit work. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes affect broadcast fee math and native Max reserves for swaps, plus mandatory uluna on create_pair when governance sets a fee—wrong estimates cause failed txs or user confusion, but scope is localized to gas/fee helpers and factory create flow. > > **Overview** > **CW20→native unwrap (#343):** Gas estimation now adds **`UNWRAP_GAS_LIMIT`** when router **`execute_swap_operations`** sets **`unwrap_output: true`**, including nested CW20 **`send`** hooks and **`estimateNativeSwapUlunaFeesTotal`**. Swap **Max** for native pay passes **`needsUnwrapOutput`** into **`computeMaxSpendableHumanAmount`** so LUNC reserves match the unwrap path. Tests lock the higher gas limit for unwrap sends. > > **Create pair (#345):** **`CREATE_PAIR_GAS_LIMIT`** rises from 800k to **1M** (LocalTerra instantiate benchmark). **`createPair`** loads factory config and attaches **`uluna`** coins when **`pair_creation_fee_uluna` > 0**; **Create Pair** lists the fee when configured. **`FactoryConfigResponse`** gains **`pair_creation_fee_uluna`**. > > Also allows **`null`** on indexer trader **`best_trade_pnl` / `worst_trade_pnl`**, and documents #343/#345 in **`AGENTS_TERRACLASSIC_GAS.md`**. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 8f2971ae3a8de715109bf76c10544d72d88c9ee5. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
PlasticDigits commented 2026-06-09 06:53:27 +00:00 (Migrated from gitlab.com)

mentioned in merge request !846

mentioned in merge request !846
ghost1 commented 2026-06-09 06:53:30 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
ghost1 commented 2026-06-09 06:53:37 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-09 06:53:41 +00:00 (Migrated from gitlab.com)

mentioned in issue #343

mentioned in issue #343
ghost1 commented 2026-06-09 06:54:56 +00:00 (Migrated from gitlab.com)

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.

Reviewed by Cursor Bugbot for commit 09e0849441. Configure here.

<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes and found 1 potential issue. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTpjOGM3ZmU2OC1kNmVjLTQwZTUtOGU3YS04YWY1OWIyYjA4ZmMiLCJlbmNyeXB0aW9uS2V5IjoicVdBQ2tsWHQ3YmNObG9iR1ZfUklIVHRNTlRNam1hREFjM2V2NXF1N0NGRSIsImJyYW5jaCI6ImxvY2FsMS8zNDMtdW53cmFwLWdhcyIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot). A cloud agent has been kicked off to fix the reported issue. <!-- BUGBOT_AUTOFIX_AGENT_LINK --></sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 09e0849441fe413ae7fec722a3f54a2defce63b3. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 06:54:57 +00:00 (Migrated from gitlab.com)

Unwrap hint not wired Max

Medium Severity

estimateNativeSwapUlunaFeesTotal now honors needsUnwrapOutput, but swap Max still calls it via NativeSwapMaxHints without that flag. Broadcast fees include UNWRAP_GAS_LIMIT for unwrap_output, while native Max reserves omit it on unwrap routes (e.g. native→native), so spendable LUNC can exceed what remains for the higher fee envelope.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 09e0849441. Configure here.

### Unwrap hint not wired Max **Medium Severity** <!-- DESCRIPTION START --> `estimateNativeSwapUlunaFeesTotal` now honors `needsUnwrapOutput`, but swap Max still calls it via `NativeSwapMaxHints` without that flag. Broadcast fees include `UNWRAP_GAS_LIMIT` for `unwrap_output`, while native Max reserves omit it on unwrap routes (e.g. native→native), so spendable LUNC can exceed what remains for the higher fee envelope. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 3a43d11e-8de7-4ee2-b1aa-7db2c1f1cb48 --> <!-- LOCATIONS START frontend-dapp/src/services/terraclassic/transactions.ts#L95-L134 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmZmMzE3MjgyLTA1YmYtNDAwYy05NDMyLTgxMjMzNzE1MmQwNCIsImVuY3J5cHRpb25LZXkiOiJTMm43SW5FN3VTaHpVT1BEOW1JSU5laVhXNmZLTWhsRUMyUnVOc2MtRGEwIiwiYnJhbmNoIjoibG9jYWwxLzM0My11bndyYXAtZ2FzIiwicmVwb093bmVyIjoiUGxhc3RpY0RpZ2l0cyIsInJlcG9OYW1lIjoiY2w4eS1kZXgtdGVycmFjbGFzc2ljIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmZmMzE3MjgyLTA1YmYtNDAwYy05NDMyLTgxMjMzNzE1MmQwNCIsImVuY3J5cHRpb25LZXkiOiJTMm43SW5FN3VTaHpVT1BEOW1JSU5laVhXNmZLTWhsRUMyUnVOc2MtRGEwIiwiYnJhbmNoIjoibG9jYWwxLzM0My11bndyYXAtZ2FzIiwicmVwb093bmVyIjoiUGxhc3RpY0RpZ2l0cyIsInJlcG9OYW1lIjoiY2w4eS1kZXgtdGVycmFjbGFzc2ljIiwicHJOdW1iZXIiOjEyNywiY29tbWl0U2hhIjoiMDllMDg0OTQ0MWZlNDEzYWU3ZmVjNzIyYTNmNTRhMmRlZmNlNjNiMyIsInByb3ZpZGVyIjoiZ2l0bGFiIiwiaG9zdG5hbWUiOiJnaXRsYWIuY29tIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 09e0849441fe413ae7fec722a3f54a2defce63b3. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 06:57:19 +00:00 (Migrated from gitlab.com)

added 1 commit

  • 8f2971ae - Wire needsUnwrapOutput into native swap Max fee reserve

Compare with previous version

added 1 commit <ul><li>8f2971ae - Wire needsUnwrapOutput into native swap Max fee reserve</li></ul> [Compare with previous version](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/127/diffs?diff_id=1841272380&start_sha=09e0849441fe413ae7fec722a3f54a2defce63b3)
ghost1 commented 2026-06-09 06:57:34 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
ghost1 commented 2026-06-09 06:57:46 +00:00 (Migrated from gitlab.com)

resolved all threads

resolved all threads
PlasticDigits (Migrated from gitlab.com) merged commit f7f56610c4 into main 2026-06-09 07:07:16 +00:00
PlasticDigits commented 2026-06-09 07:07:17 +00:00 (Migrated from gitlab.com)

mentioned in commit f7f56610c4

mentioned in commit f7f56610c4d8e539080dc77590d76b1f9cbb2663
Sign in to join this conversation.
No reviewers
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!845
No description provided.