IReward

Git Source

Interface for rewards distribution contracts in the Infrared Voter

Base interface implemented by all reward-type contracts

Functions

DURATION

Duration of each reward epoch in seconds

function DURATION() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Fixed duration of 7 days

voter

Address of the Voter contract that manages rewards

function voter() external view returns (address);

Returns

NameTypeDescription
<none>addressVoter contract address

ve

Address of the VotingEscrow contract that manages veNFTs

function ve() external view returns (address);

Returns

NameTypeDescription
<none>addressVotingEscrow contract address

authorized

Address permitted to call privileged state-changing functions

function authorized() external view returns (address);

Returns

NameTypeDescription
<none>addressAuthorized caller address

totalSupply

Total amount of staking tokens locked in contract

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Current total supply of staked tokens

balanceOf

Retrieves current staked balance for a veNFT

function balanceOf(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256ID of the veNFT to query

Returns

NameTypeDescription
<none>uint256Current staked token balance

tokenRewardsPerEpoch

Gets reward amount allocated for a specific epoch

function tokenRewardsPerEpoch(address token, uint256 epochStart)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
tokenaddressAddress of reward token
epochStartuint256Starting timestamp of epoch

Returns

NameTypeDescription
<none>uint256Amount of token allocated as rewards for the epoch

lastEarn

Retrieves timestamp of last reward claim for a veNFT

function lastEarn(address token, uint256 tokenId)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
tokenaddressAddress of reward token
tokenIduint256ID of veNFT that claimed

Returns

NameTypeDescription
<none>uint256Timestamp of last claim for this token/veNFT pair

isReward

Checks if a token is configured as a reward token

function isReward(address token) external view returns (bool);

Parameters

NameTypeDescription
tokenaddressAddress of token to check

Returns

NameTypeDescription
<none>boolTrue if token is active for rewards

numCheckpoints

Number of balance checkpoints for a veNFT

function numCheckpoints(uint256 tokenId) external view returns (uint256);

Parameters

NameTypeDescription
tokenIduint256ID of veNFT to query

Returns

NameTypeDescription
<none>uint256Number of checkpoints recorded

supplyNumCheckpoints

Total number of supply checkpoints recorded

function supplyNumCheckpoints() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Count of global supply checkpoints

checkpoints

Gets balance checkpoint data for a veNFT at specific index

function checkpoints(uint256 tokenId, uint256 index)
    external
    view
    returns (uint256 timestamp, uint256 balanceOf);

Parameters

NameTypeDescription
tokenIduint256ID of veNFT to query
indexuint256Checkpoint index to read

Returns

NameTypeDescription
timestampuint256Time checkpoint was created
balanceOfuint256Balance recorded at checkpoint

supplyCheckpoints

Gets total supply checkpoint data at specific index

function supplyCheckpoints(uint256 index)
    external
    view
    returns (uint256 timestamp, uint256 supply);

Parameters

NameTypeDescription
indexuint256Checkpoint index to read

Returns

NameTypeDescription
timestampuint256Time checkpoint was created
supplyuint256Total supply recorded at checkpoint

getPriorBalanceIndex

Gets historical balance index for a veNFT at timestamp

Uses binary search to find checkpoint index

function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
tokenIduint256ID of veNFT to query
timestampuint256Time to query balance at

Returns

NameTypeDescription
<none>uint256Index of nearest checkpoint before timestamp

getPriorSupplyIndex

Gets historical supply index at timestamp

Uses binary search to find checkpoint index

function getPriorSupplyIndex(uint256 timestamp)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
timestampuint256Time to query supply at

Returns

NameTypeDescription
<none>uint256Index of nearest checkpoint before timestamp

rewardsListLength

Number of tokens configured for rewards

function rewardsListLength() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Length of rewards token list

earned

Calculates unclaimed rewards for a veNFT

function earned(address token, uint256 tokenId)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
tokenaddressAddress of reward token to calculate
tokenIduint256ID of veNFT to calculate for

Returns

NameTypeDescription
<none>uint256Amount of unclaimed rewards

_deposit

Records a token deposit and updates checkpoints

Can only be called by authorized address

function _deposit(uint256 amount, uint256 tokenId) external;

Parameters

NameTypeDescription
amountuint256Amount of tokens being deposited
tokenIduint256ID of veNFT receiving deposit

_withdraw

Records a token withdrawal and updates checkpoints

Can only be called by authorized address

function _withdraw(uint256 amount, uint256 tokenId) external;

Parameters

NameTypeDescription
amountuint256Amount of tokens being withdrawn
tokenIduint256ID of veNFT withdrawing from

getReward

Claims accumulated rewards for a veNFT

function getReward(uint256 tokenId, address[] memory tokens) external;

Parameters

NameTypeDescription
tokenIduint256ID of veNFT claiming rewards
tokensaddress[]Array of reward token addresses to claim

notifyRewardAmount

Adds new reward tokens for distribution

Transfers tokens from caller and updates reward accounting

function notifyRewardAmount(address token, uint256 amount) external;

Parameters

NameTypeDescription
tokenaddressAddress of token to add as reward
amountuint256Amount of token to add to rewards

renotifyRewardAmount

in case rewards where distributed during a epoch with no deposits, redistribute the rewards

function renotifyRewardAmount(uint256 timestamp, address token) external;

Parameters

NameTypeDescription
timestampuint256Timestamp of the start of the epoch to renotify
tokenaddressAddress of token to renotify

Events

Deposit

Emitted when tokens are deposited for rewards

event Deposit(address indexed from, uint256 indexed tokenId, uint256 amount);

Parameters

NameTypeDescription
fromaddressAddress depositing tokens
tokenIduint256ID of the veNFT receiving deposit
amountuint256Amount of tokens deposited

Withdraw

Emitted when tokens are withdrawn from rewards

event Withdraw(address indexed from, uint256 indexed tokenId, uint256 amount);

Parameters

NameTypeDescription
fromaddressAddress withdrawing tokens
tokenIduint256ID of the veNFT withdrawing from
amountuint256Amount of tokens withdrawn

NotifyReward

Emitted when new rewards are added

event NotifyReward(
    address indexed from,
    address indexed reward,
    uint256 indexed epoch,
    uint256 amount
);

Parameters

NameTypeDescription
fromaddressAddress supplying the reward tokens
rewardaddressToken being added as reward
epochuint256Epoch timestamp for reward distribution
amountuint256Amount of reward tokens added

ClaimRewards

Emitted when rewards are claimed

event ClaimRewards(
    address indexed from, address indexed reward, uint256 amount
);

Parameters

NameTypeDescription
fromaddressAddress claiming the rewards
rewardaddressToken being claimed
amountuint256Amount of tokens claimed

Errors

InvalidReward

Thrown when attempting to interact with an invalid reward token

error InvalidReward();

NotAuthorized

Thrown when caller is not authorized to perform operation

error NotAuthorized();

NotWhitelisted

Thrown when token is not in whitelist

error NotWhitelisted();

ZeroAmount

Thrown when attempting operation with zero amount

error ZeroAmount();

NonZeroSupply

Thrown when supply is not zero

error NonZeroSupply();

ActiveEpoch

Thrown when epoch is active

error ActiveEpoch();

Structs

Checkpoint

Balance checkpoint for tracking historical balances

struct Checkpoint {
    uint256 timestamp;
    uint256 balanceOf;
}

Properties

NameTypeDescription
timestampuint256Time of checkpoint
balanceOfuint256Balance at checkpoint

SupplyCheckpoint

Supply checkpoint for tracking total supply

struct SupplyCheckpoint {
    uint256 timestamp;
    uint256 supply;
}

Properties

NameTypeDescription
timestampuint256Time of checkpoint
supplyuint256Total supply at checkpoint