@@ -1216,7 +1216,7 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
12161216 uint wadToSlash = slashingParams.wadsToSlash[0 ];
12171217 slashedShares = prevShares.mulWadRoundUp (allocateParams.newMagnitudes[0 ].mulWadRoundUp (wadToSlash));
12181218
1219- assertEq (prevShares - slashedShares, curShares, err);
1219+ assertApproxEqAbs (prevShares - slashedShares, curShares, 1e2 , err);
12201220 }
12211221
12221222 /// @dev Validates behavior of "restaking", ie. that the funds can be slashed twice
@@ -1234,29 +1234,35 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
12341234 uint prevShares = _getPrevWithdrawableShares (staker, allocateParams.strategies)[0 ];
12351235 uint depositShares = _getStakerDepositShares (staker, allocateParams.strategies)[0 ];
12361236
1237- // 1. The withdrawable shares should decrease by a factor of the BCSF
1238- assertEq (prevShares.mulWad (_getBeaconChainSlashingFactor (staker)), curShares, err);
1239-
1240- // /**
1241- // * 2. The delta in shares is given by:
1242- // * (depositShares * operatorMag) - (depositShares * operatorMag * BCSF)
1243- // * = depositShares * operatorMag * (1 - BCSF)
1244- // */
1245- // uint beaconChainSlashingFactor = _getBeaconChainSlashingFactor(staker);
1246- // uint wadToSlash = slashingParams.wadsToSlash[0];
1247- // uint originalAVSSlashedShares = depositShares.mulWadRoundUp(allocateParams.newMagnitudes[0].mulWadRoundUp(wadToSlash));
1248- // uint withdrawableSharesAfterAVSSlash = depositShares - originalAVSSlashedShares;
1249- // uint expectedDelta = withdrawableSharesAfterAVSSlash.mulWad(WAD - beaconChainSlashingFactor);
1250- // assertEq(prevShares - expectedDelta, curShares, err);
1251-
1252- // /**
1253- // * 3. The attributable avs slashed shares should decrease by a factor of the BCSF
1254- // * Attributable avs slashed shares = originalWithdrawableShares - bcSlashedShares - curShares
1255- // * Where bcSlashedShares = originalWithdrawableShares * (1 - BCSF)
1256- // */
1257- // uint bcSlashedShares = depositShares.mulWad(WAD - beaconChainSlashingFactor);
1258- // uint attributableAVSSlashedShares = depositShares - bcSlashedShares - curShares;
1259- // assertEq(originalAVSSlashedShares.mulWad(beaconChainSlashingFactor), attributableAVSSlashedShares, err);
1237+ // 1. The slashing factor and withdrawable shares should decrease by a factor of the BCSF
1238+ // We use assertApproxEq on shares since intermediate division on calculation of slashing factor introduces some additional rounding error
1239+ uint slashingFactor = _getSlashingFactor (staker, allocateParams.strategies[0 ]);
1240+ uint prevSlashingFactor = _getPrevSlashingFactor (staker, allocateParams.strategies[0 ]);
1241+ assertEq (prevSlashingFactor.mulWad (_getBeaconChainSlashingFactor (staker)), slashingFactor, err);
1242+ assertApproxEqAbs (prevShares.mulWad (_getBeaconChainSlashingFactor (staker)), curShares, 1e2 , err);
1243+
1244+ /**
1245+ * 2. The delta in shares is given by:
1246+ * (depositShares * operatorMag) - (depositShares * operatorMag * BCSF)
1247+ * = depositShares * operatorMag * (1 - BCSF)
1248+ */
1249+ uint beaconChainSlashingFactor = _getBeaconChainSlashingFactor (staker);
1250+ uint wadToSlash = slashingParams.wadsToSlash[0 ];
1251+ uint originalAVSSlashedShares = depositShares.mulWadRoundUp (allocateParams.newMagnitudes[0 ].mulWadRoundUp (wadToSlash));
1252+ {
1253+ uint withdrawableSharesAfterAVSSlash = depositShares - originalAVSSlashedShares;
1254+ uint expectedDelta = withdrawableSharesAfterAVSSlash.mulWad (WAD - beaconChainSlashingFactor);
1255+ assertApproxEqAbs (prevShares - expectedDelta, curShares, 1e2 , err);
1256+ }
1257+
1258+ /**
1259+ * 3. The attributable avs slashed shares should decrease by a factor of the BCSF
1260+ * Attributable avs slashed shares = originalWithdrawableShares - bcSlashedShares - curShares
1261+ * Where bcSlashedShares = originalWithdrawableShares * (1 - BCSF)
1262+ */
1263+ uint bcSlashedShares = depositShares.mulWad (WAD - beaconChainSlashingFactor);
1264+ uint attributableAVSSlashedShares = depositShares - bcSlashedShares - curShares;
1265+ assertApproxEqAbs (originalAVSSlashedShares.mulWad (beaconChainSlashingFactor), attributableAVSSlashedShares, 1e2 , err);
12601266 }
12611267
12621268 /**
0 commit comments