Skip to content

Commit

Permalink
address price warning feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
thal0x committed Dec 28, 2023
1 parent 41fcac7 commit c0a60d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/components/AssetInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ const AssetInput: FC<Props> = ({
<p className="text-neutral-400 text-sm">
{amountUSD ? formatUSD(amountUSD) : null}
</p>
{amountUSD !== undefined && context === "dest" ? (
{amountUSD !== undefined &&
diffPercentage !== 0 &&
context === "dest" ? (
<p
className={clsx(
"text-sm",
Expand Down
16 changes: 8 additions & 8 deletions src/components/PriceImpactWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const PriceImpactWarning = ({
}: Props) => {
const [isOpen, control] = useDisclosureKey("priceImpactWarning");

if (!isOpen) return null;
if (!isOpen || warningMessage === "") return null;

return (
<div className="absolute inset-0 bg-white rounded-3xl z-[999]">
Expand All @@ -33,7 +33,7 @@ export const PriceImpactWarning = ({
</svg>
</div>
<p className="font-bold text-lg text-center text-red-500 mb-2">
Price Impact Warning
Bad Trade Warning
</p>
<p className="text-center text-lg px-4 leading-snug text-gray-500">
{warningMessage} Do you want to continue?
Expand All @@ -42,19 +42,19 @@ export const PriceImpactWarning = ({
<div className="flex items-end gap-2">
<button
className="bg-[#FF486E] hover:bg-[#ed1149] transition-colors text-white font-semibold py-4 rounded-md w-full"
onClick={() => control.close()}
>
Continue
</button>
<button
className="border border-gray-400 text-gray-500 font-semibold py-4 rounded-md w-full transition-colors hover:bg-gray-50"
onClick={() => {
control.close();
onGoBack();
}}
>
Go Back
</button>
<button
className="border border-gray-400 text-gray-500 font-semibold py-4 rounded-md w-full transition-colors hover:bg-gray-50"
onClick={() => control.close()}
>
Continue
</button>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SwapWidget/SwapWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export const SwapWidget: FC = () => {
insufficientBalance={insufficientBalance}
shouldShowPriceImpactWarning={
priceImpactThresholdReached ||
Math.abs(usdDiffPercent * 100) > PRICE_IMPACT_THRESHOLD
Math.abs(usdDiffPercent) > PRICE_IMPACT_THRESHOLD
}
routeWarning={routeWarning}
/>
Expand Down

0 comments on commit c0a60d1

Please sign in to comment.