From 2e374b7ffe51ee9df638808bacb71b81d95fd2c7 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 19 Feb 2025 11:21:08 -0500 Subject: [PATCH] test: added check that dsf is reset on undelegation --- src/test/integration/IntegrationBase.t.sol | 23 ++++++++++++++++++++ src/test/integration/IntegrationChecks.t.sol | 2 ++ 2 files changed, 25 insertions(+) diff --git a/src/test/integration/IntegrationBase.t.sol b/src/test/integration/IntegrationBase.t.sol index 54690a4a52..62d2517902 100644 --- a/src/test/integration/IntegrationBase.t.sol +++ b/src/test/integration/IntegrationBase.t.sol @@ -564,6 +564,17 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter { assertEq(slashableStake[i], 0, err); } } + + function assert_DSF_Reset( + User staker, + IStrategy[] memory strategies, + string memory err + ) internal { + uint[] memory depositScalingFactors = _getDepositScalingFactors(staker, strategies); + for (uint i = 0; i < strategies.length; i++) { + assertEq(depositScalingFactors[i], WAD, err); + } + } /******************************************************************************* SNAPSHOT ASSERTIONS @@ -2759,6 +2770,18 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter { return shares; } + function _getDepositScalingFactors(User staker, IStrategy[] memory strategies) internal view returns (uint[] memory) { + uint[] memory depositScalingFactors = new uint[](strategies.length); + for (uint i=0; i < strategies.length; i++) { + depositScalingFactors[i] = _getDepositScalingFactor(staker, strategies[i]); + } + return depositScalingFactors; + } + + function _getDepositScalingFactor(User staker, IStrategy strategy) internal view returns (uint) { + return delegationManager.depositScalingFactor(address(staker), strategy); + } + function _getExpectedDSFUndelegate(User staker) internal view returns (uint expectedDepositScalingFactor) { return WAD.divWad(_getBeaconChainSlashingFactor(staker)); } diff --git a/src/test/integration/IntegrationChecks.t.sol b/src/test/integration/IntegrationChecks.t.sol index d4efcaf911..f7ae129933 100644 --- a/src/test/integration/IntegrationChecks.t.sol +++ b/src/test/integration/IntegrationChecks.t.sol @@ -243,6 +243,8 @@ contract IntegrationCheckUtils is IntegrationBase { "check_Undelegate_State: calculated withdrawal should match returned root"); assert_AllWithdrawalsPending(withdrawalRoots, "check_Undelegate_State: stakers withdrawal should now be pending"); + assert_DSF_Reset(staker, strategies, + "check_Undelegate_State: staker dsfs should be reset to wad"); assert_Snap_Added_QueuedWithdrawals(staker, withdrawals, "check_Undelegate_State: staker should have increased nonce by withdrawals.length"); assert_Snap_Removed_OperatorShares(operator, strategies, stakerDelegatedShares,