-
Notifications
You must be signed in to change notification settings - Fork 15
π§βπ§ XStaking 2.0.0, RevenueRouter 2.0.0 #439
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Good luck! |
Comment on lines
+261
to
+303
| function notifyRewardAmountToken( | ||
| address token, | ||
| uint amount | ||
| ) external updateRewardForToken(token, address(0)) nonReentrant { | ||
| /// @dev ensure > 0 | ||
| require(amount != 0, IncorrectZeroArgument()); | ||
|
|
||
| XStakingStorage storage $ = _getXStakingStorage(); | ||
| TokenRewards storage $$ = $.tokenRewards[token]; | ||
|
|
||
| require($$.allowed, TokenNotAllowed(token)); | ||
|
|
||
| address _xToken = $.xToken; | ||
|
|
||
| /// @dev only callable by xToken and RevenueRouter contract | ||
| require(msg.sender == _xToken || msg.sender == IXToken(_xToken).revenueRouter(), IncorrectMsgSender()); | ||
|
|
||
| /// @dev take the token from a contract to the XStaking | ||
| // slither-disable-next-line unchecked-transfer | ||
| IERC20(token).safeTransferFrom(msg.sender, address(this), amount); | ||
|
|
||
| uint _periodFinish = $$.periodFinish; | ||
| uint _duration = $.duration; | ||
|
|
||
| if (block.timestamp >= _periodFinish) { | ||
| /// @dev the new reward rate being the amount divided by the duration | ||
| $$.rewardRate = amount / _duration; | ||
| } else { | ||
| /// @dev remaining seconds until the period finishes | ||
| uint remaining = _periodFinish - block.timestamp; | ||
| /// @dev remaining tokens to stream via t * rate | ||
| uint _left = remaining * $$.rewardRate; | ||
| /// @dev update the rewardRate to the notified amount plus what is left, divided by the duration | ||
| $$.rewardRate = (amount + _left) / _duration; | ||
| } | ||
|
|
||
| /// @dev update timestamp for the rebase | ||
| $$.lastUpdateTime = block.timestamp; | ||
| /// @dev update periodFinish (when all rewards are streamed) | ||
| $$.periodFinish = block.timestamp + _duration; | ||
|
|
||
| emit NotifyRewardForToken(token, msg.sender, amount); | ||
| } |
Check notice
Code scanning / Slither
Block timestamp Low
XStaking.notifyRewardAmountToken(address,uint256) uses timestamp for comparisons
Dangerous comparisons:
- require(bool,error)($$.allowed,revert TokenNotAllowed(address)(token))
- block.timestamp >= _periodFinish
Dangerous comparisons:
- require(bool,error)($$.allowed,revert TokenNotAllowed(address)(token))
- block.timestamp >= _periodFinish
6 tasks
| } | ||
|
|
||
| uint amount = IERC20(asset).balanceOf(address(this)); | ||
| ProcessAssetVars memory v; |
Check warning
Code scanning / Slither
Uninitialized local variables Medium
RevenueRouter.processAccumulatedAssets(uint256).v is a local variable never initialized
Comment on lines
487
to
490
| function pendingRevenueAsset(address asset) external view returns (uint) { | ||
| (, uint amount) = _getRevenueRouterStorage().pendingRevenueAsset.tryGet(asset); | ||
| return amount; | ||
| } |
Check warning
Code scanning / Slither
Unused return Medium
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Uh oh!
There was an error while loading. Please reload this page.