Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(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 slashNote: the linter does not work locally for me thus the commits are not linted