Skip to content

Commit 38f5faa

Browse files
authored
feat: add OperatorSharesSlashed event to track shares slashed per operator (#1051)
* feat: add OperatorSharesSlashed event to track shares slashed per operator * feat: add unit tests * fix: add more tests
1 parent da9f3dc commit 38f5faa

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

src/contracts/core/DelegationManager.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,9 @@ contract DelegationManager is
307307
sharesToDecrease: operatorSharesSlashed
308308
});
309309

310+
// Emit event for operator shares being slashed
311+
emit OperatorSharesSlashed(operator, strategy, totalDepositSharesToBurn);
312+
310313
IShareManager shareManager = _getShareManager(strategy);
311314
// NOTE: for beaconChainETHStrategy, increased burnable shares currently have no mechanism for burning
312315
shareManager.increaseBurnableShares(strategy, totalDepositSharesToBurn);

src/contracts/interfaces/IDelegationManager.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ interface IDelegationManagerEvents is IDelegationManagerTypes {
170170

171171
/// @notice Emitted when a queued withdrawal is completed
172172
event SlashingWithdrawalCompleted(bytes32 withdrawalRoot);
173+
174+
/// @notice Emitted whenever an operator's shares are slashed for a given strategy
175+
event OperatorSharesSlashed(address indexed operator, IStrategy strategy, uint256 totalSlashedShares);
173176
}
174177

175178
/**

src/test/unit/DelegationUnit.t.sol

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6910,6 +6910,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
69106910
sharesToBurn: sharesToBurn
69116911
})
69126912
);
6913+
6914+
// Assert OperatorSharesSlashed event was emitted with correct params
6915+
cheats.expectEmit(true, true, true, true, address(delegationManager));
6916+
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);
6917+
69136918
cheats.prank(address(allocationManagerMock));
69146919
delegationManager.slashOperatorShares({
69156920
operator: operator,
@@ -6994,6 +6999,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
69946999
sharesToBurn: sharesToBurn
69957000
})
69967001
);
7002+
7003+
// Assert OperatorSharesSlashed event was emitted with correct params
7004+
cheats.expectEmit(true, true, true, true, address(delegationManager));
7005+
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);
7006+
69977007
cheats.prank(address(allocationManagerMock));
69987008
delegationManager.slashOperatorShares({
69997009
operator: operator,
@@ -7072,6 +7082,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
70727082
sharesToBurn: sharesToBurn
70737083
})
70747084
);
7085+
7086+
// Assert OperatorSharesSlashed event was emitted with correct params
7087+
cheats.expectEmit(true, true, true, true, address(delegationManager));
7088+
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);
7089+
70757090
cheats.prank(address(allocationManagerMock));
70767091
delegationManager.slashOperatorShares({
70777092
operator: operator,
@@ -7163,6 +7178,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
71637178
sharesToBurn: sharesToBurn
71647179
})
71657180
);
7181+
7182+
// Assert OperatorSharesSlashed event was emitted with correct params
7183+
cheats.expectEmit(true, true, true, true, address(delegationManager));
7184+
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);
7185+
71667186
cheats.prank(address(allocationManagerMock));
71677187
delegationManager.slashOperatorShares({
71687188
operator: operator,
@@ -7237,6 +7257,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
72377257
sharesToBurn: sharesToBurn
72387258
})
72397259
);
7260+
7261+
// Assert OperatorSharesSlashed event was emitted with correct params
7262+
cheats.expectEmit(true, true, true, true, address(delegationManager));
7263+
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);
7264+
72407265
cheats.prank(address(allocationManagerMock));
72417266
delegationManager.slashOperatorShares({
72427267
operator: operator,
@@ -7294,6 +7319,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
72947319
sharesToBurn: sharesToBurn
72957320
})
72967321
);
7322+
7323+
// Assert OperatorSharesSlashed event was emitted with correct params
7324+
cheats.expectEmit(true, true, true, true, address(delegationManager));
7325+
emit OperatorSharesSlashed(operator, strategyMock, sharesToBurn);
7326+
72977327
cheats.prank(address(allocationManagerMock));
72987328
delegationManager.slashOperatorShares({
72997329
operator: operator,
@@ -7399,6 +7429,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
73997429
sharesToBurn: 0
74007430
})
74017431
);
7432+
7433+
// Assert OperatorSharesSlashed event was emitted with correct params
7434+
cheats.expectEmit(true, true, true, true, address(delegationManager));
7435+
emit OperatorSharesSlashed(operator, strategyMock, 0);
7436+
74027437
cheats.prank(address(allocationManagerMock));
74037438
delegationManager.slashOperatorShares({
74047439
operator: operator,
@@ -7474,6 +7509,11 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
74747509
_setOperatorMagnitude(operator, beaconChainETHStrategy, newMagnitude);
74757510
cheats.expectEmit(true, true, true, true, address(delegationManager));
74767511
emit OperatorSharesDecreased(operator, address(0), beaconChainETHStrategy, sharesToDecrease);
7512+
7513+
// Assert OperatorSharesSlashed event was emitted with correct params
7514+
cheats.expectEmit(true, true, true, true, address(delegationManager));
7515+
emit OperatorSharesSlashed(operator, beaconChainETHStrategy, sharesToDecrease);
7516+
74777517
cheats.prank(address(allocationManagerMock));
74787518
delegationManager.slashOperatorShares({
74797519
operator: operator,
@@ -7518,6 +7558,10 @@ contract DelegationManagerUnitTests_slashingShares is DelegationManagerUnitTests
75187558
newOperatorMagnitude -= slashMagnitude;
75197559
_setOperatorMagnitude(defaultOperator, strategyMock, newOperatorMagnitude);
75207560

7561+
// Assert OperatorSharesSlashed event was emitted with correct params
7562+
cheats.expectEmit(true, true, true, true, address(delegationManager));
7563+
emit OperatorSharesSlashed(defaultOperator, strategyMock, 44440000449046438731194137360795695);
7564+
75217565
cheats.prank(address(allocationManagerMock));
75227566
delegationManager.slashOperatorShares(
75237567
defaultOperator,

0 commit comments

Comments
 (0)