Skip to content

Conversation

@Matt561
Copy link
Contributor

@Matt561 Matt561 commented Dec 5, 2025

Description

Removed hardcoded mainnet target when converting mUSD.

Changes

  • Attempt to convert to mUSD on the same network as the payment token. If mUSD isn't deployed on the payment token's network we fallback to mainnet.
  • Cleaned up repeated hasSeenEducationalScreen logic and centralized into initiateConversion. This way callers don't need to worry about handling educational screen redirects
  • Fixed bug where mUSD conversion CTA on Asset Overview page wasn't being rendered for BSC.

Changelog

CHANGELOG entry: removed hardcoded mainnet output chainId for mUSD conversion flow

Related issues

Fixes: MUSD-106: Support Linea to Linea conversions

Manual testing steps

Feature: mUSD Conversion Flow


  Scenario: User enters mUSD conversion from Asset List CTA with automatic token selection
    Given user has one or more supported stablecoins in their wallet

    When user taps "Get mUSD" button on the Asset List CTA
    Then the supported stablecoin with the highest balance is automatically selected as the payment token
    And mUSD conversion flow is initiated


  Scenario: mUSD conversion targets same network as payment token when supported
    Given user initiates mUSD conversion with a payment token
    And the payment token is on a network where mUSD is deployed

    When the conversion flow determines the target mUSD chain
    Then target mUSD is on the same network as the payment token


  Scenario: mUSD conversion falls back to Ethereum mainnet when payment token network is unsupported
    Given user initiates mUSD conversion with a payment token
    And the payment token is on a network where mUSD is NOT deployed

    When the conversion flow determines the target mUSD chain
    Then target mUSD falls back to Ethereum mainnet

Screenshots/Recordings

Before

mUSD conversion flow was hardcoded to convert to mainnet mUSD.

After

Linea -> Linea swap demo - link

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

Initiates mUSD conversion on the payment token’s chain when supported (fallback to mainnet) and centralizes education-screen handling; updates CTA/Stake flows and related tests.

  • mUSD Conversion Flow
    • Determine outputChainId via useMusdConversionTokens.getMusdOutputChainId, enabling same-network conversions with fallback to mainnet.
    • Centralize education-screen redirect inside useMusdConversion with skipEducationCheck support; callers no longer handle navigation.
    • Remove Relay nestedTransactions from addTransaction options.
  • Hooks
    • useMusdConversionTokens: add getMusdOutputChainId, adjust isMusdSupportedOnChain to accept optional chainId and hex-normalize.
    • useMusdConversion: add education redirect helper, allow skipEducationCheck, simplify transaction options.
  • UI
    • MusdConversionAssetListCta: remove local education routing; use checksum address; compute outputChainId per token’s chain.
    • MusdConversionAssetOverviewCta: compute outputChainId dynamically; call initiateConversion directly.
    • StakeButton: simplify mUSD convert path; compute outputChainId via hook.
    • EarnBalance: treat convertible stablecoins as lending balance when flag enabled.
  • Tests
    • Update expectations to new params (skipEducationCheck, checksummed addresses, dynamic outputChainId).
    • Remove education-navigation path tests from CTAs; adjust mocks accordingly.

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

@Matt561 Matt561 added No QA Needed Apply this label when your PR does not need any QA effort. team-earn labels Dec 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

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-L label Dec 5, 2025
@Matt561 Matt561 force-pushed the feat/musd-106-support-linea-to-linea-conversions branch from 0d0fa33 to 816f05d Compare December 5, 2025 15:29
@Matt561 Matt561 marked this pull request as ready for review December 5, 2025 15:30
@Matt561 Matt561 requested a review from a team as a code owner December 5, 2025 15:30
@github-actions github-actions bot added size-M and removed size-L labels Dec 5, 2025
});
return;
if (!paymentTokenChainId) {
throw new Error('[mUSD Conversion] payment token chainID missing');
Copy link

Choose a reason for hiding this comment

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

Bug: Unhandled throw outside try-catch in handlePress

The throw new Error('[mUSD Conversion] payment token chainID missing') statement at line 66 is outside the try-catch block that starts at line 71. While this defensive check protects against missing paymentTokenChainId, if the condition ever triggers (e.g., due to race conditions or bugs in canConvert logic), the error will be unhandled and could crash the app. Compare with MusdConversionAssetOverviewCta/index.tsx where the similar check is properly wrapped inside the try-catch block starting at line 32.

Fix in Cursor Fix in Web

if (!asset.chainId) return null;

if (isLendingToken || isReceiptToken) {
if (isLendingToken || isReceiptToken || isConvertibleStablecoin) {
Copy link

Choose a reason for hiding this comment

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

Bug: mUSD CTA blocked when stablecoin lending disabled

The new condition || isConvertibleStablecoin routes convertible stablecoins to EarnLendingBalance, but that component has an early return if (!isStablecoinLendingEnabled) return null; on line 179. This means if isMusdConversionFlowEnabled is true but selectStablecoinLendingEnabledFlag is false (these are independent feature flags), convertible stablecoins will be routed to EarnLendingBalance which immediately returns null, preventing the mUSD conversion CTA from ever rendering.

Fix in Cursor Fix in Web

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeStake
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

The changes are focused exclusively on the Earn/Stake functionality, specifically around mUSD (Meta USD) conversion flows:

  1. Scope: All 13 changed files are within app/components/UI/Earn/ or app/components/UI/Stake/ directories, which are clearly staking-related features.

  2. Nature of Changes:

    • Refactoring: The main change is centralizing the education screen redirect logic from individual components (StakeButton, MusdConversionAssetListCta, MusdConversionAssetOverviewCta) into the useMusdConversion hook's initiateConversion function
    • New helper: Added getMusdOutputChainId to determine the correct output chain for mUSD conversion
    • Cleanup: Removed nestedTransactions from transaction options (Relay-related)
    • Bug fix/improvement: Now uses toChecksumAddress for payment token addresses
  3. Risk Assessment - Medium:

    • The changes affect the user flow for mUSD conversion (staking/earning feature)
    • The refactoring centralizes logic which is a common source of bugs if not properly tested
    • However, comprehensive unit tests are included and updated
    • No changes to core engine, controllers, or critical infrastructure
  4. Tag Selection:

    • SmokeStake: This is the primary tag needed as all changes relate to staking/earning functionality, specifically the mUSD conversion user flow
    • The changes don't touch core wallet functionality, accounts, notifications, ramps, swaps, or other distinct features

The changes are contained within the staking domain and include proper unit test updates, making SmokeStake the appropriate tag to validate these changes.

View GitHub Actions results

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
62.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@nickewansmith nickewansmith self-requested a review December 5, 2025 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No QA Needed Apply this label when your PR does not need any QA effort. size-M team-earn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants