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 validation rewards #603

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

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;
}

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