@@ -479,7 +479,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
479479                        string .concat (err, " (pendingDiff) " )
480480                    );
481481
482-                     delay =  DEALLOCATION_DELAY;
482+                     delay =  DEALLOCATION_DELAY  +   1 ;
483483                }
484484
485485                assertEq (
@@ -540,6 +540,29 @@ abstract contract IntegrationBase is IntegrationDeployer {
540540        }
541541    }
542542
543+     function assert_Snap_StakerWithdrawableShares_AfterSlash  (
544+         User staker ,
545+         IAllocationManagerTypes.AllocateParams memory  allocateParams ,
546+         IAllocationManagerTypes.SlashingParams memory  slashingParams ,
547+         string  memory  err 
548+     ) internal  {
549+         uint [] memory  curShares =  _getWithdrawableShares (staker, allocateParams.strategies);
550+         uint [] memory  prevShares =  _getPrevWithdrawableShares (staker, allocateParams.strategies);
551+ 
552+         for  (uint  i =  0 ; i <  allocateParams.strategies.length ; i++ ) {
553+             IStrategy strat =  allocateParams.strategies[i];
554+ 
555+             uint256  slashedShares =  0 ;
556+ 
557+             if  (slashingParams.strategies.contains (strat)) {
558+                 uint  wadToSlash =  slashingParams.wadsToSlash[slashingParams.strategies.indexOf (strat)];
559+                 slashedShares =  prevShares[i].mulWadRoundUp (allocateParams.newMagnitudes[i].mulWadRoundUp (wadToSlash));
560+             }
561+ 
562+             assertApproxEqAbs (prevShares[i] -  slashedShares, curShares[i], 1 , err);
563+         }
564+     }
565+ 
543566    // TODO: slashable stake 
544567
545568    /******************************************************************************* 
@@ -809,7 +832,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
809832            uint  prevShare =  prevShares[i];
810833            uint  curShare =  curShares[i];
811834
812-             assertEq (prevShare -  removedShares[i], curShare, err);
835+             assertApproxEqAbs (prevShare -  removedShares[i], curShare,  1 , err);
813836        }
814837    }
815838
@@ -850,7 +873,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
850873            uint  prevBalance =  prevTokenBalances[i];
851874            uint  curBalance =  curTokenBalances[i];
852875
853-             assertEq (prevBalance +  addedTokens[i], curBalance, err);
876+             assertApproxEqAbs (prevBalance +  addedTokens[i], curBalance,  1 , err);
854877        }
855878    }
856879
@@ -1321,14 +1344,33 @@ abstract contract IntegrationBase is IntegrationDeployer {
13211344    }
13221345
13231346    /// @dev Rolls forward by the default allocation delay blocks. 
1324-     function _rollBlocksForCompleteAllocation  () internal  {
1325-         (, uint32  delay ) =  allocationManager.getAllocationDelay (address (this ));
1326-         rollForward ({blocks: delay});
1347+     function _rollBlocksForCompleteAllocation  (
1348+         User operator ,
1349+         OperatorSet memory  operatorSet ,
1350+         IStrategy[] memory  strategies 
1351+     ) internal  {
1352+         uint256  latest;
1353+         for  (uint  i =  0 ; i <  strategies.length ; ++ i) {
1354+             uint  effectBlock =  allocationManager.getAllocation (address (operator), operatorSet, strategies[i]).effectBlock;
1355+             if  (effectBlock >  latest) latest =  effectBlock;
1356+         }
1357+         cheats.roll (latest +  1 );
13271358    }
13281359
1329-     /// @dev Rolls forward by the default deallocation delay blocks. 
1330-     function _rollBlocksForCompleteDeallocation  () internal  {
1331-         cheats.roll (block .number  +  allocationManager.DEALLOCATION_DELAY () +  1 );
1360+     /// @dev Rolls forward by the default allocation delay blocks. 
1361+     function _rollBlocksForCompleteAllocation  (
1362+         User operator ,
1363+         OperatorSet[] memory  operatorSets ,
1364+         IStrategy[] memory  strategies 
1365+     ) internal  {
1366+         uint256  latest;
1367+         for  (uint  i =  0 ; i <  operatorSets.length ; ++ i) {
1368+             for  (uint  j =  0 ; j <  strategies.length ; ++ j) {
1369+                 uint  effectBlock =  allocationManager.getAllocation (address (operator), operatorSets[i], strategies[j]).effectBlock;
1370+                 if  (effectBlock >  latest) latest =  effectBlock;
1371+             }
1372+         }
1373+         cheats.roll (latest +  1 );
13321374    }
13331375
13341376    /// @dev Uses timewarp modifier to get the operator set strategy allocations at the last snapshot. 
@@ -1528,6 +1570,14 @@ abstract contract IntegrationBase is IntegrationDeployer {
15281570        return  shares;
15291571    }
15301572
1573+     function _getPrevWithdrawableShares  (User staker , IStrategy[] memory  strategies ) internal  timewarp () returns  (uint [] memory ) {
1574+         return  _getWithdrawableShares (staker, strategies);
1575+     }
1576+ 
1577+     function _getWithdrawableShares  (User staker , IStrategy[] memory  strategies ) internal  view  returns  (uint [] memory  withdrawableShares ) {
1578+         (withdrawableShares, ) =   delegationManager.getWithdrawableShares (address (staker), strategies);
1579+     }
1580+ 
15311581    function _getActiveValidatorCount  (User staker ) internal  view  returns  (uint ) {
15321582        EigenPod pod =  staker.pod ();
15331583        return  pod.activeValidatorCount ();
0 commit comments