@@ -479,7 +479,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
479
479
string .concat (err, " (pendingDiff) " )
480
480
);
481
481
482
- delay = DEALLOCATION_DELAY;
482
+ delay = DEALLOCATION_DELAY + 1 ;
483
483
}
484
484
485
485
assertEq (
@@ -540,6 +540,29 @@ abstract contract IntegrationBase is IntegrationDeployer {
540
540
}
541
541
}
542
542
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
+
543
566
// TODO: slashable stake
544
567
545
568
/*******************************************************************************
@@ -809,7 +832,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
809
832
uint prevShare = prevShares[i];
810
833
uint curShare = curShares[i];
811
834
812
- assertEq (prevShare - removedShares[i], curShare, err);
835
+ assertApproxEqAbs (prevShare - removedShares[i], curShare, 1 , err);
813
836
}
814
837
}
815
838
@@ -850,7 +873,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
850
873
uint prevBalance = prevTokenBalances[i];
851
874
uint curBalance = curTokenBalances[i];
852
875
853
- assertEq (prevBalance + addedTokens[i], curBalance, err);
876
+ assertApproxEqAbs (prevBalance + addedTokens[i], curBalance, 1 , err);
854
877
}
855
878
}
856
879
@@ -1321,14 +1344,33 @@ abstract contract IntegrationBase is IntegrationDeployer {
1321
1344
}
1322
1345
1323
1346
/// @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 );
1327
1358
}
1328
1359
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 );
1332
1374
}
1333
1375
1334
1376
/// @dev Uses timewarp modifier to get the operator set strategy allocations at the last snapshot.
@@ -1528,6 +1570,14 @@ abstract contract IntegrationBase is IntegrationDeployer {
1528
1570
return shares;
1529
1571
}
1530
1572
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
+
1531
1581
function _getActiveValidatorCount (User staker ) internal view returns (uint ) {
1532
1582
EigenPod pod = staker.pod ();
1533
1583
return pod.activeValidatorCount ();
0 commit comments