Skip to content

BlockRewardController

0x1AE7dD7AE06F6C58B4524d9c1f816094B1bcCD8e | ABI JSON

Git Source

The BlockRewardController contract is responsible for managing the reward rate of BGT. It computes and distributes block rewards to validators based on their voting power.

Inherits: IBlockRewardController, OwnableUpgradeable, UUPSUpgradeable

Constants

MAX_BASE_RATE

The maximum value for base rate.

solidity
uint256 public constant MAX_BASE_RATE = 5 * FixedPointMathLib.WAD;

MAX_BOOST_MULTIPLIER

The maximum value for boost multiplier.

solidity
uint256 public constant MAX_BOOST_MULTIPLIER = 5 * FixedPointMathLib.WAD;

MAX_MIN_BOOSTED_REWARD_RATE

The maximum value for the minimum reward rate after boosts accounting.

solidity
uint256 public constant MAX_MIN_BOOSTED_REWARD_RATE = 10 * FixedPointMathLib.WAD;

MAX_REWARD_CONVEXITY

The maximum value for reward convexity parameter.

solidity
uint256 public constant MAX_REWARD_CONVEXITY = FixedPointMathLib.WAD;

MAX_REWARD_RATE

The maximum value for reward rate.

solidity
uint256 public constant MAX_REWARD_RATE = 5 * FixedPointMathLib.WAD;

State Variables

baseRate

The constant base rate for BGT.

solidity
uint256 public baseRate;

beaconDepositContract

The Beacon deposit contract to check the pubkey -> operator relationship.

solidity
IBeaconDeposit public beaconDepositContract;

boostMultiplier

The boost multiplier parameter in the function, determines the inflation cap, 18 decimals.

solidity
uint256 public boostMultiplier;

bgt

The BGT token contract that we are minting to the distributor.

solidity
BGT public bgt;

distributor

The distributor contract that receives the minted BGT.

solidity
address public distributor;

minBoostedRewardRate

The minimum reward rate for BGT after accounting for validator boosts.

solidity
uint256 public minBoostedRewardRate;

rewardConvexity

The reward convexity parameter in the function, determines how fast it converges to its max, 18 decimals.

solidity
int256 public rewardConvexity;

rewardRate

The reward rate for BGT.

solidity
uint256 public rewardRate;

View Functions

getMaxBGTPerBlock

Returns the current max BGT production per block.

Exposed for BGT contract to calculate the max burnable native token amount.

solidity
function getMaxBGTPerBlock() public view returns (uint256 amount);

Returns

NameTypeDescription
amountuint256The maximum amount of BGT that can be minted in one block

Functions

computeReward

Computes the reward given specified parameters, according to the formula. r := (1 + mul) _ (1 - 1 / (1 + mul _ boost^conv)) _ rewardRate ∈ [0, mul _ rewardRate]

Returns 0 for boost == 0 even if conv == 0, since contract enforces conv > 0.

solidity
function computeReward(
    uint256 boostPower,
    uint256 _rewardRate,
    uint256 _boostMultiplier,
    int256 _rewardConvexity
) public pure returns (uint256 reward);

Parameters

NameTypeDescription
boostPoweruint256The normalized boost
_rewardRateuint256The reward rate parameter
_boostMultiplieruint256The boost multiplier parameter
_rewardConvexityint256The reward convexity parameter

Returns

NameTypeDescription
rewarduint256The reward amount

initialize

Initializes the BlockRewardController contract.

solidity
function initialize(
    address _bgt,
    address _distributor,
    address _beaconDepositContract,
    address _governance
) external initializer;

Parameters

NameTypeDescription
_bgtaddressThe BGT token contract address
_distributoraddressThe distributor contract address
_beaconDepositContractaddressThe Beacon deposit contract address
_governanceaddressThe governance address

processRewards

Processes the rewards for the specified block and mints BGT to validator's operator and distributor.

This function can only be called by the distributor.

Emits:

solidity
function processRewards(
    bytes calldata pubkey,
    uint64 nextTimestamp,
    bool isReady
) external onlyDistributor returns (uint256);

Parameters

NameTypeDescription
pubkeybytesThe validator's pubkey
nextTimestampuint64The timestamp of the next beacon block that was processed
isReadyboolThe flag to enable reward minting to distributor (true when BeraChef is ready)

Returns

NameTypeDescription
<none>uint256The amount of BGT minted to distributor

setBaseRate

Sets the constant base reward rate for BGT.

This function can only be called by the owner, which is the governance address.

Emits:

solidity
function setBaseRate(uint256 _baseRate) external onlyOwner;

Parameters

NameTypeDescription
_baseRateuint256The new base rate

setBoostMultiplier

Sets the boost multiplier parameter for the reward formula.

This function can only be called by the owner, which is the governance address.

Emits:

solidity
function setBoostMultiplier(uint256 _boostMultiplier) external onlyOwner;

Parameters

NameTypeDescription
_boostMultiplieruint256The new boost multiplier

setDistributor

Sets the distributor contract that receives the minted BGT.

This function can only be called by the owner, which is the governance address.

Emits:

solidity
function setDistributor(address _distributor) external onlyOwner;

Parameters

NameTypeDescription
_distributoraddressThe new distributor contract

setMinBoostedRewardRate

Sets the min boosted reward rate for BGT.

This function can only be called by the owner, which is the governance address.

Emits:

solidity
function setMinBoostedRewardRate(uint256 _minBoostedRewardRate) external onlyOwner;

Parameters

NameTypeDescription
_minBoostedRewardRateuint256The new min boosted reward rate

setRewardConvexity

Sets the reward convexity parameter for the reward formula.

This function can only be called by the owner, which is the governance address.

Emits:

solidity
function setRewardConvexity(uint256 _rewardConvexity) external onlyOwner;

Parameters

NameTypeDescription
_rewardConvexityuint256The new reward convexity

setRewardRate

Sets the reward rate for BGT.

This function can only be called by the owner, which is the governance address.

Emits:

solidity
function setRewardRate(uint256 _rewardRate) external onlyOwner;

Parameters

NameTypeDescription
_rewardRateuint256The new reward rate

Events

BaseRateChanged

Emitted when the constant base rate has changed.

solidity
event BaseRateChanged(uint256 oldBaseRate, uint256 newBaseRate);

Parameters

NameTypeDescription
oldBaseRateuint256The old base rate
newBaseRateuint256The new base rate

BlockRewardProcessed

Emitted when the rewards for the specified block have been processed.

solidity
event BlockRewardProcessed(bytes indexed pubkey, uint64 nextTimestamp, uint256 baseRate, uint256 rewardRate);

Parameters

NameTypeDescription
pubkeybytesThe validator's pubkey
nextTimestampuint64The timestamp of the next beacon block that was processed
baseRateuint256The base amount of BGT minted to the validator's operator
rewardRateuint256The amount of BGT minted to the distributor

BoostMultiplierChanged

Emitted when the boostMultiplier parameter has changed.

solidity
event BoostMultiplierChanged(uint256 oldBoostMultiplier, uint256 newBoostMultiplier);

Parameters

NameTypeDescription
oldBoostMultiplieruint256The old boost multiplier parameter
newBoostMultiplieruint256The new boost multiplier parameter

MinBoostedRewardRateChanged

Emitted when the min boosted reward rate has changed.

solidity
event MinBoostedRewardRateChanged(uint256 oldMinBoostedRewardRate, uint256 newMinBoostedRewardRate);

Parameters

NameTypeDescription
oldMinBoostedRewardRateuint256The old min boosted reward rate
newMinBoostedRewardRateuint256The new min boosted reward rate

RewardConvexityChanged

Emitted when the reward formula convexity parameter has changed.

solidity
event RewardConvexityChanged(uint256 oldRewardConvexity, uint256 newRewardConvexity);

Parameters

NameTypeDescription
oldRewardConvexityuint256The old reward formula convexity parameter
newRewardConvexityuint256The new reward formula convexity parameter

RewardRateChanged

Emitted when the reward rate has changed.

solidity
event RewardRateChanged(uint256 oldRewardRate, uint256 newRewardRate);

Parameters

NameTypeDescription
oldRewardRateuint256The old reward rate
newRewardRateuint256The new reward rate

SetDistributor

Emitted when the distributor is set.

solidity
event SetDistributor(address indexed rewardDistribution);

Parameters

NameTypeDescription
rewardDistributionaddressThe new distributor address

Errors

InvalidBaseRate

Thrown when the base rate exceeds the maximum allowed value.

solidity
error InvalidBaseRate();

InvalidBoostMultiplier

Thrown when the boost multiplier exceeds the maximum allowed value.

solidity
error InvalidBoostMultiplier();

InvalidMinBoostedRewardRate

Thrown when the minimum boosted reward rate exceeds the maximum allowed value.

solidity
error InvalidMinBoostedRewardRate();

InvalidRewardConvexity

Thrown when the reward convexity is zero or exceeds the maximum allowed value.

solidity
error InvalidRewardConvexity();

InvalidRewardRate

Thrown when the reward rate exceeds the maximum allowed value.

solidity
error InvalidRewardRate();

NotDistributor

Thrown when the caller is not the distributor.

solidity
error NotDistributor();

ZeroAddress

Thrown when a zero address is provided where a valid address is required.

solidity
error ZeroAddress();