Skip to content

Distributor

0xD2f19a79b026Fb636A7c300bF5947df113940761 | ABI JSON

Git Source

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.

Inherits: IDistributor, BeaconRootsHelper, ReentrancyGuardUpgradeable, AccessControlUpgradeable, UUPSUpgradeable, Multicallable

Constants

MANAGER_ROLE

The MANAGER role.

solidity
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

State Variables

beraChef

The BeraChef contract that we are getting the reward allocation from.

solidity
IBeraChef public beraChef;

bgt

The BGT token contract that we are distributing to the reward allocation receivers.

solidity
address public bgt;

blockRewardController

The rewards controller contract that we are getting the rewards rate from.

And is responsible for minting the BGT token.

solidity
IBlockRewardController public blockRewardController;

Functions

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.

Emits:

solidity
function distributeFor(
    uint64 nextTimestamp,
    uint64 proposerIndex,
    bytes calldata pubkey,
    bytes32[] calldata proposerIndexProof,
    bytes32[] calldata pubkeyProof
) external nonReentrant;

Parameters

NameTypeDescription
nextTimestampuint64The 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.
proposerIndexuint64The proposer index of the beacon block. This should be the validator index corresponding to the pubkey in the validator registry in the beacon state.
pubkeybytesThe validator pubkey of the proposer.
proposerIndexProofbytes32[]The Merkle proof of the proposer index in the beacon block.
pubkeyProofbytes32[]The Merkle proof of the validator pubkey of the proposer in the beacon block.

distributeFor

Distribute the rewards to the reward allocation receivers according to BRIP-0004.

This will be called for block N at the top of block N+1. Only system calls allowed i.e only the execution layer client can call this function.

Emits:

solidity
function distributeFor(bytes calldata pubkey) external onlySystemCall;

Parameters

NameTypeDescription
pubkeybytesThe validator pubkey of the proposer

initialize

Initializes the Distributor contract.

solidity
function initialize(
    address _berachef,
    address _bgt,
    address _blockRewardController,
    address _governance,
    uint64 _zeroValidatorPubkeyGIndex,
    uint64 _proposerIndexGIndex
) external initializer;

Parameters

NameTypeDescription
_berachefaddressThe BeraChef contract address
_bgtaddressThe BGT token contract address
_blockRewardControlleraddressThe BlockRewardController contract address
_governanceaddressThe governance address
_zeroValidatorPubkeyGIndexuint64The zero validator pubkey general index
_proposerIndexGIndexuint64The proposer index general index

setProposerIndexGIndex

Sets the proposer index general index.

This is necessary to call when the beacon chain hard forks (and specifically the underlying structure of beacon block header is modified).

solidity
function setProposerIndexGIndex(uint64 _proposerIndexGIndex) public override onlyRole(MANAGER_ROLE);

Parameters

NameTypeDescription
_proposerIndexGIndexuint64The new proposer index general index

setZeroValidatorPubkeyGIndex

Sets the zero validator pubkey general index.

This is necessary to call when the beacon chain hard forks (and specifically the underlying structure of beacon block header is modified).

solidity
function setZeroValidatorPubkeyGIndex(uint64 _zeroValidatorPubkeyGIndex) public override onlyRole(MANAGER_ROLE);

Parameters

NameTypeDescription
_zeroValidatorPubkeyGIndexuint64The new zero validator pubkey general index

Events

Distributed

Emitted when rewards are distributed to a receiver.

solidity
event Distributed(bytes indexed valPubkey, uint64 indexed nextTimestamp, address indexed receiver, uint256 amount);

Parameters

NameTypeDescription
valPubkeybytesThe validator pubkey
nextTimestampuint64The timestamp of the next beacon block
receiveraddressThe reward receiver address
amountuint256The amount of rewards distributed

Errors

NotSystemAddress

Thrown when the caller is not the system address.

solidity
error NotSystemAddress();

OnlySystemCallAllowed

Thrown when only system calls are allowed but a non-system call was made.

solidity
error OnlySystemCallAllowed();