File tree Expand file tree Collapse file tree 2 files changed +7
-16
lines changed Expand file tree Collapse file tree 2 files changed +7
-16
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ pragma solidity ^0.8.27;
3
3
4
4
import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol " ;
5
5
import "@openzeppelin-upgrades/contracts/security/ReentrancyGuardUpgradeable.sol " ;
6
+ import "forge-std/console.sol " ;
6
7
7
8
import "../mixins/SignatureUtilsMixin.sol " ;
8
9
import "../mixins/PermissionControllerMixin.sol " ;
@@ -793,8 +794,8 @@ contract DelegationManager is
793
794
// less than or equal to MIN_WITHDRAWAL_DELAY_BLOCKS ago. These shares are still slashable.
794
795
uint256 scaledSharesAdded = curQueuedScaledShares - prevQueuedScaledShares;
795
796
796
- return SlashingLib.scaleForBurning ({
797
- scaledShares : scaledSharesAdded,
797
+ return SlashingLib.calcSlashedAmount ({
798
+ operatorShares : scaledSharesAdded. mulWad (prevMaxMagnitude) ,
798
799
prevMaxMagnitude: prevMaxMagnitude,
799
800
newMaxMagnitude: newMaxMagnitude
800
801
});
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