Skip to content

Commit

Permalink
chore: address feedback again
Browse files Browse the repository at this point in the history
  • Loading branch information
wadealexc committed Nov 22, 2024
1 parent c324398 commit 4b035ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/contracts/interfaces/IEigenPodManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface IEigenPodManagerEvents {
);

/// @notice Emitted when a staker's beaconChainSlashingFactor is updated
event BeaconChainSlashingFactorUpdated(address staker, uint64 newBeaconChainSlashingFactor);
event BeaconChainSlashingFactorDecreased(address staker, uint256 wadSlashed, uint64 newBeaconChainSlashingFactor);
}

interface IEigenPodManagerTypes {
Expand Down
9 changes: 5 additions & 4 deletions src/contracts/pods/EigenPodManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -273,22 +273,23 @@ contract EigenPodManager is
uint256 newRestakedBalanceWei = prevRestakedBalanceWei - balanceDecreasedWei;
uint256 proportionRemainingWad = newRestakedBalanceWei.divWadRoundUp(prevRestakedBalanceWei);

// Note that underflow here should be impossible given
// `proportionRemainingWad` is guaranteed to be less than WAD.
uint256 wadSlashed = uint256(WAD) - proportionRemainingWad;

// Update pod owner's beacon chain slashing factor. Note that `newBeaconSlashingFactor`
// should be less than `prevBeaconSlashingFactor` because `proportionRemainingWad` is
// guaranteed to be less than WAD.
uint64 prevBeaconSlashingFactor = beaconChainSlashingFactor(podOwner);
uint64 newBeaconSlashingFactor = uint64(prevBeaconSlashingFactor.mulWad(proportionRemainingWad));
emit BeaconChainSlashingFactorUpdated(podOwner, newBeaconSlashingFactor);
emit BeaconChainSlashingFactorDecreased(podOwner, wadSlashed, newBeaconSlashingFactor);
/// forgefmt: disable-next-item
_beaconChainSlashingFactor[podOwner] = BeaconChainSlashingFactor({
slashingFactor: newBeaconSlashingFactor,
isSet: true
});

uint256 curDepositShares = uint256(podOwnerDepositShares[podOwner]);
// Note that underflow here should be impossible given
// `proportionRemainingWad` is guaranteed to be less than WAD.
uint256 wadSlashed = uint256(WAD) - proportionRemainingWad;
return (curDepositShares, prevBeaconSlashingFactor, wadSlashed);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/EigenPodManagerUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ contract EigenPodManagerUnitTests_BeaconChainETHBalanceUpdateTests is EigenPodMa

// Not checking the new slashing factor - just checking the invariant that new <= prev
cheats.expectEmit(true, true, true, false);
emit BeaconChainSlashingFactorUpdated(defaultStaker, 0);
emit BeaconChainSlashingFactorDecreased(defaultStaker, 0, 0);

cheats.prank(address(defaultPod));
eigenPodManager.recordBeaconChainETHBalanceUpdate(defaultStaker, prevRestakedBalanceWei, -int(sharesDelta));
Expand Down

0 comments on commit 4b035ea

Please sign in to comment.