Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor and unify low return warning #29918

Merged
merged 13 commits into from
Jan 30, 2025

Conversation

bfullam
Copy link
Contributor

@bfullam bfullam commented Jan 27, 2025

Description

Users are experiencing issues with receiving significantly lower amounts of destination tokens than expected during swaps. This is due to excessive price differentials between the estimated swap amount and the actual return. Currently, the logic for triggering a low return warning differs between swaps and bridges, leading to inconsistencies and user confusion.

This PR brings swap to parity with bridge by adding a warning when a swap results in a return below 80% of the value of the source tokens.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to swaps
  2. Select tokens and input amount to force warning (eg. 0.01 ETH to ENA)
  3. See warning

Screenshots/Recordings

Before

Screenshot 2025-01-27 at 19 55 48

After

Screenshot 2025-01-27 at 19 55 18

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.

Copy link
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.

@metamaskbot
Copy link
Collaborator

Builds ready [ca439f6]
Page Load Metrics (1786 ± 110 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint29523931628445214
domContentLoaded142223821760230111
load142923961786230110
domInteractive18131462914
backgroundConnect892322512
firstReactRender1673372311
getState5401184
initialActions01000
loadScripts101318751294208100
setupStore684192311
uiStartup162426332030253121
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 42 Bytes (0.00%)
  • common: 20 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [6c2cc08]
Page Load Metrics (1805 ± 76 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15452150181216278
domContentLoaded15372136177615273
load15462153180515976
domInteractive2399442010
backgroundConnect980352612
firstReactRender1688372311
getState574272311
initialActions01000
loadScripts10821570130311756
setupStore96020199
uiStartup17022467209119594
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.5 KiB (0.02%)
  • common: 117 Bytes (0.00%)

),
)
: false;
setIsEstimatedReturnLow(isEstimatedReturnLow);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe better to import this logic from a util file?

ghgoodreau
ghgoodreau previously approved these changes Jan 27, 2025
Copy link
Contributor

@ghgoodreau ghgoodreau left a comment

Choose a reason for hiding this comment

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

approved with nit

@metamaskbot
Copy link
Collaborator

Builds ready [bcdc0de]
Page Load Metrics (1873 ± 125 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30421661581551265
domContentLoaded151025681847259125
load152025831873260125
domInteractive25131472814
backgroundConnect978342211
firstReactRender1596442713
getState594222311
initialActions01000
loadScripts105818701347207100
setupStore960252110
uiStartup175629232203338162
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: -1.34 KiB (-0.02%)
  • common: 3.04 KiB (0.03%)

@metamaskbot
Copy link
Collaborator

Builds ready [f77e3a4]
Page Load Metrics (1993 ± 81 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint40222701822498239
domContentLoaded17052256195617082
load17162279199316981
domInteractive27107462311
backgroundConnect1092372713
firstReactRender18102503115
getState765262311
initialActions01000
loadScripts12231737145214670
setupStore890232311
uiStartup200830142348248119
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: -1.34 KiB (-0.02%)
  • common: 3.04 KiB (0.03%)

@metamaskbot
Copy link
Collaborator

Builds ready [44c1587]
Page Load Metrics (2011 ± 131 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint27524671742651313
domContentLoaded142224171985264127
load143224642011272131
domInteractive2410845189
backgroundConnect977292110
firstReactRender16101492813
getState464272110
initialActions01000
loadScripts102317721460220106
setupStore899232311
uiStartup164632872353349167
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: -1.34 KiB (-0.02%)
  • common: 3.05 KiB (0.03%)

@metamaskbot
Copy link
Collaborator

Builds ready [981a5e3]
Page Load Metrics (1641 ± 71 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint55318601574265127
domContentLoaded14241990161414972
load14521996164114771
domInteractive25101432311
backgroundConnect106627199
firstReactRender1670332211
getState56417199
initialActions01000
loadScripts10141458117812158
setupStore896222713
uiStartup164624931920217104
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: -1.34 KiB (-0.02%)
  • common: 3.05 KiB (0.03%)

@bfullam bfullam marked this pull request as ready for review January 29, 2025 15:37
@bfullam bfullam requested a review from a team as a code owner January 29, 2025 15:37
@bfullam bfullam enabled auto-merge January 29, 2025 15:37
@bfullam bfullam added this pull request to the merge queue Jan 30, 2025
Merged via the queue into main with commit 5f76d25 Jan 30, 2025
72 checks passed
@bfullam bfullam deleted the MMS-1851-refactor-and-unify-low-return-warning branch January 30, 2025 16:48
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2025
@metamaskbot metamaskbot added the release-12.12.0 Issue or pull request that will be included in release 12.12.0 label Jan 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.12.0 Issue or pull request that will be included in release 12.12.0 team-swaps
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants