fix: ignore saved advanced gas fees for bridge transactions#9401
Open
cloudonshore wants to merge 2 commits into
Open
fix: ignore saved advanced gas fees for bridge transactions#9401cloudonshore wants to merge 2 commits into
cloudonshore wants to merge 2 commits into
Conversation
Bridge and bridge approval transactions applied the user's saved advanced gas fees, which swaps already deliberately ignore. A user with a low saved max base fee (e.g. 0.05 gwei on mainnet) would therefore submit underpriced bridge transactions that fail or get stuck as pending. Introduce a dedicated SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES list (swap + bridge types) to decide whether saved gas fees apply, keeping the "ignore saved gas fees" concern decoupled from SWAP_TRANSACTION_TYPES, which also gates swap-specific behavior.
chaitanyapotti
approved these changes
Jul 7, 2026
matthewwalsh0
requested changes
Jul 7, 2026
| * fees are dictated by the swap/bridge aggregator or relay; applying saved gas | ||
| * fees could underprice the transaction and cause it to fail or get stuck. | ||
| */ | ||
| const SAVED_GAS_FEES_IGNORED_TRANSACTION_TYPES: TransactionType[] = [ |
Member
There was a problem hiding this comment.
Rather than doing this per type, should we just exclude based on isInternal so it only applies to dApp transactions as was the intent?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Bridge transactions apply the user's saved advanced gas fees, whereas swaps deliberately ignore them.
In
updateGasFees, saved gas fees are skipped only forSWAP_TRANSACTION_TYPES(swap,swapAndSend,swapApproval).bridge/bridgeApprovalare not in that list, so a user's saved advanced gas fees are applied to bridge transactions.For a user who has saved a low max base fee (observed in production:
maxBaseFee: "0.05"gwei,priorityFee: "0"for mainnet), every bridge is submitted underpriced — below the current base fee — causing it to fail (GAS_TOO_LOWon the relay) or get stuck as pending. This is exactly the failure swaps were already protected from.Fix
Ignore saved gas fees for bridge transactions as well, via a dedicated list:
I intentionally did not add the bridge types to
SWAP_TRANSACTION_TYPESitself, because that constant also gates swap-specific behavior inupdateSwapsTransaction(e.g. thesimulationFailscancel-and-throw, andtransactionNewSwap*events). Keeping a separate, purpose-named list decouples "ignore saved gas fees" from "is a swap".References
maxFeePerGas: 0x2faf080(0.05 gwei) /maxPriorityFeePerGas: 0x0, sourced fromadvancedGasFee["0x1"] = { maxBaseFee: "0.05", priorityFee: "0" }.Changelog
@metamask/transaction-controllerbridgeandbridgeApprovaltransactions now ignore user-saved (advanced) gas fees, matching swaps.Checklist
Note
Low Risk
Small, localized change to gas-fee selection in
updateGasFeeswith tests; fixes production bridge failures without altering swap-only code paths.Overview
Bridge and bridge approval transactions no longer apply user-saved advanced gas fees in
updateGasFees, aligning them with swap flows where aggregator/relay pricing must win.updateGasFeespreviously skipped saved fees only when the tx type was inSWAP_TRANSACTION_TYPES.bridgeandbridgeApprovalare now included via a dedicatedSAVED_GAS_FEES_IGNORED_TRANSACTION_TYPESlist (swaps plus bridge types), without folding bridge intoSWAP_TRANSACTION_TYPESso swap-only logic elsewhere stays unchanged.Tests cover that saved fees still apply for ordinary sends and are ignored for swap and bridge types. Changelog documents the fix for underpriced bridges stuck or failing on relay.
Reviewed by Cursor Bugbot for commit 21a2f82. Bugbot is set up for automated code reviews on this repo. Configure here.