Skip to content

Commit

Permalink
fix: forge fmt in slashing lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ypatil12 committed Oct 10, 2024
1 parent e6d7ea6 commit 010f883
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/contracts/libraries/SlashingLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ library SlashingLib {
) internal {
if (existingDepositShares == 0) {
// if this is their first deposit for the operator, set the scaling factor to inverse of totalMagnitude
ssf.depositScalingFactor = uint256(WAD).divWad(ssf.getBeaconChainScalingFactor()).divWad(totalMagnitude);
/// forgefmt: disable-next-item
ssf.depositScalingFactor =
uint256(WAD)
.divWad(ssf.getBeaconChainScalingFactor())
.divWad(totalMagnitude);

return;
}
/**
Expand Down Expand Up @@ -133,9 +138,12 @@ library SlashingLib {
uint256 newShares = currentShares + addedShares;

// Step 3: Calculate newStakerDepositScalingFactor
uint256 newStakerDepositScalingFactor = newShares.divWad(existingDepositShares + addedShares).divWad(
totalMagnitude
).divWad(uint256(ssf.getBeaconChainScalingFactor()));
/// forgefmt: disable-next-item
uint256 newStakerDepositScalingFactor =
newShares
.divWad(existingDepositShares + addedShares)
.divWad(totalMagnitude)
.divWad(uint256(ssf.getBeaconChainScalingFactor()));

ssf.depositScalingFactor = newStakerDepositScalingFactor;
}
Expand All @@ -147,7 +155,11 @@ library SlashingLib {
StakerScalingFactors memory ssf,
uint64 magnitude
) internal pure returns (uint256 depositShares) {
depositShares = shares.divWad(ssf.getDepositScalingFactor()).divWad(uint256(ssf.getBeaconChainScalingFactor()))
/// forgefmt: disable-next-item
depositShares =
shares
.divWad(ssf.getDepositScalingFactor())
.divWad(uint256(ssf.getBeaconChainScalingFactor()))
.divWad(uint256(magnitude));
}

Expand All @@ -156,7 +168,11 @@ library SlashingLib {
StakerScalingFactors memory ssf,
uint64 magnitude
) internal pure returns (uint256 shares) {
shares = depositShares.mulWad(ssf.getDepositScalingFactor()).mulWad(uint256(ssf.getBeaconChainScalingFactor()))
/// forgefmt: disable-next-item
shares =
depositShares
.mulWad(ssf.getDepositScalingFactor())
.mulWad(uint256(ssf.getBeaconChainScalingFactor()))
.mulWad(uint256(magnitude));
}
}

0 comments on commit 010f883

Please sign in to comment.