π§βπ§ XStaking 2.0.0, RevenueRouter 2.0.0#439
Merged
Conversation
|
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
6 tasks
| } | ||
|
|
||
| uint amount = IERC20(asset).balanceOf(address(this)); | ||
| ProcessAssetVars memory v; |
Check warning
Code scanning / Slither
Uninitialized local variables Medium
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
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
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.