Skip to content

feat(rewards): expose swaps and perps rebate quotes - #37251

Merged
sophieqgu merged 2 commits into
mainfrom
feat/rewards-money-rebate-quote
Oct 7, 2026
Merged

sophieqgu merged 2 commits into
mainfrom
feat/rewards-money-rebate-quote

Conversation

@sophieqgu

@sophieqgu sophieqgu commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

Exposes the money service POST /earnings/rebate/quote through RewardsMoneyController, the same way /vip/fees is reached through RewardsController.

Swaps and perps each get their own method so a confirmation screen does not have to learn the other product's body. getSwapsRebateQuote sends the bridge quote's feeData.metabridge, which is all the backend reads. getPerpsRebateQuote sends an optional trade, and drops a trade that would not pass the backend's format checks. Both share one data-service POST. The answer is not cached: swaps eligibility depends on the fee token, and the rate has to disappear when an operator ends a window.

A quote that is not eligible stays a normal response (eligible: false and a reason). A refused request, or a 200 whose body is not a quote, is a RewardsMoneyRebateQuoteError, so a validation failure, a rate limit, and the in-flight shed stay distinct. A 401 stays a RewardsMoneyAuthorizationError. A timeout is a plain Error.

The endpoint is on money main but not deployed to DEV, UAT, or PRD yet (Argo promotion freeze). Until it is, every call answers 404, which surfaces as RewardsMoneyRebateQuoteError with failure: 'FAILED'. A screen that consumes these methods has to wait for that deploy.

Changelog

CHANGELOG entry: null

Related issues

Fixes: no tracked issue — controller wiring for the money rebate quote

Manual testing steps

N/A — no confirmation screen calls these methods yet. Unit tests cover the data-service POST, the product bodies, the feature gate, and the distinct refusal errors.

Screenshots/Recordings

Before

N/A

After

N/A

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.

Confirmation screens need the money service rebate rate, and a validation failure, rate limit, and in-flight shed have to stay distinct from a quote that simply is not eligible.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sophieqgu sophieqgu self-assigned this Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

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 the size-M label Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Smart E2E Test Selection

AI Confidence: 90

E2E reasoning

Expand to read

The PR adds new rebate quote functionality (getSwapsRebateQuote, getPerpsRebateQuote) to the RewardsMoneyController and its data service. All changes are purely additive:

  1. No existing behavior modified: Only new methods, types, and action handlers are added. No existing controller methods, state shape, or messenger wiring is changed.

  2. No UI changes: The new controller methods are intended to be consumed by confirmation screens for swaps/perps, but no UI components are modified in this PR. No existing E2E smoke specs will be affected.

  3. No E2E test references: Searching the codebase confirms no existing smoke specs reference RewardsMoneyController or the new rebate quote methods.

  4. Well-tested at unit level: The PR includes comprehensive unit tests (200+ lines) covering the new rebate quote functionality, including edge cases for rate limiting, validation, and error handling.

  5. Controller is critical path but changes are additive: While RewardsMoneyController is part of Engine (a critical file), the changes only add new action types and methods without touching existing ones. The messenger wiring adds one new allowed action without removing or modifying existing ones.

  6. No regression risk to existing flows: SmokeSwap, SmokePerps, SmokeMoney, and SmokeConfirmations tests are not affected because the new methods are not yet wired into any UI components in this PR.

Running zero E2E smoke tags is appropriate here — the changes are backend controller additions with no UI surface impact and no modification to existing behavior.

Performance reasoning

Expand to read

The PR adds new controller methods for fetching rebate quotes. These are network-call-based methods that will be invoked from confirmation screens (not yet wired in this PR). No rendering code, Redux state shape, selector memoization, or UI component is changed. There is no impact on app launch, login, account list, swap flow performance, or any other measured performance scenario. No performance test tags are warranted.

View run

@sophieqgu
sophieqgu marked this pull request as ready for review October 7, 2026 01:43
@sophieqgu
sophieqgu requested a review from a team as a code owner October 7, 2026 01:43
@VGR-GIT VGR-GIT added the team-rewards Rewards team label Oct 7, 2026
Type the swaps quote as the bridge-controller Quote (V1 or V2) and send
only its feeData.metabridge, so passing the whole QuoteResponse is a type
error instead of a silent FEE_TOKEN_NOT_ELIGIBLE.

Leave out a perps trade the money service would refuse (coin and
notionalUsd checked with its regexes), so an optional field it drops can
no longer turn the quote into a 400.

Refuse a 200 whose body is not a quote as a FAILED quote error, document
that timeouts and network failures reject with a plain Error, and cover
the Retry-After date form, the reason-only fallback and empty error
bodies.
@github-actions github-actions Bot added size-L and removed size-M labels Oct 7, 2026
@VGR-GIT

VGR-GIT commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Pushed b77a864 with a few fixes after checking this against money main:

  • getSwapsRebateQuote now takes the bridge-controller Quote type and only sends feeData.metabridge, which is all the backend reads. Passing a whole QuoteResponse used to come back as FEE_TOKEN_NOT_ELIGIBLE with no error; now it fails the type check.
  • getPerpsRebateQuote drops trade if it wouldn't pass the backend's format checks, so a bad value can't turn the whole quote into a 400.
  • A 200 with an unexpected body now throws RewardsMoneyRebateQuoteError (FAILED) instead of being cast through.
  • JSDoc notes that timeouts come back as a plain Error.
  • More tests: realistic metabridge fixtures, Retry-After as a date, empty error bodies.

I also updated the description (Refs: N/A, plus a note that the endpoint isn't deployed to DEV/UAT/PRD yet) and added team-rewards.

@sonarqubecloud

sonarqubecloud Bot commented Oct 7, 2026

Copy link
Copy Markdown

@sophieqgu
sophieqgu enabled auto-merge October 7, 2026 18:43
@sophieqgu
sophieqgu added this pull request to the merge queue Oct 7, 2026
Merged via the queue into main with commit 17202dd Oct 7, 2026
124 of 127 checks passed
@sophieqgu
sophieqgu deleted the feat/rewards-money-rebate-quote branch October 7, 2026 19:05
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 7, 2026
@metamask-ci metamask-ci Bot added the release-8.16.0 Issue or pull request that will be included in release 8.16.0 label Oct 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-8.16.0 Issue or pull request that will be included in release 8.16.0 size-L team-rewards Rewards team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants