Skip to content

Commit 3137b9c

Browse files
committed
add warning for high percentage of costs in swap modal
1 parent 095e6bf commit 3137b9c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/components/transactions/Switch/BaseSwitchModalContent.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ export const BaseSwitchModalContent = ({
442442
})
443443
: null;
444444

445+
const receivingPercentage = !switchRates
446+
? undefined
447+
: (Number(switchRates?.destUSD) * (1 - safeSlippage)) / Number(switchRates?.srcUSD);
448+
445449
// Component
446450
return (
447451
<>
@@ -626,6 +630,15 @@ export const BaseSwitchModalContent = ({
626630
/>
627631
{txError && <ParaswapErrorDisplay txError={txError} />}
628632

633+
{receivingPercentage && receivingPercentage < 0.7 && (
634+
<Warning severity="warning" icon={false} sx={{ mt: 2, mb: 2 }}>
635+
<Typography variant="caption">
636+
Costs may be up to {100 - Math.round(receivingPercentage * 100)}% of the value
637+
sent
638+
</Typography>
639+
</Warning>
640+
)}
641+
629642
<SwitchActions
630643
isWrongNetwork={isWrongNetwork.isWrongNetwork}
631644
inputAmount={debounceInputAmount}

0 commit comments

Comments
 (0)