feat: display a warning if the output amount changes on the confirm swap page #943
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
If the user proceeds to the confirm swap page and the output amount differs from the previous quote response, or if the output amount changes when the quote refreshes on the confirm swap page and these changes meet certain criteria, we should display an appropriate warning to prevent potential loss for the user:
usdInput >= 1000 and percentageChange >= 1
usdInput >= 500 and percentageChange >= 2
In this pull request, I also removed some unused code that was previously needed for route update situations. Additionally, I worked on refactoring and cleaning up how we retrieve the USD value of the source or destination token.
How did you test this change?
To test these changes, it’s best to manipulate the quote response in the confirm swap flow, as the real scenario may not occur frequently.
Make this changes to
generateQuoteWarnings
function :Checklist: