first pass on user alert for slippage (this does not include bug where we calculate neg slippage because of price issue)

This commit is contained in:
2025-11-25 19:02:41 -04:00
parent 8cc9d00521
commit c8c23a4f54
2 changed files with 60 additions and 5 deletions

View File

@@ -370,6 +370,18 @@ export function SwapForm() {
</div>
)}
{/* High slippage warning - show if calculated slippage exceeds max slippage OR 5% */}
{swapAmounts && swapAmounts.length > 0 && swapAmounts[0].calculatedSlippage !== undefined && (
Math.abs(swapAmounts[0].calculatedSlippage) > Math.max(currentSlippage, 5)
) && (
<div className="px-4 py-3 bg-yellow-500/10 border border-yellow-500/20 rounded-lg">
<p className="text-sm text-yellow-600 dark:text-yellow-500 font-medium"> High Slippage Warning</p>
<p className="text-xs text-yellow-600/80 dark:text-yellow-500/80 mt-1">
The estimated slippage for this swap is {Math.abs(swapAmounts[0].calculatedSlippage).toFixed(2)}%. You may lose money due to low liquidity in this pool.
</p>
</div>
)}
{/* Gas Estimate, Slippage, and Fees */}
{isConnected && fromAmount && toAmount && (
<div className="px-4 py-2 bg-muted/30 rounded-lg space-y-2">