InfraredDistributor
Inherits: InfraredUpgradeable, IInfraredDistributor
Title: InfraredDistributor
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
| 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 onlyGovernor;
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 |