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

Feat/claim st rewards #482

Merged
merged 6 commits into from
Oct 11, 2023
Merged

Feat/claim st rewards #482

merged 6 commits into from
Oct 11, 2023

Conversation

albert-llimos
Copy link
Collaborator

@albert-llimos albert-llimos commented Oct 9, 2023

(from #481)

Added Features

uint256 stTokenStaked
Value to be incremented by the quantity of incoming stFLIP after every staking operation.

uint256 stTokenUnstaked
Value to be incremented by the quantity of outgoing stFLIP after every unstaking operation. We must have this in a separate value since a dynamic principal counter would overflow in the case that a user unstakes their entire principal + rewards.

function claimStProviderRewards(address recipient_, uint256 amount_)
Allows a user to claim stFLIP rewards. claimableRewards = stflip.balanceOf(this) + stTokenUnstaked - stTokenStaked. This keeps track of the amount of stFLIP rewards the user can claim at a given moment. It is possible that a user can have claimableRewards > 0 and not be able to claim stFLIP because of insufficient stFLIP balance due to unstaking. If a user's stFLIP drops below their principal due to a slash, the claimableRewards calculation will underflow.

Tests

Test cases include three scenarios for reward claiming functionality - the mechanism is pretty straightforward.

Mocks

Added mockSlash which emulates a slash

Note: the linter does not work locally for me thus the commits are not linted

@albert-llimos albert-llimos merged commit 8466176 into master Oct 11, 2023
4 checks passed
@albert-llimos albert-llimos deleted the feat/claim_st_rewards branch October 11, 2023 11:42
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