Skip to content

feat(predict): add FAK order type support#26718

Merged
matallui merged 3 commits into
mainfrom
predict/permit2-pr3
Mar 2, 2026
Merged

feat(predict): add FAK order type support#26718
matallui merged 3 commits into
mainfrom
predict/permit2-pr3

Conversation

@matallui

@matallui matallui commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Description

Adds Fill-and-Kill (FAK) order type support, feature-flagged OFF by default via the predictFakOrders version-gated remote flag.

How it works:
When both conditions are met:

  1. Permit2 fee authorization is active (Permit2 allowance exists AND being used)
  2. fakOrdersEnabled flag is true (via predictFakOrders remote flag)

→ The order is submitted with OrderType.FAK instead of OrderType.FOK.

In all other cases (no Permit2, fallback to Safe tx, or fakOrdersEnabled false), orders continue to use OrderType.FOK.

Changes (~20 lines of logic):

  • Add fakOrdersEnabled: boolean to PredictFeatureFlags
  • Resolve predictFakOrders version-gated remote flag in resolveFeatureFlags()
  • In placeOrder(): when Permit2 path is taken AND fakOrdersEnabledOrderType.FAK
  • 4 new test cases covering FAK/FOK selection logic

Double-gated safety: FAK requires both Permit2 AND the FAK flag. The predictFakOrders flag is version-gated, so old app versions won't get FAK even if the remote flag is enabled.

Depends on: #26711 (Permit2 fee authorization)

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/PRED-715

Manual testing steps

Feature: FAK order type support (feature-flagged OFF)

  Scenario: user places orders with FAK disabled (default)
    Given user has Predict feature enabled
    And fakOrdersEnabled remote flag is false (default)

    When user places a buy order (even with Permit2 active)
    Then order type is FOK

  Scenario: user places orders with FAK enabled and Permit2 active
    Given user has Predict feature enabled
    And fakOrdersEnabled remote flag is true
    And permit2Enabled is true with executors configured
    And user's Safe has Permit2 USDC allowance

    When user places a buy order
    Then order type is FAK
    And Permit2 fee authorization is used

  Scenario: user places orders with FAK enabled but no Permit2
    Given user has Predict feature enabled
    And fakOrdersEnabled remote flag is true
    And Permit2 conditions are NOT met (no allowance or flag off)

    When user places a buy order
    Then order type is FOK (fallback)
    And Safe transaction fee authorization is used

Screenshots/Recordings

N/A — backend logic, no UI changes.

Before

N/A

After

N/A

Pre-merge author checklist

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 Polymarket order submission to conditionally use a new FAK order type, which can affect trade execution semantics and request signing when enabled. Risk is mitigated by a version-gated remote flag and only applying the behavior on the Permit2 fee-authorization path.

Overview
Adds a new fakOrdersEnabled feature flag (resolved from the version-gated remote flag predictFakOrders) to control whether Predict orders may be submitted as Fill-and-Kill.

Updates Polymarket placeOrder to choose OrderType.FAK only when Permit2 fee authorization is actually used and fakOrdersEnabled is true (otherwise it remains FOK), and restructures header signing so the HMAC covers the selected orderType.

Expands Polymarket provider tests to cover FAK vs FOK selection across Permit2, Safe fallback, and flag combinations.

Written by Cursor Bugbot for commit 054dccc. This will update automatically on new commits. Configure here.

@matallui matallui added no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed team-predict Predict team labels Feb 27, 2026
@github-actions

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.

Base automatically changed from predict/permit2-pr2 to main March 2, 2026 18:32
matallui added 2 commits March 2, 2026 11:41
Add fakOrdersEnabled to PredictFeatureFlags interface and resolve
predictFakOrders version-gated remote flag in resolveFeatureFlags().
Defaults to false when the remote flag is absent or invalid.
…re active

When a Permit2 fee authorization is used AND fakOrdersEnabled is true,
submit the order with OrderType.FAK instead of FOK. Falls back to FOK
in all other cases (no Permit2, no allowance, or fakOrdersEnabled false).
@matallui matallui force-pushed the predict/permit2-pr3 branch from ba7ae0d to 7d29258 Compare March 2, 2026 18:42
@matallui matallui marked this pull request as ready for review March 2, 2026 18:42
@matallui matallui requested a review from a team as a code owner March 2, 2026 18:42

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/Predict/providers/polymarket/PolymarketProvider.ts Outdated
Hoist fee/permit2/FAK determination before clobOrder construction
so the HMAC signature covers the correct orderType (FAK vs FOK)
instead of always signing FOK and overriding afterward.
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePredict
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are focused on the Predictions/Polymarket feature, specifically adding support for FAK (Fill-And-Kill) order types when using Permit2 fee authorization. The changes include:

  1. PredictController.ts: Added extraction of a new fakOrdersEnabled feature flag from remote feature flags
  2. PolymarketProvider.ts: Modified order placement logic to use FAK order type instead of FOK when Permit2 is used AND the feature flag is enabled. The code was restructured to determine the order type before building the clobOrder for correct HMAC signature calculation.
  3. flags.ts: Added the new fakOrdersEnabled boolean to the PredictFeatureFlags interface
  4. PolymarketProvider.test.ts: Added comprehensive unit tests covering all scenarios (FAK with Permit2+flag, FOK without flag, FOK with Safe tx fallback)

Selected tags based on tag descriptions:

  • SmokePredictions: Primary tag - tests Polymarket prediction market integration including opening/closing positions
  • SmokeWalletPlatform: Required per SmokePredictions description - Predictions is a section inside the Trending tab
  • SmokeConfirmations: Required per SmokePredictions description - opening/closing positions are on-chain transactions

The risk is medium because:

  • Changes affect trading/order placement logic which is financially sensitive
  • However, the change is feature-flag gated (fakOrdersEnabled)
  • Well-covered by unit tests
  • Isolated to Predict functionality with no broader impact

Performance Test Selection:
The changes modify order placement logic in PolymarketProvider which is part of the prediction market flow. While the changes are primarily logic-based (order type selection), they do restructure the order building process. The @PerformancePredict tag covers prediction market flows including deposit flows and order execution, which could be affected by the restructured order building logic. Running this performance test will help ensure the changes don't introduce any performance regressions in the prediction market flow.

View GitHub Actions results

@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

⚠️ E2E Fixture Validation — Structural changes detected

Category Count
New keys 60
Missing keys 0
Type mismatches 0
Value mismatches 6 (informational)

The committed fixture schema is out of date. To update, comment:

@metamaskbot update-mobile-fixture

View full details | Download diff report

@matallui matallui enabled auto-merge March 2, 2026 21:22

@caieu caieu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matallui matallui added this pull request to the merge queue Mar 2, 2026
Merged via the queue into main with commit 19b3758 Mar 2, 2026
98 checks passed
@matallui matallui deleted the predict/permit2-pr3 branch March 2, 2026 23:25
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 2, 2026
@metamaskbot metamaskbot added the release-7.69.0 Issue or pull request that will be included in release 7.69.0 label Mar 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.69.0 Issue or pull request that will be included in release 7.69.0 size-M team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants