Skip to content

chore(runway): cherry-pick feat(predict): remove CLOB v1 support and migrate to pUSD#29819

Merged
chloeYue merged 1 commit into
release/7.76.0from
cherry-pick-7-76-0-bf54b9b
May 6, 2026
Merged

chore(runway): cherry-pick feat(predict): remove CLOB v1 support and migrate to pUSD#29819
chloeYue merged 1 commit into
release/7.76.0from
cherry-pick-7-76-0-bf54b9b

Conversation

@runway-github

@runway-github runway-github Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Description

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

CHANGELOG entry: Updated Predict to use pUSD and the Polymarket CLOB v2
protocol.

Related issues

Fixes:
PRED-851 ,
PRED-852

Manual testing steps

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

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: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

Pre-merge author checklist

Performance checks (if applicable)

  • 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

    to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production
    performance metrics
  • See trace() for usage and
    addToken
    for an example

For performance guidelines and tooling, see the Performance
Guide
.

Pre-merge reviewer checklist

  • 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.

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.

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

…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>
@runway-github runway-github Bot requested review from a team as code owners May 6, 2026 18:53
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
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.

@metamaskbotv2 metamaskbotv2 Bot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - PR targets a release branch (release/*)

All E2E tests pre-selected.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

@chloeYue chloeYue added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label May 6, 2026
@chloeYue chloeYue merged commit cc932b3 into release/7.76.0 May 6, 2026
211 of 215 checks passed
@chloeYue chloeYue deleted the cherry-pick-7-76-0-bf54b9b branch May 6, 2026 19:52
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size-XL skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants