metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

fix: rounds down the min received amount in swaps

Open ghgoodreau opened this issue 2 months ago • 3 comments

Description

Changelog

CHANGELOG entry:

Related issues

Fixes:

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

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] Adds a formatter that floors minimum received to 8 decimals and uses it in QuoteDetailsCard, with unit tests.

  • Bridge Utils:
    • Add formatMinimumReceived in utils/currencyUtils to floor values to 8 decimals and format via locale.
    • Add tests in utils/currencyUtils.test.ts covering flooring behavior, string parsing, invalid input, and locale usage.
  • UI:
    • Update components/QuoteDetailsCard/QuoteDetailsCard.tsx to use formatMinimumReceived for displaying minimum_received, replacing direct intl formatting.

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

ghgoodreau avatar Dec 10 '25 03:12 ghgoodreau

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[bot] avatar Dec 10 '25 03:12 github-actions[bot]

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeTrade
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

The changes are focused on a specific utility function for formatting minimum received amounts in the Bridge feature. The modifications include:

  1. A new formatMinimumReceived() function in currencyUtils.ts that floors values to 8 decimal places to ensure users never see a minimum higher than they might receive
  2. Refactoring QuoteDetailsCard.tsx to use this new centralized utility function
  3. Unit tests for the new function

This is a low-risk change because:

  • It's a localized formatting change that doesn't affect core business logic
  • The function has proper unit test coverage
  • The change improves accuracy by flooring instead of standard rounding
  • It's purely a display/UX refinement

The SmokeTrade tag is appropriate as it covers Bridge functionality (verified via bridge-action-smoke.spec.ts which uses SmokeTrade). The QuoteDetailsCard is also referenced by Perps components, but the formatting change primarily impacts the Bridge flow where it's directly integrated.

View GitHub Actions results

github-actions[bot] avatar Dec 10 '25 03:12 github-actions[bot]