-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: delegate shares #1045
fix: delegate shares #1045
Changes from 36 commits
f893aeb
9c22d31
eb011b6
aaa92c8
e543dd1
d2f5fe0
a4b8281
3bac447
7f7bd79
769f6d7
811c240
b584ee4
71e498b
ef50a8b
2b46b93
5c6f931
9eb35aa
2e5d79d
0b556de
5b8703f
d467531
832153e
d6837d5
57883c1
73df934
6b87670
19952dc
a465514
8ec0162
4f6ba21
13b5170
55abe6a
1ce151a
9757137
4292393
b24ad11
6eb8ab3
bfa0c7f
c5d71cf
2fc9a4c
578b9f0
31e04bd
768597f
9a6b3de
6948470
beddfe4
1e232d7
f4a0163
86c255d
00fadd6
3b418ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,7 @@ contract IntegrationCheckUtils is IntegrationBase { | |
) internal { | ||
/// Undelegate from an operator | ||
// | ||
// ... check that the staker is undelegated, all strategies from which the staker is deposited are unqeuued, | ||
// ... check that the staker is undelegated, all strategies from which the staker is deposited are unqueued, | ||
// that the returned root matches the hashes for each strategy and share amounts, and that the staker | ||
// and operator have reduced shares | ||
assertFalse(delegationManager.isDelegated(address(staker)), | ||
|
@@ -250,6 +250,35 @@ contract IntegrationCheckUtils is IntegrationBase { | |
"check_QueuedWithdrawal_State: failed to remove staker withdrawable shares"); | ||
} | ||
|
||
function check_Redelegate_State( | ||
User staker, | ||
User operator, | ||
IDelegationManagerTypes.Withdrawal[] memory withdrawals, | ||
bytes32[] memory withdrawalRoots, | ||
IStrategy[] memory strategies, | ||
uint[] memory shares | ||
) internal { | ||
/// Redelegate to a new operator | ||
// | ||
// ... check that the staker is delegated to new operator, all strategies from which the staker is deposited are unqueued, | ||
// that the returned root matches the hashes for each strategy and share amounts, and that the staker | ||
// and operator have reduced shares | ||
assertTrue(delegationManager.isDelegated(address(staker)), | ||
"check_Undelegate_State: staker should not be delegated"); | ||
assert_ValidWithdrawalHashes(withdrawals, withdrawalRoots, | ||
"check_Undelegate_State: calculated withdrawl should match returned root"); | ||
assert_AllWithdrawalsPending(withdrawalRoots, | ||
"check_Undelegate_State: stakers withdrawal should now be pending"); | ||
assert_Snap_Added_QueuedWithdrawals(staker, withdrawals, | ||
"check_Undelegate_State: staker should have increased nonce by withdrawals.length"); | ||
assert_Snap_Removed_OperatorShares(operator, strategies, shares, | ||
"check_Undelegate_State: failed to remove operator shares"); | ||
assert_Snap_Removed_Staker_DepositShares(staker, strategies, shares, | ||
"check_Undelegate_State: failed to remove staker shares"); | ||
assert_Snap_Removed_Staker_WithdrawableShares(staker, strategies, shares, | ||
"check_QueuedWithdrawal_State: failed to remove staker withdrawable shares"); | ||
} | ||
|
||
/** | ||
* @notice Overloaded function to check the state after a withdrawal as tokens, accepting a non-user type for the operator. | ||
* @param staker The staker who completed the withdrawal. | ||
|
@@ -329,6 +358,28 @@ contract IntegrationCheckUtils is IntegrationBase { | |
assert_Snap_Unchanged_StrategyShares(strategies, "strategies should have total shares unchanged"); | ||
} | ||
|
||
function check_Withdrawal_AsShares_Redelegated_State( | ||
User staker, | ||
User operator, | ||
User newOperator, | ||
IDelegationManagerTypes.Withdrawal memory withdrawal, | ||
IStrategy[] memory strategies, | ||
uint[] memory shares | ||
) internal { | ||
/// Complete withdrawal(s): | ||
// The staker will complete the withdrawal as shares | ||
// | ||
// ... check that the withdrawal is not pending, that the token balances of the staker and operator are unchanged, | ||
// that the withdrawer received the expected shares, and that that the total shares of each o | ||
// strategy withdrawn remains unchanged | ||
assert_WithdrawalNotPending(delegationManager.calculateWithdrawalRoot(withdrawal), "staker withdrawal should no longer be pending"); | ||
assert_Snap_Unchanged_TokenBalances(staker, "staker should not have any change in underlying token balances"); | ||
assert_Snap_Unchanged_TokenBalances(operator, "operator should not have any change in underlying token balances"); | ||
assert_Snap_Added_Staker_DepositShares(staker, strategies, shares, "staker should have received expected shares"); | ||
assert_Snap_Unchanged_OperatorShares(operator, "operator should have shares unchanged"); | ||
assert_Snap_Unchanged_StrategyShares(strategies, "strategies should have total shares unchanged"); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thoughts on asserting DSF in these tests, esp on undelegate? Non-blocking, but IMO something we should add to our invariants over the next 2 weeks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably also assert the BCSF, but can do this in our integration testing push There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, just trying to limit the scope a bit since this PR is already touching so many things outside of the core fix. Made a mental note to put this in test PRs this/next week |
||
|
||
/******************************************************************************* | ||
ALM - BASIC INVARIANTS | ||
*******************************************************************************/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: since undelegated, staker maxMagnitude is 0 so their slashingFactor only needs to use the BCSF for calculating withdrawable.