InfraredDistributor

Git Source

Inherits: InfraredUpgradeable, IInfraredDistributor

Distributes rewards to validators.

*Validator pubkeys are mapped to an EVM address and the pool of rewards from which they claim is porportional to the number of validators.

  • for example, if there are 10 validators and 100 tokens are notified, each validator can claim 10 tokens.*

State Variables

token

Token used for reward distributions

ERC20 public token;

amountsCumulative

Tracks reward amount accumulation per validator

uint256 public amountsCumulative;

residualAmount

uint256 private residualAmount;

_snapshots

mapping(bytes32 pubkeyHash => Snapshot) internal _snapshots;

_validators

mapping(bytes32 pubkeyHash => address) internal _validators;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

Functions

initialize

function initialize(address _infrared, address _gov, address _token)
    external
    initializer;

add

Register new validator for rewards

Only callable by Infrared contract

Notes:

  • access-control: Requires INFRARED_ROLE

  • error: ValidatorAlreadyExists if validator already registered

function add(bytes calldata pubkey, address validator) external onlyInfrared;

Parameters

NameTypeDescription
pubkeybytesValidator's public key
validatoraddressAddress authorized to claim rewards

remove

Removes validator from reward-eligible set

Only callable by Infrared contract

Note: access-control: Requires INFRARED_ROLE

function remove(bytes calldata pubkey) external onlyInfrared;

Parameters

NameTypeDescription
pubkeybytesValidator's public key

purge

Purges validator from registry completely

Only possible after all rewards are claimed

Note: error: ClaimableRewardsExist if unclaimed rewards remain

function purge(bytes calldata pubkey) external onlyGovernor;

Parameters

NameTypeDescription
pubkeybytesValidator's public key

notifyRewardAmount

Distributes new commission rewards to validator set

Note: error: ZeroAmount if amount is 0

function notifyRewardAmount(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256Amount to distribute equally among validators

claim

Claims outstanding commission rewards

Note: error: InvalidValidator if caller not authorized

function claim(bytes calldata pubkey, address recipient) external;

Parameters

NameTypeDescription
pubkeybytesValidator's public key
recipientaddressAddress to receive the claimed rewards

getSnapshot

Get validator's reward snapshots

Returns (0,0) if validator doesn't exist

function getSnapshot(bytes calldata pubkey)
    external
    view
    returns (uint256 amountCumulativeLast, uint256 amountCumulativeFinal);

Parameters

NameTypeDescription
pubkeybytesValidator's public key

Returns

NameTypeDescription
amountCumulativeLastuint256Last claimed accumulator value
amountCumulativeFinaluint256Final accumulator value if removed

getValidator

Get validator's registered claim address

function getValidator(bytes calldata pubkey) external view returns (address);

Parameters

NameTypeDescription
pubkeybytesValidator's public key

Returns

NameTypeDescription
<none>addressAddress authorized to claim validator rewards