1+ // SPDX-License-Identifier: BUSL-1.1
2+ pragma solidity ^ 0.8.27 ;
3+
4+ import "src/test/integration/IntegrationChecks.t.sol " ;
5+ import "src/test/integration/users/User.t.sol " ;
6+ import {console} from "forge-std/console.sol " ;
7+
8+ contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is IntegrationCheckUtils , IDelegationManagerTypes {
9+
10+ function testFuzz_deposit_delegate_allocate_fullSlash_queue_complete_redeposit (
11+ uint24 _random
12+ ) public {
13+ _configRand ({_randomSeed: _random, _assetTypes: HOLDS_LST, _userTypes: DEFAULT});
14+ _upgradeEigenLayerContracts ();
15+
16+ (User staker , IStrategy[] memory strategies , uint256 [] memory tokenBalances ) = _newRandomStaker ();
17+ (User operator ,,) = _newRandomOperator ();
18+ (AVS avs ,) = _newRandomAVS ();
19+
20+ uint256 [] memory tokensToDeposit = new uint256 [](tokenBalances.length );
21+ uint256 [] memory numTokensRemaining = new uint256 [](tokenBalances.length );
22+ for (uint256 i = 0 ; i < tokenBalances.length ; i++ ) {
23+ tokensToDeposit[i] = tokenBalances[i]/ 2 ;
24+ numTokensRemaining[i] = tokenBalances[i] - tokensToDeposit[i];
25+ }
26+
27+ uint256 [] memory shares = _calculateExpectedShares (strategies, tokensToDeposit);
28+
29+ // 1. Deposit Into Strategies
30+ staker.depositIntoEigenlayer (strategies, tokensToDeposit);
31+ check_Deposit_State_PartialDeposit (staker, strategies, shares, numTokensRemaining);
32+
33+ // 2. Delegate to operator
34+ staker.delegateTo (operator);
35+ check_Delegation_State (staker, operator, strategies, shares);
36+
37+ // Create operator set and register operator
38+ OperatorSet memory operatorSet = avs.createOperatorSet (strategies);
39+ operator.registerForOperatorSet (operatorSet);
40+
41+ // 3. Allocate to operator set
42+ IAllocationManagerTypes.AllocateParams memory allocateParams =
43+ operator.modifyAllocations (operatorSet, _maxMagnitudes (operatorSet, operator));
44+
45+ assert_Snap_Allocations_Modified (
46+ operator,
47+ allocateParams,
48+ false ,
49+ "operator allocations should be updated before delay "
50+ );
51+
52+ _rollBlocksForCompleteAllocation (operator, operatorSet, strategies);
53+
54+ assert_Snap_Allocations_Modified (
55+ operator,
56+ allocateParams,
57+ true ,
58+ "operator allocations should be updated after delay "
59+ );
60+
61+ // 4. Fully slash operator
62+ IAllocationManagerTypes.SlashingParams memory slashingParams;
63+ {
64+ (IStrategy[] memory strategiesToSlash , uint256 [] memory wadsToSlash ) =
65+ _strategiesAndWadsForFullSlash (operatorSet);
66+
67+ slashingParams = avs.slashOperator (operator, operatorSet.id, strategiesToSlash, wadsToSlash);
68+ assert_Snap_Allocations_Slashed (slashingParams, operatorSet, true , "operator allocations should be slashed " );
69+ assert_Snap_Unchanged_StakerDepositShares (staker, "staker deposit shares should be unchanged after slashing " );
70+ assert_Snap_StakerWithdrawableShares_AfterSlash (staker, allocateParams, slashingParams, "staker deposit shares should be slashed " );
71+ }
72+
73+ // 5. Undelegate from an operator
74+ IDelegationManagerTypes.Withdrawal[] memory withdrawals = staker.undelegate ();
75+ bytes32 [] memory withdrawalRoots = _getWithdrawalHashes (withdrawals);
76+
77+ // 6. Complete withdrawal
78+ _rollBlocksForCompleteWithdrawals (withdrawals);
79+ for (uint256 i = 0 ; i < withdrawals.length ; ++ i) {
80+ uint256 [] memory expectedTokens =
81+ _calculateExpectedTokens (withdrawals[i].strategies, withdrawals[i].scaledShares);
82+ for (uint256 i = 0 ; i < expectedTokens.length ; i++ ) {
83+ }
84+ staker.completeWithdrawalAsTokens (withdrawals[i]);
85+ check_Withdrawal_AsTokens_State_AfterSlash (staker, operator, withdrawals[i], allocateParams, slashingParams, expectedTokens);
86+ }
87+
88+ // 7. Redeposit
89+ shares = _calculateExpectedShares (strategies, numTokensRemaining);
90+ staker.depositIntoEigenlayer (strategies, numTokensRemaining);
91+ check_Deposit_State (staker, strategies, shares);
92+
93+ // Final state checks
94+ assert_HasExpectedShares (staker, strategies, shares, "staker should have expected shares after redeposit " );
95+ assert_NoWithdrawalsPending (withdrawalRoots, "all withdrawals should be removed from pending " );
96+ }
97+ }
0 commit comments