Repository navigation
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. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
fa959e7 to
f903a5e
Compare
Smart E2E Test SelectionSelected E2E tags: ALL Selected Performance tags: @PerformancePreps AI Confidence: 100 E2E reasoningExpand to readThis PR introduces significant changes to the Perps fee discount system and RewardsController:
The hard rule seed selected ALL due to the controller package version update. I'm refining to the most relevant tags since the changes are scoped to Perps/Rewards functionality. The RewardsController changes (new getPerpsTradingFeeGrant method) and the perps-controller preview version are the highest-risk elements, but they primarily affect the perps flow rather than all wallet functionality. The activity adapter fix for perps transactions without PnL is also scoped to perps transaction history display. Performance reasoningExpand to readThe perps fee calculation logic has been significantly refactored (usePerpsOrderFees, usePerpsCloseAllCalculations, usePerpsRewards hooks all updated). The mobile infrastructure adapter now calls getPerpsTradingFeeGrant in addition to getPerpsDiscountForAccount, adding a new async call to the fee resolution path. These changes could impact perps market loading, position management, and add funds flow performance. @PerformancePreps covers perps market loading, position management, add funds flow, and order execution - all directly affected by these fee calculation changes. |
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. |
display resolved perps fee discounts use perps controller fee grant preview
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Alejandro Garcia Anglada <aganglada@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
55702f4 to
ec648e6
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 ec648e6. Configure here.
⚡ Performance Test Results
Branch: |
|




Description
Adds support for profile-based Perps trading fee grants. These grants apply to eligible Profile Sync users independently of Rewards opt-in or VIP membership.
Mobile retrieves grants using the Profile Sync JWT and supplies them to the fee resolver introduced in
MetaMask/core#10664. Core selects the lowest applicable fee and returns its source with the quote, preventing Mobile from applying discounts twice.
The UI now presents the resolved source appropriately:
This also adds accurate original fee totals, mixed-source handling for close all flows, runtime response validation, stale profile protection, and focused test coverage.
Changelog
CHANGELOG entry: Added profile based promotional fee grants for eligible Perps trades.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-4020
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
Touches fee quoting, Rewards API auth, and payment-adjacent display logic across many Perps surfaces; incorrect grant or double-discount handling would misstate costs to users.
Overview
Adds profile-based Perps trading fee grants wired through Rewards (
getPerpsTradingFeeGrant, Profile Sync JWT onGET /trading-fee-grants) and mobile infrastructure, without gating VIP discount lookup on the VIP feature flag. Bumps@metamask/perps-controllerto a preview build so Core resolves the winning fee and returnsfeeSource; mobile hooks (usePerpsOrderFees,usePerpsCloseAllCalculations) stop re-applying Rewards discounts and only derive presentation via newfeeDiscounthelpers.Fee UI now distinguishes attribution: VIP badge for
rewards, “Promotional discount” for grants, generic “Fee discount” otherwise (PerpsFeeDiscountLabel, updated tooltips and trade/close summaries withoriginalTotalFees/feeDiscountKind). Close-all aggregation weights by notional and uses generic labeling when sources mix.Separately, transaction history treats missing realized PnL as unknown (blank close amounts, safer fill aggregation) instead of coercing to zero.
Reviewed by Cursor Bugbot for commit af50d38. Bugbot is set up for automated code reviews on this repo. Configure here.