Conversation
…ds DI method and carry it through fee resolution and logging, with no new fee source
geositta
force-pushed
the
TAT-4019-rewards-grant
branch
from
October 1, 2026 22:53
d0ab0dd to
794ae4a
Compare
scope fee grants to routed provider preserve exact builder fee quantization
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
10 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
What is the current state of things and why does it need to change?
Perps currently receives VIP, season, and targeted profile grants as one client-combined rewards discount. This couples profile grants to an account-scoped Rewards flow and prevents Core from independently selecting and attributing the winning fee source. Profile grants must work without Rewards opt-in and compete consistently with default, VIP/season, and subscription fees.
What is the solution your changes offer and how does it work?
This change adds an optional getPerpsTradingFeeGrant() platform dependency and a distinct grant fee source. The grant supplies an absolute builder fee and expiry.
Core retrieves VIP/season and grant candidates concurrently, isolates failures, validates the grant after all asynchronous work completes, and selects the cheapest applicable fee at Hyperliquid’s charged precision. Grants are not cached in Core. Older clients that omit the new capability retain their existing behavior.
Are there any changes whose purpose might not be obvious?
VIP/season wins a quantized tie with a grant.
Default wins when a grant does not reduce the charged fee.
Subscription still wins only when strictly cheaper after quantization, preventing allowance consumption on ties.
Zero is a valid grant fee and waives only the builder fee, not protocol fees.
Grant expiry is checked after concurrent VIP retrieval, preventing an expired grant from winning while another request was in flight.
Grant retrieval deliberately has no selected-account or network prerequisite because eligibility belongs to the authenticated profile.
The draft combined RewardsDiscountResponse and targetedDiscountApplied fields are removed because grant attribution now comes from the distinct grant source.
Did updating one package require updating another?
No additional Core package was changed. All changes are contained within @metamask/perps-controller. MetaMask Mobile will require a coordinated follow-up to fetch the grant with the Profile Sync JWT and provide the new optional dependency.
Were any dependencies upgraded?
No dependencies were upgraded. Mobile will later need a Core package build containing this contract before its integration can be completed.
Draft note: quote attribution reconciliation with Core #10650 and Mobile integration are still in progress.
References
Checklist