Skip to content

Commit

Permalink
fix(STK-215): update our checks for stack remaining funds (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElRodrigote authored Aug 8, 2024
1 parent f0118ad commit eb3965a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/app/models/stack-order/stack-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eb3965a

Please sign in to comment.