diff --git a/src/test/integration/IntegrationBase.t.sol b/src/test/integration/IntegrationBase.t.sol index 94a5efed02..c998e6de9f 100644 --- a/src/test/integration/IntegrationBase.t.sol +++ b/src/test/integration/IntegrationBase.t.sol @@ -1483,7 +1483,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter { for (uint i = 0; i < strategies.length; i++) { assertEq(prevShares[i], curShares[i], err); } -<<<<<<< HEAD } /// @dev Check that the staker's withdrawable shares have increased by `addedShares` @@ -1504,28 +1503,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter { } /// @dev Check that the staker's withdrawable shares have decreased by `removedShares` -======= - } - - /// @dev Check that the staker's withdrawable shares have decreased by `removedShares` - function assert_Snap_Added_Staker_WithdrawableShares( - User staker, - IStrategy[] memory strategies, - uint[] memory addedShares, - string memory err - ) internal { - uint[] memory curShares = _getStakerWithdrawableShares(staker, strategies); - // Use timewarp to get previous staker shares - uint[] memory prevShares = _getPrevStakerWithdrawableShares(staker, strategies); - - // For each strategy, check (prev - removed == cur) - for (uint i = 0; i < strategies.length; i++) { - assertEq(prevShares[i] + addedShares[i], curShares[i], err); - } - } - - /// @dev Check that the staker's withdrawable shares have decreased by `removedShares` ->>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036)) function assert_Snap_Removed_Staker_WithdrawableShares( User staker, IStrategy[] memory strategies, @@ -1542,7 +1519,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter { } } -<<<<<<< HEAD /// @dev Check that all the staker's withdrawable shares have been removed function assert_Snap_RemovedAll_Staker_WithdrawableShares( User staker, @@ -1568,19 +1544,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter { /// @dev Check that the staker's withdrawable shares have decreased by `removedShares` /// FIX THIS WHEN WORKING ON ROUNDING ISSUES function assert_Snap_Unchanged_Staker_WithdrawableShares_Delegation( -======= - function assert_Snap_Removed_Staker_WithdrawableShares( - User staker, - IStrategy strat, - uint removedShares, - string memory err - ) internal { - assert_Snap_Removed_Staker_WithdrawableShares(staker, strat.toArray(), removedShares.toArrayU256(), err); - } - - /// @dev Check that the staker's withdrawable shares have decreased by `removedShares` - function assert_Snap_Unchanged_Staker_WithdrawableShares( ->>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036)) User staker, string memory err ) internal { @@ -1592,11 +1555,7 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter { // For each strategy, check (prev - removed == cur) for (uint i = 0; i < strategies.length; i++) { -<<<<<<< HEAD assertApproxEqAbs(prevShares[i], curShares[i], 100000, err); -======= - assertEq(prevShares[i], curShares[i], err); ->>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036)) } } diff --git a/src/test/integration/IntegrationChecks.t.sol b/src/test/integration/IntegrationChecks.t.sol index 4a221ac1a4..28523405f3 100644 --- a/src/test/integration/IntegrationChecks.t.sol +++ b/src/test/integration/IntegrationChecks.t.sol @@ -249,7 +249,6 @@ contract IntegrationCheckUtils is IntegrationBase { "check_Undelegate_State: staker should have increased nonce by withdrawals.length"); assert_Snap_Removed_OperatorShares(operator, strategies, stakerDelegatedShares, "check_Undelegate_State: failed to remove operator shares"); -<<<<<<< HEAD assert_Snap_Removed_Staker_DepositShares(staker, strategies, stakerDepositShares, "check_Undelegate_State: failed to remove staker shares"); assert_Snap_RemovedAll_Staker_WithdrawableShares(staker, strategies, @@ -283,11 +282,6 @@ contract IntegrationCheckUtils is IntegrationBase { assert_Snap_Removed_Staker_DepositShares(staker, strategies, stakerDepositShares, "check_Redelegate_State: failed to remove staker shares"); assert_Snap_RemovedAll_Staker_WithdrawableShares(staker, strategies, -======= - assert_Snap_Removed_Staker_DepositShares(staker, strategies, shares, - "check_Undelegate_State: failed to remove staker shares"); - assert_Snap_Removed_Staker_WithdrawableShares(staker, strategies, shares, ->>>>>>> 6eac6b5b (test: enable shared setups for integration tests (#1036)) "check_QueuedWithdrawal_State: failed to remove staker withdrawable shares"); } @@ -993,4 +987,4 @@ contract IntegrationCheckUtils is IntegrationBase { } } } -} +} \ No newline at end of file diff --git a/src/test/integration/IntegrationDeployer.t.sol b/src/test/integration/IntegrationDeployer.t.sol index d9146aebcb..196624570d 100644 --- a/src/test/integration/IntegrationDeployer.t.sol +++ b/src/test/integration/IntegrationDeployer.t.sol @@ -40,6 +40,8 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { bool isUpgraded; uint mainnetForkBlock = 21_616_692; // Post Protocol Council upgrade + string version = "v9.9.9"; + // Beacon chain genesis time when running locally // Multiple of 12 for sanity's sake uint64 constant GENESIS_TIME_LOCAL = 1 hours * 12; @@ -160,10 +162,8 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { } /// Deploy EigenLayer locally - function _setUpLocal() public virtual { + function _setUpLocal() public noTracing virtual { console.log("Setting up `%s` integration tests:", "LOCAL".yellow().bold()); - // Bypass upgrade tests when running locally - isUpgraded = true; // Deploy ProxyAdmin eigenLayerProxyAdmin = new ProxyAdmin(); @@ -204,6 +204,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { ethStrats.push(BEACONCHAIN_ETH_STRAT); allStrats.push(BEACONCHAIN_ETH_STRAT); allTokens.push(NATIVE_ETH); + maxUniqueAssetsHeld = allStrats.length; // Create time machine and beacon chain. Set block time to beacon chain genesis time BEACON_GENESIS_TIME = GENESIS_TIME_LOCAL; @@ -213,7 +214,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { } /// Parse existing contracts from mainnet - function _setUpMainnet() public virtual { + function _setUpMainnet() public noTracing virtual { console.log("Setting up `%s` integration tests:", "MAINNET_FORK".green().bold()); console.log("RPC:", cheats.rpcUrl("mainnet")); console.log("Block:", mainnetForkBlock); @@ -239,13 +240,20 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { allTokens.push(strategy.underlyingToken()); } + maxUniqueAssetsHeld = allStrats.length; + // Create time machine and mock beacon chain BEACON_GENESIS_TIME = GENESIS_TIME_MAINNET; timeMachine = new TimeMachine(); beaconChain = new BeaconChainMock(eigenPodManager, BEACON_GENESIS_TIME); + + // Since we haven't done the slashing upgrade on mainnet yet, upgrade mainnet contracts + // prior to test. `isUpgraded` is true by default, but is set to false in `UpgradeTest.t.sol` + if (isUpgraded) { + _upgradeMainnetContracts(); + } } - /// Deploy current implementation contracts and upgrade existing proxies function _upgradeMainnetContracts() public virtual { cheats.startPrank(address(executorMultisig)); @@ -277,6 +285,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { ethStrats.push(BEACONCHAIN_ETH_STRAT); allStrats.push(BEACONCHAIN_ETH_STRAT); allTokens.push(NATIVE_ETH); + maxUniqueAssetsHeld = allStrats.length; } function _deployProxies() public { @@ -310,10 +319,25 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { /// Deploy an implementation contract for each contract in the system function _deployImplementations() public { - allocationManagerImplementation = new AllocationManager(delegationManager, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY); - permissionControllerImplementation = new PermissionController(); - delegationManagerImplementation = new DelegationManager(strategyManager, eigenPodManager, allocationManager, eigenLayerPauserReg, permissionController, DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS); - strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg); + allocationManagerImplementation = new AllocationManager( + delegationManager, + eigenLayerPauserReg, + permissionController, + DEALLOCATION_DELAY, + ALLOCATION_CONFIGURATION_DELAY, + version + ); + permissionControllerImplementation = new PermissionController(version); + delegationManagerImplementation = new DelegationManager( + strategyManager, + eigenPodManager, + allocationManager, + eigenLayerPauserReg, + permissionController, + DELEGATION_MANAGER_MIN_WITHDRAWAL_DELAY_BLOCKS, + version + ); + strategyManagerImplementation = new StrategyManager(delegationManager, eigenLayerPauserReg, version); rewardsCoordinatorImplementation = new RewardsCoordinator( IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams({ delegationManager: delegationManager, @@ -337,17 +361,17 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { eigenLayerPauserReg, "v9.9.9" ); - strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg); + strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg, "v9.9.9"); // Beacon implementations - eigenPodImplementation = new EigenPod(DEPOSIT_CONTRACT, eigenPodManager, BEACON_GENESIS_TIME); - baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg); + eigenPodImplementation = new EigenPod(DEPOSIT_CONTRACT, eigenPodManager, BEACON_GENESIS_TIME, "v9.9.9"); + baseStrategyImplementation = new StrategyBase(strategyManager, eigenLayerPauserReg, "v9.9.9"); // Pre-longtail StrategyBaseTVLLimits implementation // TODO - need to update ExistingDeploymentParser } - function _upgradeProxies() public { + function _upgradeProxies() public noTracing { // DelegationManager eigenLayerProxyAdmin.upgrade( ITransparentUpgradeableProxy(payable(address(delegationManager))), @@ -412,7 +436,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { } } - function _initializeProxies() public { + function _initializeProxies() public noTracing { delegationManager.initialize({ initialOwner: executorMultisig, initialPausedStatus: 0 @@ -486,7 +510,7 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { allTokens.push(underlyingToken); } - function _configRand(uint24 _randomSeed, uint _assetTypes, uint _userTypes) private { + function _configRand(uint24 _randomSeed, uint _assetTypes, uint _userTypes) private noTracing { // Using uint24 for the seed type so that if a test fails, it's easier // to manually use the seed to replay the same test. random = _hash(_randomSeed); @@ -496,6 +520,25 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { _configUserTypes(_userTypes); } + function _configAssetTypes(uint _assetTypes) internal { + assetTypes = _bitmapToBytes(_assetTypes); + assertTrue(assetTypes.length != 0, "_configRand: no asset types selected"); + } + + function _configAssetAmounts(uint _maxUniqueAssetsHeld) internal { + if (_maxUniqueAssetsHeld > allStrats.length) { + _maxUniqueAssetsHeld = allStrats.length; + } + + maxUniqueAssetsHeld = _maxUniqueAssetsHeld; + require(maxUniqueAssetsHeld != 0, "_configAssetAmounts: invalid 0"); + } + + function _configUserTypes(uint _userTypes) internal { + userTypes = _bitmapToBytes(_userTypes); + assertTrue(userTypes.length != 0, "_configRand: no user types selected"); + } + /** * @dev Create a new User with a random config using the range defined in `_configRand` * @@ -795,4 +838,4 @@ abstract contract IntegrationDeployer is ExistingDeploymentParser { ) internal pure returns (bytes32) { return keccak256(abi.encodePacked(x)); } -} +} \ No newline at end of file diff --git a/src/test/integration/tests/Deposit_Delegate_Allocate_Slash_Queue_Redeposit.t.sol b/src/test/integration/tests/Deposit_Delegate_Allocate_Slash_Queue_Redeposit.t.sol index 9e45caa799..e38bc43ecb 100644 --- a/src/test/integration/tests/Deposit_Delegate_Allocate_Slash_Queue_Redeposit.t.sol +++ b/src/test/integration/tests/Deposit_Delegate_Allocate_Slash_Queue_Redeposit.t.sol @@ -7,12 +7,8 @@ import {console} from "forge-std/console.sol"; contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is IntegrationCheckUtils { - function _init() internal override { - // TODO: Partial deposits don't work when beacon chain eth balance is initialized to < 64 ETH, need to write _newRandomStaker variant that ensures beacon chain ETH balance - // greater than or equal to 64 - _configAssetTypes(HOLDS_LST); - _configUserTypes(DEFAULT); - } + AVS avs; + OperatorSet operatorSet; User operator; AllocateParams allocateParams; @@ -46,18 +42,15 @@ contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is Integrat numTokensRemaining[i] = initTokenBalances[i] - tokensToDeposit[i]; } - // uint256[] memory tokensToDeposit = new uint256[](tokenBalances.length); - // uint256[] memory numTokensRemaining = new uint256[](tokenBalances.length); - // for (uint256 i = 0; i < tokenBalances.length; i++) { - // tokensToDeposit[i] = tokenBalances[i]/2; - // numTokensRemaining[i] = tokenBalances[i] - tokensToDeposit[i]; - // } + uint256[] memory shares = _calculateExpectedShares(strategies, tokensToDeposit); - // uint256[] memory shares = _calculateExpectedShares(strategies, tokensToDeposit); + // 1. Deposit Into Strategies + staker.depositIntoEigenlayer(strategies, tokensToDeposit); + check_Deposit_State_PartialDeposit(staker, strategies, shares, numTokensRemaining); - // // 1. Deposit Into Strategies - // staker.depositIntoEigenlayer(strategies, tokensToDeposit); - // check_Deposit_State_PartialDeposit(staker, strategies, shares, numTokensRemaining); + // 2. Delegate to operator + staker.delegateTo(operator); + check_Delegation_State(staker, operator, strategies, shares); // Create operator set and register operator operatorSet = avs.createOperatorSet(strategies); @@ -81,24 +74,24 @@ contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is Integrat (IStrategy[] memory strategiesToSlash, uint256[] memory wadsToSlash) = _strategiesAndWadsForFullSlash(operatorSet); - // slashingParams = avs.slashOperator(operator, operatorSet.id, strategiesToSlash, wadsToSlash); - // assert_Snap_Allocations_Slashed(slashingParams, operatorSet, true, "operator allocations should be slashed"); - // assert_Snap_Unchanged_Staker_DepositShares(staker, "staker deposit shares should be unchanged after slashing"); - // assert_Snap_StakerWithdrawableShares_AfterSlash(staker, allocateParams, slashingParams, "staker deposit shares should be slashed"); - // } + slashingParams = avs.slashOperator(operator, operatorSet.id, strategiesToSlash, wadsToSlash); + assert_Snap_Allocations_Slashed(slashingParams, operatorSet, true, "operator allocations should be slashed"); + assert_Snap_Unchanged_Staker_DepositShares(staker, "staker deposit shares should be unchanged after slashing"); + assert_Snap_StakerWithdrawableShares_AfterSlash(staker, allocateParams, slashingParams, "staker deposit shares should be slashed"); + } // 5. Undelegate from an operator Withdrawal[] memory withdrawals = staker.undelegate(); bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals); - // // 6. Complete withdrawal - // _rollBlocksForCompleteWithdrawals(withdrawals); - // for (uint256 i = 0; i < withdrawals.length; ++i) { - // uint256[] memory expectedTokens = - // _calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].scaledShares); - // staker.completeWithdrawalAsTokens(withdrawals[i]); - // check_Withdrawal_AsTokens_State_AfterSlash(staker, operator, withdrawals[i], allocateParams, slashingParams, expectedTokens); - // } + // 6. Complete withdrawal + _rollBlocksForCompleteWithdrawals(withdrawals); + for (uint256 i = 0; i < withdrawals.length; ++i) { + uint256[] memory expectedTokens = + _calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].scaledShares); + staker.completeWithdrawalAsTokens(withdrawals[i]); + check_Withdrawal_AsTokens_State_AfterSlash(staker, operator, withdrawals[i], allocateParams, slashingParams, expectedTokens); + } // 7. Redeposit uint[] memory shares = _calculateExpectedShares(strategies, numTokensRemaining); @@ -106,9 +99,9 @@ contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is Integrat check_Deposit_State(staker, strategies, shares); // Final state checks - // assert_HasExpectedShares(staker, strategies, shares, "staker should have expected shares after redeposit"); - // assert_NoWithdrawalsPending(withdrawalRoots, "all withdrawals should be removed from pending"); - // } + assert_HasExpectedShares(staker, strategies, shares, "staker should have expected shares after redeposit"); + assert_NoWithdrawalsPending(withdrawalRoots, "all withdrawals should be removed from pending"); + } function testFuzz_undelegate_fullSlash_complete_redeposit( uint24 _random @@ -151,87 +144,7 @@ contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is Integrat function testFuzz_depositFull_fullSlash_undelegate_completeAsShares( uint24 _random ) public rand(_random) { - (User staker, IStrategy[] memory strategies, uint256[] memory tokenBalances) = _newRandomStaker(); - (User operator,,) = _newRandomOperator(); - (AVS avs,) = _newRandomAVS(); - OperatorSet memory operatorSet; - - uint256[] memory tokensToDeposit = new uint256[](tokenBalances.length); - uint256[] memory numTokensRemaining = new uint256[](tokenBalances.length); - for (uint256 i = 0; i < tokenBalances.length; i++) { - tokensToDeposit[i] = tokenBalances[i]/2; - numTokensRemaining[i] = tokenBalances[i] - tokensToDeposit[i]; - } - - uint256[] memory shares = _calculateExpectedShares(strategies, tokensToDeposit); - - // 1. Deposit Into Strategies - staker.depositIntoEigenlayer(strategies, tokensToDeposit); - check_Deposit_State_PartialDeposit(staker, strategies, shares, numTokensRemaining); - - // 2. Delegate to operator - staker.delegateTo(operator); - check_Delegation_State(staker, operator, strategies, shares); - - // Create operator sets and register operator - { - uint numOpSets = _randUint({min: 2, max: 4}); - OperatorSet[] memory operatorSets = new OperatorSet[](numOpSets); - for (uint i = 0; i < numOpSets; i++){ - operatorSets[i] = avs.createOperatorSet(strategies); - } - operatorSet = operatorSets[_randUint({min: 0, max: numOpSets-1})]; - } - - operator.registerForOperatorSet(operatorSet); - - // 3. Allocate to operator set - IAllocationManagerTypes.AllocateParams memory allocateParams = - operator.modifyAllocations(operatorSet, _maxMagnitudes(operatorSet, operator)); - - assert_Snap_Allocations_Modified( - operator, - allocateParams, - false, - "operator allocations should be updated before delay" - ); - - _rollBlocksForCompleteAllocation(operator, operatorSet, strategies); - - assert_Snap_Allocations_Modified( - operator, - allocateParams, - true, - "operator allocations should be updated after delay" - ); - - // 4. Fully slash operator - IAllocationManagerTypes.SlashingParams memory slashingParams; - { - (IStrategy[] memory strategiesToSlash, uint256[] memory wadsToSlash) = - _strategiesAndWadsForFullSlash(operatorSet); - - slashingParams = avs.slashOperator(operator, operatorSet.id, strategiesToSlash, wadsToSlash); - assert_Snap_Allocations_Slashed(slashingParams, operatorSet, true, "operator allocations should be slashed"); - assert_Snap_Unchanged_Staker_DepositShares(staker, "staker deposit shares should be unchanged after slashing"); - assert_Snap_StakerWithdrawableShares_AfterSlash(staker, allocateParams, slashingParams, "staker deposit shares should be slashed"); - } - - // 5. Undelegate from an operator - IDelegationManagerTypes.Withdrawal[] memory withdrawals = staker.undelegate(); - bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals); - - // 6. Complete withdrawal - _rollBlocksForCompleteWithdrawals(withdrawals); - for (uint256 i = 0; i < withdrawals.length; ++i) { - uint256[] memory expectedTokens = - _calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].scaledShares); - staker.completeWithdrawalAsTokens(withdrawals[i]); - check_Withdrawal_AsTokens_State_AfterSlash(staker, operator, withdrawals[i], allocateParams, slashingParams, expectedTokens); - } - - // 7. Redeposit - shares = _calculateExpectedShares(strategies, numTokensRemaining); + uint[] memory shares = _calculateExpectedShares(strategies, numTokensRemaining); staker.depositIntoEigenlayer(strategies, numTokensRemaining); check_Deposit_State(staker, strategies, shares); @@ -250,14 +163,14 @@ contract Integration_Deposit_Delegate_Allocate_Slash_Queue_Redeposit is Integrat Withdrawal[] memory withdrawals = staker.undelegate(); bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals); - // // 6. Complete withdrawal as shares - // // Fast forward to when we can complete the withdrawal - // _rollBlocksForCompleteWithdrawals(withdrawals); + // 6. Complete withdrawal as shares + // Fast forward to when we can complete the withdrawal + _rollBlocksForCompleteWithdrawals(withdrawals); - // for (uint256 i = 0; i < withdrawals.length; ++i) { - // staker.completeWithdrawalAsShares(withdrawals[i]); - // check_Withdrawal_AsShares_State_AfterSlash(staker, operator, withdrawals[i], allocateParams, slashingParams); - // } + for (uint256 i = 0; i < withdrawals.length; ++i) { + staker.completeWithdrawalAsShares(withdrawals[i]); + check_Withdrawal_AsShares_State_AfterSlash(staker, operator, withdrawals[i], allocateParams, slashingParams); + } // Check final state: assert_HasNoUnderlyingTokenBalance(staker, slashingParams.strategies, "staker not have any underlying tokens"); diff --git a/src/test/integration/tests/Deposit_Delegate_Redelegate_Complete.t.sol b/src/test/integration/tests/Deposit_Delegate_Redelegate_Complete.t.sol index 755c8532f8..e3b60becdb 100644 --- a/src/test/integration/tests/Deposit_Delegate_Redelegate_Complete.t.sol +++ b/src/test/integration/tests/Deposit_Delegate_Redelegate_Complete.t.sol @@ -275,20 +275,23 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti numTokensToDeposit[i] = tokenBalances[i] / 2; numTokensRemaining[i] = tokenBalances[i] - numTokensToDeposit[i]; } - uint[] memory sharesFromFirstDeposit = _calculateExpectedShares(strategies, numTokensToDeposit); + { + uint[] memory sharesFromFirstDeposit = _calculateExpectedShares(strategies, numTokensToDeposit); + //delegatable shares equals deposit shares here because no bc slashing + uint[] memory delegatableShares = sharesFromFirstDeposit; - /// 1. Deposit Into Strategies - staker.depositIntoEigenlayer(strategies, numTokensToDeposit); - check_Deposit_State_PartialDeposit(staker, strategies, sharesFromFirstDeposit, numTokensRemaining); + /// 1. Deposit Into Strategies + staker.depositIntoEigenlayer(strategies, numTokensToDeposit); + check_Deposit_State_PartialDeposit(staker, strategies, sharesFromFirstDeposit, numTokensRemaining); - // 2. Delegate to an operator - staker.delegateTo(operator1); - check_Delegation_State(staker, operator1, strategies, sharesFromFirstDeposit); + // 2. Delegate to an operator + staker.delegateTo(operator1); + check_Delegation_State(staker, operator1, strategies, sharesFromFirstDeposit); - // 3. Undelegate from an operator - IDelegationManagerTypes.Withdrawal[] memory withdrawals = staker.undelegate(); - bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals); - check_Undelegate_State(staker, operator1, withdrawals, withdrawalRoots, strategies, sharesFromFirstDeposit); + // 3. Undelegate from an operator + Withdrawal[] memory withdrawals = staker.undelegate(); + bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals); + check_Undelegate_State(staker, operator1, withdrawals, withdrawalRoots, strategies, sharesFromFirstDeposit, delegatableShares); // 4. Complete withdrawal as shares // Fast forward to when we can complete the withdrawal @@ -309,16 +312,6 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti check_Deposit_State(staker, strategies, sharesFromSecondDeposit); } - // 5. Deposit into Strategies - uint[] memory sharesFromSecondDeposit = _calculateExpectedShares(strategies, numTokensRemaining); - for (uint i = 0; i < strategies.length; i++) { - totalShares[i] = sharesFromFirstDeposit[i] + sharesFromSecondDeposit[i]; - } - - staker.depositIntoEigenlayer(strategies, numTokensRemaining); - tokenBalances = _calculateExpectedTokens(strategies, totalShares); - check_Deposit_State(staker, strategies, sharesFromSecondDeposit); - // 6. Delegate to a new operator staker.delegateTo(operator2); check_Delegation_State(staker, operator2, strategies, totalShares); @@ -328,7 +321,7 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti { // 7. Queue Withdrawal totalShares = _calculateExpectedShares(strategies, tokenBalances); - IDelegationManagerTypes.Withdrawal[] memory newWithdrawals = staker.queueWithdrawals(strategies, totalShares); + Withdrawal[] memory newWithdrawals = staker.queueWithdrawals(strategies, totalShares); bytes32[] memory newWithdrawalRoots = _getWithdrawalHashes(newWithdrawals); check_QueuedWithdrawal_State(staker, operator2, strategies, totalShares, newWithdrawals, newWithdrawalRoots); @@ -478,4 +471,4 @@ contract Integration_Deposit_Delegate_Redelegate_Complete is IntegrationCheckUti check_Withdrawal_AsShares_State(staker, operator2, withdrawals[i], strategies, shares); } } -} +} \ No newline at end of file