Skip to content

fix: [MUSD-857] show native amount for erc20 money account deposits#30789

Merged
Jwhiles merged 4 commits into
mainfrom
john-musd-857
Jun 4, 2026
Merged

fix: [MUSD-857] show native amount for erc20 money account deposits#30789
Jwhiles merged 4 commits into
mainfrom
john-musd-857

Conversation

@Jwhiles

@Jwhiles Jwhiles commented May 29, 2026

Copy link
Copy Markdown
Contributor

Description

This fixes a bug where we would miscalculate the token value shown for ERC20 token deposits to the money account. The root of the problem was that we calculated the token values assuming an incorrect number of decimal places.

Changelog

CHANGELOG entry: show correct token values for ERC20 token deposits to money account

Related issues

Fixes: musd-857

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

image

After

image

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

Medium Risk
Changes user-visible transaction amounts for Money/Pay deposits and depends on live rates; scope is limited to display logic in the Money activity hook with strong test coverage.

Overview
Fixes MetaMask Pay money-account deposit activity rows where the pay-token primary line was wrong for ERC-20s (e.g. misleading +0.00 LINK for MUSD-857).

useMoneyTransactionDisplayInfo now treats requiredAssets[0].amount as the 6-decimal USD deposit value for every pay token, then divides by that token’s USD price—the same model already used for native ETH. ERC-20 USD price comes from token→ETH market data × ETH→USD via a shared getPayTokenUsdPrice helper; getTokenToEthPrice is exported from moneyActivityFiat for that lookup.

Stablecoins (USDC, USDT, etc.) are priced from the API, not assumed $1; the stable symbol list only drives 2-decimal display vs up to 6 trimmed decimals for other tokens. The primary line is left blank when rates are missing or the computed amount would show as zero, while the fiat line still uses existing logic.

Tests are expanded for USDC (market price, de-peg, no rates), LINK regressions, and related edge cases.

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

@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.

@Jwhiles Jwhiles marked this pull request as ready for review May 29, 2026 10:51
@Jwhiles Jwhiles requested a review from a team as a code owner May 29, 2026 10:51
@github-actions github-actions Bot added the risk:low AI analysis: low risk label May 29, 2026
@codecov-commenter

codecov-commenter commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.77%. Comparing base (716c344) to head (bc52065).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...s/UI/Money/hooks/useMoneyTransactionDisplayInfo.ts 77.77% 2 Missing and 4 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #30789   +/-   ##
=======================================
  Coverage   82.77%   82.77%           
=======================================
  Files        5584     5585    +1     
  Lines      144075   144119   +44     
  Branches    33332    33352   +20     
=======================================
+ Hits       119254   119300   +46     
+ Misses      16874    16866    -8     
- Partials     7947     7953    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 bc52065. Configure here.

maximumFractionDigits: 2,
useGrouping: true,
}).format(amount.toNumber());
return `+${formatted} ${symbol}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stable path shows misleading zero

Medium Severity

In formatPrimaryTokenAmount, USD-pegged stables always format with two fixed decimals and never treat a rounded "0.00" as too small to display. A positive pay-token amount below half a cent (e.g. ~$0.004 USDC) can still render as +0.00 USDC, while the non-stable branch returns an empty primary line for the same “misleading zero” case this PR fixes for tokens like LINK.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bc52065. Configure here.

@Matt561 Matt561 Jun 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A positive pay-token amount below half a cent (e.g. ~$0.004 USDC) can still render as +0.00 USDC,

@cursoragent this seems very unlikely to happen. Additionally, the lowest denomination of USD is a cent so we likely wouldn't want to display sub-cent values. Ultimately a product decision. I think you're overestimating the severity here.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeMoney
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are entirely scoped to the MetaMask Money/Card feature within app/components/UI/Money/. Specifically:

  1. useMoneyTransactionDisplayInfo.ts: Bug fix (MUSD-857) for how token amounts are displayed in the Money activity feed. The fix corrects ERC-20 token display (e.g., LINK showing "+0.00 LINK") by using the Price API (token→ETH × ETH→USD) to convert the 6-decimal USD value into the correct token amount for all pay tokens. New helpers getPayTokenUsdPrice and formatPrimaryTokenAmount were added, along with a USD_PEGGED_STABLE_SYMBOLS set for display formatting.

  2. moneyActivityFiat.ts: Minor change — exports getTokenToEthPrice (previously private) for reuse in the hook.

  3. useMoneyTransactionDisplayInfo.test.ts: Expanded unit tests covering the new pricing logic.

The hook is only consumed by MoneyActivityItem.tsxMoneyActivityList.tsxMoneyActivityView.tsx, all within the Money module. No shared components (TabBar, navigation, confirmations, controllers) are affected. SmokeMoney is the appropriate tag as it covers MetaMask Card and fiat flows including activity display. No other tags are needed since this is a display-only fix in an isolated Money component.

Performance Test Selection:
The changes are limited to display formatting logic in the Money activity feed — computing and formatting token amounts from USD values. No list rendering performance, no state management changes, no app startup or initialization code, and no performance-sensitive data loading paths are affected. Performance tests are not warranted.

View GitHub Actions results

@github-actions github-actions Bot added risk:medium AI analysis: medium risk and removed risk:low AI analysis: low risk labels Jun 2, 2026
@Jwhiles Jwhiles added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit c9a690b Jun 4, 2026
187 of 189 checks passed
@Jwhiles Jwhiles deleted the john-musd-857 branch June 4, 2026 10:46
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 4, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.81.0 Issue or pull request that will be included in release 7.81.0 label Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.81.0 Issue or pull request that will be included in release 7.81.0 risk:medium AI analysis: medium risk size-M team-earn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants