fix(perps): use recorded fees for historical orders - #34514
Conversation
|
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. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
🧪 Flaky unit test detectionRun history flaky detectionHistorical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow. Failures / runs sampled per window:
AI-detected flaky patterns
|
b43cc91 to
29a4028
Compare
29a4028 to
fadc851
Compare
cce6dca to
09045da
Compare
89e9c31 to
75f4a25
Compare
75f4a25 to
a23957e
Compare
a23957e to
dbee7fd
Compare
…clears isHistoryLoading
6979f8c to
72452de
Compare
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
SmokePerps: Directly affected - the Perps order transaction views and fee display are changed. Smoke tests cover limit orders, fills, and cancels which exercise the transaction history and fee display. SmokeWalletPlatform: Required by SmokePerps description - "When selecting SmokePerps, also select SmokeWalletPlatform (Trending section)" since Perps is embedded in Trending. SmokeConfirmations: Required by SmokePerps description - "When selecting SmokePerps, also select SmokeConfirmations (Add Funds deposits are on-chain transactions)". All other tags (SmokeAccounts, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeMoney, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps, SmokeMMConnect) are unaffected as the changes are isolated to Perps transaction history and fee display. Performance Test Selection: |
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 72452de. Configure here.
|
|
||
| setRestFills([]); | ||
| fetchRestFills(); | ||
| }, [fetchRestFills, selectedAddress]); |
There was a problem hiding this comment.
False zero fees without provider
Medium Severity
When getActiveProviderOrNull() is null, historical fill loading ends as a quiet success (isHistoryLoading false, historyError null, empty REST fills). usePerpsRecordedOrderFees then treats in-window orders with no matches as a confirmed $0, so order details can show $0 instead of — even though fills were never fetched. That conflicts with this PR’s goal of not presenting failed or incomplete lookups as zero fees.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 72452de. Configure here.
|
⚡ Performance Test Results
✅ All tests passed · 2 tests · 1 device 📱 Devices tested (1)Android: Google Pixel 8 Pro (v14.0) ✅ Passed Tests (2)
Branch: |





Description
Historical Perps order details recalculated fees using the current fee schedule, which could differ from the fees charged when the order executed.
This change associates orders with their execution fills and displays the summed recorded fee. It also replaces the estimated MetaMask/Hyperliquid breakdown with one accurate Total fee row and prevents loading failures from appearing as $0.
Fees are derived from matching fills rather than order status because canceled orders may have partial fills that incurred fees, while triggered orders may not use the literal Filled status.
Expected QA behavior: Recent fully filled orders may show the same total as main — that is expected when current rates match execution-time rates. The clearest regression to verify is a partially filled, then canceled order: main showed $0 fees; this branch should show the sum of fees from those partial fills. Larger divergence is more likely on older orders or after VIP/builder fee tier changes.
Changelog
CHANGELOG entry: Fixed historical Perps orders displaying fees calculated from current rates.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-3693
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Changes how users see historical trading fees (user-facing money display) and adds async fill lookup edge cases, but scope is limited to Perps order/activity detail UI and improves accuracy versus estimates.
Overview
Fixes incorrect historical order fees by replacing
usePerpsOrderFees(current schedule estimates) withusePerpsRecordedOrderFees, which sumsfeeon fills sharing the order’sorderId. Order history mapping now carriesorderIdso details views can correlate partial fills (e.g. canceled orders that still paid fees).PerpsOrderTransactionViewand activityPerpsDetailsdrop the MetaMask/Hyperliquid breakdown and show one Total fee row. Values use—while fills load, on history errors, or when the order is outside the fill lookback; covered orders with no matching fills still show $0.usePerpsMarketFillsgainsisHistoryLoading/historyError, waits for Perps connection readiness before REST backfill, and ignores stale in-flight fetches on account/symbol changes or refresh overlap.Reviewed by Cursor Bugbot for commit 72452de. Bugbot is set up for automated code reviews on this repo. Configure here.