InfraredDistributor

Git Source

Inherits: InfraredUpgradeable, IInfraredDistributor

A contract for distributing rewards in a single ERC20 token (iBERA) to validators

State Variables

token

Token used for reward distributions

ERC20 public token;

amountsCumulative

Tracks reward amount accumulation per validator

uint256 public amountsCumulative;

_snapshots

mapping(bytes32 pubkeyHash => Snapshot) internal _snapshots;

_validators

mapping(bytes32 pubkeyHash => address) internal _validators;

Functions

constructor

constructor(address _infrared) InfraredUpgradeable(_infrared);

initialize

function initialize(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;

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