Skip to content

refactor(transaction-pay-controller): extract shared max quote flow - #11440

Open
matthewwalsh0 wants to merge 1 commit into
mainfrom
refactor/shared-max-quote
Open

matthewwalsh0 wants to merge 1 commit into
mainfrom
refactor/shared-max-quote

Conversation

@matthewwalsh0

@matthewwalsh0 matthewwalsh0 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Explanation

The max-amount quote flow (atomic-first max quotes, subsidized promotion, and the gas station re-quote) lives in RelayStrategy and reads Relay's quote shape directly, so it can't be reused by ServerStrategy.

This moves it into provider-agnostic utilities, with no behaviour change:

  • utils/max-quote.ts: getMaxQuotes runs the max flow (atomic first when supported, otherwise non-atomic with subsidized promotion, including the MFA keyring guard from fix(transaction-pay-controller): keep max quotes non-atomic for MFA keyrings #11389). Also exports isAtomicMaxSupported and isAtomicMaxQuote.
  • utils/max-gas-station.ts: getMaxGasStationQuote runs the probe → adjusted quote flow with the configurable cost buffer from feat(transaction-pay-controller): add buffer to max gas station cost #11434.
  • Strategy callbacks: each strategy supplies getQuoteDetails (gas limits, gas station transactions, gasless, subsidized, target amount), getQuotes, requote and validateAtomicQuote, so the shared code never reads a strategy's original quote.
  • RelayStrategy now calls getMaxQuotes; relay-max.ts is removed, along with the unused isMaxGasStation metadata tag and ATOMIC_PROMOTION_FAILURE_PREFIX constant.

ServerStrategy adoption follows separately in #11418.

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
Refactors max-amount and gas-station quoting on payment-critical paths; behavior is intended to be unchanged but regression risk is moderate given removed Relay-only implementation and new shared routing.

Overview
Moves Relay-specific max-amount quoting into shared utils/max-quote and utils/max-gas-station, and wires Relay through strategy callbacks instead of relay-max.ts.

The deleted relay-max module (and its large test file) is replaced by getMaxQuotes (atomic-first vs promoted subsidized routes, MFA guard, atomic validation errors) and getMaxGasStationQuote (probe → adjusted re-quote with gas buffer). Relay now implements getRelayMaxQuoteDetails and passes getQuotes / requote / validateAtomicQuote into the shared flow. Quote validation skips quotes already handled as atomic max via isAtomicMaxQuote, and max call embedding uses isAtomicMaxSupported instead of inline feature-flag checks.

Cleanup and tests: ATOMIC_PROMOTION_FAILURE_PREFIX moves into max-quote.ts; isMaxGasStation metadata and related oxlint suppressions are removed. New unit suites cover the shared max and gas-station paths; Relay gains a gasless max quote test and a submit test rename (source gas fee token vs max-gas-station). GasStationStepData is exported for reuse across strategies.

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

@matthewwalsh0
matthewwalsh0 force-pushed the feat/gas-station-buffer branch from 56020f0 to 771a44d Compare November 11, 2026 18:03
@matthewwalsh0
matthewwalsh0 force-pushed the refactor/shared-max-quote branch from 0a7086e to ff683d5 Compare November 11, 2026 18:04
Base automatically changed from feat/gas-station-buffer to main November 11, 2026 21:06
Move the max gas station and atomic max promotion logic out of
RelayStrategy into provider-agnostic utils (max-quote, max-gas-station),
with RelayStrategy supplying quote details and re-quote callbacks.

This branch was successfully deployed

1 active deployment
default-branch — e12bca01 Deployed Nov 12, 2026 by matthewwalsh0 via Determine whether this PR is a release PR #6932
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.

1 participant