You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix the Predict fee calculation to match the backend order relay calculation. Previously, individual fee components (metamaskFee, providerFee) were rounded to 3 decimal places before summing, and previewOrder was passing size instead of makerAmount as the fee basis. This caused rounding discrepancies that led to order failures on certain amounts (e.g., $6.12 yielding a $0.244 fee instead of $0.2448).
Changes:
Remove per-component rounding of metamaskFee and providerFee — keep full precision
Round only totalFee to 6 decimal places (matching backend precision)
Use makerAmount instead of size as the userBetAmount in previewOrder, aligning with the backend order relay
Feature: Predict fee calculation accuracyScenario: user places a bet with an amount that previously caused rounding errorsGiven the user is on the Predict market detail screen
When user enters a bet amount of $6.12
Then the displayed fee should be $0.2448 (not $0.244)
And the order should succeed without a fee mismatch error
I've completed the PR template to the best of my ability
I've included tests if applicable
I've documented my code using JSDoc format if applicable
I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
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 fee math used for order previews/relaying; incorrect rounding or amount basis could still cause fee mismatches and failed orders, but the change is localized to fee computation.
Overview
Adjusts Predict’s Polymarket fee calculation to stop rounding metamaskFee/providerFee individually and instead round only totalFee to 6 decimals, matching backend precision.
Updates previewOrder (BUY) to compute fees from the rounded makerAmount rather than the raw input size, reducing client/backend fee discrepancies that can cause order submission failures.
Written by Cursor Bugbot for commit 06004e3. This will update automatically on new commits. Configure here.
Selected Performance tags: None (no tests recommended)
Risk Level: medium
AI Confidence: 90%
click to see 🤖 AI reasoning details
E2E Test Selection:
The changes modify fee calculation and order preview logic in the Polymarket Predict provider (app/components/UI/Predict/providers/polymarket/utils.ts). Specifically:
Removed 3-decimal rounding for individual metamaskFee and providerFee.
Changed totalFee rounding to 6 decimals.
Updated previewOrder to use makerAmount instead of size for userBetAmount when calculating fees.
These changes directly impact the Predict (Polymarket) flow, including fee previews, order summaries, and potentially final transaction values. This can affect:
Opening new prediction positions
Fee display and correctness
Balance updates after transactions
On-chain confirmation flows tied to prediction orders
Therefore:
SmokePredictions is required to validate full position lifecycle and balance synchronization.
SmokeConfirmations is required because opening/closing prediction positions involves on-chain transactions and confirmations.
SmokeWalletPlatform is required because Predictions is embedded in the Trending tab and tightly integrated with wallet platform flows.
No other core wallet, network, or controller logic is affected.
Performance Test Selection:
The changes are limited to arithmetic rounding and parameter usage in fee calculation utilities. There are no UI rendering, list performance, network loading, controller, or initialization changes. No measurable performance impact is expected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix the Predict fee calculation to match the backend order relay calculation. Previously, individual fee components (
metamaskFee,providerFee) were rounded to 3 decimal places before summing, andpreviewOrderwas passingsizeinstead ofmakerAmountas the fee basis. This caused rounding discrepancies that led to order failures on certain amounts (e.g., $6.12 yielding a $0.244 fee instead of $0.2448).Changes:
metamaskFeeandproviderFee— keep full precisiontotalFeeto 6 decimal places (matching backend precision)makerAmountinstead ofsizeas theuserBetAmountinpreviewOrder, aligning with the backend order relayChangelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/PRED-740
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Updates fee math used for order previews/relaying; incorrect rounding or amount basis could still cause fee mismatches and failed orders, but the change is localized to fee computation.
Overview
Adjusts Predict’s Polymarket fee calculation to stop rounding
metamaskFee/providerFeeindividually and instead round onlytotalFeeto 6 decimals, matching backend precision.Updates
previewOrder(BUY) to compute fees from the roundedmakerAmountrather than the raw inputsize, reducing client/backend fee discrepancies that can cause order submission failures.Written by Cursor Bugbot for commit 06004e3. This will update automatically on new commits. Configure here.