Commit 74325fd
feat(rewards): expose VIP perps fee discount via getPerpsDiscountForAccount (#30024)
## Summary
Keep the existing `RewardsController.getPerpsDiscountForAccount`
contract (still returns a discount in basis points; perps still applies
it via `metamaskFeeRate = base * (1 - discount/10000)`), and only swap
*how* the discount is derived. When the account's active subscription
has `features.vip.enabled === true`, the controller calls the new
authenticated `GET /vip/fees`, reads `hyperliquid.builderFeeBips`, and
converts it to a discount fraction using the base fee the caller passes
in. Non-VIP accounts now receive a 0 discount; the legacy
`/public/rewards/perps-fee-discount` endpoint and its data-service
method are removed.
Targets [#29888
(`vip-feature-icon-menu`)](#29888)
because it relies on the new `SubscriptionDto.features.vip.enabled` flag
and the per-subscription VIP state introduced there.
- Adds `RewardsDataService.getVipFees` (auth'd, mirrors
[va-mmcx-rewards#546](consensys-vertical-apps/va-mmcx-rewards#546)
DTOs)
- Adds per-subscription cache slot `RewardsControllerState.vipPerpsFees`
(5-min TTL; stores raw bips so the cache is independent of
`baseFeeBips`)
- Extends `getPerpsDiscountForAccount(account, baseFeeBips)` — perps
callers pass `BUILDER_FEE_CONFIG.MaxFeeDecimal * BASIS_POINTS_DIVISOR`
so the controller stays a pure transformer (no perps constant import
inside rewards)
- Removes `getPerpsDiscount` data service method,
`RewardsDataServiceGetPerpsDiscountAction`, `#getPerpsFeeDiscountData`,
`GetPerpsDiscountDto`, `PerpsDiscountData`
- Simplifies `getHasAccountOptedIn` to rely on cached state only
- Updates the three perps call sites (`RewardsIntegrationService`,
`usePerpsOrderFees`, `usePerpsCloseAllCalculations`) and the mobile
infrastructure adapter
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: null
## Screenshots
- Opening position (tier with 5 perps bips fee, so 50 percent discount)
<img width="464" height="877" alt="Screenshot_2026-05-12_13-45-27"
src="https://github.com/user-attachments/assets/359fdefb-9234-43d0-83f4-88509822469d"
/>
<img width="466" height="910" alt="Screenshot_2026-05-12_13-45-36"
src="https://github.com/user-attachments/assets/943fbbad-88d2-4d2d-b984-98e090f5ead1"
/>
- Opening position (tier with 0.5 perps bips fee so 95 percent discount)
<img width="464" height="877" alt="Screenshot_2026-05-12_13-41-57"
src="https://github.com/user-attachments/assets/af76267b-2001-4faf-96f4-1d8d4f4c60c5"
/>
<img width="464" height="877" alt="Screenshot_2026-05-12_13-42-02"
src="https://github.com/user-attachments/assets/cd8c0475-9800-4d9f-a52e-b8192d10a0d2"
/>
- Closing position (tier with 5 perps bip fee, so 50 percent discount)
<img width="472" height="936" alt="image"
src="https://github.com/user-attachments/assets/a5462f66-b5a7-470d-a570-e64de9c68e90"
/>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes the perps fee-discount source and contract (adds
`baseFeeBips`, introduces `null` for unhydrated/failed VIP lookups),
which can affect fee calculations and caching behavior across perps UI
flows.
>
> **Overview**
> Perps fee discounts are now derived from VIP subscription data:
`RewardsController.getPerpsDiscountForAccount(account, baseFeeBips)`
calls a new authenticated `GET /vip/fees`, converts the returned
absolute VIP builder fee into a discount fraction vs the caller-provided
base fee, and caches the raw VIP builder fee per subscription
(`vipPerpsFees`, 5‑min TTL).
>
> The legacy public perps-discount endpoint and related
data-service/action/types/caching logic are removed, and
`getHasAccountOptedIn` no longer falls back to perps-discount API calls.
>
> All perps call sites (`RewardsIntegrationService`,
`usePerpsOrderFees`, `usePerpsCloseAllCalculations`,
`mobileInfrastructure`) are updated to pass `baseFeeBips` and to treat
`null` as *unhydrated/unavailable* (don’t cache; retry on subsequent
calculations), with new tests covering these cases and VIP fee
edge-condition handling.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
cb9ccbc. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: sophieqgu <sophieqgu@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent de98c47 commit 74325fd
19 files changed
Lines changed: 782 additions & 759 deletions
File tree
- app
- components/UI/Perps
- adapters
- hooks
- controllers/perps
- services
- types
- core/Engine
- controllers/rewards-controller
- services
- messengers/rewards-controller-messenger
- util/test
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
219 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
220 | 222 | | |
221 | 223 | | |
222 | 224 | | |
223 | | - | |
| 225 | + | |
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
| 309 | + | |
308 | 310 | | |
309 | 311 | | |
310 | 312 | | |
| |||
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 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 | + | |
493 | 534 | | |
494 | 535 | | |
495 | 536 | | |
| |||
Lines changed: 32 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
| |||
143 | 149 | | |
144 | 150 | | |
145 | 151 | | |
146 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
150 | | - | |
151 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
152 | 165 | | |
153 | 166 | | |
154 | 167 | | |
| |||
188 | 201 | | |
189 | 202 | | |
190 | 203 | | |
| 204 | + | |
191 | 205 | | |
192 | 206 | | |
193 | 207 | | |
194 | 208 | | |
195 | 209 | | |
196 | 210 | | |
197 | 211 | | |
198 | | - | |
199 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
200 | 226 | | |
201 | 227 | | |
202 | 228 | | |
| |||
214 | 240 | | |
215 | 241 | | |
216 | 242 | | |
217 | | - | |
| 243 | + | |
218 | 244 | | |
219 | 245 | | |
220 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
497 | 497 | | |
498 | 498 | | |
499 | 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 | + | |
500 | 532 | | |
501 | 533 | | |
502 | 534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
182 | 184 | | |
183 | 185 | | |
184 | 186 | | |
185 | | - | |
186 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
187 | 198 | | |
188 | 199 | | |
189 | 200 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
92 | 110 | | |
93 | 111 | | |
94 | 112 | | |
| |||
Lines changed: 21 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
118 | 122 | | |
119 | 123 | | |
120 | 124 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
124 | 142 | | |
125 | 143 | | |
126 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1589 | 1589 | | |
1590 | 1590 | | |
1591 | 1591 | | |
1592 | | - | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
1593 | 1598 | | |
1594 | 1599 | | |
1595 | 1600 | | |
1596 | | - | |
| 1601 | + | |
| 1602 | + | |
1597 | 1603 | | |
1598 | 1604 | | |
1599 | 1605 | | |
| |||
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
175 | 180 | | |
176 | 181 | | |
177 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
178 | 187 | | |
179 | 188 | | |
180 | 189 | | |
| |||
0 commit comments