@@ -237,6 +237,7 @@ contract IntegrationCheckUtils is IntegrationBase {
237237        // ... check that the staker is undelegated, all strategies from which the staker is deposited are unqueued, 
238238        //     that the returned root matches the hashes for each strategy and share amounts, and that the staker 
239239        //     and operator have reduced shares 
240+         assert_HasNoDelegatableShares (staker, "staker should have withdrawn all shares " );
240241        assertFalse (delegationManager.isDelegated (address (staker)),
241242            "check_Undelegate_State: staker should not be delegated " );
242243        assert_ValidWithdrawalHashes (withdrawals, withdrawalRoots,
@@ -338,7 +339,7 @@ contract IntegrationCheckUtils is IntegrationBase {
338339            if  (operator !=  staker) {
339340                assert_Snap_Unchanged_TokenBalances (operator, "operator should not have any change in underlying token balances " );
340341            }
341-             assert_Snap_Added_OperatorShares (operator, withdrawal. strategies, withdrawal.scaledShares , "operator should have received shares " );
342+             assert_Snap_Added_OperatorShares (operator, strategies, shares , "operator should have received shares " );
342343        }
343344    }
344345
@@ -882,7 +883,7 @@ contract IntegrationCheckUtils is IntegrationBase {
882883        check_IsSlashable_State (operator, operatorSet, allocateParams.strategies);
883884
884885        // Slashing SHOULD change max magnitude and current allocation 
885-         assert_Snap_Slashed_MaxMagnitude (operator, slashParams, "slash should lower max magnitude " );
886+         assert_Snap_Slashed_MaxMagnitude (operator, operatorSet,  slashParams, "slash should lower max magnitude " );
886887        assert_Snap_Slashed_EncumberedMagnitude (operator, slashParams, "slash should lower max magnitude " );
887888        assert_Snap_Slashed_AllocatedStake (operator, operatorSet, slashParams, "slash should lower allocated stake " );
888889        assert_Snap_Slashed_SlashableStake (operator, operatorSet, slashParams, "slash should lower slashable stake " );
@@ -894,97 +895,19 @@ contract IntegrationCheckUtils is IntegrationBase {
894895        assert_Snap_Unchanged_AllocatableMagnitude (operator, allStrats, "slashing should not change allocatable magnitude " );
895896        assert_Snap_Unchanged_Registration (operator, operatorSet, "slash should not change registration status " );
896897        assert_Snap_Unchanged_Slashability (operator, operatorSet, "slash should not change slashability status " );
897-         assert_Snap_Unchanged_AllocatedSets (operator, "should not have updated allocated sets " );
898-         assert_Snap_Unchanged_AllocatedStrats (operator, operatorSet, "should not have updated allocated strategies " );
898+         //  assert_Snap_Unchanged_AllocatedSets(operator, "should not have updated allocated sets");
899+         //  assert_Snap_Unchanged_AllocatedStrats(operator, operatorSet, "should not have updated allocated strategies");
899900    }
900901
901-     // TODO: improvement needed  
902- 
903-     function check_Withdrawal_AsTokens_State_AfterSlash  (
904-         User staker ,
902+     /// Slashing invariants when the operator has been fully slashed for every strategy in the operator set 
903+     function check_FullySlashed_State  (
905904        User operator ,
906-         Withdrawal memory  withdrawal ,
907905        AllocateParams memory  allocateParams ,
908-         SlashingParams memory  slashingParams ,
909-         uint [] memory  expectedTokens 
910-     ) internal  {
911-         IERC20 [] memory  tokens =  new  IERC20 [](withdrawal.strategies.length );
912- 
913-         for  (uint  i; i <  withdrawal.strategies.length ; i++ ) {
914-             IStrategy strat =  withdrawal.strategies[i];
915- 
916-             bool  isBeaconChainETHStrategy =  strat ==  beaconChainETHStrategy;
917- 
918-             tokens[i] =  isBeaconChainETHStrategy ?  NATIVE_ETH :  withdrawal.strategies[i].underlyingToken ();
919-             
920-             if  (slashingParams.strategies.contains (strat)) {
921-                 uint  wadToSlash =  slashingParams.wadsToSlash[slashingParams.strategies.indexOf (strat)];
922- 
923-                 expectedTokens[i] -=  expectedTokens[i]
924-                     .mulWadRoundUp (allocateParams.newMagnitudes[i].mulWadRoundUp (wadToSlash));
925- 
926-                 uint256  max =  allocationManager.getMaxMagnitude (address (operator), strat);
927- 
928-                 withdrawal.scaledShares[i] -=  withdrawal.scaledShares[i].calcSlashedAmount (WAD, max);
929- 
930-                 // Round down to the nearest gwei for beaconchain ETH strategy. 
931-                 if  (isBeaconChainETHStrategy) {
932-                     expectedTokens[i] -=  expectedTokens[i] %  1  gwei ;
933-                 }
934-             }
935-         }
936- 
937-         // Common checks 
938-         assert_WithdrawalNotPending (delegationManager.calculateWithdrawalRoot (withdrawal), "staker withdrawal should no longer be pending " );
939-         
940-         // TODO FIXME 
941-         // assert_Snap_Added_TokenBalances(staker, tokens, expectedTokens, "staker should have received expected tokens"); 
942-         assert_Snap_Unchanged_Staker_DepositShares (staker, "staker shares should not have changed " );
943-         assert_Snap_Removed_StrategyShares (withdrawal.strategies, withdrawal.scaledShares, "strategies should have total shares decremented " );
944- 
945-         // Checks specific to an operator that the Staker has delegated to 
946-         if  (operator !=  User (payable (0 ))) {
947-             if  (operator !=  staker) {
948-                 assert_Snap_Unchanged_TokenBalances (operator, "operator token balances should not have changed " );
949-             }
950-             assert_Snap_Unchanged_OperatorShares (operator, "operator shares should not have changed " );
951-         }
952-     }
953- 
954-     function check_Withdrawal_AsShares_State_AfterSlash  (
955-         User staker ,
956-         User operator ,
957-         Withdrawal memory  withdrawal ,
958-         AllocateParams memory  allocateParams , // TODO - was this needed? 
959-         SlashingParams memory  slashingParams 
906+         SlashingParams memory  slashParams 
960907    ) internal  {
961-         IERC20 [] memory  tokens =  new  IERC20 [](withdrawal.strategies.length );
962- 
963-         for  (uint  i; i <  withdrawal.strategies.length ; i++ ) {
964-             IStrategy strat =  withdrawal.strategies[i];
908+         check_Base_Slashing_State (operator, allocateParams, slashParams);
965909
966-             bool  isBeaconChainETHStrategy =  strat ==  beaconChainETHStrategy;
967- 
968-             tokens[i] =  isBeaconChainETHStrategy ?  NATIVE_ETH :  withdrawal.strategies[i].underlyingToken ();
969-             
970-             if  (slashingParams.strategies.contains (strat)) {
971-                 uint256  max =  allocationManager.getMaxMagnitude (address (operator), strat);
972- 
973-                 withdrawal.scaledShares[i] -=  withdrawal.scaledShares[i].calcSlashedAmount (WAD, max);
974-             }
975-         }
976-         
977-         // Common checks applicable to both user and non-user operator types 
978-         assert_WithdrawalNotPending (delegationManager.calculateWithdrawalRoot (withdrawal), "staker withdrawal should no longer be pending " );
979-         assert_Snap_Unchanged_TokenBalances (staker, "staker should not have any change in underlying token balances " );
980-         assert_Snap_Added_Staker_DepositShares (staker, withdrawal.strategies,  withdrawal.scaledShares, "staker should have received expected shares " );
981-         assert_Snap_Unchanged_StrategyShares (withdrawal.strategies, "strategies should have total shares unchanged " );
982- 
983-         // Additional checks or handling for the non-user operator scenario 
984-         if  (operator !=  User (User (payable (0 )))) {
985-             if  (operator !=  staker) {
986-                 assert_Snap_Unchanged_TokenBalances (operator, "operator should not have any change in underlying token balances " );
987-             }
988-         }
910+         assert_Snap_Removed_AllocatedSet (operator, allocateParams.operatorSet, "should not have updated allocated sets " );
911+         assert_Snap_Removed_AllocatedStrats (operator, allocateParams.operatorSet, slashParams.strategies, "should not have updated allocated strategies " );
989912    }
990913}
0 commit comments