From 33c32ac4ddfaca897924ea1462e268cc1ff67b90 Mon Sep 17 00:00:00 2001 From: Michael Sun Date: Thu, 12 Sep 2024 12:13:33 -0400 Subject: [PATCH] fix: scaledStakerShares equation --- src/contracts/core/DelegationManager.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/contracts/core/DelegationManager.sol b/src/contracts/core/DelegationManager.sol index 3de7a8001d..30fd6d79bb 100644 --- a/src/contracts/core/DelegationManager.sol +++ b/src/contracts/core/DelegationManager.sol @@ -905,9 +905,11 @@ contract DelegationManager is // NOTE that to prevent numerator overflow, the max sharesToWithdraw is // x*1e36 <= 2^256-1 // => x <= 1.1579e41 + // however we know that the max shares in a strategy is 1e38-1 and all the ETH on the beaconchain staked + // in one eigenPod would be ~3e25. This product here is safe sharesToDecrement = (sharesToWithdraw * SlashingConstants.PRECISION_FACTOR_SQUARED) / (stakerScalingFactor * totalMagnitude); - scaledStakerShares = sharesToWithdraw * stakerScalingFactor / SlashingConstants.PRECISION_FACTOR; + scaledStakerShares = sharesToWithdraw * SlashingConstants.PRECISION_FACTOR / totalMagnitude; return (sharesToDecrement, scaledStakerShares); }