Skip to content

Conversation

@abretonc7s
Copy link
Contributor

@abretonc7s abretonc7s commented Sep 16, 2025

Description

This PR implements MetaMask Points rewards integration for Perps trading, including tier-based fee discounts and points estimation display. Users now see their estimated points earnings and receive fee discounts based on their MetaMask Points tier before executing trades.

What is the reason for the change?

  • TAT-1221: Users need tier-based MetaMask builder fee discounts (Tier 1-3: 10bps, Tier 4-5: 5bps, Tier 6-7: 3.5bps)
  • TAT-1223: Users need to see estimated points earnings before trading

What is the improvement/solution?

  • Integrated RewardsController for fee discount and points estimation
  • Added RewardPointsDisplay component with fox icon animation states
  • Implemented fee discount visualization with fox icon in fee row
  • Added comprehensive error handling with tooltips
  • Supports development simulation with magic numbers (41, 42, 43)

Changelog

CHANGELOG entry: Added MetaMask Points rewards integration to Perps trading with tier-based fee discounts and points estimation display

Related issues

Fixes:

Manual testing steps

Feature: MetaMask Points Rewards Integration

  Scenario: User sees fee discount for their tier
    Given user has MetaMask Points tier 4-5
    And user is on Perps order view with valid order amount
    When user enters order details
    Then user sees orange fox icon with "-X%" discount in fee row
    And total fee reflects the discount amount

  Scenario: User sees estimated points for trade
    Given user has opted into rewards program
    And user is on Perps order view
    When user enters valid order amount and leverage
    Then user sees orange fox icon with estimated points number
    And points animate on value changes (refresh state)

  Scenario: User sees error state handling
    Given rewards API is unavailable
    When user attempts to view rewards information
    Then user sees greyed out fox icon with "Couldn't load" text
    And user can tap info icon to see error details

  Scenario: Development simulation testing
    Given __DEV__ mode is enabled
    When user enters amount "41"
    Then user sees simulated 20% fee discount
    When user enters amount "42"
    Then user sees error state
    When user enters amount "43"
    Then user sees loading state

Screenshots/Recordings

Before

  • No rewards integration
  • Standard fees without discounts
  • No points estimation

After

  • Fee discount displayed with fox icon and percentage
  • Points estimation with animated fox icon
  • Error states with tooltips
  • Proper alignment and design system compliance
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-09-16.at.20.55.00.mp4

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.

- Resolve merge conflicts in PerpsOrderView, perpsConfig, HyperLiquidProvider
- Migrate from direct API calls to RewardsController pattern
- Add CAIP-10 account formatting for Arbitrum perps
- Integrate fee discount display based on MetaMask Points tier
- Add points estimation for perps trading activities
- Remove direct REWARDS_API_CONFIG usage
- Keep main's cleaner logging and formatPerpsFiat utilities
- Maintain non-blocking rewards features with graceful fallbacks
- Remove broken REWARDS_API_CONFIG imports
- Migrate fetchFeeDiscount to use RewardsController:getPerpsDiscountForAccount
- Migrate estimatePoints to use RewardsController:estimatePoints
- Add proper CAIP-10 account formatting for Arbitrum (eip155:42161)
- Simplify EstimatePointsDto structure to match controller interface
- Maintain caching behavior and error handling
- Enable points estimation display for manual validation

This fixes the broken points estimation that was preventing users from
seeing estimated points before placing perps orders as per TASK_CALLDL_REWARDS.md
@github-actions
Copy link
Contributor

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.

@metamaskbot metamaskbot added the team-perps Perps team label Sep 16, 2025
@MetaMask MetaMask deleted a comment from pramot999 Sep 16, 2025
@github-actions github-actions bot added size-XL and removed size-L labels Sep 16, 2025
@abretonc7s abretonc7s marked this pull request as ready for review September 16, 2025 12:56
@abretonc7s abretonc7s requested review from a team as code owners September 16, 2025 12:56
@MetaMask MetaMask deleted a comment from pramot999 Sep 16, 2025
@abretonc7s abretonc7s changed the title Perps/feat/rewards feat(perps): integrate MetaMask Points rewards and fee discounts for Perps trading Sep 16, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

- Add comprehensive edge case tests to FoxIcon.test.tsx
- Fix ESLint errors: replace 'any' types with proper typing
- Fix non-null assertion with optional chaining
- Add missing Engine mock for rewards controller
- Fix import/export style in usePerpsRewards.test.ts
- Add newline at end of test files for eslint compliance
- Complete test coverage improvements following unit testing guidelines
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@sonarqubecloud
Copy link

@abretonc7s abretonc7s added this pull request to the merge queue Sep 18, 2025
Merged via the queue into main with commit 61eab45 Sep 18, 2025
86 of 87 checks passed
@abretonc7s abretonc7s deleted the perps/feat/rewards branch September 18, 2025 11:28
@github-actions github-actions bot locked and limited conversation to collaborators Sep 18, 2025
@metamaskbot metamaskbot added the release-7.57.0 Issue or pull request that will be included in release 7.57.0 label Sep 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

No QA Needed Apply this label when your PR does not need any QA effort. release-7.57.0 Issue or pull request that will be included in release 7.57.0 size-XL team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants