Skip to content

Commit

Permalink
fix: require for settling status
Browse files Browse the repository at this point in the history
  • Loading branch information
fb-alexcq committed Aug 27, 2024
1 parent 60d1a52 commit 0f7f6fc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions contracts/earn/WooSuperChargerVaultV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ contract WooSuperChargerVaultV2 is ERC20, Ownable, Pausable, ReentrancyGuard {
}

function batchEndWeeklySettle(uint256 _length) public onlyAdmin {
require(isSettling, "!SETTLING");
// require(weeklyNeededAmountForWithdraw() == 0, "WEEKLY_REPAY_NOT_CLEARED");

uint256 sharePrice = getPricePerFullShare();
uint256 _batchWithdrawAmount = 0;
uint256 _batchRequestedShares = 0;
Expand All @@ -455,7 +458,7 @@ contract WooSuperChargerVaultV2 is ERC20, Ownable, Pausable, ReentrancyGuard {

_batchWithdrawAmount += _amount;
_batchRequestedShares += requestedWithdrawShares[user];
withdrawManager.addWithdrawAmount(user, _amount);
withdrawManager.addWithdrawAmount(user, _amount); // NOTE: accounting only, no fund transfering.

requestedWithdrawShares[user] = 0;
requestUsers.remove(user);
Expand All @@ -465,7 +468,7 @@ contract WooSuperChargerVaultV2 is ERC20, Ownable, Pausable, ReentrancyGuard {
reserveVault.withdraw(shares);

if (want == weth) {
IWETH(weth).deposit{value: _batchWithdrawAmount}();
IWETH(weth).deposit{value: _batchWithdrawAmount}(); // WETH for withdraw manager
}
require(available() >= _batchWithdrawAmount, "!available_amount_for_withdraw");

Expand All @@ -474,7 +477,7 @@ contract WooSuperChargerVaultV2 is ERC20, Ownable, Pausable, ReentrancyGuard {

TransferHelper.safeTransfer(want, address(withdrawManager), _batchWithdrawAmount);

if (requestUsers.length() == 0) {
if (requestUsers.length() == 0) { // NOTE: all settling finished
isSettling == false;

instantWithdrawnAmount = 0;
Expand Down

0 comments on commit 0f7f6fc

Please sign in to comment.