Commit 61eab45
feat(perps): integrate MetaMask Points rewards and fee discounts for Perps trading (#19808)
## **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:
- [TAT-1221](https://consensyssoftware.atlassian.net/browse/TAT-1221)
- [TAT-1223](https://consensyssoftware.atlassian.net/browse/TAT-1223)
- [TAT-1226](https://consensyssoftware.atlassian.net/browse/TAT-1426)
## **Manual testing steps**
```gherkin
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
https://github.com/user-attachments/assets/6101166d-0565-4859-b37b-6d1569bc0afd
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
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.
---
[TAT-1221]:
https://consensyssoftware.atlassian.net/browse/TAT-1221?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
---------
Co-authored-by: Rik Van Gulck <vangulckrik@gmail.com>1 parent 363cd23 commit 61eab45
File tree
50 files changed
+5809
-458
lines changed- app
- components/UI
- Bridge/hooks/useRewardsIconAnimation
- Perps
- Views
- PerpsClosePositionView
- PerpsOrderView
- __mocks__
- components
- FoxIcon
- PerpsBottomSheetTooltip
- content
- PerpsFeesDisplay
- RewardPointsDisplay
- constants
- controllers
- providers
- types
- hooks
- utils
- core/Engine/controllers/rewards-controller
- services
- locales/languages
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
50 files changed
+5809
-458
lines changedLines changed: 142 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
402 | 544 | | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
56 | 67 | | |
57 | 68 | | |
58 | 69 | | |
| |||
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| 85 | + | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| 132 | + | |
130 | 133 | | |
131 | 134 | | |
132 | 135 | | |
| |||
161 | 164 | | |
162 | 165 | | |
163 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
164 | 170 | | |
165 | 171 | | |
166 | 172 | | |
| |||
Lines changed: 24 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
| |||
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
181 | 196 | | |
182 | 197 | | |
183 | 198 | | |
| |||
469 | 484 | | |
470 | 485 | | |
471 | 486 | | |
472 | | - | |
473 | | - | |
474 | | - | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
475 | 494 | | |
476 | 495 | | |
477 | 496 | | |
| |||
744 | 763 | | |
745 | 764 | | |
746 | 765 | | |
| 766 | + | |
| 767 | + | |
747 | 768 | | |
748 | 769 | | |
749 | 770 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
103 | 106 | | |
104 | 107 | | |
0 commit comments