File tree Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Original file line number Diff line number Diff line change @@ -793,8 +793,8 @@ contract DelegationManager is
793
793
// less than or equal to MIN_WITHDRAWAL_DELAY_BLOCKS ago. These shares are still slashable.
794
794
uint256 scaledSharesAdded = curQueuedScaledShares - prevQueuedScaledShares;
795
795
796
- return SlashingLib.scaleForBurning ({
797
- scaledShares : scaledSharesAdded,
796
+ return SlashingLib.calcSlashedAmount ({
797
+ operatorShares : scaledSharesAdded. mulWad (prevMaxMagnitude) ,
798
798
prevMaxMagnitude: prevMaxMagnitude,
799
799
newMaxMagnitude: newMaxMagnitude
800
800
});
Original file line number Diff line number Diff line change @@ -74,20 +74,6 @@ library SlashingLib {
74
74
return scaledShares.mulWad (slashingFactor);
75
75
}
76
76
77
- /**
78
- * @notice Scales shares according to the difference in an operator's magnitude before and
79
- * after being slashed. This is used to calculate the number of slashable shares in the
80
- * withdrawal queue.
81
- * NOTE: max magnitude is guaranteed to only ever decrease.
82
- */
83
- function scaleForBurning (
84
- uint256 scaledShares ,
85
- uint64 prevMaxMagnitude ,
86
- uint64 newMaxMagnitude
87
- ) internal pure returns (uint256 ) {
88
- return scaledShares.mulWad (prevMaxMagnitude - newMaxMagnitude);
89
- }
90
-
91
77
function update (
92
78
DepositScalingFactor storage dsf ,
93
79
uint256 prevDepositShares ,
@@ -178,6 +164,10 @@ library SlashingLib {
178
164
uint256 prevMaxMagnitude ,
179
165
uint256 newMaxMagnitude
180
166
) internal pure returns (uint256 ) {
167
+ if (prevMaxMagnitude == 0 ) {
168
+ // TODO: consider throwing an error instead
169
+ return 0 ;
170
+ }
181
171
// round up mulDiv so we don't overslash
182
172
return operatorShares - operatorShares.mulDiv (newMaxMagnitude, prevMaxMagnitude, Math.Rounding.Up);
183
173
}
You can’t perform that action at this time.
0 commit comments