fix: rounds down the min received amount in swaps
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
- [ ] I’ve followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards.
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using JSDoc format if applicable
- [ ] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
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
formatMinimumReceivedinutils/currencyUtilsto floor values to 8 decimals and format via locale.- Add tests in
utils/currencyUtils.test.tscovering flooring behavior, string parsing, invalid input, and locale usage.- UI:
- Update
components/QuoteDetailsCard/QuoteDetailsCard.tsxto useformatMinimumReceivedfor displayingminimum_received, replacing direct intl formatting.Written by Cursor Bugbot for commit f7abb276748a8dba075b2e06ed395c1a58d51e62. This will update automatically on new commits. Configure here.
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.
🔍 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:
- A new
formatMinimumReceived()function incurrencyUtils.tsthat floors values to 8 decimal places to ensure users never see a minimum higher than they might receive - Refactoring
QuoteDetailsCard.tsxto use this new centralized utility function - 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.
Quality Gate passed
Issues
3 New issues
0 Accepted issues
Measures
0 Security Hotspots
100.0% Coverage on New Code
0.0% Duplication on New Code