Skip to content

Commit

Permalink
fix: Remove deprecated middlewareTimesIndexes
Browse files Browse the repository at this point in the history
  • Loading branch information
fzavalia committed Feb 12, 2025
1 parent 6eb0276 commit 2de65d2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 70 deletions.
5 changes: 1 addition & 4 deletions src/interfaces/ITokenStakingNode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,16 @@ interface ITokenStakingNode {
returns (bytes32[] memory _fullWithdrawalRoots);
function completeQueuedWithdrawals(
IDelegationManager.Withdrawal calldata withdrawal,
uint256 middlewareTimesIndex,
bool updateTokenStakingNodesBalances
) external;

function completeQueuedWithdrawals(
IDelegationManager.Withdrawal[] memory withdrawals,
uint256[] memory middlewareTimesIndexes,
bool updateTokenStakingNodesBalances
) external;

function completeQueuedWithdrawalsAsShares(
IDelegationManager.Withdrawal[] calldata withdrawals,
uint256[] calldata middlewareTimesIndexes
IDelegationManager.Withdrawal[] calldata withdrawals
) external;

function deallocateTokens(IERC20 _token, uint256 _amount) external;
Expand Down
35 changes: 4 additions & 31 deletions src/ynEIGEN/TokenStakingNode.sol
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,12 @@ contract TokenStakingNode is ITokenStakingNode, Initializable, ReentrancyGuardUp
/**
* @notice Completes queued withdrawals with receiveAsTokens set to true
* @param withdrawals Array of withdrawals to complete
* @param middlewareTimesIndexes Array of middleware times indexes
* @param updateTokenStakingNodesBalances If true calls updateTokenStakingNodesBalances for yieldNestStrategyManager
*/
function completeQueuedWithdrawals(
IDelegationManager.Withdrawal[] memory withdrawals,
uint256[] memory middlewareTimesIndexes,
bool updateTokenStakingNodesBalances
) public onlyTokenStakingNodesWithdrawer onlyWhenSynchronized {

if (withdrawals.length != middlewareTimesIndexes.length) {
revert ArrayLengthMismatch();
}

IDelegationManagerExtended _delegationManager = IDelegationManagerExtended(address(tokenStakingNodesManager.delegationManager()));
IERC20V4[][] memory _tokens = new IERC20V4[][](withdrawals.length);
IStrategy[] memory _strategies = new IStrategy[](withdrawals.length);
Expand Down Expand Up @@ -241,12 +234,7 @@ contract TokenStakingNode is ITokenStakingNode, Initializable, ReentrancyGuardUp
_balancesBefore[i] = IERC20(_dedupTokens[i]).balanceOf(address(this));
}

_delegationManager.completeQueuedWithdrawals(
withdrawals,
_tokens,
// middlewareTimesIndexes,
_receiveAsTokens
);
_delegationManager.completeQueuedWithdrawals(withdrawals, _tokens, _receiveAsTokens);

for (uint256 i = 0; i < _dedupTokens.length; i++) {
IERC20 _token = IERC20(_dedupTokens[i]);
Expand All @@ -266,19 +254,15 @@ contract TokenStakingNode is ITokenStakingNode, Initializable, ReentrancyGuardUp
/**
* @notice Completes queued withdrawals with receiveAsTokens set to true
* @param withdrawal The withdrawal to complete
* @param middlewareTimesIndex The middleware times index
* @param updateTokenStakingNodesBalances If true calls updateTokenStakingNodesBalances for yieldNestStrategyManager
*/
function completeQueuedWithdrawals(
IDelegationManager.Withdrawal calldata withdrawal,
uint256 middlewareTimesIndex,
bool updateTokenStakingNodesBalances
) public onlyTokenStakingNodesWithdrawer onlyWhenSynchronized {
IDelegationManager.Withdrawal[] memory _withdrawals = new IDelegationManager.Withdrawal[](1);
_withdrawals[0] = withdrawal;
uint256[] memory _middlewareTimesIndexes = new uint256[](1);
_middlewareTimesIndexes[0] = middlewareTimesIndex;
completeQueuedWithdrawals(_withdrawals, _middlewareTimesIndexes, updateTokenStakingNodesBalances);
completeQueuedWithdrawals(_withdrawals, updateTokenStakingNodesBalances);
}

/**
Expand All @@ -294,16 +278,10 @@ contract TokenStakingNode is ITokenStakingNode, Initializable, ReentrancyGuardUp
/**
* @notice Completes queued withdrawals with receiveAsTokens set to false
* @param withdrawals Array of withdrawals to complete
* @param middlewareTimesIndexes Array of middleware times indexes
*/
function completeQueuedWithdrawalsAsShares(
IDelegationManager.Withdrawal[] calldata withdrawals,
uint256[] calldata middlewareTimesIndexes
IDelegationManager.Withdrawal[] calldata withdrawals
) external onlyDelegator onlyWhenSynchronized {
if (withdrawals.length != middlewareTimesIndexes.length) {
revert ArrayLengthMismatch();
}

IDelegationManagerExtended _delegationManager = IDelegationManagerExtended(address(tokenStakingNodesManager.delegationManager()));
IERC20V4[][] memory _tokens = new IERC20V4[][](withdrawals.length);
bool[] memory _receiveAsTokens = new bool[](withdrawals.length);
Expand All @@ -328,12 +306,7 @@ contract TokenStakingNode is ITokenStakingNode, Initializable, ReentrancyGuardUp
}

// Complete withdrawals with receiveAsTokens = false
_delegationManager.completeQueuedWithdrawals(
withdrawals,
_tokens,
// middlewareTimesIndexes,
_receiveAsTokens
);
_delegationManager.completeQueuedWithdrawals(withdrawals, _tokens, _receiveAsTokens);

emit CompletedManyQueuedWithdrawals(withdrawals);
}
Expand Down
4 changes: 0 additions & 4 deletions src/ynEIGEN/WithdrawalsProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,6 @@ contract WithdrawalsProcessor is IWithdrawalsProcessor, Initializable, AccessCon

QueuedWithdrawal memory queuedWithdrawal_ = _queuedWithdrawals[_completedId];

uint256[] memory _middlewareTimesIndexes = new uint256[](1);
_middlewareTimesIndexes[0] = 0;

IStrategy[] memory _strategies = new IStrategy[](1);
_strategies[0] = IStrategy(queuedWithdrawal_.strategy);

Expand All @@ -351,7 +348,6 @@ contract WithdrawalsProcessor is IWithdrawalsProcessor, Initializable, AccessCon
});
ITokenStakingNode(queuedWithdrawal_.node).completeQueuedWithdrawals(
_withdrawal,
0,
true // updateTokenStakingNodesBalances
);
}
Expand Down
24 changes: 5 additions & 19 deletions test/integration/ynEIGEN/TokenStakingNode.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ contract TokenStakingNodeTest is ynEigenIntegrationBaseTest {
});
tokenStakingNode.completeQueuedWithdrawals(
withdrawal,
0, // _middlewareTimesIndexes
false
);
vm.stopPrank();
Expand Down Expand Up @@ -779,12 +778,9 @@ contract TokenStakingNodeDelegate is ynEigenIntegrationBaseTest {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
// all is zeroed out by default
_middlewareTimesIndexes[0] = 0;
vm.startPrank(actors.admin.STAKING_NODES_DELEGATOR);
tokenStakingNodesManager.nodes(nodeId).completeQueuedWithdrawalsAsShares(
_withdrawals, _middlewareTimesIndexes
_withdrawals
);
vm.stopPrank();
}
Expand Down Expand Up @@ -880,14 +876,13 @@ contract TokenStakingNodeDelegate is ynEigenIntegrationBaseTest {
strategies: new IStrategy[](0),
scaledShares: new uint256[](0)
}),
0,
true
);

vm.expectRevert(TokenStakingNode.NotSynchronized.selector);
vm.prank(actors.admin.STAKING_NODES_DELEGATOR);
tokenStakingNodeInstance.completeQueuedWithdrawalsAsShares(
new IDelegationManager.Withdrawal[](0), new uint256[](0)
new IDelegationManager.Withdrawal[](0)
);

vm.expectRevert(TokenStakingNode.NotSynchronized.selector);
Expand Down Expand Up @@ -996,12 +991,9 @@ contract TokenStakingNodeDelegate is ynEigenIntegrationBaseTest {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
// all is zeroed out by default
_middlewareTimesIndexes[0] = 0;
vm.startPrank(actors.admin.STAKING_NODES_DELEGATOR);
tokenStakingNodesManager.nodes(nodeId).completeQueuedWithdrawalsAsShares(
_withdrawals, _middlewareTimesIndexes
_withdrawals
);
vm.stopPrank();
}
Expand Down Expand Up @@ -1131,12 +1123,9 @@ contract TokenStakingNodeDelegate is ynEigenIntegrationBaseTest {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
// all is zeroed out by default
_middlewareTimesIndexes[0] = 0;
vm.startPrank(actors.admin.STAKING_NODES_DELEGATOR);
tokenStakingNodesManager.nodes(nodeId).completeQueuedWithdrawalsAsShares(
_withdrawals, _middlewareTimesIndexes
_withdrawals
);
vm.stopPrank();
}
Expand Down Expand Up @@ -1262,12 +1251,9 @@ contract TokenStakingNodeDelegate is ynEigenIntegrationBaseTest {

// complete queued withdrawals
{
uint256[] memory _middlewareTimesIndexes = new uint256[](_withdrawals.length);
// all is zeroed out by default
_middlewareTimesIndexes[0] = 0;
vm.startPrank(actors.admin.STAKING_NODES_DELEGATOR);
tokenStakingNodesManager.nodes(nodeId).completeQueuedWithdrawalsAsShares(
_withdrawals, _middlewareTimesIndexes
_withdrawals
);
vm.stopPrank();
}
Expand Down
4 changes: 1 addition & 3 deletions test/scenarios/ynEIGEN/Delegation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ contract YnEigenDelegationScenarioTest is ynLSDeScenarioBaseTest {

// Complete queued withdrawals as shares
IDelegationManager.Withdrawal[] memory withdrawals = new IDelegationManager.Withdrawal[](strategies.length);
uint256[] memory middlewareTimesIndexes = new uint256[](strategies.length);
for (uint256 i = 0; i < strategies.length; i++) {
IStrategy[] memory singleStrategy = new IStrategy[](1);
singleStrategy[0] = strategies[i];
Expand All @@ -112,13 +111,12 @@ contract YnEigenDelegationScenarioTest is ynLSDeScenarioBaseTest {
strategies: singleStrategy,
scaledShares: singleShare
});
middlewareTimesIndexes[i] = 0;
}
// advance time to allow completion
vm.roll(block.number + delegationManager.minWithdrawalDelayBlocks() + 1);

vm.prank(actors.admin.TOKEN_STAKING_NODES_DELEGATOR);
tokenStakingNode.completeQueuedWithdrawalsAsShares(withdrawals, middlewareTimesIndexes);
tokenStakingNode.completeQueuedWithdrawalsAsShares(withdrawals);

for (uint256 i = 0; i < strategies.length; i++) {
assertEq(
Expand Down
12 changes: 3 additions & 9 deletions test/scenarios/ynEIGEN/ynLSDeWithdrawals.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ contract ynLSDeWithdrawalsTest is ynLSDeScenarioBaseTest {
uint32 _startBlock = uint32(block.number);
IStrategy _strategy = IStrategy(chainAddresses.lsdStrategies.STETH_STRATEGY_ADDRESS);
uint256 _share = tokenStakingNode.queuedShares(_strategy);
uint256[] memory _middlewareTimesIndexes = new uint256[](1);
_middlewareTimesIndexes[0] = 0;

IStrategy[] memory _strategies = new IStrategy[](1);
_strategies[0] = _strategy;
Expand All @@ -245,7 +243,7 @@ contract ynLSDeWithdrawalsTest is ynLSDeScenarioBaseTest {
});

vm.prank(actors.ops.YNEIGEN_WITHDRAWAL_MANAGER);
tokenStakingNode.completeQueuedWithdrawals(withdrawal, 0, true);
tokenStakingNode.completeQueuedWithdrawals(withdrawal, true);

assertApproxEqAbs(yneigen.totalAssets(), _totalAssetsBefore, 10, "completeQueuedWithdrawalsSTETH: E0");
assertEq(tokenStakingNode.queuedShares(_strategy), 0, "completeQueuedWithdrawalsSTETH: E1");
Expand All @@ -262,8 +260,6 @@ contract ynLSDeWithdrawalsTest is ynLSDeScenarioBaseTest {
uint32 _startBlock = uint32(block.number);
IStrategy _strategy = IStrategy(chainAddresses.lsdStrategies.SFRXETH_STRATEGY_ADDRESS);
uint256 _share = tokenStakingNode.queuedShares(_strategy);
uint256[] memory _middlewareTimesIndexes = new uint256[](1);
_middlewareTimesIndexes[0] = 0;

IStrategy[] memory _strategies = new IStrategy[](1);
_strategies[0] = _strategy;
Expand All @@ -284,7 +280,7 @@ contract ynLSDeWithdrawalsTest is ynLSDeScenarioBaseTest {
});

vm.prank(actors.ops.YNEIGEN_WITHDRAWAL_MANAGER);
tokenStakingNode.completeQueuedWithdrawals(withdrawal, 0, true);
tokenStakingNode.completeQueuedWithdrawals(withdrawal, true);

assertApproxEqAbs(yneigen.totalAssets(), _totalAssetsBefore, 10, "completeQueuedWithdrawalsSFRXETH: E0");
assertEq(tokenStakingNode.queuedShares(_strategy), 0, "completeQueuedWithdrawalsSFRXETH: E1");
Expand All @@ -301,8 +297,6 @@ contract ynLSDeWithdrawalsTest is ynLSDeScenarioBaseTest {
uint32 _startBlock = uint32(block.number);
IStrategy _strategy = IStrategy(chainAddresses.lsdStrategies.OETH_STRATEGY_ADDRESS);
uint256 _share = tokenStakingNode.queuedShares(_strategy);
uint256[] memory _middlewareTimesIndexes = new uint256[](1);
_middlewareTimesIndexes[0] = 0;

IStrategy[] memory _strategies = new IStrategy[](1);
_strategies[0] = _strategy;
Expand All @@ -322,7 +316,7 @@ contract ynLSDeWithdrawalsTest is ynLSDeScenarioBaseTest {
scaledShares: _shares
});
vm.prank(actors.ops.YNEIGEN_WITHDRAWAL_MANAGER);
tokenStakingNode.completeQueuedWithdrawals(withdrawal, 0, true);
tokenStakingNode.completeQueuedWithdrawals(withdrawal, true);

assertApproxEqAbs(yneigen.totalAssets(), _totalAssetsBefore, 10, "completeQueuedWithdrawalsOETH: E0");
assertEq(tokenStakingNode.queuedShares(_strategy), 0, "completeQueuedWithdrawalsOETH: E1");
Expand Down

0 comments on commit 2de65d2

Please sign in to comment.