Skip to content

feat(predict): clob v2 cleanup core (testing E2E fixes)#29614

Open
MarioAslau wants to merge 21 commits intomainfrom
predict/clob-v2-cleanup-core-mario
Open

feat(predict): clob v2 cleanup core (testing E2E fixes)#29614
MarioAslau wants to merge 21 commits intomainfrom
predict/clob-v2-cleanup-core-mario

Conversation

@MarioAslau
Copy link
Copy Markdown
Contributor

@MarioAslau MarioAslau commented May 1, 2026

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

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 Predict transaction batching to use the v2 collateral (pUSD) as the gasFeeToken and switches rewards fee-asset IDs to pUSD, which can impact on-chain transaction submission and points estimation. Also changes balance-row display metadata and removes hasAllowances from account-state expectations, so regressions would mainly show up in Predict payment UI/state handling.

Overview
Predict now uses the CLOB v2 collateral (MATIC_CONTRACTS_V2.collateral, i.e. pUSD) when submitting claim/withdraw transaction batches by setting it as the gasFeeToken.

The Predict payment token list row is updated to be pUSD-centric: it pulls the pUSD token image, shows the formatted balance as the row description, and labels the fiat description as pUSD.

Rewards estimation requests now report the fee asset as POLYGON_PUSD_CAIP_ASSET_ID (and corresponding comment/test updates), and usePredictAccountState tests/docs are aligned to no longer expect hasAllowances in returned AccountState.

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

matallui and others added 18 commits April 29, 2026 14:02
* main: (21 commits)
  feat(predict): Add A/B Test Analytics Instrumentation: Bet Slip + Pay with Any Token (#29464)
  feat: Accounts Metrics (#29015)
  feat: Enable mUSD conversion flow for hardware wallet accounts (#29418)
  chore: QA and bug fixes from dry run apr 29 (#29519)
  test: remove toMatchSnapshot and removed snapshot files in unassigned code owners pt 3/3 (#29441)
  fix(card): initialize spending limit from saved allowance (#29517)
  perf(accessibility): fix iOS accessibility in Ramp components (#29126)
  test: e2e labels rename and shards update (#29431)
  test: fix missing mock (#29549)
  feat(rewards): add targeted Sentry capture for rewards auth errors (#29545)
  feat: track token_security_type_destination in metrics (#29381)
  fix(bridge): hide sponsored label on cross-chain bridge with insufficient balance (#29490)
  ci: fix scheduled e2e runs (#29539)
  chore: Bump `snaps-controllers` (#29486)
  chore: add buy/sell trade markers to trader position chart (#29478)
  fix(rewards): leaderboard split view (#29500)
  perf(accessibility): fix iOS accessibility in shared components for p… (#29119)
  ci: switch OTA hotfix release branch to `-ota` suffix convention (#29353)
  ci: fix `get-requirements.yml` checks for `pull_request` events (#29528)
  feat: added developer options button to clear dismissed mUSD conversion asset details CTAs (#29510)
  ...
* main:
  feat: add Tempo chain as additionnal network (#29515)
  feat: add token list security badges (#29509)
  fix: percentage buttons for money account withdraw (#29339)
  feat(predict): Add Funds / Change Payment Method CTA (#29461)
  chore: enable swaps asset picker security tags (#29570)
  test: mock accounts v4 transactions endpoint (#29569)
  feat: money account transaction - add default value for accountOverride (#29332)
  fix: Refine Perps section and empty state patterns to match Home and Money (#29009)
@MarioAslau MarioAslau self-assigned this May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

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.

@MarioAslau MarioAslau marked this pull request as ready for review May 1, 2026 16:26
@MarioAslau MarioAslau requested review from a team as code owners May 1, 2026 16:26
@MarioAslau MarioAslau added the team-predict Predict team label May 1, 2026
@MarioAslau MarioAslau changed the title predict: clob v2 cleanup core (testing E2E fixes) feat(predict): clob v2 cleanup core (testing E2E fixes) May 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeConfirmations, SmokeWalletPlatform
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR makes a significant protocol migration in the Polymarket/Predict feature: switching from USDC.e (legacy v1 protocol) to pUSD (Polymarket USD, v2 protocol) as the collateral token. Key changes:

  1. SmokePredictions (primary): All 4 predict smoke tests were directly modified (predict-open-position, predict-cash-out, predict-claim-positions, predict-withdraw). The core PredictController.ts now uses MATIC_CONTRACTS_V2 for gasFeeToken. PolymarketProvider.ts had major refactoring - v1 protocol removed entirely, v2 is now the only protocol. All polymarket mock infrastructure updated (polymarket-constants.ts, polymarket-mocks.ts, polymarket-rpc-response.ts). These tests must run to validate the pUSD migration works end-to-end.

  2. SmokeConfirmations (required per tag description + direct change): transaction-pay.spec.ts is a SmokeConfirmations test that was directly modified to use pUSD instead of USDC.e as the output token. The relay quote mock (transaction-pay.ts) was updated to reference pUSD. Per SmokePredictions tag description: 'When selecting SmokePredictions, also select SmokeConfirmations (opening/closing positions are on-chain transactions).'

  3. SmokeWalletPlatform (required per tag description): Per SmokePredictions tag description: 'Predictions is also a section inside the Trending tab (SmokeWalletPlatform); changes to Predictions views affect Trending. When selecting SmokePredictions, also select SmokeWalletPlatform (Trending section).' The PredictPayWithRow.tsx UI component was also updated.

The risk is high because this is a fundamental protocol change affecting the collateral token address used across all Predict flows (deposit, withdraw, claim, trade). The feature flag predictClobV2Enabled was removed entirely, making v2 the permanent protocol - any regression would break all Predict functionality.

Performance Test Selection:
The changes are focused on the Polymarket/Predict protocol migration (USDC.e to pUSD) and do not affect core performance-sensitive areas like app startup, account list rendering, login flows, or asset loading. The changes are primarily business logic (contract addresses, protocol definitions) and E2E test infrastructure updates. No performance-critical rendering paths, Redux state management, or initialization code was modified.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 1, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants