InfraredDistributor
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
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
validator | address | Address 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
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator'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
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
notifyRewardAmount
Distributes new commission rewards to validator set
Note: error: ZeroAmount if amount is 0
function notifyRewardAmount(uint256 amount) external;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | Amount 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
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
recipient | address | Address 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
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
Returns
Name | Type | Description |
---|---|---|
amountCumulativeLast | uint256 | Last claimed accumulator value |
amountCumulativeFinal | uint256 | Final accumulator value if removed |
getValidator
Get validator's registered claim address
function getValidator(bytes calldata pubkey) external view returns (address);
Parameters
Name | Type | Description |
---|---|---|
pubkey | bytes | Validator's public key |
Returns
Name | Type | Description |
---|---|---|
<none> | address | Address authorized to claim validator rewards |