@@ -20,7 +20,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
20
20
using Strings for * ;
21
21
using print for * ;
22
22
23
- using ArrayLib for IStrategy[] ;
23
+ using ArrayLib for * ;
24
24
25
25
uint numStakers = 0 ;
26
26
uint numOperators = 0 ;
@@ -49,7 +49,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
49
49
IStrategy[] memory strategies;
50
50
uint [] memory tokenBalances;
51
51
52
- if (forkType == MAINNET && ! isUpgraded) {
52
+ if (! isUpgraded) {
53
53
stakerName = string .concat ("M2Staker " , cheats.toString (numStakers));
54
54
55
55
(staker, strategies, tokenBalances) = _randUser (stakerName);
@@ -79,7 +79,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
79
79
uint [] memory tokenBalances;
80
80
uint [] memory addedShares;
81
81
82
- if (forkType == MAINNET && ! isUpgraded) {
82
+ if (! isUpgraded) {
83
83
string memory operatorName = string .concat ("M2Operator " , numOperators.toString ());
84
84
85
85
// Create an operator for M2.
@@ -102,11 +102,12 @@ abstract contract IntegrationBase is IntegrationDeployer {
102
102
operator.registerAsOperator ();
103
103
operator.depositIntoEigenlayer (strategies, tokenBalances);
104
104
105
- // Roll passed the allocation configuration delay
105
+ // Roll past the allocation configuration delay
106
106
rollForward ({blocks: ALLOCATION_CONFIGURATION_DELAY});
107
- }
108
107
109
- assert_Snap_Added_Staker_DepositShares (operator, strategies, addedShares, "_newRandomOperator: failed to add delegatable shares " );
108
+ assert_Snap_Added_Staker_DepositShares (operator, strategies, addedShares, "_newRandomOperator: failed to add delegatable shares " );
109
+ }
110
+
110
111
assert_Snap_Added_OperatorShares (operator, strategies, addedShares, "_newRandomOperator: failed to award shares to operator " );
111
112
assertTrue (delegationManager.isOperator (address (operator)), "_newRandomOperator: operator should be registered " );
112
113
@@ -141,13 +142,13 @@ abstract contract IntegrationBase is IntegrationDeployer {
141
142
142
143
/// @dev Choose a random subset of validators (selects AT LEAST ONE)
143
144
function _choose (uint40 [] memory validators ) internal returns (uint40 [] memory ) {
144
- uint rand = _randUint ({ min: 1 , max: validators.length ** 2 });
145
+ uint _rand = _randUint ({ min: 1 , max: validators.length ** 2 });
145
146
146
147
uint40 [] memory result = new uint40 [](validators.length );
147
148
uint newLen;
148
149
for (uint i = 0 ; i < validators.length ; i++ ) {
149
150
// if bit set, add validator
150
- if (rand >> i & 1 == 1 ) {
151
+ if (_rand >> i & 1 == 1 ) {
151
152
result[newLen] = validators[i];
152
153
newLen++ ;
153
154
}
@@ -645,20 +646,15 @@ abstract contract IntegrationBase is IntegrationDeployer {
645
646
function assert_Snap_Added_Staker_DepositShares (
646
647
User staker ,
647
648
IStrategy strat ,
648
- uint _addedShares ,
649
+ uint addedShares ,
649
650
string memory err
650
651
) internal {
651
- IStrategy[] memory strategies = new IStrategy [](1 );
652
- uint [] memory addedShares = new uint [](1 );
653
- strategies[0 ] = strat;
654
- addedShares[0 ] = _addedShares;
655
-
656
- assert_Snap_Added_Staker_DepositShares (staker, strategies, addedShares, err);
652
+ assert_Snap_Added_Staker_DepositShares (staker, strat.toArray (), addedShares.toArrayU256 (), err);
657
653
}
658
654
659
655
/// @dev Check that the staker has `removedShares` fewer delegatable shares
660
656
/// for each strategy since the last snapshot
661
- function assert_Snap_Removed_StakerDepositShares (
657
+ function assert_Snap_Removed_Staker_DepositShares (
662
658
User staker ,
663
659
IStrategy[] memory strategies ,
664
660
uint [] memory removedShares ,
@@ -674,22 +670,52 @@ abstract contract IntegrationBase is IntegrationDeployer {
674
670
}
675
671
}
676
672
677
- function assert_Snap_Removed_StakerDepositShares (
673
+ function assert_Snap_Removed_Staker_DepositShares (
678
674
User staker ,
679
675
IStrategy strat ,
680
- uint _removedShares ,
676
+ uint removedShares ,
677
+ string memory err
678
+ ) internal {
679
+ assert_Snap_Removed_Staker_DepositShares (staker, strat.toArray (), removedShares.toArrayU256 (), err);
680
+ }
681
+
682
+ /// @dev Check that the staker's delegatable shares in ALL strategies have not changed
683
+ /// since the last snapshot
684
+ function assert_Snap_Unchanged_Staker_DepositShares (
685
+ User staker ,
681
686
string memory err
682
687
) internal {
683
- IStrategy[] memory strategies = new IStrategy [](1 );
684
- uint [] memory removedShares = new uint [](1 );
685
- strategies[0 ] = strat;
686
- removedShares[0 ] = _removedShares;
688
+ IStrategy[] memory strategies = allStrats;
689
+
690
+ uint [] memory curShares = _getStakerDepositShares (staker, strategies);
691
+ // Use timewarp to get previous staker shares
692
+ uint [] memory prevShares = _getPrevStakerDepositShares (staker, strategies);
687
693
688
- assert_Snap_Removed_StakerDepositShares (staker, strategies, removedShares, err);
694
+ // For each strategy, check (prev == cur)
695
+ for (uint i = 0 ; i < strategies.length ; i++ ) {
696
+ assertEq (prevShares[i], curShares[i], err);
697
+ }
689
698
}
690
699
691
700
/// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
692
- function assert_Snap_Removed_StakerWithdrawableShares (
701
+ function assert_Snap_Added_Staker_WithdrawableShares (
702
+ User staker ,
703
+ IStrategy[] memory strategies ,
704
+ uint [] memory addedShares ,
705
+ string memory err
706
+ ) internal {
707
+ uint [] memory curShares = _getStakerWithdrawableShares (staker, strategies);
708
+ // Use timewarp to get previous staker shares
709
+ uint [] memory prevShares = _getPrevStakerWithdrawableShares (staker, strategies);
710
+
711
+ // For each strategy, check (prev - removed == cur)
712
+ for (uint i = 0 ; i < strategies.length ; i++ ) {
713
+ assertEq (prevShares[i] + addedShares[i], curShares[i], err);
714
+ }
715
+ }
716
+
717
+ /// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
718
+ function assert_Snap_Removed_Staker_WithdrawableShares (
693
719
User staker ,
694
720
IStrategy[] memory strategies ,
695
721
uint [] memory removedShares ,
@@ -705,18 +731,30 @@ abstract contract IntegrationBase is IntegrationDeployer {
705
731
}
706
732
}
707
733
708
- function assert_Snap_Removed_StakerWithdrawableShares (
734
+ function assert_Snap_Removed_Staker_WithdrawableShares (
709
735
User staker ,
710
736
IStrategy strat ,
711
- uint _removedShares ,
737
+ uint removedShares ,
738
+ string memory err
739
+ ) internal {
740
+ assert_Snap_Removed_Staker_WithdrawableShares (staker, strat.toArray (), removedShares.toArrayU256 (), err);
741
+ }
742
+
743
+ /// @dev Check that the staker's withdrawable shares have decreased by `removedShares`
744
+ function assert_Snap_Unchanged_Staker_WithdrawableShares (
745
+ User staker ,
712
746
string memory err
713
747
) internal {
714
- IStrategy[] memory strategies = new IStrategy [](1 );
715
- uint [] memory removedShares = new uint [](1 );
716
- strategies[0 ] = strat;
717
- removedShares[0 ] = _removedShares;
748
+ IStrategy[] memory strategies = allStrats;
749
+
750
+ uint [] memory curShares = _getStakerWithdrawableShares (staker, strategies);
751
+ // Use timewarp to get previous staker shares
752
+ uint [] memory prevShares = _getPrevStakerWithdrawableShares (staker, strategies);
718
753
719
- assert_Snap_Removed_StakerWithdrawableShares (staker, strategies, removedShares, err);
754
+ // For each strategy, check (prev - removed == cur)
755
+ for (uint i = 0 ; i < strategies.length ; i++ ) {
756
+ assertEq (prevShares[i], curShares[i], err);
757
+ }
720
758
}
721
759
722
760
/// @dev Check that the staker's withdrawable shares have decreased by at least `removedShares`
@@ -743,30 +781,7 @@ abstract contract IntegrationBase is IntegrationDeployer {
743
781
uint removedShares ,
744
782
string memory err
745
783
) internal {
746
- IStrategy[] memory strategies = new IStrategy [](1 );
747
- uint [] memory removedSharesArr = new uint [](1 );
748
- strategies[0 ] = strat;
749
- removedSharesArr[0 ] = removedShares;
750
-
751
- assert_Snap_Removed_Staker_WithdrawableShares_AtLeast (staker, strategies, removedSharesArr, err);
752
- }
753
-
754
- /// @dev Check that the staker's delegatable shares in ALL strategies have not changed
755
- /// since the last snapshot
756
- function assert_Snap_Unchanged_StakerDepositShares (
757
- User staker ,
758
- string memory err
759
- ) internal {
760
- IStrategy[] memory strategies = allStrats;
761
-
762
- uint [] memory curShares = _getStakerDepositShares (staker, strategies);
763
- // Use timewarp to get previous staker shares
764
- uint [] memory prevShares = _getPrevStakerDepositShares (staker, strategies);
765
-
766
- // For each strategy, check (prev == cur)
767
- for (uint i = 0 ; i < strategies.length ; i++ ) {
768
- assertEq (prevShares[i], curShares[i], err);
769
- }
784
+ assert_Snap_Removed_Staker_WithdrawableShares_AtLeast (staker, strat.toArray (), removedShares.toArrayU256 (), err);
770
785
}
771
786
772
787
function assert_Snap_Delta_StakerShares (
@@ -1485,24 +1500,15 @@ abstract contract IntegrationBase is IntegrationDeployer {
1485
1500
// This method should only be used for tests that handle positive
1486
1501
// balances. Negative balances are an edge case that require
1487
1502
// the own tests and helper methods.
1488
- int shares;
1489
- if (forkType != LOCAL && ! isUpgraded) {
1490
- shares = int (IEigenPodManager_DeprecatedM2 (address (eigenPodManager)).podOwnerShares (address (staker)));
1491
- } else {
1492
- shares = int (eigenPodManager.podOwnerDepositShares (address (staker)));
1493
- }
1503
+ int shares = eigenPodManager.podOwnerDepositShares (address (staker));
1494
1504
1495
1505
if (shares < 0 ) {
1496
1506
revert ("_getStakerDepositShares: negative shares " );
1497
1507
}
1498
1508
1499
1509
curShares[i] = uint (shares);
1500
1510
} else {
1501
- if (forkType != LOCAL && ! isUpgraded) {
1502
- curShares[i] = IStrategyManager_DeprecatedM2 (address (strategyManager)).stakerStrategyShares (address (staker), strat);
1503
- } else {
1504
- curShares[i] = strategyManager.stakerDepositShares (address (staker), strat);
1505
- }
1511
+ curShares[i] = strategyManager.stakerDepositShares (address (staker), strat);
1506
1512
}
1507
1513
}
1508
1514
@@ -1656,13 +1662,8 @@ abstract contract IntegrationBase is IntegrationDeployer {
1656
1662
}
1657
1663
1658
1664
function _getCheckpointPodBalanceGwei (User staker ) internal view returns (uint64 ) {
1659
- if (forkType != LOCAL && ! isUpgraded) {
1660
- IEigenPod_DeprecatedM2 pod = IEigenPod_DeprecatedM2 (address (staker.pod ()));
1661
- return uint64 (pod.currentCheckpoint ().podBalanceGwei);
1662
- } else {
1663
- EigenPod pod = staker.pod ();
1664
- return uint64 (pod.currentCheckpoint ().podBalanceGwei);
1665
- }
1665
+ EigenPod pod = staker.pod ();
1666
+ return uint64 (pod.currentCheckpoint ().podBalanceGwei);
1666
1667
}
1667
1668
1668
1669
function _getPrevCheckpointPodBalanceGwei (User staker ) internal timewarp () returns (uint64 ) {
0 commit comments