Skip to content

fix: totals in MUSD conversion using max button#26015

Merged
matthewwalsh0 merged 3 commits intomainfrom
fix/metamask-pay-max-totals
Feb 13, 2026
Merged

fix: totals in MUSD conversion using max button#26015
matthewwalsh0 merged 3 commits intomainfrom
fix/metamask-pay-max-totals

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented Feb 12, 2026

Description

Ensure totals are correct for MUSD conversions using Max button.

  • Bump @metamask/transaction-pay-controller and handle breaking changes.
  • Add MUSD, USDC, and USDT on Mainnet and Linea to stablecoin support in useTokenFiatRates.

Changelog

CHANGELOG entry: null

Related issues

Fixes: #25972

Manual testing steps

Screenshots/Recordings

Pre-merge author checklist

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

Medium Risk
Upgrades @metamask/transaction-pay-controller with API changes and alters how Max-state is persisted, which could impact confirmation totals and transaction config behavior across networks.

Overview
Fixes USD totals for stablecoin payments by treating a broader set of stablecoins as having a fixed 1 USD rate in useTokenFiatRates (adds MUSD/USDC/USDT on Mainnet & Linea, plus Polygon USDC.e; replaces per-feature constants with a chain/address allowlist).

Updates useTransactionCustomAmount to reflect breaking changes from bumping @metamask/transaction-pay-controller to ^14.0.0, switching from setIsMaxAmount to setTransactionConfig for toggling isMaxAmount, and adjusts related unit tests/messenger action delegation accordingly.

Written by Cursor Bugbot for commit 9d2309c. This will update automatically on new commits. Configure here.

@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Feb 12, 2026
@matthewwalsh0 matthewwalsh0 changed the title fix: update stablecoin fiat rates and pay controller usage fix: totals in MUSD conversion using max button Feb 12, 2026
@socket-security
Copy link
Copy Markdown

socket-security bot commented Feb 12, 2026

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review February 12, 2026 15:52
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners February 12, 2026 15:52
@matthewwalsh0 matthewwalsh0 force-pushed the fix/metamask-pay-max-totals branch from 8a8a0b1 to 8d1faf4 Compare February 12, 2026 16:10
@nickewansmith nickewansmith self-requested a review February 12, 2026 16:36
@matthewwalsh0 matthewwalsh0 force-pushed the fix/metamask-pay-max-totals branch 2 times, most recently from 7974246 to 6ed2017 Compare February 12, 2026 18:14
joaoloureirop pushed a commit that referenced this pull request Feb 12, 2026
## **Description**

Cherry-pick #26015 into `7.65.0` release.

Applies a Yarn patch to `@metamask/transaction-pay-controller` instead
of bumping controller version to avoid unrelated changes.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: #25972 

## **Manual testing steps**

## **Screenshots/Recordings**

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches transaction-pay quoting/totals and stablecoin detection, which
can affect displayed costs and max-amount behavior across networks;
mitigated by being a targeted patch and limited app-side changes.
> 
> **Overview**
> Fixes transaction pay quote/total calculations by **patching
`@metamask/transaction-pay-controller` 12.1.0** rather than bumping the
dependency.
> 
> The patch centralizes a multi-chain `STABLECOINS` list, treats
stablecoins as $1 in token fiat-rate logic, and changes `targetAmount`
across quotes/totals to be a `FiatValue` summed via `sumFiat` (avoiding
incorrect max/totals math). Relay quote normalization now accounts for
`fees.subsidized` by zeroing provider fees when subsidized and
optionally including the subsidized amount in the computed target fiat
value; Bridge normalization aligns `targetAmount` to fiat-only as well.
> 
> On the mobile side, `useTokenFiatRates` now uses a stablecoin
allowlist (Mainnet/Arbitrum/Linea/Polygon) to return a fixed USD rate of
`1`, and the related unit test is generalized accordingly. The
Transaction Pay controller messenger drops the unused
`TokenListController:getState` action, and `package.json`/`yarn.lock`
are updated to consume the patched controller via Yarn’s `patch:`
protocol.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
61d257e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@nickewansmith nickewansmith changed the title fix: totals in MUSD conversion using max button fix: cp-7.65.0 totals in MUSD conversion using max button Feb 12, 2026
nickewansmith
nickewansmith previously approved these changes Feb 12, 2026
@nickewansmith nickewansmith changed the title fix: cp-7.65.0 totals in MUSD conversion using max button fix: totals in MUSD conversion using max button Feb 12, 2026
OGPoyraz
OGPoyraz previously approved these changes Feb 12, 2026
sleepytanya
sleepytanya previously approved these changes Feb 12, 2026
vinistevam
vinistevam previously approved these changes Feb 12, 2026
@matthewwalsh0 matthewwalsh0 dismissed stale reviews from vinistevam and sleepytanya via 9d2309c February 13, 2026 09:23
@matthewwalsh0 matthewwalsh0 dismissed stale reviews from OGPoyraz and nickewansmith via 9d2309c February 13, 2026 09:23
@matthewwalsh0 matthewwalsh0 force-pushed the fix/metamask-pay-max-totals branch from 6ed2017 to 9d2309c Compare February 13, 2026 09:23
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeCard, SmokePerps, SmokeRamps, SmokeMultiChainAPI, SmokePredictions, FlaskBuildTests
  • Selected Performance tags: @PerformanceAccountList, @PerformanceOnboarding, @PerformanceLogin, @PerformanceSwaps, @PerformanceLaunch, @PerformanceAssetLoading, @PerformancePredict, @PerformancePreps
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/transaction-pay-controller. Running all tests.

Performance Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/transaction-pay-controller. Running all tests.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@matthewwalsh0 matthewwalsh0 added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit 61f4916 Feb 13, 2026
187 of 189 checks passed
@matthewwalsh0 matthewwalsh0 deleted the fix/metamask-pay-max-totals branch February 13, 2026 12:04
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2026
@metamaskbot metamaskbot added the release-7.67.0 Issue or pull request that will be included in release 7.67.0 label Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.67.0 Issue or pull request that will be included in release 7.67.0 size-S team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Total doesn't add up for MAX USD conversion

8 participants