Repository navigation
Conversation
065da61 to
aeb52ce
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
| this.#getStrategy = getStrategy; | ||
| this.#getStrategies = getStrategies; | ||
| this.#polymarket = polymarket; | ||
| this.#maxBalanceRefresher = new MaxBalanceRefresher({ |
There was a problem hiding this comment.
Instead of setting up an additional loop that may clash with the default QuoteRefresher, could we just update getRefreshInterval in the RelayStrategy to check the feature flag based on max mode and transaction type according to the feature flag?
We could add transactionId to PayStrategyGetRefreshIntervalRequest then it's nicely encapsulated and fits in the existing refresh loop?
And call updateSourceAmounts as standard inside refreshQuotes?
| pollingTimeout?: number; | ||
| }; | ||
| }; | ||
| maxBalanceRefreshInterval?: MaxBalanceRefreshIntervalConfig; |
| return STABLECOINS; | ||
| } | ||
|
|
||
| export function getMaxBalanceRefreshInterval( |
aeb52ce to
d5be077
Compare
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a963107. Configure here.
|
|
||
| const latestTransactionData = messenger.call( | ||
| 'TransactionPayController:getState', | ||
| ).transactionData[transactionId]; |
There was a problem hiding this comment.
Refresh can replace quotes with no-op
Medium Severity
Unconditionally calling updateSourceAmounts before each expired requote now also rewrites non-max source amounts. That helper can persist an empty list when getTokenFiatRate is briefly unavailable, and updateQuotes then treats empty requests plus a payment token as a direct route. The stored conversion quotes become a no-op, and QuoteRefresher stops because only a None strategy remains.
Reviewed by Cursor Bugbot for commit a963107. Configure here.
…-hook-generic-pay-controller # Conflicts: # packages/transaction-pay-controller/CHANGELOG.md # packages/transaction-pay-controller/src/TransactionPayController.test.ts


Explanation
Max-amount transactions can stay open while their source balance changes. The stored quote keeps the amount derived from the earlier balance, so submitting it can request more than the source account holds (for example, a Perps withdrawal quoted for 10 after the balance drops to 9.9).
This PR refreshes the max-amount source balance as part of the existing
QuoteRefresherloop, using a per-transaction-type interval from a newmaxBalanceRefreshIntervalfield inconfirmations_pay_extended:{ "maxBalanceRefreshInterval": { "perpsWithdraw": 5000 } }PayStrategyGetRefreshIntervalRequestnow includestransactionId.RelayStrategy.getRefreshIntervalreturns the configured interval for max-amount transactions whose type matches the flag (including nested batch transactions). Otherwise it returnsundefined, keeping the default 30-second refresh.refreshQuotesrequotes a max-amount transaction, it first re-derives source amounts through the controller update path using the existinggetBalancecallback, then requotes from the latest state.TransactionPayControllerpassesgetBalancetoQuoteRefresher.Because this runs inside the existing refresh loop, a refresh never overlaps an in-flight quote request for the same transaction. Transaction types with no configured interval are unchanged.
References
Checklist
Note
Medium Risk
Changes the periodic requote path and max-amount sizing for pay/withdraw flows; incorrect balance or interval logic could mis-quote or refresh too often, though behavior is gated by feature flags and max-amount checks.
Overview
Fixes max-amount pay flows staying quoted against an outdated source balance while the confirmation stays open (e.g. a Perps withdrawal still sized for 10 after the balance drops).
The periodic
QuoteRefresherpath now passes the controller’s optionalgetBalanceintorefreshQuotes. When quotes are expired,refreshQuotesre-runsupdateSourceAmounts(with that callback when set) before fetching new quotes, and requotes from the latest controller state.Max-amount transactions can use a shorter requote cadence via a new
confirmations_pay_extended.maxBalanceRefreshIntervalmap (perTransactionType, including nested batch types).RelayStrategy.getRefreshIntervalreturns that interval only whenisMaxAmountis set; otherwise behavior stays on the default 30s refresh.PayStrategyGetRefreshIntervalRequestnow includestransactionIdso strategies can read transaction data when resolving the interval.Reviewed by Cursor Bugbot for commit e0b8b94. Bugbot is set up for automated code reviews on this repo. Configure here.