Skip to content

Commit

Permalink
minor fix to sorting logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Jan 7, 2025
1 parent 5a9a3db commit d630c27
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/BaseKeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,16 @@ contract BaseKeeper is Ownable, ReentrancyGuard {
depositAmount += deposits[i].amount;
}
}
if (withdrawAmount > 0) {
if (withdrawAmount > 0 && depositAmount == 0) {
sortedWithdraws[sortedWithdrawIndex++] = Withdraw(j, withdrawAmount);
}
if (depositAmount > 0) {
} else if (depositAmount > 0 && withdrawAmount == 0) {
sortedDeposits[sortedDepositIndex++] = Deposit(j, depositAmount);
} else if (withdrawAmount > depositAmount) {
sortedWithdraws[sortedWithdrawIndex++] = Withdraw(j, withdrawAmount - depositAmount);
} else if (depositAmount > withdrawAmount) {
sortedDeposits[sortedDepositIndex++] = Deposit(j, depositAmount - withdrawAmount);
}

}

Withdraw[] memory finalWithdraws = new Withdraw[](sortedWithdrawIndex);
Expand Down

0 comments on commit d630c27

Please sign in to comment.