From b626d18b95ca33111dfe6577bb1d557bbb2ff80f Mon Sep 17 00:00:00 2001 From: ElRodrigote Date: Tue, 6 Aug 2024 16:12:14 +0200 Subject: [PATCH] fix: update our checks for stack remaining funds --- packages/app/models/stack-order/stack-order.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/app/models/stack-order/stack-order.ts b/packages/app/models/stack-order/stack-order.ts index e90350ac..42b57261 100644 --- a/packages/app/models/stack-order/stack-order.ts +++ b/packages/app/models/stack-order/stack-order.ts @@ -64,13 +64,16 @@ export const totalStacked = (order: StackOrder) => }, 0) ?? 0; export const stackHasRemainingFunds = (stackOrder: StackOrder) => - totalFundsUsed(stackOrder) > stacklyFee(stackOrder) && + totalFundsUsed(stackOrder) >= stacklyFee(stackOrder) && stackRemainingFunds(stackOrder) > stacklyFee(stackOrder); export const stackRemainingFunds = (stackOrder: StackOrder) => { - if (totalFundsUsed(stackOrder) === 0 && totalStackOrdersDone(stackOrder) > 0) + if ( + stackOrder.cowOrders.length && + totalFundsUsed(stackOrder) === 0 && + totalStackOrdersDone(stackOrder) > 0 + ) return 0; - return ( convertedAmount(stackOrder.amount, stackOrder.sellToken.decimals) - totalFundsUsed(stackOrder)