Skip to content

Commit f74dd1d

Browse files
MichaelMichael
authored andcommitted
test: explicitly calculate expected withdrawable shares to account for rounding
1 parent 5ebed67 commit f74dd1d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/test/integration/IntegrationBase.t.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2759,6 +2759,22 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
27592759
return shares;
27602760
}
27612761

2762+
function _getExpectedDSFUndelegate(User staker) internal view returns (uint expectedDepositScalingFactor) {
2763+
return WAD.divWad(_getBeaconChainSlashingFactor(staker));
2764+
}
2765+
2766+
function _getExpectedWithdrawableSharesUndelegate(User staker, IStrategy[] memory strategies, uint[] memory shares) internal view returns (uint[] memory){
2767+
uint[] memory expectedWithdrawableShares = new uint[](strategies.length);
2768+
for (uint i = 0; i < strategies.length; i++) {
2769+
if (strategies[i] == BEACONCHAIN_ETH_STRAT) {
2770+
expectedWithdrawableShares[i] = shares[i].mulWad(_getExpectedDSFUndelegate(staker)).mulWad(_getBeaconChainSlashingFactor(staker));
2771+
} else {
2772+
expectedWithdrawableShares[i] = shares[i];
2773+
}
2774+
}
2775+
return expectedWithdrawableShares;
2776+
}
2777+
27622778
function _getPrevWithdrawableShares(User staker, IStrategy[] memory strategies) internal timewarp() returns (uint[] memory) {
27632779
return _getWithdrawableShares(staker, strategies);
27642780
}

src/test/integration/IntegrationChecks.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ contract IntegrationCheckUtils is IntegrationBase {
358358
assert_Snap_Unchanged_TokenBalances(staker, "staker should not have any change in underlying token balances");
359359
assert_Snap_Unchanged_TokenBalances(operator, "operator should not have any change in underlying token balances");
360360
assert_Snap_Added_Staker_DepositShares(staker, strategies, shares, "staker should have received expected deposit shares");
361-
assert_Snap_Added_Staker_WithdrawableShares(staker, strategies, shares, "staker should have received expected withdrawable shares");
361+
uint[] memory expectedWithdrawableShares = _getExpectedWithdrawableSharesUndelegate(staker, strategies, shares);
362+
assert_Snap_Added_Staker_WithdrawableShares(staker, strategies, expectedWithdrawableShares, "staker should have received expected withdrawable shares");
362363
assert_Snap_Unchanged_OperatorShares(operator, "operator should have shares unchanged");
363364
assert_Snap_Unchanged_StrategyShares(strategies, "strategies should have total shares unchanged");
364365
}

0 commit comments

Comments
 (0)