From 916bf779b849a26329bdb60d92688f74fa56337b Mon Sep 17 00:00:00 2001 From: Brooks Student Portal Date: Sun, 26 Jul 2026 09:14:44 -0700 Subject: [PATCH] feat(escrow): implement high-volatility slippage warnings for fiat pairs Extract the FX rate slippage warning UI out of FiatXlmPreview into a standalone SlippageWarning component so any escrow flow that quotes a fiat/XLM rate can reuse the same 2%/5% threshold warning and blocking acknowledgment checkbox, rather than duplicating the markup per consumer. FiatXlmPreview now composes SlippageWarning, wiring it to the existing useFiatXlmSlippage hook and fiatXlmSlippageService; behavior (2% advisory banner, 5% blocking checkbox, submission gating) is unchanged. Adds a dedicated test suite covering SlippageWarning in isolation. --- components/escrow/FiatXlmPreview.tsx | 81 ++----------- components/escrow/SlippageWarning.tsx | 113 ++++++++++++++++++ .../escrow/__tests__/SlippageWarning.test.tsx | 111 +++++++++++++++++ 3 files changed, 234 insertions(+), 71 deletions(-) create mode 100644 components/escrow/SlippageWarning.tsx create mode 100644 components/escrow/__tests__/SlippageWarning.test.tsx diff --git a/components/escrow/FiatXlmPreview.tsx b/components/escrow/FiatXlmPreview.tsx index 11d76c8..26b2e58 100644 --- a/components/escrow/FiatXlmPreview.tsx +++ b/components/escrow/FiatXlmPreview.tsx @@ -15,15 +15,14 @@ import React, { useEffect } from 'react'; import { - AlertTriangle, AlertCircle, TrendingDown, TrendingUp, Loader2, - CheckCircle2, } from 'lucide-react'; import { useFiatXlmSlippage } from '@/hooks/useFiatXlmSlippage'; import { formatNgn } from '@/services/fxService'; +import { SlippageWarning } from '@/components/escrow/SlippageWarning'; export interface FiatXlmPreviewProps { /** The XLM amount being paid */ @@ -184,67 +183,15 @@ export function FiatXlmPreview({ )} - {/* Warning Section — volatile slippage (>2%) */} - {slippage.isVolatile && !slippage.requiresAcknowledgment && ( -
-
- )} - - {/* Critical Section — critical slippage (>5%) */} - {slippage.requiresAcknowledgment && ( -
-
- )} + {/* FX rate volatility warning — see SlippageWarning for the 2%/5% threshold UI */} + {/* Loading State */} {slippage.isLoadingRate && ( @@ -254,14 +201,6 @@ export function FiatXlmPreview({ )} - {/* Success State */} - {slippage.isAcknowledged && slippage.requiresAcknowledgment && ( -
-
- )} - {/* Action Buttons */}