chore(runway): cherry-pick feat(predict): remove CLOB v1 support and migrate to pUSD#29819
Merged
Merged
Conversation
…29451) This PR removes legacy Predict Polymarket CLOB v1 support and completes the pUSD migration in Predict-owned code. It includes: - CLOB v2 as the unconditional Polymarket protocol path. - Removal of CLOB v1 protocol selection, order codec branches, and v1 Safe helper wrappers. - pUSD as the canonical Predict trading, fee, deposit, withdraw, reward-fee, and claim gas top-up token. - Legacy Safe USDC.e retained only as temporary hidden sweep state. - Legacy USDC.e → pUSD sweep preflight for deposit, withdraw, trade, and claim operations. - Displayed Predict balance as total recoverable Predict funds (`pUSD + legacy USDC.e`). - In-memory cache to stop refetching legacy USDC.e balance for a Safe after a zero balance is observed. Stack note: this PR is stacked on the confirmations-only pUSD PR so the diff stays limited to Predict-owned files. CHANGELOG entry: Updated Predict to use pUSD and the Polymarket CLOB v2 protocol. Fixes: [PRED-851](https://consensyssoftware.atlassian.net/browse/PRED-851) , [PRED-852](https://consensyssoftware.atlassian.net/browse/PRED-852) ```gherkin Feature: Predict pUSD migration Scenario: user with pUSD places a Predict trade Given the user has a funded Predict Safe with pUSD When the user places a Predict trade Then the order is submitted through the CLOB v2 path And pUSD is used for trading and fee authorization Scenario: legacy user performs their first Predict operation Given the user has legacy USDC.e in their Predict Safe When the user deposits, withdraws, trades, or claims Then the Safe preflight wraps legacy USDC.e into pUSD before the main operation ``` N/A — code-only protocol migration PR; no screenshots captured. N/A — code-only protocol migration PR; no screenshots captured. - `yarn lint:tsc` - `yarn jest app/components/UI/Predict/providers/polymarket/protocol/definitions.test.ts app/components/UI/Predict/providers/polymarket/protocol/orderCodec.test.ts app/components/UI/Predict/providers/polymarket/protocol/transport.test.ts app/components/UI/Predict/providers/polymarket/preflight/v2AllowanceRequirements.test.ts app/components/UI/Predict/providers/polymarket/preflight/withdraw.test.ts app/components/UI/Predict/providers/polymarket/preflight/workflows.test.ts app/components/UI/Predict/providers/polymarket/PolymarketProvider.test.ts app/components/UI/Predict/controllers/PredictController.test.ts app/components/UI/Predict/hooks/usePredictBalanceTokenFilter.test.ts app/components/UI/Predict/hooks/usePredictRewards.test.ts app/components/UI/Predict/views/PredictBuyWithAnyToken/components/PredictPayWithRow/PredictPayWithRow.test.tsx --runInBand --forceExit` - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [ ] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [ ] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Updates on-chain token identifiers/addresses used for Predict gas fee and rewards calculations, which could impact transactions if misconfigured. Changes are localized to Predict hooks/controller and accompanying tests. > > **Overview** > Predict now consistently references the **pUSD / CLOB v2 collateral** across Predict-owned code: `PredictController` uses `MATIC_CONTRACTS_V2.collateral` as the `gasFeeToken` for claim/withdraw `addTransactionBatch`, `usePredictBalanceTokenFilter` displays the Predict balance row using the `POLYGON_PUSD` token (icon + symbol), and `usePredictRewards` estimates points using `POLYGON_PUSD_CAIP_ASSET_ID`. > > Cleans up account-state handling by removing `hasAllowances` expectations/tests and updating `usePredictAccountState` docs to reflect the slimmer `AccountState` shape. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7dfda61. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> [PRED-851]: https://consensyssoftware.atlassian.net/browse/PRED-851?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: Caainã Jeronimo <caainaje@gmail.com>
Contributor
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Contributor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - PR targets a release branch (release/*) All E2E tests pre-selected. |
|
chloeYue
approved these changes
May 6, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.



Description
This PR removes legacy Predict Polymarket CLOB v1 support and completes
the pUSD migration in Predict-owned code.
It includes:
Safe helper wrappers.
reward-fee, and claim gas top-up token.
claim operations.
pUSD + legacy USDC.e).after a zero balance is observed.
Stack note: this PR is stacked on the confirmations-only pUSD PR so the
diff stays limited to Predict-owned files.
Changelog
CHANGELOG entry: Updated Predict to use pUSD and the Polymarket CLOB v2
protocol.
Related issues
Fixes:
PRED-851 ,
PRED-852
Manual testing steps
Screenshots/Recordings
Before
N/A — code-only protocol migration PR; no screenshots captured.
After
N/A — code-only protocol migration PR; no screenshots captured.
Testing
yarn lint:tscyarn jest app/components/UI/Predict/providers/polymarket/protocol/definitions.test.ts app/components/UI/Predict/providers/polymarket/protocol/orderCodec.test.ts app/components/UI/Predict/providers/polymarket/protocol/transport.test.ts app/components/UI/Predict/providers/polymarket/preflight/v2AllowanceRequirements.test.ts app/components/UI/Predict/providers/polymarket/preflight/withdraw.test.ts app/components/UI/Predict/providers/polymarket/preflight/workflows.test.ts app/components/UI/Predict/providers/polymarket/PolymarketProvider.test.ts app/components/UI/Predict/controllers/PredictController.test.ts app/components/UI/Predict/hooks/usePredictBalanceTokenFilter.test.ts app/components/UI/Predict/hooks/usePredictRewards.test.ts app/components/UI/Predict/views/PredictBuyWithAnyToken/components/PredictPayWithRow/PredictPayWithRow.test.tsx --runInBand --forceExitPre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Performance checks (if applicable)
SRPs
to import wallets with many accounts and tokens
performance metrics
trace()for usage andaddTokenfor an example
For performance guidelines and tooling, see the Performance
Guide.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Medium Risk
Updates on-chain token identifiers/addresses used for Predict gas fee
and rewards calculations, which could impact transactions if
misconfigured. Changes are localized to Predict hooks/controller and
accompanying tests.
Overview
Predict now consistently references the pUSD / CLOB v2 collateral
across Predict-owned code:
PredictControllerusesMATIC_CONTRACTS_V2.collateralas thegasFeeTokenfor claim/withdrawaddTransactionBatch,usePredictBalanceTokenFilterdisplays thePredict balance row using the
POLYGON_PUSDtoken (icon + symbol), andusePredictRewardsestimates points usingPOLYGON_PUSD_CAIP_ASSET_ID.Cleans up account-state handling by removing
hasAllowancesexpectations/tests and updating
usePredictAccountStatedocs to reflectthe slimmer
AccountStateshape.Reviewed by Cursor Bugbot for commit
7dfda61. Bugbot is set up for automated
code reviews on this repo. Configure
here.
Co-authored-by: Caainã Jeronimo caainaje@gmail.com bf54b9b