Skip to content

[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

Merged
merged 7 commits into from
Apr 15, 2025
Merged

Conversation

daps94
Copy link
Contributor

@daps94 daps94 commented Apr 14, 2025

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.

…rice impact warnings more effectively. Update SwapPage to rely solely on API warning type for bad price warnings.
Copy link

changeset-bot bot commented Apr 14, 2025

🦋 Changeset detected

Latest commit: 3d0bb84

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@skip-go/widget Minor
nextjs Patch

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

Copy link

vercel bot commented Apr 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
widget-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 14, 2025 8:58pm

@daps94 daps94 changed the title Improve Bad Price Error Handling [FRE-1641] Improve Bad Price Error Handling Apr 14, 2025
@codingki codingki requested a review from Copilot April 14, 2025 20:25
Copy link

@Copilot Copilot AI left a 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.

…mization and improve title/description handling. Remove unused priceChangePercentage from SwapPage.
Comment on lines 64 to 99
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 />

</>
),
};
}
Copy link
Collaborator

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;
}

Copy link
Collaborator

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 😆

@toddkao toddkao merged commit 9afbd48 into staging Apr 15, 2025
6 checks passed
@toddkao toddkao deleted the ds/fix_bad_price_warning branch April 15, 2025 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants