-
Notifications
You must be signed in to change notification settings - Fork 22
[FRE-1641] Improve Bad Price Error Handling #1070
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
Conversation
…rice impact warnings more effectively. Update SwapPage to rely solely on API warning type for bad price warnings.
🦋 Changeset detectedLatest commit: 3d0bb84 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
packages/widget/src/pages/ErrorPage/ErrorPageBadPriceWarning.tsx
Outdated
Show resolved
Hide resolved
packages/widget/src/pages/ErrorPage/ErrorPageBadPriceWarning.tsx
Outdated
Show resolved
Hide resolved
…mization and improve title/description handling. Remove unused priceChangePercentage from SwapPage.
packages/widget/src/pages/ErrorPage/ErrorPageBadPriceWarning.tsx
Outdated
Show resolved
Hide resolved
if (hasUsdValues && swapDifferencePercentage) { | ||
return { | ||
title: `Warning: Bad trade (-${swapDifferencePercentage})`, | ||
descriptionContent: ( | ||
<> | ||
You will lose {swapDifferencePercentage} of your input value with this trade | ||
<br /> | ||
Input: {sourceDetails?.amount} {sourceDetails?.symbol} ({usdAmountIn}) | ||
<br /> | ||
Estimated output: {destinationDetails?.amount} {destinationDetails?.symbol} ({usdAmountOut}) | ||
</> | ||
), | ||
}; | ||
} else if (priceImpactPercentage) { | ||
return { | ||
title: `Warning: High Price Impact (${priceImpactPercentage})`, | ||
descriptionContent: ( | ||
<> | ||
Executing this trade is expected to impact the price by {priceImpactPercentage}. Please verify the amounts. | ||
<br /> | ||
|
||
</> | ||
), | ||
}; | ||
} else { | ||
return { | ||
title: "Warning: Bad Trade", | ||
descriptionContent: ( | ||
<> | ||
This trade may result in a poor execution price. Please verify the amounts carefully. | ||
<br /> | ||
|
||
</> | ||
), | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is purely a stylistic thing, but in the cases where each if condition has an early return I prefer this:
if () {
return 1;
}
if () {
return 2;
}
return 3;
over
if () {
return 1;
} else if () {
return 2;
} else {
return 3;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh you updated it before I finished writing my comment 😆
Enhance ErrorPageBadPriceWarning component to handle USD values and p…rice impact warnings more effectively. Update SwapPage to rely solely on API warning type for bad price warnings.