-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat: Batch NXM withdrawals #1201
Conversation
if (withdrawOptions.assessmentStake) { | ||
IAssessment _assessment = assessment(); | ||
(uint96 amount, , ) = _assessment.stakeOf(msg.sender); | ||
_assessment.unstakeFor(msg.sender, amount, msg.sender); |
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.
I'd create one more function that doesn't need the amount as an input and withdraws all to avoid extra calls and extraneous validations.
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.
new assessment.unstakeAllFor
function:
- drop all checks except for assessment vote locked check
is it worth adding validation that only TokenController can call assessment.unstakeAllFor
?
Could it be considered a griefing attack if anyone can unstake the staker? (staker receives the stake so funds are safe)
ff727b7
to
ef35f46
Compare
65106fb
to
507a140
Compare
@@ -189,20 +213,14 @@ contract Assessment is IAssessment, MasterAwareV2 { | |||
address destination, | |||
uint104 batchSize | |||
) internal returns (uint withdrawn, uint withdrawnUntilIndex) { | |||
require( |
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.
why was this removed?
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.
its a redundant check as it duplicates the check that TokenController.mint does.
relevant discussion: #1201 (comment)
80a427e
to
6223456
Compare
if (withdrawAssessment.rewards) { | ||
// pass in 0 batchSize to withdraw ALL Assessment rewards | ||
assessment().withdrawRewards(msg.sender, 0); | ||
} | ||
|
||
// governance rewards | ||
uint governanceRewards = governance().claimReward(msg.sender, govRewardsBatchSize); |
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.
We separated the batchSize that is passed to the assessment and governance rewards to fix the batchSize issue.
Hardcoded 0 batchSize for assessment.withdrawRewards
, which effectively withdraws ALL assessment rewards.
And the batchSize from the parameters (govRewardsBatchSize
) will now only be used in governance rewards.
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.
is it possible that all assessment rewards withdrawal won't fit in a block? I guess that's why the batchSize argument was implemented in the first place
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.
There has been only 21 assessment so far so it seemed relatively safe to hardcode 0. but now in hindsight, this is a bad design.
it better to expose the assessment batchSize and let the caller (FE) have the option to withdraw all or in batches.
i will add a new assessmentRewardsBatchSize
param. the withdrawNxm will now look like:
function withdrawNXM(
WithdrawAssessment calldata withdrawAssessment,
StakingPoolDeposit[] calldata stakingPoolDeposits,
StakingPoolManagerReward[] calldata stakingPoolManagerRewards,
uint assessmentRewardsBatchSize,
uint govRewardsBatchSize
) external {
6223456
to
6cd1e3b
Compare
cd0d12e
to
22e1d99
Compare
c37d784
to
fea86de
Compare
Context
Closes #1173
Add
TokenController.withdrawNXM
to withdraw all NXM from the platform. The caller must do the checks if the NXM is withdrawable and modify params accordingly to skip / include specific NXM withdrawals.Changes proposed in this pull request
unstakeForAll
withdrawRewardsTo
withdrawNXM
_withdrawClaimAssessmentTokensForUser
internal functionwithdrawPendingRewards
in favour ofwithdrawNXM
Test plan
Checklist
Review
When reviewing a PR, please indicate intention in comments using the following emojis: