Skip to content

Commit 25e5ce8

Browse files
8sunyuanypatil12
authored andcommitted
fix: remove numtocomplete interface (#966)
1 parent 55d9651 commit 25e5ce8

File tree

3 files changed

+3
-121
lines changed

3 files changed

+3
-121
lines changed

src/contracts/core/DelegationManager.sol

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -241,28 +241,6 @@ contract DelegationManager is
241241
}
242242
}
243243

244-
/// @inheritdoc IDelegationManager
245-
function completeQueuedWithdrawals(
246-
IERC20[][] calldata tokens,
247-
bool[] calldata receiveAsTokens,
248-
uint256 numToComplete
249-
) external onlyWhenNotPaused(PAUSED_EXIT_WITHDRAWAL_QUEUE) nonReentrant {
250-
EnumerableSet.Bytes32Set storage withdrawalRoots = _stakerQueuedWithdrawalRoots[msg.sender];
251-
uint256 length = withdrawalRoots.length();
252-
numToComplete = numToComplete > length ? length : numToComplete;
253-
254-
// Read withdrawals to complete. We use 2 seperate loops here because the second
255-
// loop will remove elements by index from `withdrawalRoots`.
256-
Withdrawal[] memory withdrawals = new Withdrawal[](numToComplete);
257-
for (uint256 i; i < withdrawals.length; ++i) {
258-
withdrawals[i] = queuedWithdrawals[withdrawalRoots.at(i)];
259-
}
260-
261-
for (uint256 i; i < withdrawals.length; ++i) {
262-
_completeQueuedWithdrawal(withdrawals[i], tokens[i], receiveAsTokens[i]);
263-
}
264-
}
265-
266244
/// @inheritdoc IDelegationManager
267245
function increaseDelegatedShares(
268246
address staker,

src/contracts/interfaces/IDelegationManager.sol

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -288,20 +288,6 @@ interface IDelegationManager is ISignatureUtils, IDelegationManagerErrors, IDele
288288
QueuedWithdrawalParams[] calldata params
289289
) external returns (bytes32[] memory);
290290

291-
/**
292-
* @notice Used to complete the all queued withdrawals.
293-
* Used to complete the specified `withdrawals`. The function caller must match `withdrawals[...].withdrawer`
294-
* @param tokens Array of tokens for each Withdrawal. See `completeQueuedWithdrawal` for the usage of a single array.
295-
* @param receiveAsTokens Whether or not to complete each withdrawal as tokens. See `completeQueuedWithdrawal` for the usage of a single boolean.
296-
* @param numToComplete The number of withdrawals to complete. This must be less than or equal to the number of queued withdrawals.
297-
* @dev See `completeQueuedWithdrawal` for relevant dev tags
298-
*/
299-
function completeQueuedWithdrawals(
300-
IERC20[][] calldata tokens,
301-
bool[] calldata receiveAsTokens,
302-
uint256 numToComplete
303-
) external;
304-
305291
/**
306292
* @notice Used to complete the lastest queued withdrawal.
307293
* @param withdrawal The withdrawal to complete.

src/test/unit/DelegationUnit.t.sol

Lines changed: 3 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5887,10 +5887,6 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage
58875887
// multiple Withdrawal interface
58885888
cheats.expectRevert(IPausable.CurrentlyPaused.selector);
58895889
delegationManager.completeQueuedWithdrawals(withdrawals, tokensArray, receiveAsTokens);
5890-
5891-
// numToComplete interface
5892-
cheats.expectRevert(IPausable.CurrentlyPaused.selector);
5893-
delegationManager.completeQueuedWithdrawals(tokensArray, receiveAsTokens, 1);
58945890
}
58955891

58965892
function test_Revert_WhenInputArrayLengthMismatch() public {
@@ -5918,16 +5914,6 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage
59185914
cheats.expectRevert(InputArrayLengthMismatch.selector);
59195915
delegationManager.completeQueuedWithdrawal(withdrawal, newTokens, false);
59205916

5921-
IERC20[][] memory tokensArray = new IERC20[][](1);
5922-
tokensArray[0] = newTokens;
5923-
5924-
bool[] memory receiveAsTokens = new bool[](1);
5925-
receiveAsTokens[0] = true;
5926-
5927-
cheats.prank(defaultStaker);
5928-
cheats.expectRevert(InputArrayLengthMismatch.selector);
5929-
delegationManager.completeQueuedWithdrawals(tokensArray, receiveAsTokens, 1);
5930-
59315917
// check that the withdrawal completes otherwise
59325918
cheats.prank(defaultStaker);
59335919
delegationManager.completeQueuedWithdrawal(withdrawal, tokens, true);
@@ -6012,16 +5998,6 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage
60125998
cheats.expectRevert(WithdrawalDelayNotElapsed.selector);
60135999
cheats.prank(defaultStaker);
60146000
delegationManager.completeQueuedWithdrawal(withdrawal, tokens, receiveAsTokens);
6015-
6016-
IERC20[][] memory tokensArray = new IERC20[][](1);
6017-
tokensArray[0] = tokens;
6018-
6019-
bool[] memory receiveAsTokensArray = new bool[](1);
6020-
receiveAsTokensArray[0] = false;
6021-
6022-
cheats.expectRevert(WithdrawalDelayNotElapsed.selector);
6023-
cheats.prank(defaultStaker);
6024-
delegationManager.completeQueuedWithdrawals(tokensArray, receiveAsTokensArray, 1);
60256001
}
60266002

60276003
/**
@@ -6108,63 +6084,6 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage
61086084
);
61096085
}
61106086

6111-
/**
6112-
* Test completing multiple queued withdrawals for a single strategy without passing in the withdrawals
6113-
*/
6114-
function test_completeQueuedWithdrawals_NumToComplete(Randomness r) public rand(r) {
6115-
address staker = r.Address();
6116-
uint256 depositAmount = r.Uint256(1, MAX_STRATEGY_SHARES);
6117-
uint256 numWithdrawals = r.Uint256(2, 20);
6118-
uint256 numToComplete = r.Uint256(2, numWithdrawals);
6119-
6120-
(
6121-
Withdrawal[] memory withdrawals,
6122-
IERC20[][] memory tokens,
6123-
bytes32[] memory withdrawalRoots
6124-
) = _setUpCompleteQueuedWithdrawalsSingleStrat({
6125-
staker: staker,
6126-
withdrawer: staker,
6127-
depositAmount: depositAmount,
6128-
numWithdrawals: numWithdrawals
6129-
});
6130-
6131-
_registerOperatorWithBaseDetails(defaultOperator);
6132-
_delegateToOperatorWhoAcceptsAllStakers(staker, defaultOperator);
6133-
uint256 operatorSharesBefore = delegationManager.operatorShares(defaultOperator, withdrawals[0].strategies[0]);
6134-
6135-
for (uint i = 0; i < withdrawalRoots.length; i++) {
6136-
assertTrue(delegationManager.pendingWithdrawals(withdrawalRoots[i]), "withdrawalRoots should be pending");
6137-
}
6138-
6139-
bool[] memory receiveAsTokens = new bool[](withdrawals.length);
6140-
for (uint i = 0; i < withdrawals.length; i++) {
6141-
receiveAsTokens[i] = true;
6142-
}
6143-
6144-
// completeQueuedWithdrawal
6145-
cheats.roll(withdrawals[0].startBlock + delegationManager.minWithdrawalDelayBlocks());
6146-
_completeQueuedWithdrawals_expectEmit(
6147-
CompleteQueuedWithdrawalsEmitStruct({
6148-
withdrawals: withdrawals,
6149-
tokens: tokens,
6150-
receiveAsTokens: receiveAsTokens
6151-
})
6152-
);
6153-
cheats.prank(staker);
6154-
delegationManager.completeQueuedWithdrawals(tokens, receiveAsTokens, numToComplete);
6155-
6156-
uint256 operatorSharesAfter = delegationManager.operatorShares(defaultOperator, withdrawals[0].strategies[0]);
6157-
assertEq(operatorSharesAfter, operatorSharesBefore, "operator shares should be unchanged");
6158-
6159-
for (uint i = 0; i < numToComplete; i++) {
6160-
assertFalse(delegationManager.pendingWithdrawals(withdrawalRoots[i]), "withdrawalRoot should be completed and marked false now");
6161-
}
6162-
6163-
for (uint i = numToComplete; i < numWithdrawals; i++) {
6164-
assertTrue(delegationManager.pendingWithdrawals(withdrawalRoots[i]), "withdrawalRoot should still be pending");
6165-
}
6166-
}
6167-
61686087
/**
61696088
* @notice Verifies that `DelegationManager.completeQueuedWithdrawal` properly completes a queued withdrawal for the `withdrawer`
61706089
* for a single strategy.
@@ -8263,10 +8182,9 @@ contract DelegationManagerUnitTests_Lifecycle is DelegationManagerUnitTests {
82638182
assertEq(stakerWithdrawableShares[0], 0, "staker withdrawable shares not calculated correctly");
82648183
assertEq(depositShares[0], 0, "staker deposit shares not reset correctly");
82658184

8266-
bool[] memory receiveAsTokens = new bool[](1);
8267-
receiveAsTokens[0] = false;
8268-
IERC20[][] memory tokens = new IERC20[][](1);
8269-
delegationManager.completeQueuedWithdrawals(tokens, receiveAsTokens, 1);
8185+
cheats.roll(withdrawal.startBlock + delegationManager.minWithdrawalDelayBlocks() + 1);
8186+
cheats.prank(defaultStaker);
8187+
delegationManager.completeQueuedWithdrawal(withdrawal, tokenMock.toArray(), false);
82708188

82718189
(stakerWithdrawableShares, depositShares) = delegationManager.getWithdrawableShares(defaultStaker, strategyArray);
82728190
assertEq(stakerWithdrawableShares[0], 0, "staker withdrawable shares not calculated correctly");

0 commit comments

Comments
 (0)