-
Notifications
You must be signed in to change notification settings - Fork 10
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
[Staking] Update reward calculation mechanism #44
[Staking] Update reward calculation mechanism #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/// @dev Mapping from the pool address => settled pool data | ||
mapping(address => SettledPool) internal _settledPool; | ||
/// @dev Mapping from period number => accumulated rewards per share (one unit staking) | ||
mapping(uint256 => PeriodWrapper) private _accumulatedRps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, this is used to track the rps
of pool in period, so this must be per pool and a new pool address dimension is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense
uint256 _aRps = _accumulatedRps[_reward.lastPeriod].inner; | ||
uint256 _lastPeriodReward = _minAmount * (_aRps - _reward.aRps); | ||
uint256 _newPeriodsReward = _latestStakingAmount * (_pool.aRps - _aRps); | ||
return _reward.debited + (_lastPeriodReward + _newPeriodsReward) / 1e18; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove 1e18
here and in _recordRewards
below?
Description
RewardCalculation.sol
] Update reward calculation mechanism: Deprecated slashing feature for staking contractRoninValidatorSet.sol
] Update staking reward recording: updating rewards at the end of each block -> periodbalance
tostakingAmount
to avoid misleadingbalanceOf
->stakingAmountOf
,totalBalance
->stakingTotal
What's to be noticed?
RoninValidatorSet.sol
RewardCalculation.sol
RewardCalculation.test.ts
Checklist