Distributor
The Distributor contract is responsible for distributing the block rewards from the reward controller and the reward allocation weights, to the reward allocation receivers.
Each validator has its own reward allocation, if it does not exist, a default reward allocation is used. And if governance has not set the default reward allocation, the rewards are not minted and distributed.
State Variables
MANAGER_ROLE
The MANAGER role.
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
ONE_HUNDRED_PERCENT
Represents 100%. Chosen to be less granular.
uint96 internal constant ONE_HUNDRED_PERCENT = 1e4;
beraChef
The BeraChef contract that we are getting the reward allocation from.
IBeraChef public beraChef;
blockRewardController
The rewards controller contract that we are getting the rewards rate from.
And is responsible for minting the BGT token.
IBlockRewardController public blockRewardController;
bgt
The BGT token contract that we are distributing to the reward allocation receivers.
address public bgt;
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor();
initialize
function initialize(
address _berachef,
address _bgt,
address _blockRewardController,
address _governance,
uint64 _zeroValidatorPubkeyGIndex,
uint64 _proposerIndexGIndex
)
external
initializer;
_authorizeUpgrade
function _authorizeUpgrade(address newImplementation) internal override onlyRole(DEFAULT_ADMIN_ROLE);
setZeroValidatorPubkeyGIndex
This is necessary to call when the beacon chain hard forks (and specifically the underlying structure of beacon state is modified).
function setZeroValidatorPubkeyGIndex(uint64 _zeroValidatorPubkeyGIndex) public override onlyRole(MANAGER_ROLE);
setProposerIndexGIndex
This is necessary to call when the beacon chain hard forks (and specifically the underlying structure of beacon state is modified).
function setProposerIndexGIndex(uint64 _proposerIndexGIndex) public override onlyRole(MANAGER_ROLE);
distributeFor
Distribute the rewards to the reward allocation receivers.
Permissionless function to distribute rewards by providing the necessary Merkle proofs. Reverts if the proofs are invalid.
function distributeFor(
uint64 nextTimestamp,
uint64 proposerIndex,
bytes calldata pubkey,
bytes32[] calldata proposerIndexProof,
bytes32[] calldata pubkeyProof
)
external
nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
nextTimestamp | uint64 | The timestamp of the next beacon block to distribute for. The EIP-4788 Beacon Roots contract is queried by this key, returning the parent beacon block root from the next timestamp. |
proposerIndex | uint64 | The proposer index of the beacon block. This should be the validator index corresponding to the pubkey in the validator registry in the beacon state. |
pubkey | bytes | The validator pubkey of the proposer. |
proposerIndexProof | bytes32[] | The Merkle proof of the proposer index in the beacon block. |
pubkeyProof | bytes32[] | The Merkle proof of the validator pubkey of the proposer in the beacon block. |
_distributeFor
Distributes the rewards for the given validator for the given timestamp's parent block.
function _distributeFor(bytes calldata pubkey, uint64 nextTimestamp) internal;