Skip to content

fix: only show claim button if there is at least 1 cent of rewards#40444

Merged
Jwhiles merged 1 commit intomainfrom
fix-only-show-claim-for-at-least-1-cent
Mar 2, 2026
Merged

fix: only show claim button if there is at least 1 cent of rewards#40444
Jwhiles merged 1 commit intomainfrom
fix-only-show-claim-for-at-least-1-cent

Conversation

@Jwhiles
Copy link
Copy Markdown
Contributor

@Jwhiles Jwhiles commented Feb 26, 2026

Description

Updates the useMerklRewards hook to only say that there are claimable rewards, if those rewards are at least $0.01 MUSD. Adds tests for the failure case, and the case where we have exactly 1 cent!

Open in GitHub Codespaces

Changelog

CHANGELOG entry: only show claim bonus CTA if there is at least 1 cent to claim

Related issues

Fixes:

Manual testing steps

  1. For an account with less than 1 cent of MUSD to claim - verify that claim bonus CTA is not shown
  2. For an account with more than 1 cent of MUSD to claim - verify that claim bonuis CTA is shown.

Screenshots/Recordings

Before

After

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

Low Risk
Low risk: small UI gating change in useMerklRewards plus unit tests; main risk is edge-case handling for unusual token decimals affecting the 1-cent threshold calculation.

Overview
Updates useMerklRewards to only set hasClaimableReward when unclaimed rewards are at least $0.01 (computed as 10^(decimals-2) base units) instead of any positive amount.

Adds tests to assert sub-cent unclaimed amounts return false and an exact 1-cent amount returns true.

Written by Cursor Bugbot for commit 37b3a22. This will update automatically on new commits. 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.

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 26, 2026

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/metamask-earn (2 files, +67 -1)
  • 📁 ui/
    • 📁 components/
      • 📁 app/
        • 📁 musd/
          • 📁 hooks/
            • 📄 useMerklRewards.test.ts +64 -0
            • 📄 useMerklRewards.ts +3 -1

@Jwhiles Jwhiles marked this pull request as ready for review February 26, 2026 15:55
Copy link
Copy Markdown

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

if (!abortController.signal.aborted) {
setHasClaimableReward(unclaimedBaseUnits > 0n);
const oneCentInBaseUnits =
10n ** BigInt(matchingReward.token.decimals - 2);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Negative BigInt exponent crashes for low-decimal tokens

Low Severity

The expression 10n ** BigInt(matchingReward.token.decimals - 2) throws a RangeError if decimals is 0 or 1, since BigInt exponentiation doesn't support negative exponents. The decimals field comes from an external API (MerklReward.token.decimals typed as number), so there's no compile-time guarantee it's >= 2. While the surrounding try-catch prevents a full crash, it silently causes hasClaimableReward to remain false, hiding legitimate claimable rewards from the user.

Fix in Cursor Fix in Web

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Feb 26, 2026

Builds ready [37b3a22]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account31027337537322375
total31027337537322375
Confirm Txconfirm_tx6119605561694161506169
total6119605561694161506169
Bridge User Actionsbridge_load_page27926130316285303
bridge_load_asset_picker20114424637218246
bridge_search_token73871475715746757
total1251114313717612871371
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup15041260197812115841691
load12681054171011213421449
domContentLoaded12601046167010913351424
domInteractive3217124222792
firstPaint185721268135235320
backgroundConnect22720331717231253
firstReactRender2213227212132
initialActions106124
loadScripts1052833144910911271214
setupStore1574671830
numNetworkReqs312290202285
Power User HomeuiStartup3272154910241201141828771
load12651088180813612891574
domContentLoaded12451075175513012591544
domInteractive3820453463590
firstPaint224801490160281342
backgroundConnect10852707842128513183087
firstReactRender2717201192736
initialActions104112
loadScripts1020864152412710311322
setupStore17663111940
numNetworkReqs81361292398119
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2212212220222222
srpButtonToSrpForm95959509595
confirmSrpToPwForm22222302223
pwFormToMetricsScreen16151601616
metricsToWalletReadyScreen17171701717
doneButtonToHomeScreen704598856110762856
openAccountMenuToAccountListLoaded7657762676792376797679
total8843879288723188608872
Onboarding New WalletcreateWalletToSocialScreen2182172191218219
srpButtonToPwForm1091051133111113
createPwToRecoveryScreen989099
skipBackupToMetricsScreen36353913739
agreeButtonToOnboardingSuccess16161701617
doneButtonToAssetList61647773195671731
total100386811169410611116
Asset DetailsassetClickToPriceChart523773177273
total523773177273
Solana Asset DetailsassetClickToPriceChart50475325153
total50475325153
Import Srp HomeloginToHomeScreen21121895239917321952399
openAccountMenuAfterLogin46444714747
homeAfterImportWithNewWallet22972114244013324392440
total4377434944012244014401
Send TransactionsopenSendPageFromHome331749123949
selectTokenToSendFormLoaded20182212122
reviewTransactionToConfirmationPage86185188615853886
total91488696028911960
SwapopenSwapPageFromHome1069612410111124
fetchAndDisplaySwapQuotes53264583627177362696271
total54324684639578363806395
🌐 Dapp Page Load Benchmarks

Current Commit: 37b3a22 | Date: 2/26/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±47ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 741ms (±36ms) 🟢 | historical mean value: 731ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 83ms (±13ms) 🟢 | historical mean value: 82ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 47ms 1.02s 1.34s 1.09s 1.34s
domContentLoaded 741ms 36ms 714ms 1.00s 764ms 1.00s
firstPaint 83ms 13ms 68ms 200ms 96ms 200ms
firstContentfulPaint 83ms 13ms 68ms 200ms 96ms 200ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 1.6 KiB (0.02%)
  • common: 20 Bytes (0%)

@Matt561 Matt561 self-requested a review February 26, 2026 16:33
@sonarqubecloud
Copy link
Copy Markdown

@Jwhiles Jwhiles added this pull request to the merge queue Mar 2, 2026
Merged via the queue into main with commit c76a8a7 Mar 2, 2026
510 of 520 checks passed
@Jwhiles Jwhiles deleted the fix-only-show-claim-for-at-least-1-cent branch March 2, 2026 16:40
@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2026
@metamaskbot metamaskbot added the release-13.22.0 Issue or pull request that will be included in release 13.22.0 label Mar 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.22.0 Issue or pull request that will be included in release 13.22.0 size-S team-earn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants