Skip to content

feat(predict): add Deposit Wallet order flow#29933

Merged
matallui merged 2 commits into
mainfrom
predict/dw-order-flow
May 8, 2026
Merged

feat(predict): add Deposit Wallet order flow#29933
matallui merged 2 commits into
mainfrom
predict/dw-order-flow

Conversation

@matallui

@matallui matallui commented May 8, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Predict order placement support for Polymarket Deposit Wallet accounts on top of the Deposit Wallet deposit foundation.

This PR:

  • Adds the POLY_1271 Polymarket signature type.
  • Adds Deposit Wallet / ERC-1271 order signing via the TypedDataSign wrapper.
  • Routes order maker/signer fields from active Predict account state.
  • Uses Deposit Wallet maker/signer for Deposit Wallet users.
  • Preserves legacy Safe order signing for grandfathered Safe users.
  • Runs Deposit Wallet create/setup preflight before submitting Deposit Wallet orders.
  • Passes an optional signed legacy Safe migration sweep as allowancesTx for Deposit Wallet orders, so stranded pUSD/USDC.e can be swept before the backend relays the order.
  • Skips Safe trade allowance and Permit2 fee preflight for Deposit Wallet orders.
  • Continues signing CLOB L2 headers with the EOA owner address.

This PR is temporarily stacked on predict/dw-deposit-foundation while PRs 1 and 2 are under review, and should be rebased/retargeted after those merge.

Validation run locally:

yarn jest app/components/UI/Predict/providers/polymarket/protocol/orderCodec.test.ts app/components/UI/Predict/providers/polymarket/PolymarketProvider.test.ts --runInBand
yarn lint:tsc

Changelog

CHANGELOG entry: Fixed Predict order placement for Polymarket Deposit Wallet accounts

Related issues

Fixes: PRED-860

Manual testing steps

Feature: Predict Deposit Wallet order flow

  Scenario: Deposit Wallet user places a Predict order
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the Deposit Wallet has enough pUSD balance and required setup from the deposit flow
    When the user places a Predict buy or sell order
    Then the order is signed with POLY_1271 semantics
      And the order is submitted successfully to the Polymarket CLOB

  Scenario: Deposit Wallet user places first order before wallet setup
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the Deposit Wallet still needs creation or allowance setup
    When the user places a Predict buy or sell order
    Then the app creates/sets up the Deposit Wallet before order submission
      And the order is submitted successfully to the Polymarket CLOB

  Scenario: Deposit Wallet user has funds stranded in legacy Safe
    Given a Predict user is routed to a Polymarket Deposit Wallet
      And the deterministic legacy Safe has sweepable pUSD or USDC.e
    When the user places a Predict buy or sell order
    Then the signed legacy Safe sweep is included as allowancesTx
      And the backend can submit the sweep before relaying the order

  Scenario: Legacy Safe user places a Predict order
    Given a Predict user is grandfathered to the legacy Safe wallet
    When the user places a Predict buy or sell order
    Then the order continues to use legacy Safe signing and preflight behavior

Screenshots/Recordings

Before

N/A - provider/order-signing change only.

After

N/A - provider/order-signing change only.

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
Changes core Predict order submission/signing paths, adding a new ERC-1271 signing format and deposit-wallet preflight flows; mistakes could cause failed or incorrectly-signed orders. Legacy Safe behavior is preserved but now shares more conditional branching.

Overview
Adds end-to-end order placement support for Polymarket Deposit Wallet accounts.

Order submission now derives maker/signer from the resolved account state and, for deposit-wallet users, performs a create/allowance batch preflight before signing/submitting. Deposit-wallet orders use the new SignatureType.POLY_1271 and are signed via signProtocolOrder using an ERC-7739 TypedDataSign wrapper, while Safe users keep legacy Safe signing.

Fee collection and Safe trade preflight steps (Permit2 fee authorization + allowances tx) are skipped for deposit-wallet orders; instead an optional legacy Safe migration sweep can be attached as allowancesTx. L2 CLOB headers are consistently signed using the EOA owner address. Tests were expanded to cover both Safe and deposit-wallet order flows and the new signing payload.

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

@metamaskbotv2 metamaskbotv2 Bot added the team-predict Predict team label May 8, 2026
@github-actions

github-actions Bot commented May 8, 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.

@github-actions github-actions Bot added the size-L label May 8, 2026
@matallui matallui force-pushed the predict/dw-deposit-foundation branch from 61b290a to 4a42a4a Compare May 8, 2026 18:39
@matallui matallui force-pushed the predict/dw-order-flow branch 3 times, most recently from a0abdbe to 2da0b25 Compare May 8, 2026 20:32
@matallui matallui added the force-builds Forces e2e native builds to trigger label May 8, 2026
Base automatically changed from predict/dw-deposit-foundation to main May 8, 2026 21:43
@matallui matallui force-pushed the predict/dw-order-flow branch from 2da0b25 to b2bf1ee Compare May 8, 2026 21:46
@matallui matallui marked this pull request as ready for review May 8, 2026 21:46
@matallui matallui requested a review from a team as a code owner May 8, 2026 21:46
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
All 5 changed files are within app/components/UI/Predict/providers/polymarket/ and relate exclusively to the Polymarket Predictions feature:

  1. PolymarketProvider.ts: Major refactoring of placeOrder to support a new "deposit wallet" order flow. Key changes:

    • New ensureDepositWalletReady private method (extracted and generalized from beforePublishDepositWalletDeposit)
    • New syncDepositWalletBalanceAllowanceForOrderIfNeeded private method
    • placeOrder now detects wallet type (deposit-wallet vs Gnosis Safe) and routes accordingly
    • Deposit wallets skip Permit2 fee authorization and Safe trade allowances preflight
    • Legacy Safe migration sweep transaction support for deposit wallet users
  2. types.ts: Added POLY_1271 = 3 to SignatureType enum for ERC-1271 signatures validated by Polymarket deposit wallets.

  3. orderCodec.ts: Added signProtocolOrder function that handles both POLY_GNOSIS_SAFE (existing V4 typed data signing) and POLY_1271 (new EIP-712 wrapped signature with app domain separator + contents hash). Also added buildProtocolUnsignedOrder now accepts optional signatureType parameter.

  4. Test files: Unit tests updated to cover the new deposit wallet order flow and POLY_1271 signature type.

Tag selection rationale:

  • SmokePredictions: Directly impacted — placeOrder is the core function for opening/closing prediction market positions. The new deposit wallet path changes how orders are signed and submitted.
  • SmokeWalletPlatform: Required per SmokePredictions tag description (Predictions is a section inside Trending tab).
  • SmokeConfirmations: Required per SmokePredictions tag description (opening/closing positions are on-chain transactions).

No other areas are affected — no shared components, no navigation changes, no controller changes, no infrastructure changes.

Performance Test Selection:
Changes are confined to the Polymarket provider business logic layer (order signing, deposit wallet preflight). No UI rendering changes, no list components, no state management changes, no app startup changes. The modifications are purely in the order placement and signing logic, which does not impact measurable performance metrics tracked by the available performance test tags.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown

@matallui matallui enabled auto-merge May 8, 2026 22:08
@matallui matallui removed the force-builds Forces e2e native builds to trigger label May 8, 2026
@matallui matallui added this pull request to the merge queue May 8, 2026
Merged via the queue into main with commit 36fb960 May 8, 2026
189 of 191 checks passed
@matallui matallui deleted the predict/dw-order-flow branch May 8, 2026 23:25
@github-actions github-actions Bot locked and limited conversation to collaborators May 8, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.78.0 Issue or pull request that will be included in release 7.78.0 label May 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.78.0 Issue or pull request that will be included in release 7.78.0 size-L team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants