Conversation
…ess Predict same-chain withdraw on swap-only Relay routes Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
…elper
Both branches of `estimateGasBatch` (EIP-7702 and non-7702) now share a
single helper that returns parsed limits + sum when every transaction
has a provided `gas`, or `undefined` otherwise.
Adds a focused `describe('getProvidedBatchGasLimits')` block covering:
- all transactions have gas
- none have gas
- mixed (some have gas)
- hex gas values
- empty batch (documents current behaviour)
No behavioural change.
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
Since the Polymarket pUSD migration on April 28 2026, Predict same-chain withdraws on Polygon (e.g. pUSD → USDC) sometimes fail with
transaction gas limit too high (cap: 33554432, tx: 42121000).Two interacting bugs:
transaction-pay-controller—calculateSourceNetworkCostalways usesfromOverride = Safe proxyfor Predict withdraws. That works for deposit-style Relay routes but breaks for the swap-aggregator routes that same-chain destinations now use post-migration: DEX aggregators reject contract callers (anti-MEVmsg.sender == tx.originchecks etc.), so the swap step reverts in simulation.transaction-controller—estimateGasBatch's 7702 path always callsestimateGas, even when every batch entry already has agasvalue. The non-7702 path has had anallTransactionsHaveGasshort-circuit since #7405; the 7702 path was missed. When TPC tries the EOAfrom, the swap sub-call reverts (EOA has no source token until the prependedSafe.execTransactionsub-call runs mid-batch), the whole 7702 batch falls back to ~block-gas-limit × buffer ≈ 42M, and Polygon's per-txgascaprejects it.Fix
relay-quotes.ts: gatefromOverride = Safe proxyon the route having adepositstep. Same-chain swap routes use the relay params' EOAfrominstead. Gas-fee-token lookup keeps using the Safe proxy (gated onisPredictWithdraw && refundTo) so the gasless flow still works for users with 0 POL.constants.ts: addPOLYGON_PUSD_ADDRESSand include it inSTABLECOINS[Polygon]for correct stablecoin display.gas.ts: mirror the existing non-7702 short-circuit in the 7702 branch — when every transaction has a providedgas, sum them and skip simulation.Verified end-to-end on mobile (yalc-linked): Polygon pUSD → USDC withdraw produces a sane fee both with POL and gasless (paid in pUSD). BNB cross-chain unchanged.
References
N/A
Checklist
Note
Medium Risk
Changes affect gas estimation and relay quote simulation paths for Predict withdraws, where subtle address-selection logic can impact fee calculation and transaction success on specific routes/chains.
Overview
Fixes Predict same-chain withdraws on swap-only Relay routes by avoiding Safe-proxy
fromoverrides unless the quote includes adepositstep, while still using the Safe proxy for gas-fee-token lookup so gasless flows continue to work.Updates
TransactionController.estimateGasBatchto skip EIP-7702 simulation when all batch transactions already specifygas, via a new sharedgetProvidedBatchGasLimitshelper, preventing fallback to near-block gas limits when sub-calls can’t be simulated standalone.Adds Polygon Polymarket
pUSD(POLYGON_PUSD_ADDRESS) to the stablecoin list for display/fiat-rate logic, and expands tests/changelogs to cover the new behaviors.Reviewed by Cursor Bugbot for commit c6678db. Bugbot is set up for automated code reviews on this repo. Configure here.