@@ -73,7 +73,7 @@ contract SlashEscrowFactoryUnitTests is EigenLayerUnitTestSetup, ISlashEscrowFac
73
73
return factory.getPendingUnderlyingAmountForStrategy (operatorSet, slashId, strategy);
74
74
}
75
75
76
- /// @dev Starts a burn or redistribution for a given strategy and token.
76
+ /// @dev Starts a escrow for a given strategy and token.
77
77
/// - Calls as the `StrategyManager`.
78
78
/// - Asserts that the `StartEscrow` event is emitted.
79
79
/// - Mocks the strategy sending the underlying token to the `SlashEscrow`.
@@ -111,16 +111,18 @@ contract SlashEscrowFactoryUnitTests is EigenLayerUnitTestSetup, ISlashEscrowFac
111
111
assertTrue (slashEscrow.verifyDeploymentParameters (factory, slashEscrowImplementation, operatorSet, slashId));
112
112
}
113
113
114
+ /// @dev Calls the `releaseSlashEscrow` function as the redistribution recipient.
115
+ /// - Asserts that the `Escrow` event is emitted
114
116
function _releaseSlashEscrowByIndex (OperatorSet memory operatorSet , uint slashId , uint index ) internal {
115
117
(IStrategy[] memory strategies ) = factory.getPendingStrategiesForSlashId (operatorSet, slashId);
116
118
117
119
address redistributionRecipient = allocationManagerMock.getRedistributionRecipient (operatorSet);
118
120
119
121
cheats.expectEmit (true , true , true , true );
120
- emit EscrowComplete (operatorSet, slashId, strategies[index], defaultRedistributionRecipient );
122
+ emit EscrowComplete (operatorSet, slashId, strategies[index], redistributionRecipient );
121
123
122
124
// If the redistribution recipient is any address
123
- if (redistributionRecipient != DEFAULT_BURN_ADDRESS) cheats.prank (defaultRedistributionRecipient );
125
+ if (redistributionRecipient != DEFAULT_BURN_ADDRESS) cheats.prank (redistributionRecipient );
124
126
else cheats.prank (cheats.randomAddress ());
125
127
factory.releaseSlashEscrowByIndex (operatorSet, slashId, index);
126
128
@@ -131,7 +133,7 @@ contract SlashEscrowFactoryUnitTests is EigenLayerUnitTestSetup, ISlashEscrowFac
131
133
assertTrue (slashEscrow.verifyDeploymentParameters (factory, slashEscrowImplementation, operatorSet, slashId));
132
134
}
133
135
134
- /// @dev Asserts that the operator set and slash ID are pending, and that the strategy and underlying amount are in the pending burn or redistributions .
136
+ /// @dev Asserts that the operator set and slash ID are pending, and that the strategy and underlying amount are in the pending escrows .
135
137
function _checkStartEscrows (
136
138
OperatorSet memory operatorSet ,
137
139
uint slashId ,
@@ -152,7 +154,7 @@ contract SlashEscrowFactoryUnitTests is EigenLayerUnitTestSetup, ISlashEscrowFac
152
154
// Assert that the underlying amount in escrow for the (operator set, slash ID, strategy) is correct.
153
155
assertEq (_getPendingUnderlyingAmountForStrategy (operatorSet, slashId, strategy, token), expectedUnderlyingAmount);
154
156
155
- // Assert that the number of pending burn or redistributions is correct.
157
+ // Assert that the number of pending escrows is correct.
156
158
(IStrategy[] memory strategies ) = factory.getPendingStrategiesForSlashId (operatorSet, slashId);
157
159
158
160
assertEq (strategies.length , expectedCount);
@@ -189,16 +191,16 @@ contract SlashEscrowFactoryUnitTests_initiateSlashEscrow is SlashEscrowFactoryUn
189
191
function testFuzz_initiateSlashEscrow_multipleStrategies (uint r ) public {
190
192
// Initialize arrays to store test data for multiple strategies
191
193
uint numStrategies = bound (r, 2 , 10 );
192
- // Set up each strategy with random data and start burn/redistribution
194
+ // Set up each strategy with random data and start escrow
193
195
for (uint i = 0 ; i < numStrategies; i++ ) {
194
196
// Generate random strategy address and token
195
197
IStrategy strategy = IStrategy (cheats.randomAddress ());
196
198
MockERC20 token = new MockERC20 ();
197
199
uint underlyingAmount = cheats.randomUint ();
198
200
199
- // Start burn/redistribution for this strategy
201
+ // Start escrow for this strategy
200
202
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategy, token, underlyingAmount);
201
- // Verify the burn/redistribution was started correctly
203
+ // Verify the escrow was started correctly
202
204
_checkStartEscrows (defaultOperatorSet, defaultSlashId, strategy, token, underlyingAmount, i + 1 );
203
205
}
204
206
}
@@ -261,31 +263,31 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrow is SlashEscrowFactoryUni
261
263
MockERC20[] memory tokens = new MockERC20 [](numStrategies);
262
264
uint [] memory underlyingAmounts = new uint [](numStrategies);
263
265
264
- // Randomly update the redistribution to be the default burn address
265
- _setRedistributionRecipient (r % 2 == 0 );
266
+ // // Randomly update the redistribution to be the default burn address
267
+ // _setRedistributionRecipient(r % 2 == 0);
266
268
267
- // Set up each strategy with random data and start burn/redistribution
269
+ // Set up each strategy with random data and start escrow
268
270
for (uint i = 0 ; i < numStrategies; i++ ) {
269
271
// Generate random strategy address and token
270
272
strategies[i] = IStrategy (cheats.randomAddress ());
271
273
tokens[i] = new MockERC20 ();
272
274
underlyingAmounts[i] = cheats.randomUint ();
273
275
274
- // Start burn/redistribution for this strategy
276
+ // Start escrow for this strategy
275
277
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i]);
276
- // Verify the burn/redistribution was started correctly
278
+ // Verify the escrow was started correctly
277
279
_checkStartEscrows (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i], i + 1 );
278
280
}
279
281
280
- // Advance time to allow burn/redistribution to occur
282
+ // Advance time to allow escrow to occur
281
283
_rollForwardDefaultEscrowDelay ();
282
284
283
285
// Set up mock calls for each strategy's underlying token
284
286
for (uint i = numStrategies; i > 0 ; i-- ) {
285
287
_mockStrategyUnderlyingTokenCall (strategies[i - 1 ], address (tokens[i - 1 ]));
286
288
}
287
289
288
- // Execute the burn/redistribution
290
+ // Execute the escrow
289
291
_releaseSlashEscrow (defaultOperatorSet, defaultSlashId);
290
292
291
293
// Checks
@@ -296,7 +298,7 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrow is SlashEscrowFactoryUni
296
298
assertEq (factory.getTotalPendingOperatorSets (), 0 );
297
299
assertEq (factory.getTotalPendingSlashIds (defaultOperatorSet), 0 );
298
300
299
- // Assert that the strategies and underlying amounts are no longer in the pending burn or redistributions .
301
+ // Assert that the strategies and underlying amounts are no longer in the pending escrows .
300
302
assertEq (factory.getTotalPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId), 0 );
301
303
302
304
// Assert that the underlying amounts are no longer set.
@@ -338,9 +340,9 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrow is SlashEscrowFactoryUni
338
340
cheats.prank (defaultOwner);
339
341
factory.setStrategyEscrowDelay (strategies[i], delays[i]);
340
342
341
- // Start burn/redistribution for this strategy
343
+ // Start escrow for this strategy
342
344
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i]);
343
- // Verify the burn/redistribution was started correctly
345
+ // Verify the escrow was started correctly
344
346
_checkStartEscrows (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i], i + 1 );
345
347
}
346
348
@@ -358,7 +360,7 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrow is SlashEscrowFactoryUni
358
360
_mockStrategyUnderlyingTokenCall (strategies[i], address (tokens[i]));
359
361
}
360
362
361
- // Execute the burn/redistribution
363
+ // Execute the escrow
362
364
_releaseSlashEscrow (defaultOperatorSet, defaultSlashId);
363
365
364
366
// Verify that all strategies have been processed
@@ -392,9 +394,9 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrow is SlashEscrowFactoryUni
392
394
393
395
// Set up numEscrows slash escrows for the same operator set
394
396
for (uint i = 0 ; i < numEscrows; i++ ) {
395
- // Start burn/redistribution for this slash
397
+ // Start escrow for this slash
396
398
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId + i, strategies[0 ], tokens[0 ], underlyingAmounts[0 ]);
397
- // Verify the burn/redistribution was started correctly
399
+ // Verify the escrow was started correctly
398
400
_checkStartEscrows (defaultOperatorSet, defaultSlashId + i, strategies[0 ], tokens[0 ], underlyingAmounts[0 ], 1 );
399
401
}
400
402
@@ -475,7 +477,7 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrowByIndex is SlashEscrowFac
475
477
}
476
478
477
479
/// @dev Tests that multiple strategies can be burned or redistributed across multiple calls
478
- function testFuzz_releaseSlashEscrow_multipleStrategies_sameDelay (uint r ) public {
480
+ function testFuzz_releaseSlashEscrowByIndex__multipleStrategies_sameDelay (uint r ) public {
479
481
// Initialize arrays to store test data for multiple strategies
480
482
uint numStrategies = bound (r, 2 , 10 );
481
483
IStrategy[] memory strategies = new IStrategy [](numStrategies);
@@ -485,20 +487,20 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrowByIndex is SlashEscrowFac
485
487
// Randomly update the redistribution to be the default burn address
486
488
_setRedistributionRecipient (r % 2 == 0 );
487
489
488
- // Set up each strategy with random data and start burn/redistribution
490
+ // Set up each strategy with random data and start escrow
489
491
for (uint i = 0 ; i < numStrategies; i++ ) {
490
492
// Generate random strategy address and token
491
493
strategies[i] = IStrategy (cheats.randomAddress ());
492
494
tokens[i] = new MockERC20 ();
493
495
underlyingAmounts[i] = cheats.randomUint ();
494
496
495
- // Start burn/redistribution for this strategy
497
+ // Start escrow for this strategy
496
498
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i]);
497
- // Verify the burn/redistribution was started correctly
499
+ // Verify the escrow was started correctly
498
500
_checkStartEscrows (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i], i + 1 );
499
501
}
500
502
501
- // Advance time to allow burn/redistribution to occur
503
+ // Advance time to allow escrow to occur
502
504
_rollForwardDefaultEscrowDelay ();
503
505
504
506
// Set up mock calls for each strategy's underlying token
@@ -516,7 +518,7 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrowByIndex is SlashEscrowFac
516
518
assertTrue (factory.isPendingSlashId (defaultOperatorSet, defaultSlashId));
517
519
assertEq (factory.getTotalPendingOperatorSets (), 1 );
518
520
assertEq (factory.getTotalPendingSlashIds (defaultOperatorSet), 1 );
519
- assertEq (factory.getTotalPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId), numStrategies - 1 );
521
+ assertEq (factory.getTotalPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId), 1 );
520
522
521
523
// Release the last slash escrow
522
524
_releaseSlashEscrowByIndex (defaultOperatorSet, defaultSlashId, 0 );
@@ -529,7 +531,67 @@ contract SlashEscrowFactoryUnitTests_releaseSlashEscrowByIndex is SlashEscrowFac
529
531
assertEq (factory.getTotalPendingOperatorSets (), 0 );
530
532
assertEq (factory.getTotalPendingSlashIds (defaultOperatorSet), 0 );
531
533
532
- // Assert that the strategies and underlying amounts are no longer in the pending burn or redistributions.
534
+ // Assert that the strategies and underlying amounts are no longer in the pending escrows.
535
+ assertEq (factory.getTotalPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId), 0 );
536
+
537
+ // Assert that the underlying amounts are no longer set.
538
+ for (uint i = numStrategies; i > 0 ; i-- ) {
539
+ assertEq (_getPendingUnderlyingAmountForStrategy (defaultOperatorSet, defaultSlashId, strategies[i - 1 ], tokens[i - 1 ]), 0 );
540
+ }
541
+
542
+ // Assert that the start block for the (operator set, slash ID) is no longer set.
543
+ assertEq (factory.getEscrowStartBlock (defaultOperatorSet, defaultSlashId), 0 );
544
+ }
545
+
546
+ /// @dev Tests that multiple strategies can be burned or redistributed across multiple calls
547
+ function testFuzz_releaseSlashEscrowByIndex__multipleStrategies_byIndexThenAll (uint r ) public {
548
+ // Initialize arrays to store test data for multiple strategies
549
+ uint numStrategies = bound (r, 2 , 10 );
550
+ IStrategy[] memory strategies = new IStrategy [](numStrategies);
551
+ MockERC20[] memory tokens = new MockERC20 [](numStrategies);
552
+ uint [] memory underlyingAmounts = new uint [](numStrategies);
553
+
554
+ // Randomly update the redistribution to be the default burn address
555
+ _setRedistributionRecipient (r % 2 == 0 );
556
+
557
+ // Set up each strategy with random data and start escrow
558
+ for (uint i = 0 ; i < numStrategies; i++ ) {
559
+ // Generate random strategy address and token
560
+ strategies[i] = IStrategy (cheats.randomAddress ());
561
+ tokens[i] = new MockERC20 ();
562
+ underlyingAmounts[i] = cheats.randomUint ();
563
+
564
+ // Start escrow for this strategy
565
+ _initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i]);
566
+ // Verify the escrow was started correctly
567
+ _checkStartEscrows (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i], i + 1 );
568
+ }
569
+
570
+ // Advance time to allow escrow to occur
571
+ _rollForwardDefaultEscrowDelay ();
572
+
573
+ // Release the first index
574
+ _releaseSlashEscrowByIndex (defaultOperatorSet, defaultSlashId, 0 );
575
+
576
+ // Assert that the slashId and operatorSet are still pending
577
+ assertTrue (factory.isPendingOperatorSet (defaultOperatorSet));
578
+ assertTrue (factory.isPendingSlashId (defaultOperatorSet, defaultSlashId));
579
+ assertEq (factory.getTotalPendingOperatorSets (), 1 );
580
+ assertEq (factory.getTotalPendingSlashIds (defaultOperatorSet), 1 );
581
+ assertEq (factory.getTotalPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId), numStrategies - 1 );
582
+
583
+ // Release remaining
584
+ _releaseSlashEscrow (defaultOperatorSet, defaultSlashId);
585
+
586
+ // Checks
587
+
588
+ // Assert that the operator set and slash ID are no longer pending.
589
+ assertFalse (factory.isPendingOperatorSet (defaultOperatorSet));
590
+ assertFalse (factory.isPendingSlashId (defaultOperatorSet, defaultSlashId));
591
+ assertEq (factory.getTotalPendingOperatorSets (), 0 );
592
+ assertEq (factory.getTotalPendingSlashIds (defaultOperatorSet), 0 );
593
+
594
+ // Assert that the strategies and underlying amounts are no longer in the pending escrows.
533
595
assertEq (factory.getTotalPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId), 0 );
534
596
535
597
// Assert that the underlying amounts are no longer set.
@@ -639,9 +701,9 @@ contract SlashEscrowFactoryUnitTests_getBurnOrRedistributionDelay is SlashEscrow
639
701
cheats.prank (defaultOwner);
640
702
factory.setStrategyEscrowDelay (strategies[i], delays[i]);
641
703
642
- // Start burn/redistribution for this strategy
704
+ // Start escrow for this strategy
643
705
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i]);
644
- // Verify the burn/redistribution was started correctly
706
+ // Verify the escrow was started correctly
645
707
_checkStartEscrows (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i], i + 1 );
646
708
}
647
709
@@ -677,9 +739,9 @@ contract SlashEscrowFactoryUnitTests_getEscrowDelay is SlashEscrowFactoryUnitTes
677
739
cheats.prank (defaultOwner);
678
740
factory.setStrategyEscrowDelay (strategies[i], delays[i]);
679
741
680
- // Start burn/redistribution for this strategy
742
+ // Start escrow for this strategy
681
743
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i]);
682
- // Verify the burn/redistribution was started correctly
744
+ // Verify the escrow was started correctly
683
745
_checkStartEscrows (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i], i + 1 );
684
746
}
685
747
@@ -706,10 +768,10 @@ contract SlashEscrowFactoryUnitTests_setGlobalEscrowDelay is SlashEscrowFactoryU
706
768
707
769
contract SlashEscrowFactoryUnitTests_getPendingEscrows is SlashEscrowFactoryUnitTests {
708
770
function test_getPendingEscrows_singleSlashId () public {
709
- // Start burn/redistribution for a single strategy
771
+ // Start escrow for a single strategy
710
772
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, defaultStrategy, defaultToken, 100 );
711
773
712
- // Get pending burn/redistributions for the specific slash ID
774
+ // Get pending escrows for the specific slash ID
713
775
(IStrategy[] memory strategies ) = factory.getPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId);
714
776
715
777
// Verify results
@@ -718,7 +780,7 @@ contract SlashEscrowFactoryUnitTests_getPendingEscrows is SlashEscrowFactoryUnit
718
780
}
719
781
720
782
function test_getPendingEscrows_multipleStrategies () public {
721
- // Create multiple strategies and start burn/redistributions
783
+ // Create multiple strategies and start escrows
722
784
IStrategy strategy1 = IStrategy (cheats.randomAddress ());
723
785
IStrategy strategy2 = IStrategy (cheats.randomAddress ());
724
786
MockERC20 token1 = new MockERC20 ();
@@ -727,7 +789,7 @@ contract SlashEscrowFactoryUnitTests_getPendingEscrows is SlashEscrowFactoryUnit
727
789
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategy1, token1, 100 );
728
790
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategy2, token2, 200 );
729
791
730
- // Get pending burn/redistributions for the specific slash ID
792
+ // Get pending escrows for the specific slash ID
731
793
(IStrategy[] memory strategies ) = factory.getPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId);
732
794
733
795
// Verify results
@@ -747,11 +809,11 @@ contract SlashEscrowFactoryUnitTests_getPendingEscrows is SlashEscrowFactoryUnit
747
809
MockERC20 token1 = new MockERC20 ();
748
810
MockERC20 token2 = new MockERC20 ();
749
811
750
- // Start burn/redistributions for different slash IDs
812
+ // Start escrows for different slash IDs
751
813
_initiateSlashEscrow (defaultOperatorSet, slashId1, strategy1, token1, 100 );
752
814
_initiateSlashEscrow (defaultOperatorSet, slashId2, strategy2, token2, 200 );
753
815
754
- // Get pending burn/redistributions for all slash IDs of the operator set
816
+ // Get pending escrows for all slash IDs of the operator set
755
817
(IStrategy[][] memory strategies ) = factory.getPendingStrategiesForSlashIds (defaultOperatorSet);
756
818
757
819
// Verify results
@@ -769,7 +831,7 @@ contract SlashEscrowFactoryUnitTests_getPendingEscrows is SlashEscrowFactoryUnit
769
831
}
770
832
771
833
function test_getPendingEscrows_empty () public {
772
- // Test with no pending burn/redistributions
834
+ // Test with no pending escrows
773
835
(IStrategy[] memory strategies ) = factory.getPendingStrategiesForSlashId (defaultOperatorSet, defaultSlashId);
774
836
assertEq (strategies.length , 0 );
775
837
@@ -811,9 +873,9 @@ contract SlashEscrowFactoryUnitTests_getEscrowCompleteBlock is SlashEscrowFactor
811
873
cheats.prank (defaultOwner);
812
874
factory.setStrategyEscrowDelay (strategies[i], delays[i]);
813
875
814
- // Start burn/redistribution for this strategy
876
+ // Start escrow for this strategy
815
877
_initiateSlashEscrow (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i]);
816
- // Verify the burn/redistribution was started correctly
878
+ // Verify the escrow was started correctly
817
879
_checkStartEscrows (defaultOperatorSet, defaultSlashId, strategies[i], tokens[i], underlyingAmounts[i], i + 1 );
818
880
}
819
881
0 commit comments