Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

IRRewardDistributor

Git Source

Inherits: InfraredUpgradeable

Title: IRRewardDistributor

Distributes IR emissions to Infrared vaults based on governance/keeper configured weights

Integrates with Infrared.addIncentives() for vault reward distribution

Maintains a list of eligible stakingTokens (added by governor) for distribution

Mandatory minimum allocation to iBGT vault (siBGT stakers); iBGT cannot be weighted or excluded

State Variables

BASIS_POINTS

Basis points denominator (100%)

uint256 public constant BASIS_POINTS = 10000

MAX_IBGT_ALLOCATION

Maximum iBGT vault allocation (50%)

uint256 public constant MAX_IBGT_ALLOCATION = 5000

_irToken

IR token for rewards

ERC20 private _irToken

lastEpochTimestamp

Start timestamp of current epoch

uint256 public lastEpochTimestamp

totalRewardsPerEpoch

Total IR to distribute per epoch

uint256 public totalRewardsPerEpoch

currentEpoch

Current epoch number

uint256 public currentEpoch

minIBGTAllocation

Minimum allocation to iBGT vault in basis points (e.g., 2000 = 20%)

uint256 public minIBGTAllocation

_excludedVaults

Set of excluded vaults (not eligible for distribution)

EnumerableSet.AddressSet private _excludedVaults

_eligibleVaults

Set of eligible vaults (maintained by governor; excludes iBGT and excluded vaults)

EnumerableSet.AddressSet private _eligibleVaults

defaultVaultWeights

stakingToken => weight (basis points) - configurable by governance/keeper

mapping(address => uint256) public defaultVaultWeights

totalDefaultWeight

Sum of default weights

uint256 public totalDefaultWeight

epochDuration

Reward distribution period

uint256 public epochDuration

carryOverRewards

Accumulated undistributed rewards from previous failed distributions per vault

mapping(address => uint256) public carryOverRewards

__gap

uint256[40] private __gap

Functions

initialize

Initialize the contract

function initialize(
    address _infrared,
    address _gov,
    address irToken,
    uint256 _minIBGTAllocation
) external initializer;

Parameters

NameTypeDescription
_infraredaddressInfrared protocol address
_govaddressGovernance address
irTokenaddressIR token address
_minIBGTAllocationuint256Minimum allocation to iBGT vault in basis points

excludeVault

Exclude a stakingToken from distribution and voting

function excludeVault(address stakingToken) external virtual onlyGovernor;

Parameters

NameTypeDescription
stakingTokenaddressThe stakingToken address to exclude

includeVault

Include a previously excluded stakingToken (does not auto-add to eligible)

function includeVault(address stakingToken) external virtual onlyGovernor;

Parameters

NameTypeDescription
stakingTokenaddressThe stakingToken address to include

addEligibleVault

Add an eligible stakingToken for distribution (must be a valid Infrared vault)

function addEligibleVault(address stakingToken)
    external
    virtual
    onlyGovernor;

Parameters

NameTypeDescription
stakingTokenaddressThe stakingToken address to add

removeEligibleVault

Remove an eligible stakingToken

function removeEligibleVault(address stakingToken)
    external
    virtual
    onlyGovernor;

Parameters

NameTypeDescription
stakingTokenaddressThe stakingToken address to remove

setRewardsPerEpoch

Set total rewards per epoch

function setRewardsPerEpoch(uint256 amount) external virtual onlyGovernor;

Parameters

NameTypeDescription
amountuint256Total IR tokens to distribute per epoch

setEpochDuration

Set epoch duration (time between distrubtions)

function setEpochDuration(uint256 _newDuration)
    external
    virtual
    onlyGovernor;

Parameters

NameTypeDescription
_newDurationuint256Duration, in seconds, between distribution events

setMinIBGTAllocation

Set minimum iBGT vault allocation

function setMinIBGTAllocation(uint256 allocation)
    external
    virtual
    onlyGovernor;

Parameters

NameTypeDescription
allocationuint256Minimum allocation in basis points (max 50%)

updateDefaultWeights

Update vault weights (sum must be BASIS_POINTS)

Callable by governance or keeper for operational flexibility

function updateDefaultWeights(
    address[] calldata stakingTokens_,
    uint256[] calldata weights
) external virtual onlyKeeper;

Parameters

NameTypeDescription
stakingTokens_address[]Array of stakingToken addresses
weightsuint256[]Array of weights in basis points

recoverERC20

Recover ERC20 tokens sent to this contract (governor only)

function recoverERC20(address token, uint256 amount)
    external
    virtual
    onlyGovernor;

Parameters

NameTypeDescription
tokenaddressThe ERC20 token to recover
amountuint256The amount to recover (or max balance if 0)

distributeRewards

Distribute rewards to vaults based on configured weights

Can only be called after epoch ends

function distributeRewards() external virtual;

_getEligibleVaults

Get all eligible vaults for distribution

function _getEligibleVaults()
    internal
    view
    virtual
    returns (address[] memory);

Returns

NameTypeDescription
<none>address[]Array of eligible stakingToken addresses

_calculateTotalCarryOver

Calculate the total carry-over rewards across iBGT and all eligible vaults

function _calculateTotalCarryOver()
    internal
    view
    virtual
    returns (uint256);

Returns

NameTypeDescription
<none>uint256The sum of all carry-over amounts

IR_TOKEN

Get IR token address

function IR_TOKEN() external view virtual returns (address);

Returns

NameTypeDescription
<none>addressThe IR token address

getExcludedVaults

Get all excluded vaults

function getExcludedVaults()
    external
    view
    virtual
    returns (address[] memory);

Returns

NameTypeDescription
<none>address[]Array of excluded stakingToken addresses

getEligibleVaults

Get all eligible vaults

function getEligibleVaults()
    external
    view
    virtual
    returns (address[] memory);

Returns

NameTypeDescription
<none>address[]Array of eligible stakingToken addresses

isVaultExcluded

Check if vault is excluded

function isVaultExcluded(address stakingToken)
    external
    view
    virtual
    returns (bool);

Parameters

NameTypeDescription
stakingTokenaddressThe stakingToken address

Returns

NameTypeDescription
<none>boolTrue if vault is excluded

timeUntilNextEpoch

Get time until next epoch

function timeUntilNextEpoch() external view virtual returns (uint256);

Returns

NameTypeDescription
<none>uint256Seconds until next epoch (0 if epoch has ended)

getVaultAllocation

Preview the allocation for a specific vault in the next distribution

function getVaultAllocation(address stakingToken)
    external
    view
    virtual
    returns (uint256);

Parameters

NameTypeDescription
stakingTokenaddressThe stakingToken address

Returns

NameTypeDescription
<none>uint256The estimated reward amount for the vault

getNextEpochRewards

Get the total rewards for the next epoch

function getNextEpochRewards() external view virtual returns (uint256);

Returns

NameTypeDescription
<none>uint256The total rewards per epoch (pending distribution)

Events

RewardsDistributed

event RewardsDistributed(address indexed stakingToken, uint256 amount);

VaultExcluded

event VaultExcluded(address indexed stakingToken);

VaultIncluded

event VaultIncluded(address indexed stakingToken);

EligibleVaultAdded

event EligibleVaultAdded(address indexed stakingToken);

EligibleVaultRemoved

event EligibleVaultRemoved(address indexed stakingToken);

EpochStarted

event EpochStarted(
    uint256 indexed epoch, uint256 timestamp, uint256 totalRewards
);

EpochFinalized

event EpochFinalized(uint256 indexed epoch);

WeightsUpdated

event WeightsUpdated(address indexed stakingToken, uint256 weight);

RewardsPerEpochUpdated

event RewardsPerEpochUpdated(uint256 oldAmount, uint256 newAmount);

EpochDurationUpdated

event EpochDurationUpdated(uint256 oldDuration, uint256 newDuration);

MinIBGTAllocationUpdated

event MinIBGTAllocationUpdated(
    uint256 oldAllocation, uint256 newAllocation
);

TokensRecovered

event TokensRecovered(address indexed token, uint256 amount);

DistributionFailed

event DistributionFailed(
    address indexed stakingToken, uint256 amount, bytes errorData
);

Errors

InvalidVault

error InvalidVault();

InvalidAmount

error InvalidAmount();

EpochNotEnded

error EpochNotEnded();

NoRewardsAvailable

error NoRewardsAvailable();

InvalidWeights

error InvalidWeights();

NoWeightsSet

error NoWeightsSet();

InsufficientIRBalance

error InsufficientIRBalance();

InvalidArrayLength

error InvalidArrayLength();

ZeroAddress

error ZeroAddress();

InvalidAllocation

error InvalidAllocation();