Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/test/integration/IntegrationBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3207,10 +3207,6 @@ abstract contract IntegrationBase is IntegrationDeployer, TypeImporter {
function _getStakerStrategyList(User staker) internal view returns (IStrategy[] memory) {
return strategyManager.getStakerStrategyList(address(staker));
}

function _getExpectedWithdrawableSharesAfterCompletion(User staker, uint scaledShares, uint depositScalingFactor, uint slashingFactor) internal view returns (uint) {
return scaledShares.mulWad(depositScalingFactor).mulWad(slashingFactor);
}

function _getPrevStakerWithdrawableShares(User staker, IStrategy[] memory strategies) internal timewarp() returns (uint[] memory) {
return _getStakerWithdrawableShares(staker, strategies);
Expand Down
31 changes: 15 additions & 16 deletions src/test/integration/tests/Slashed_Eigenpod_AVS.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ contract Integration_SlashedEigenpod_AVS_Withdraw is Integration_SlashedEigenpod
using Math for uint256;
using SlashingLib for uint256;

uint[] withdrawableSharesAfterSlash;

function _init() internal override {
super._init();

Expand All @@ -89,20 +91,24 @@ contract Integration_SlashedEigenpod_AVS_Withdraw is Integration_SlashedEigenpod
avs.slashOperator(slashParams);
check_Base_Slashing_State(operator, allocateParams, slashParams);

// 8. Queue Withdrawal for all shares. TODO: add proper assertion
staker.queueWithdrawals(strategies, initDepositShares);
// 8. Queue Withdrawal for all shares.
Withdrawal[] memory withdrawals = staker.queueWithdrawals(strategies, initDepositShares);
bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals);
withdrawableSharesAfterSlash = _calcWithdrawable(staker, strategies, initDepositShares);
check_QueuedWithdrawal_State(staker, operator, strategies, initDepositShares, withdrawableSharesAfterSlash, withdrawals, withdrawalRoots);
} else { // Queue Withdrawal -> Slash
// 7. Queue Withdrawal for all shares
Withdrawal[] memory withdrawals = staker.queueWithdrawals(strategies, initDepositShares);
bytes32[] memory withdrawalRoots = _getWithdrawalHashes(withdrawals);
// TODO: fix check
// check_QueuedWithdrawal_State(staker, operator, strategies, initDepositShares, withdrawals, withdrawalRoots);
withdrawableSharesAfterSlash = _calcWithdrawable(staker, strategies, initDepositShares);
check_QueuedWithdrawal_State(staker, operator, strategies, initDepositShares, withdrawableSharesAfterSlash, withdrawals, withdrawalRoots);

// 8. Slash
slashParams = _genSlashing_Half(operator, operatorSet);
avs.slashOperator(slashParams);
check_Base_Slashing_State(operator, allocateParams, slashParams);
}
withdrawableSharesAfterSlash = _calcWithdrawable(staker, strategies, initDepositShares);

beaconChain.advanceEpoch_NoRewards();
}
Expand Down Expand Up @@ -131,11 +137,11 @@ contract Integration_SlashedEigenpod_AVS_Withdraw is Integration_SlashedEigenpod

// 9. Complete withdrawal as tokens
for (uint256 i = 0; i < withdrawals.length; ++i) {
IERC20[] memory tokens = _getUnderlyingTokens(withdrawals[i].strategies);
uint256[] memory expectedTokens =
_calculateExpectedTokens(withdrawals[i].strategies, withdrawals[i].scaledShares);
_calculateExpectedTokens(withdrawals[i].strategies, withdrawableSharesAfterSlash);
staker.completeWithdrawalAsTokens(withdrawals[i]);
// TODO: fix this
// check_Withdrawal_AsTokens_State_AfterSlash(staker, operator, withdrawals[i], allocateParams, slashParams, expectedTokens);
check_Withdrawal_AsTokens_State(staker, operator, withdrawals[i], strategies, withdrawals[i].scaledShares, tokens, expectedTokens);
}

// 10. Redeposit
Expand All @@ -152,7 +158,7 @@ contract Integration_SlashedEigenpod_AVS_Withdraw is Integration_SlashedEigenpod
_rollBlocksForCompleteWithdrawals(withdrawals);
uint slashingFactor = _getSlashingFactor(staker, BEACONCHAIN_ETH_STRAT);
uint depositScalingFactor = _getDepositScalingFactor(staker, BEACONCHAIN_ETH_STRAT);
initDepositShares[0] = initDepositShares[0].mulWad(slashingFactor); // Apply slashing factor to deposit shares
uint[] memory withdrawableShares = _calcWithdrawable(staker, strategies, initDepositShares);

// 9. Start & complete checkpoint, since the next step does not.
staker.startCheckpoint();
Expand All @@ -162,13 +168,6 @@ contract Integration_SlashedEigenpod_AVS_Withdraw is Integration_SlashedEigenpod

// 10. Complete withdrawal as shares. Deposit scaling factor is doubled because operator was slashed by half.
staker.completeWithdrawalAsShares(withdrawals[0]);
// TODO: fix this
// check_Withdrawal_AsShares_State_AfterSlash(staker, operator, withdrawals[0], allocateParams, slashParams);
assertEq(
_getStakerWithdrawableShares(staker, strategies)[0],
_calcWithdrawable(staker, strategies, initDepositShares)[0],
// _getExpectedWithdrawableSharesAfterCompletion(staker, withdrawals[0].scaledShares[0], depositScalingFactor * 2, slashingFactor),
"withdrawable shares not incremented correctly"
);
check_Withdrawal_AsShares_State(staker, operator, withdrawals[0], strategies, withdrawableShares);
}
}
Loading