Skip to content

feat: read stablecoins from stable-tokens LD flag in useTokenFiatRates cp-8.3.0#33251

Merged
jpuri merged 8 commits into
mainfrom
feat/stable-tokens-flag-useTokenFiatRates
Jul 16, 2026
Merged

feat: read stablecoins from stable-tokens LD flag in useTokenFiatRates cp-8.3.0#33251
jpuri merged 8 commits into
mainfrom
feat/stable-tokens-flag-useTokenFiatRates

Conversation

@jpuri

@jpuri jpuri commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Description

On MM Pay UI read stablecoins from stable-tokens LD flag.

Changelog

CHANGELOG entry:

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1671

Manual testing steps

NA

Screenshots/Recordings

NA

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 how USD fiat rates and MM Pay deposit prefills are computed; wrong flag or route data could mis-price tokens or prefill amounts, though defaults mirror prior behavior.

Overview
Stablecoin fiat pricing no longer uses a hardcoded per-chain address map in useTokenFiatRates. It now reads selectStablecoins from the remote stable-tokens LaunchDarkly flag (with the previous addresses as defaults and normalization for invalid flag shapes).

Deposit prefill (100% vs 50% of balance) switches from isStablecoin in token.ts to isRouteToken in relayFixedSpread, which treats a pay token as “stable” when it appears on any relay fixed-spread route as source or target. That helper is new; isStablecoin is removed from token.ts. Related hooks/tests are updated accordingly.

The stable-tokens flag is registered in the feature-flag registry (remote, not in prod by default).

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

@jpuri jpuri added team-confirmations Push issues to confirmations team no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed labels Jul 14, 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 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

🧪 Flaky unit test detection

✅ All previously detected unit test flakiness issues in this PR have been fixed.

View recent run history

This check is informational only and does not block merging.

@jpuri jpuri force-pushed the feat/stable-tokens-flag-useTokenFiatRates branch from e3f7f02 to 5a4a6b0 Compare July 14, 2026 12:25
@jpuri jpuri marked this pull request as ready for review July 14, 2026 13:44
@jpuri jpuri requested review from a team as code owners July 14, 2026 13:44
@jpuri jpuri enabled auto-merge July 14, 2026 13:44
@github-actions github-actions Bot added the risk:high AI analysis: high risk label Jul 14, 2026

@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 2 potential issues.

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 ecd1bb7. Configure here.

Comment thread app/selectors/featureFlagController/stableTokens/index.ts
@socket-security

socket-security Bot commented Jul 14, 2026

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@jpuri jpuri changed the title feat: read stablecoins from stable-tokens LD flag in useTokenFiatRates feat: read stablecoins from stable-tokens LD flag in useTokenFiatRates cp-8.3.0 Jul 14, 2026
jpuri added 6 commits July 15, 2026 17:50
Replace the hardcoded STABLECOINS constant in useTokenFiatRates with a selectStablecoins Redux selector that reads the stable-tokens LaunchDarkly flag, normalizing addresses to lowercase and falling back to the previous defaults when absent.
Move the stablecoin-check logic into relayFixedSpread.ts as isRouteToken and remove the now-unused isStablecoin from token.ts. useDepositPrefillAmount and its tests updated accordingly.
@OGPoyraz OGPoyraz force-pushed the feat/stable-tokens-flag-useTokenFiatRates branch from ecd1bb7 to e691927 Compare July 15, 2026 14:52
@github-actions github-actions Bot added risk:medium AI analysis: medium risk and removed risk:high AI analysis: high risk labels Jul 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The PR makes the following changes:

  1. New selectStablecoins selector (feature-flag-driven): Moves stablecoin list from a hardcoded constant in useTokenFiatRates.ts to a remote feature flag (stable-tokens), with the same hardcoded values as defaults. This affects how token fiat rates are computed in confirmations — stablecoins get a 1:1 USD rate instead of market rate.

  2. useTokenFiatRates.ts refactor: Now reads stablecoins from the Redux store via selectStablecoins instead of a local constant. The logic is functionally equivalent when the feature flag is not set (defaults match old hardcoded values), but the data source is now dynamic.

  3. isStablecoinisRouteToken rename/refactor: The isStablecoin function in token.ts is removed and replaced by isRouteToken in relayFixedSpread.ts. The new function uses addressesEqual for comparison (case-insensitive), which is more robust than the old string comparison. This affects useDepositPrefillAmount.ts which determines whether to prefill 100% (stablecoin) or 50% (non-stablecoin) of balance for deposits.

Tag selection rationale:

  • SmokeConfirmations: useTokenFiatRates is used in pay-token-amount components and other confirmation hooks. The stablecoin detection change affects fiat rate display in transaction confirmations.
  • SmokeMoney: useDepositPrefillAmount and useTransactionCustomAmount are directly used in MetaMask Card deposit flows. The prefill percentage logic (100% vs 50%) is critical for the deposit UX.
  • SmokeStake: Lending deposit flows also use confirmation components and may be affected by the token fiat rate changes.

The feature flag registry change is a test infrastructure addition that registers the new stable-tokens flag — no functional risk on its own.

Performance Test Selection:
The changes are refactors of stablecoin detection logic (moving from hardcoded constants to a feature flag selector) and deposit prefill amount calculation. These are not performance-sensitive paths — they involve simple selector lookups and array comparisons. No performance test tags are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@jpuri jpuri added this pull request to the merge queue Jul 16, 2026
Merged via the queue into main with commit dd7bf15 Jul 16, 2026
279 of 282 checks passed
@jpuri jpuri deleted the feat/stable-tokens-flag-useTokenFiatRates branch July 16, 2026 06:25
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 16, 2026
@metamask-ci metamask-ci Bot added the release-8.4.0 Issue or pull request that will be included in release 8.4.0 label Jul 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-8.4.0 Issue or pull request that will be included in release 8.4.0 risk:medium AI analysis: medium risk size-M team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants