Skip to content

feat(swaps): show fee rebate banner in Swaps and Quick Buy (SWAPS-5196) - #37623

Merged
bfullam merged 7 commits into
mainfrom
swaps-5196-musd-rebate-row
Oct 16, 2026
Merged

bfullam merged 7 commits into
mainfrom
swaps-5196-musd-rebate-row

Conversation

@bfullam

@bfullam bfullam commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a fee rebate banner, "You’re getting X% back on fees", directly above the CTA in the Swaps market order footer and in Quick Buy. Quick Buy covers both regular and "Copy trade" entries. Users who are eligible for a rebate (from the rebate test or a referral offer) see what share of the MetaMask fee they'll get back. Rebates are paid to the user's Money account.

How it works:

  • useSwapsRebate hook: calls RewardsMoneyController:getSwapsRebateQuote (#37251) with the selected quote.
    • It calls once when the screen opens and again only when the MetaMask fee token changes, never on quote refresh.
    • It returns rebateBips / 100, but only when eligible is true and reason is null.
    • Any error hides the banner and is not retried: 400, 401, 404, 413, 429, 503, a timeout, or the Rewards Money feature being disabled. This follows the ticket's error handling.
  • RebateBanner component: a shared banner made from design-system components, the existing money-balance.svg icon and the standard tooltip sheet. It renders nothing when there's no rebate.
  • Placement:
    • Swaps: BridgeMarketViewFooter, above the Confirm button.
    • Quick Buy: QuickBuyActionFooter, between "Pay with" and the Buy button.
  • Feature flag: the whole feature is behind the version-gated swapsRebateBannerEnabled LaunchDarkly flag ({ enabled, minimumVersion }), which defaults to off. When it's off, the endpoint isn't called and no banner renders. The flag isn't in LaunchDarkly yet, so it's registered as inProd: false in feature-flag-registry.ts. Update that entry once the flag is created.

Out of scope: the Perps UI and the Social team's post-trade card.

Changelog

CHANGELOG entry: Added a fee rebate banner to Swaps and Quick Buy for users eligible for a MetaMask fee rebate

Related issues

Fixes: SWAPS-5196

Manual testing steps

Until the endpoint is live, test by temporarily replacing the controller call in useSwapsRebate.ts with Promise.resolve({ product: 'swaps', eligible: true, rebateBips: 1000, reason: null }).

Feature: Fee rebate banner

  Scenario: eligible user sees the rebate banner in Swaps
    Given the user is eligible for a fee rebate
    When user enters an amount on the Swaps screen and a quote with a MetaMask fee loads
    Then a "You’re getting 10% back on fees" banner is shown above the Confirm button
    And tapping the info icon opens the "Trading Rewards" tooltip

  Scenario: eligible user sees the rebate banner in Quick Buy
    Given the user is eligible for a fee rebate
    When user opens Quick Buy (regular or Copy trade) and enters an amount
    Then a "You’re getting 10% back on fees" banner is shown above the Buy button

  Scenario: ineligible user or failed request
    Given the rebate quote returns eligible false, a non-null reason, or an error
    When user gets a quote in Swaps or Quick Buy
    Then no rebate banner is shown and the flow is otherwise unchanged

  Scenario: quote refresh does not refetch the rebate
    Given the rebate banner is shown
    When the quote refreshes with the same fee token
    Then the rebate quote endpoint is not called again

Screenshots/Recordings

Before

No rebate banner.

After

To be added once the banner has been tested against the live endpoint with final copy.

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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.

Note

Low Risk
Additive, flag-gated UI that fails closed (no banner on errors) and does not alter swap or payment execution.

Overview
Adds a fee rebate banner (“You’re getting X% back on fees”) above the confirm CTA in Swaps (BridgeMarketViewFooter) and Quick Buy (QuickBuyActionFooter), including copy-trade.

A new useSwapsRebate hook loads eligibility via RewardsMoneyController:getSwapsRebateQuote when the version-gated remote flag swapsRebateBannerEnabled is on. It refetches only when the MetaMask fee token changes (not on quote refresh), converts eligible rebateBips to a percent, and returns null on ineligible responses or errors so the trade flow stays unchanged. RebateBanner renders the message and an info tooltip using new bridge.rebate_* strings.

Registers the flag in the feature-flag registry (default off, inProd: false) and adds unit tests for the hook, banner, and selector; parent footer tests mock the banner.

Reviewed by Cursor Bugbot for commit 7cd9138. Bugbot is set up for automated code reviews on this repo. Configure here.

@bfullam bfullam self-assigned this Oct 15, 2026
@github-actions

Copy link
Copy Markdown
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.

@github-actions github-actions Bot added size-M pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. labels Oct 15, 2026
@metamask-ci metamask-ci Bot added the team-swaps-and-bridge Swaps and Bridge team label Oct 15, 2026
@bfullam bfullam added the DO-NOT-MERGE Pull requests that should not be merged label Oct 15, 2026
@metamask-ci

metamask-ci Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Pre-merge author checklist has unchecked items (e.g. "I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors."). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Flaky unit test detection

No same-SHA fail-then-pass history and no flaky pattern found for the 5 modified unit test files in the inspected range.

History coverage incomplete: 2026-09-12 to 2026-10-15, 34 day(s), 9480 ci run(s). 26 day(s) inside the window were never fully walked. Nothing was found in the covered range, but this is not an all-clear.

See the flaky-test-detection skill.

@bfullam bfullam removed DO-NOT-MERGE Pull requests that should not be merged pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. labels Oct 16, 2026
@bfullam
bfullam marked this pull request as ready for review October 16, 2026 10:12
@bfullam
bfullam requested review from a team as code owners October 16, 2026 10:12
@bfullam
bfullam enabled auto-merge October 16, 2026 10:12
GeorgeGkas
GeorgeGkas previously approved these changes Oct 16, 2026
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Smart E2E Test Selection

Selected E2E tags: ALL

Selected Performance tags: @PerformanceSwaps

AI Confidence: 100

E2E reasoning

Expand to read

The PR adds a new rebate banner feature used in both Bridge and Quick Buy trading flows, plus a new remote feature flag and locale strings. The banner is rendered in the Bridge market footer and Quick Buy footer, so the impacted user journeys are swap/bridge entry, quote display, and transaction confirmation. Per tag rules, SmokeSwap covers swap/bridge trading flows and requires SmokeConfirmations; SmokeWalletPlatform is also relevant because the change touches wallet actions entry surfaces and activity/trading platform UI. I am not selecting unrelated account/network/onboarding tags because the diff is localized to trading UI and feature-flagged banner behavior.

Performance reasoning

Expand to read

The change adds UI and selector work directly on the swap/bridge quote path and Quick Buy footer, which can affect swap flow rendering and quote/CTA responsiveness. @PerformanceSwaps is the only performance tag aligned with quote fetching, token selection, swap execution, and transaction completion times.

View run

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@github-actions

Copy link
Copy Markdown
Contributor

⚡ Performance Test Results

ℹ️ Performance test results are currently non-blocking and will not block this PR.

✅ All tests passed · 2 tests · 1 device

📱 Devices tested (1)

Android: Google Pixel 8 Pro (v14.0)

✅ Passed Tests (2)
Test Platform Device Duration Team Recording
Cross-chain swap flow - ETH to SOL - 50+ accounts, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 5.48s @swap-bridge-dev-team 📹 Watch
Swap flow - ETH to LINK, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 1.54s @swap-bridge-dev-team 📹 Watch

Branch: swaps-5196-musd-rebate-row · Build: E2E · Commit: f206180 · View full run

@bfullam
bfullam added this pull request to the merge queue Oct 16, 2026
Merged via the queue into main with commit 61bdf49 Oct 16, 2026
119 of 120 checks passed
@bfullam
bfullam deleted the swaps-5196-musd-rebate-row branch October 16, 2026 11:47
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 16, 2026
@metamask-ci metamask-ci Bot added the release-8.18.0 Issue or pull request that will be included in release 8.18.0 label Oct 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.18.0 Issue or pull request that will be included in release 8.18.0 size-M team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants