Repository navigation
feat(swaps): show fee rebate banner in Swaps (SWAPS-5293) - #47618
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. |
✨ Files requiring CODEOWNER review ✨🔄 @MetaMask/swaps-engineers (5 files, +383 -0)
|
Builds ready [f7cca83]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 3 warn · 🔴 4 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [9d66552]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 2 warn · 🔴 2 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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 592d76f. Configure here.
Builds ready [592d76f]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 3 warn · 🔴 4 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [63cdc7d]
⚡ Performance Benchmarks (Total: 🟢 9 pass · 🟡 1 warn · 🔴 3 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
|
|
No release label on PR. Adding release label release-13.57.0 on PR, as PR was added to branch 13.57.0 when release was cut. |




Description
Adds the fee rebate banner, "You’re getting X% back on fees", directly above the CTA button in Swaps. This mirrors Mobile's implementation (metamask-mobile#37623). Users who are eligible for a rebate see what share of the MetaMask fee they'll get back, paid to their Money account.
How it works:
useSwapsRebatehook: callsRewardsMoneyController:getSwapsRebateQuote(already in the extension) with the active quote, through a route messenger that allows only that action.rebateBips / 100, but only wheneligibleis true andreasonis null.SwapsRebateBanner: shows the message, the existingmoney.pngicon, and a "Trading Rewards" info tooltip. It renders nothing when there's no rebate. The tooltip popover is givenzIndex: 20so it paints above the sticky CTA footer.swapsRebateBannerEnabledremote flag ({ enabled, minimumVersion }), the same key Mobile uses. It defaults to off, and when it's off the endpoint isn't called. The flag is registered asinProd: falseinfeature-flag-registry.ts.Changelog
CHANGELOG entry: Added a fee rebate banner to Swaps for users eligible for a MetaMask fee rebate
Related issues
Fixes: SWAPS-5293
Manual testing steps
Until the endpoint returns a rebate for your account, you can force one by temporarily replacing the controller call in
ui/hooks/bridge/useSwapsRebate.tswithPromise.resolve({ eligible: true, rebateBips: 1000, reason: null }).swapsRebateBannerEnabledremote flag, for example in.manifest-overrides.jsonwith{ "enabled": true, "minimumVersion": "0.0.0" }.eligible: falseor an error, and verify that no banner is shown and the swap flow is unchanged.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Promotional UI behind a remote flag that fails closed; it uses an existing rewards endpoint and does not gate or alter swap execution.
Overview
Adds an optional Trading Rewards banner above the Swaps prepare CTA that tells eligible users what % of the MetaMask fee they’ll get back (paid in mUSD to Money), aligned with Mobile.
The flow is gated by the remote
swapsRebateBannerEnabledflag (defaults off). When enabled,useSwapsRebatecallsRewardsMoneyController:getSwapsRebateQuotevia a scoped route messenger, converts eligiblerebateBipsto a display percentage, and does not block the swap button. Rebates are fetched on mount and only when the MetaMask fee token changes (not on quote refresh); failures or ineligibility hide the banner.SwapsRebateBannerrenders the message, Money icon, and tooltip (with elevated z-index over the sticky footer). New locale strings and unit/component tests cover the hook and banner.Reviewed by Cursor Bugbot for commit 63cdc7d. Bugbot is set up for automated code reviews on this repo. Configure here.