Skip to content
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

Limit collecting rewards up to 48 intervals #101

Merged
merged 1 commit into from
May 13, 2024
Merged

Conversation

kevin-fruitful
Copy link
Contributor

The motivation is to give the user a better error than out of gas when attempting to collect staking rewards through a large number of reward intervals.

We now limit the max number of intervals that a user can collect to 48 and throw a custom error if the user is attempting to collect more.

We added a method called collectRewardsThroughInterval which lets a user collect up to a specific interval.

Copy link
Member

@amarinkovic amarinkovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but please don't merge yet. We will merge this with the audit fixes later.

@@ -115,7 +115,8 @@ library LibTokenizedVaultStaking {
bytes32 nextVTokenId = _vTokenId(tokenId, currentInterval + 1);

// First collect rewards. This will update the current state.
_collectRewards(_stakerId, _entityId, currentInterval);
// If the user does not have anything staked, then skip `_collectRewards()`.
if (s.stakeBalance[vTokenIdMax][_stakerId] != 0) _collectRewards(_stakerId, _entityId, currentInterval);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@amarinkovic amarinkovic changed the base branch from main to dev May 13, 2024 09:08
@amarinkovic amarinkovic mentioned this pull request May 13, 2024
@kevin-fruitful kevin-fruitful merged commit e2fe5ea into dev May 13, 2024
4 checks passed
@kevin-fruitful kevin-fruitful deleted the fix-staking branch May 13, 2024 09:17
amarinkovic added a commit that referenced this pull request May 16, 2024
@amarinkovic amarinkovic restored the fix-staking branch May 16, 2024 09:21
@amarinkovic amarinkovic deleted the fix-staking branch June 7, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants