Skip to content

feat(transaction-pay-controller): add buffer to max gas station cost - #11434

Merged
matthewwalsh0 merged 1 commit into
mainfrom
feat/gas-station-buffer
Nov 11, 2026
Merged

matthewwalsh0 merged 1 commit into
mainfrom
feat/gas-station-buffer

Conversation

@matthewwalsh0

@matthewwalsh0 matthewwalsh0 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Explanation

For max-amount quotes where the user can't cover origin gas in native token, RelayStrategy uses a gas station flow: it prices gas in the source token with a smaller probe quote, then re-quotes with the source amount reduced by that cost. The adjusted quote is only accepted if validation passes, otherwise the original max quote is used.

Our gas estimate varies slightly between quotes (e.g. +22 gas out of ~970k), and for multi-item quotes the source-token gas cost is Sentinel's rate × our gas estimate. With nothing reserved beyond the probe's cost, the adjusted quote regularly failed affordability by a handful of raw units. Separately, the adjusted quote was rejected whenever its total gas limit exceeded the phase-1 quote's, even when it was below the probe's.

This change:

  • Reserves a buffer on top of the probe's gas cost when reducing the source amount. Configurable via confirmations_pay_extended.gasStationCostBuffer (a multiplier, defaults to 1.0, i.e. no buffer until configured).
  • Removes the gas limit checks (shape and total) on the adjusted quote. In the 7702 gas station flow the relayer sets the on-chain gas, and our limit only affects the cost estimate, which the affordability check already validates.

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

Medium Risk
Changes max-amount quote math and acceptance rules in RelayStrategy; misconfigured buffer could reduce spendable amount or accept quotes that previously fell back to phase 1.

Overview
Relay max-amount gas station now reserves extra headroom on top of the probe quote’s gas cost when computing the phase-2 source amount, and no longer rejects adjusted quotes based on gas-limit shape or totals between phases.

A new feature flag confirmations_pay_extended.gasStationCostBuffer (multiplier, default 1.0) drives getGasStationCostBuffer(); values below 1 fall back to the default. Phase-2 acceptance still requires source gas-fee-token pricing and the existing affordability check.

Tests and changelog document the new flag and updated fallback vs phase-2 expectations when gas limits or costs drift slightly.

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

@matthewwalsh0 matthewwalsh0 changed the title feat(transaction-pay-controller): tolerate gas re-estimation in max gas station feat(transaction-pay-controller): add buffer to max gas station cost Nov 11, 2026
@matthewwalsh0
matthewwalsh0 force-pushed the feat/gas-station-buffer branch from da5b2ff to 12ee73e Compare November 11, 2026 14:32
@matthewwalsh0
matthewwalsh0 marked this pull request as ready for review November 11, 2026 16:50
@matthewwalsh0
matthewwalsh0 requested review from a team as code owners November 11, 2026 16:50
@matthewwalsh0
matthewwalsh0 deployed to default-branch November 11, 2026 16:50 — with GitHub Actions Active
Reserve a configurable buffer (confirmations_pay_extended.gasStationCostBuffer,
default 1.0) on top of the probe gas cost, and remove the gas limit checks on
the adjusted quote since the affordability check already covers any gas cost
change.
@matthewwalsh0
matthewwalsh0 added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 5f51e2b Nov 11, 2026
72 checks passed
@matthewwalsh0
matthewwalsh0 deleted the feat/gas-station-buffer branch November 11, 2026 21:06
@jpuri jpuri mentioned this pull request Nov 12, 2026
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants