Skip to content

fix(gasless): use quote gas fees for Max native swap with STX off#7306

Merged
rarquevaux merged 3 commits into
mainfrom
fix/gasless-swap-max-native-stx-off
Dec 3, 2025
Merged

fix(gasless): use quote gas fees for Max native swap with STX off#7306
rarquevaux merged 3 commits into
mainfrom
fix/gasless-swap-max-native-stx-off

Conversation

@rarquevaux
Copy link
Copy Markdown
Contributor

@rarquevaux rarquevaux commented Dec 3, 2025

Fix MAX native token swap failing with "insufficient gas" when STX is off

Problem

When performing a MAX native token swap (e.g., MAX ETH → USDC on Base) with:

  • Smart Transactions (STX) OFF
  • gasIncluded: true in the quote
  • gasIncluded7702: false

The transaction failed with "insufficient gas" error.

Root cause: The quote provides pre-calculated gas fees in feeData.txFee (because the gas cost is included in the swap amount), but the single transaction path was re-estimating gas instead of using the quote's values. This re-estimation fails for MAX swaps because it doesn't account for the gas already deducted from the swap value.

Solution

Updated #handleEvmTransaction and #calculateGasFees in bridge-status-controller.ts to accept and use the quote's txFee when gasIncluded: true:

  1. Pass txFee from the quote when calling #handleEvmTransaction for gasIncluded cases
  2. Skip gas estimation in #calculateGasFees when txFee is provided
  3. Convert decimal string values from the quote to hex format (matching the batch path behavior)

Changes

  • bridge-status-controller.ts:
    • #handleEvmTransaction now accepts optional txFee parameter
    • #calculateGasFees uses provided txFee (converted to hex) instead of estimating when available
    • Pass txFee when gasIncluded: true in the submitTx flow

Tests Added

  • should use quote txFee when gasIncluded is true and STX is off (Max native token swap)
  • should estimate gas when gasIncluded is false and STX is off
  • should use batch path when gasIncluded7702 is true regardless of STX setting

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Use quote-provided txFee for gas-included EVM swaps (non-STX) to prevent insufficient gas on MAX native swaps; add tests and update changelog.

  • BridgeStatusController (EVM submission):
    • Accept optional txFee in #handleEvmTransaction and pass it from submitTx when quote.gasIncluded is true.
    • In #calculateGasFees, use quote txFee (convert decimal strings to hex) instead of estimating; otherwise continue estimating.
    • Preserve batch path when gasIncluded7702 is true regardless of STX.
  • Tests:
    • Add cases for using quote txFee (gasIncluded true, STX off), estimating when gasIncluded is false, and forcing batch path with gasIncluded7702.
  • Changelog:
    • Document fix for MAX native token swap failing with insufficient gas when STX is off.

Written by Cursor Bugbot for commit c1849c7. This will update automatically on new commits. Configure here.

@rarquevaux rarquevaux requested a review from a team as a code owner December 3, 2025 19:48
@rarquevaux rarquevaux requested a review from a team as a code owner December 3, 2025 20:02
micaelae
micaelae previously approved these changes Dec 3, 2025
@rarquevaux rarquevaux added this pull request to the merge queue Dec 3, 2025
Merged via the queue into main with commit f369c3d Dec 3, 2025
281 checks passed
@rarquevaux rarquevaux deleted the fix/gasless-swap-max-native-stx-off branch December 3, 2025 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants