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
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.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection rationale:
No other feature areas (accounts, network, browser, snaps, swap, etc.) are affected by these changes. Performance Test Selection: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #34514 +/- ##
==========================================
+ Coverage 85.12% 85.17% +0.04%
==========================================
Files 6350 6397 +47
Lines 173080 174329 +1249
Branches 42804 43214 +410
==========================================
+ Hits 147333 148483 +1150
- Misses 15708 15722 +14
- Partials 10039 10124 +85 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
⚡ 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 historical trading fees are sourced and displayed, which affects user-facing financial accuracy. Also tightens fill-history fetch lifecycle around connection and stale requests.
Overview
Historical Perps order details now show the actual fees charged at execution instead of recalculating from the current fee schedule.
Adds
usePerpsRecordedOrderFees, which sums fees from fills matching an order ID. BothPerpsOrderTransactionViewandPerpsDetailsswitch to this hook and collapse the MetaMask/Hyperliquid breakdown into a single Total fee row. Loading or unavailable lookups show—instead of$0.usePerpsMarketFillsgains arestHistoryStatusand waits for connection readiness, so fee lookups can distinguish pending, ready, and failed history. Orders now carryorderIdso fills can be correlated, including partial fills on canceled orders.Reviewed by Cursor Bugbot for commit 1640437. Bugbot is set up for automated code reviews on this repo. Configure here.