Skip to content

Commit

Permalink
fix: overspend condition blocking review modal
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseRFelix committed Dec 2, 2024
1 parent e5e3ff4 commit f1a1a7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -309,7 +310,7 @@ function useOneClickRemainingSpendLimit({

return wouldSpend.gt(spendLimit);
},
[amountSpentData, transactionParams]
[amountSpentData?.amountSpent, enabled, transactionParams?.spendLimit]
);

return {
Expand Down
9 changes: 8 additions & 1 deletion packages/web/modals/review-order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f1a1a7b

Please sign in to comment.