Skip to content

Commit

Permalink
fix: sean's findings
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyonline committed Dec 13, 2024
1 parent 1d91dd2 commit f18e821
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/interfaces/IWithdrawalsProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ interface IWithdrawalsProcessor {
error NoQueuedWithdrawals();
error NothingToProcess();
error SanityCheck();
error CurrentRedemptionAssetsSufficient();

//
// Events
Expand Down
14 changes: 9 additions & 5 deletions src/ynEIGEN/WithdrawalsProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ contract WithdrawalsProcessor is IWithdrawalsProcessor, Initializable, AccessCon
/// @notice Checks if withdrawals should be queued
/// @return True if withdrawals should be queued, false otherwise
function shouldQueueWithdrawals() external view returns (bool) {
return withdrawalQueueManager.pendingRequestedRedemptionAmount() - totalQueuedWithdrawals
- redemptionAssetsVault.availableRedemptionAssets() > minPendingWithdrawalRequestAmount;
uint256 _pendingUnqueudRequests = withdrawalQueueManager.pendingRequestedRedemptionAmount() - totalQueuedWithdrawals;
uint256 _availableRedemptionAssets = redemptionAssetsVault.availableRedemptionAssets();
if (_availableRedemptionAssets >= _pendingUnqueudRequests) return false;
return _pendingUnqueudRequests - _availableRedemptionAssets > minPendingWithdrawalRequestAmount;
}

/// @notice Checks if queued withdrawals should be completed
Expand All @@ -150,15 +152,17 @@ contract WithdrawalsProcessor is IWithdrawalsProcessor, Initializable, AccessCon

/// @notice Checks if principal withdrawals should be processed
/// @return True if principal withdrawals should be processed, false otherwise
function shouldProcessPrincipalWithdrawals() public returns (bool) {
function shouldProcessPrincipalWithdrawals() public view returns (bool) {
return _ids.completed != _ids.processed;
}

/// @notice Gets the total pending withdrawal requests
/// @return _pendingWithdrawalRequests The total pending withdrawal requests
function getPendingWithdrawalRequests() public view returns (uint256 _pendingWithdrawalRequests) {
_pendingWithdrawalRequests = withdrawalQueueManager.pendingRequestedRedemptionAmount() - totalQueuedWithdrawals
- redemptionAssetsVault.availableRedemptionAssets();
uint256 _pendingUnqueudRequests = withdrawalQueueManager.pendingRequestedRedemptionAmount() - totalQueuedWithdrawals;
uint256 _availableRedemptionAssets = redemptionAssetsVault.availableRedemptionAssets();
if (_availableRedemptionAssets >= _pendingUnqueudRequests) revert CurrentRedemptionAssetsSufficient();
_pendingWithdrawalRequests = _pendingUnqueudRequests - _availableRedemptionAssets;
if (_pendingWithdrawalRequests <= minPendingWithdrawalRequestAmount) revert PendingWithdrawalRequestsTooLow();
}

Expand Down

0 comments on commit f18e821

Please sign in to comment.