diff --git a/src/components/SwapWidget/SwapWidget.tsx b/src/components/SwapWidget/SwapWidget.tsx index 7140b427..70ccf702 100644 --- a/src/components/SwapWidget/SwapWidget.tsx +++ b/src/components/SwapWidget/SwapWidget.tsx @@ -23,7 +23,7 @@ import TransactionDialog from "../TransactionDialog"; import { UsdDiff } from "../UsdValue"; import { useWalletModal, WalletModal } from "../WalletModal"; import { SwapDetails } from "./SwapDetails"; -import { useSwapWidget } from "./useSwapWidget"; +import { PRICE_IMPACT_THRESHOLD, useSwapWidget } from "./useSwapWidget"; export const SwapWidget: FC = () => { const { openWalletModal } = useWalletModal(); @@ -265,7 +265,10 @@ export const SwapWidget: FC = () => { route={route} transactionCount={numberOfTransactions} insufficientBalance={insufficientBalance} - priceImpactThresholdReached={priceImpactThresholdReached} + shouldShowPriceImpactWarning={ + priceImpactThresholdReached || + Math.abs(usdDiffPercent * 100) > PRICE_IMPACT_THRESHOLD + } /> {insufficientBalance && (

diff --git a/src/components/TransactionDialog/index.tsx b/src/components/TransactionDialog/index.tsx index 5308b68d..c478dffe 100644 --- a/src/components/TransactionDialog/index.tsx +++ b/src/components/TransactionDialog/index.tsx @@ -13,7 +13,7 @@ interface Props { route?: RouteResponse; transactionCount: number; insufficientBalance?: boolean; - priceImpactThresholdReached?: boolean; + shouldShowPriceImpactWarning?: boolean; } const TransactionDialog: FC = ({ @@ -21,7 +21,7 @@ const TransactionDialog: FC = ({ route, insufficientBalance, transactionCount, - priceImpactThresholdReached, + shouldShowPriceImpactWarning, }) => { const [hasDisplayedWarning, setHasDisplayedWarning] = useState(false); const [isOpen, setIsOpen] = useState(false); @@ -38,7 +38,7 @@ const TransactionDialog: FC = ({ return; } - if (priceImpactThresholdReached) { + if (shouldShowPriceImpactWarning) { control.open(); setHasDisplayedWarning(true); } @@ -47,7 +47,7 @@ const TransactionDialog: FC = ({ setHasDisplayedWarning, isOpen, hasDisplayedWarning, - priceImpactThresholdReached, + shouldShowPriceImpactWarning, ]); return (