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

feat(contracts): update validator reward calculation #355

Merged
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
11 changes: 9 additions & 2 deletions packages/contracts/contracts/L1/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,9 @@ contract ValidatorManager is ISemver, IValidatorManager {
*
* @param validator Address of the validator.
*
* @return The amount of base reward.
* @return The amount of base reward, excluding base reward for the validator.
* @return The amount of boosted reward.
* @return The amount of validator reward.
* @return The amount of reward from commission and base reward for the validator.
*/
function _calculateReward(address validator) internal view returns (uint128, uint128, uint128) {
uint128 commissionRate = _validatorInfo[validator].commissionRate;
Expand All @@ -624,6 +624,13 @@ contract ValidatorManager is ISemver, IValidatorManager {
COMMISSION_RATE_DENOM - commissionRate,
COMMISSION_RATE_DENOM
);

uint128 validatorKro = ASSET_MANAGER.totalValidatorKro(validator);
uint128 totalKro = ASSET_MANAGER.totalKroAssets(validator);
uint128 validatorBaseReward = baseReward.mulDiv(validatorKro, totalKro + validatorKro);
// Exclude the base reward for the validator from total base reward given to KRO delegators.
baseReward -= validatorBaseReward;
validatorReward += validatorBaseReward;
}

return (baseReward, boostedReward, validatorReward);
Expand Down
Loading