Skip to content

Conversation

@matallui
Copy link
Contributor

@matallui matallui commented Nov 8, 2025

Description

Fixed a floating-point precision issue in the Polymarket fee calculation that was causing order placement failures. When calculating fees (e.g., for a $7.40 bet), JavaScript floating-point arithmetic would produce values with excessive decimal places (e.g., 0.29600000000000004), which would later fail when passed to parseUnits. The fix rounds the fee to 4 decimal places to prevent these precision errors while maintaining sufficient accuracy for fee calculations.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: Polymarket bet placement

  Scenario: user places a bet with amount that triggers floating-point precision issue
    Given user is on the Predict feature
    And user has selected a Polymarket prediction market

    When user enters a bet amount of $7.40
    And user confirms the bet placement
    Then the order should be successfully placed without errors

Screenshots/Recordings

Before

Order placement would fail with parseUnits error when fee calculation resulted in values like 0.29600000000000004

After

Order placement succeeds as fee is properly rounded to 0.2960 (4 decimal places)

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

Round totalFee to 4 decimals in calculateFees to prevent floating-point precision issues.

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2025

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.

@matallui matallui requested review from caieu and kevinbluer November 8, 2025 17:08
@metamaskbot metamaskbot added the team-predict Predict team label Nov 8, 2025
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
E Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@matallui matallui added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Nov 10, 2025
@matallui matallui enabled auto-merge November 10, 2025 17:36
Copy link
Contributor

@caieu caieu left a comment

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 Nov 10, 2025
Merged via the queue into main with commit 3574cb5 Nov 10, 2025
152 of 155 checks passed
@matallui matallui deleted the predict/round-fee-decimals branch November 10, 2025 17:55
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2025
@metamaskbot metamaskbot added the release-7.60.0 Issue or pull request that will be included in release 7.60.0 label Nov 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.60.0 Issue or pull request that will be included in release 7.60.0 size-XS skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants