From f1a1a7b352446b3e0b4f9dffacbcf6674d5e7aca Mon Sep 17 00:00:00 2001 From: Jose Felix Date: Sun, 1 Dec 2024 20:34:24 -0400 Subject: [PATCH] fix: overspend condition blocking review modal --- .../use-one-click-trading-swap-review.ts | 3 ++- packages/web/modals/review-order.tsx | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts b/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts index 29859bc342..e9650962e7 100644 --- a/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts +++ b/packages/web/hooks/one-click-trading/use-one-click-trading-swap-review.ts @@ -296,6 +296,7 @@ function useOneClickRemainingSpendLimit({ wantToSpend: Dec; maybeWouldSpendTotal?: Dec; }) => { + if (!enabled) return false; if (wantToSpend.isZero()) return false; const spendLimit = transactionParams?.spendLimit?.toDec() ?? new Dec(0); @@ -309,7 +310,7 @@ function useOneClickRemainingSpendLimit({ return wouldSpend.gt(spendLimit); }, - [amountSpentData, transactionParams] + [amountSpentData?.amountSpent, enabled, transactionParams?.spendLimit] ); return { diff --git a/packages/web/modals/review-order.tsx b/packages/web/modals/review-order.tsx index 520611f8e2..4b97b6d78b 100644 --- a/packages/web/modals/review-order.tsx +++ b/packages/web/modals/review-order.tsx @@ -132,11 +132,18 @@ export function ReviewOrder({ } = useOneClickTradingSwapReview({ isModalOpen: isOpen }); const wouldExceedSpendLimit = useMemo(() => { + if (!is1CTEnabled) return false; + return wouldExceedSpendLimit1CT({ wantToSpend: fiatAmountWithSlippage?.toDec() ?? new Dec(0), maybeWouldSpendTotal: overspendErrorParams?.wouldSpendTotal, }); - }, [overspendErrorParams, fiatAmountWithSlippage, wouldExceedSpendLimit1CT]); + }, [ + is1CTEnabled, + wouldExceedSpendLimit1CT, + fiatAmountWithSlippage, + overspendErrorParams?.wouldSpendTotal, + ]); const [orderType] = useQueryState( "type",