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

Prorated rewards v2 #631

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions contracts/validator-manager/ExampleRewardCalculator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import {IRewardCalculator} from "./interfaces/IRewardCalculator.sol";
contract ExampleRewardCalculator is IRewardCalculator {
uint256 public constant SECONDS_IN_YEAR = 31536000;

uint8 public constant UPTIME_REWARDS_THRESHOLD_PERCENTAGE = 80;

uint16 public constant BIPS_CONVERSION_FACTOR = 10000;

uint64 public immutable rewardBasisPoints;
Expand All @@ -26,20 +24,11 @@ contract ExampleRewardCalculator is IRewardCalculator {
*/
function calculateReward(
uint256 stakeAmount,
uint64 validatorStartTime,
uint64, // validatorStartTime
uint64 stakingStartTime,
uint64 stakingEndTime,
uint64 uptimeSeconds
uint64 // uptimeSeconds
) external view returns (uint256) {
// Equivalent to uptimeSeconds/(validator.endedAt - validator.startedAt) < UPTIME_REWARDS_THRESHOLD_PERCENTAGE/100
// Rearranged to prevent integer division truncation.
if (
uptimeSeconds * 100
< (stakingEndTime - validatorStartTime) * UPTIME_REWARDS_THRESHOLD_PERCENTAGE
) {
return 0;
}

Comment on lines -34 to -42
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with the current implementation, it would make more sense to keep all the uptime checks in the calculator. If the calculator returns 0, we don't release any rewards which is totally fine.

return (stakeAmount * rewardBasisPoints * (stakingEndTime - stakingStartTime))
/ SECONDS_IN_YEAR / BIPS_CONVERSION_FACTOR;
}
Expand Down
Loading
Loading