Infrared Protocol

The Infrared Protocol revolutionizes the way users engage with the Berachain ecosystem, particularly in how they stake consensus assets and receive the Proof-of-Liquidity inflation. It enables users to stake their assets effortlessly and receive IBGT, a liquid staked representation of BGT, significantly enhancing BGT's utility. Additionally, Infrared democratizes access to Validator staking through the IBERA contract suite, a liquid staking token tightly integrated with Proof-of-Liquidity (POL) and the Infrared ecosystem.

Learn More

Contract Architecture

Architecture

https://link.excalidraw.com/l/1Tuu8vTTCh1/1f3jMvwGuuS

Core Contracts

  • full overview here

  • IBERA.sol: Main liquid staking token contract. Handles minting/burning of iBERA, facilitates POL rewards and manages validators.

  • InfraredVault.sol: Manages staking pools and reward distribution. Integrates with Berachain's POL system.

  • InfraredDistributor.sol: Handles distribution of validator rewards and commission management.

  • BribeCollector.sol: Collects and auctions bribes from Berachain reward vaults.

Staking Contracts

  • full overview here

  • IBERADepositor.sol: Handles deposits to CL through Berachain beacon deposit contract.

  • IBERAWithdrawor.sol: Manages withdrawals from CL through Berachain precompiles.

  • IBERAClaimor.sol: Processes user claims for withdrawn funds.

  • IBERAFeeReceivor.sol: Receives and processes validator rewards from EL.

Voting Contracts

  • full overview here

  • VotingEscrow.sol: Implementation of vote-escrowed NFTs (veNFTs) for protocol governance.

  • Voter.sol: Manages voting logic for POL cutting board allocation.

  • MultiRewards.sol: Base contract for reward distribution across multiple tokens.

Getting Started

Prerequisites

# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup

Quick Start

# Clone the repository
git clone https://github.com/infrared-dao/infrared-contracts.git
cd infrared-protocol

# Install dependencies
forge install

# Build contracts
forge build

# Run tests
forge test

Integration Guide

Developers who want to integrate with InfraredVault and IBGTVault can do so by following these steps:

Installation

Add the infrared-contracts to your Foundry project:

forge install infrared-dao/infrared-contracts

Update your foundry.toml with the following remapping:

@infrared/=lib/infrared-contracts/contracts

Example Usage

import {IInfrared} from '@infrared/interfaces/IInfrared.sol';
import {IInfraredVault} from '@infrared/interfaces/IInfraredVault.sol';
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

// Query InfraredVault
IInfraredVault infraredVault = IInfrared(infrared).vaultRegistry(asset);

// Stake into InfraredVault
IERC20(asset).approve(address(infraredVault), amount);
infraredVault.stake(amount);

// Check earned rewards
IInfraredVault.RewardData[] memory rTs = infraredVault.getUserRewardsEarned(user);

// Harvest rewards
infraredVault.getReward();

// Withdraw assets and harvest remaining rewards
infraredVault.exit();

Contents

Contents

ConfigTypes

Git Source

Enums

FeeType

Fee type enum for determining rates to charge on reward distribution.

enum FeeType {
    HarvestOperatorFeeRate,
    HarvestOperatorProtocolRate,
    HarvestVaultFeeRate,
    HarvestVaultProtocolRate,
    HarvestBribesFeeRate,
    HarvestBribesProtocolRate,
    HarvestBoostFeeRate,
    HarvestBoostProtocolRate
}

RewardsLib

Git Source

State Variables

RATE_UNIT

RED mint rate in hundredths of 1 bip

Used as the denominator when calculating IRED minting (1e6)

uint256 internal constant RATE_UNIT = 1e6;

WEIGHT_UNIT

Weight units when partitioning reward amounts in hundredths of 1 bip

Used as the denominator when calculating weighted distributions (1e6)

uint256 internal constant WEIGHT_UNIT = 1e6;

FEE_UNIT

Protocol fee rate in hundredths of 1 bip

Used as the denominator when calculating protocol fees (1e6)

uint256 internal constant FEE_UNIT = 1e6;

Functions

chargedFeesOnRewards

Calculates how fees are split between protocol, voters, and the recipient.

function chargedFeesOnRewards(
    RewardsStorage storage,
    uint256 _amt,
    uint256 _feeTotal,
    uint256 _feeProtocol
)
    external
    pure
    returns (uint256 amtRecipient, uint256 amtVoter, uint256 amtProtocol);

_chargedFeesOnRewards

function _chargedFeesOnRewards(
    uint256 _amt,
    uint256 _feeTotal,
    uint256 _feeProtocol
)
    internal
    pure
    returns (uint256 amtRecipient, uint256 amtVoter, uint256 amtProtocol);

_distributeFeesOnRewards

function _distributeFeesOnRewards(
    mapping(address => uint256) storage protocolFeeAmounts,
    address _voter,
    address _token,
    uint256 _amtVoter,
    uint256 _amtProtocol
) internal;

harvestBase

function harvestBase(address bgt, address ibgt, address ibera)
    external
    returns (uint256 bgtAmt);

harvestVault

function harvestVault(
    RewardsStorage storage $,
    IInfraredVault vault,
    address bgt,
    address ibgt,
    address voter,
    address red,
    uint256 rewardsDuration
) external returns (uint256 bgtAmt);

harvestBribes

function harvestBribes(
    RewardsStorage storage $,
    address wbera,
    address collector,
    address[] memory _tokens,
    bool[] memory whitelisted
) external returns (address[] memory tokens, uint256[] memory _amounts);

collectBribesInWBERA

function collectBribesInWBERA(
    RewardsStorage storage $,
    uint256 _amount,
    address wbera,
    address ibera,
    address ibgtVault,
    address voter,
    uint256 rewardsDuration
) external returns (uint256 amtInfraredBERA, uint256 amtIbgtVault);

harvestBoostRewards

function harvestBoostRewards(
    RewardsStorage storage $,
    address bgt,
    address ibgtVault,
    address voter,
    uint256 rewardsDuration
) external returns (address _vault, address _token, uint256 _amount);

harvestOperatorRewards

function harvestOperatorRewards(
    RewardsStorage storage $,
    address ibera,
    address voter,
    address distributor
) external returns (uint256 _amt);

_handleTokenRewardsForVault

Handles non-InfraredBGT token rewards to the vault.

function _handleTokenRewardsForVault(
    RewardsStorage storage $,
    IInfraredVault _vault,
    address _token,
    address voter,
    uint256 _amount,
    uint256 _feeTotal,
    uint256 _feeProtocol,
    uint256 rewardsDuration
) internal;

Parameters

NameTypeDescription
$RewardsStorage
_vaultIInfraredVaultIInfraredVault The address of the vault.
_tokenaddressaddress The reward token.
voteraddress
_amountuint256uint256 The amount of reward token to send to vault.
_feeTotaluint256uint256 The rate to charge for total fees on _amount.
_feeProtocoluint256uint256 The rate to charge for protocol treasury on total fees.
rewardsDurationuint256

_handleTokenBribesForReceiver

Handles non-InfraredBGT token bribe rewards to a non-vault receiver address.

Does not take protocol fee on bribe coin, as taken on bribe collector payout token in eventual callback.

function _handleTokenBribesForReceiver(
    RewardsStorage storage,
    address _recipient,
    address _token,
    uint256 _amount
) internal;

Parameters

NameTypeDescription
<none>RewardsStorage
_recipientaddressaddress The address of the recipient.
_tokenaddressaddress The address of the token to forward to recipient.
_amountuint256

_handleRewardsForOperators

Handles BGT base rewards supplied to validator distributor.

function _handleRewardsForOperators(
    RewardsStorage storage $,
    address ibera,
    address voter,
    address distributor,
    uint256 _iBERAShares,
    uint256 _feeTotal,
    uint256 _feeProtocol
) internal returns (uint256 _amt);

Parameters

NameTypeDescription
$RewardsStorage
iberaaddress
voteraddress
distributoraddress
_iBERASharesuint256uint256 The BGT reward amount.
_feeTotaluint256uint256 The rate to charge for total fees on _iBERAShares.
_feeProtocoluint256uint256 The rate to charge for protocol treasury on total fees.

delegateBGT

function delegateBGT(RewardsStorage storage, address _delegatee, address bgt)
    external;

updateInfraredBERABribesWeight

function updateInfraredBERABribesWeight(
    RewardsStorage storage $,
    uint256 _weight
) external;

updateFee

function updateFee(
    RewardsStorage storage $,
    ConfigTypes.FeeType _t,
    uint256 _fee
) external;

claimProtocolFees

function claimProtocolFees(
    RewardsStorage storage $,
    address _to,
    address _token,
    uint256 _amount
) external;

getBGTBalance

function getBGTBalance(RewardsStorage storage, address bgt)
    external
    view
    returns (uint256);

_getBGTBalance

function _getBGTBalance(address bgt) internal view returns (uint256);

updateRedMintRate

function updateRedMintRate(RewardsStorage storage $, uint256 _iredMintRate)
    external;

Events

RedNotMinted

Emitted when Red cannot be minted during a harvest because of pause

event RedNotMinted(uint256 amount);

Structs

RewardsStorage

struct RewardsStorage {
    mapping(address => uint256) protocolFeeAmounts;
    uint256 redMintRate;
    uint256 collectBribesWeight;
    mapping(uint256 => uint256) fees;
}

ValidatorManagerLib

Git Source

Functions

isValidator

function isValidator(ValidatorStorage storage $, bytes memory pubkey)
    external
    view
    returns (bool);

_getValidatorId

Gets the validator ID for associated CL pubkey

function _getValidatorId(bytes memory pubkey) internal pure returns (bytes32);

Parameters

NameTypeDescription
pubkeybytesThe CL pubkey of validator

addValidators

function addValidators(
    ValidatorStorage storage $,
    address distributor,
    ValidatorTypes.Validator[] memory _validators
) external;

removeValidators

function removeValidators(
    ValidatorStorage storage $,
    address distributor,
    bytes[] memory _pubkeys
) external;

replaceValidator

function replaceValidator(
    ValidatorStorage storage $,
    address distributor,
    bytes calldata _current,
    bytes calldata _new
) external;

queueBoosts

function queueBoosts(
    ValidatorStorage storage $,
    address bgt,
    address ibgt,
    bytes[] memory _pubkeys,
    uint128[] memory _amts
) external;

cancelBoosts

function cancelBoosts(
    ValidatorStorage storage $,
    address bgt,
    bytes[] memory _pubkeys,
    uint128[] memory _amts
) external;

activateBoosts

function activateBoosts(
    ValidatorStorage storage $,
    address bgt,
    bytes[] memory _pubkeys
) external;

queueDropBoosts

function queueDropBoosts(
    ValidatorStorage storage $,
    address bgt,
    bytes[] memory _pubkeys,
    uint128[] memory _amts
) external;

cancelDropBoosts

function cancelDropBoosts(
    ValidatorStorage storage $,
    address bgt,
    bytes[] memory _pubkeys,
    uint128[] memory _amts
) external;

dropBoosts

function dropBoosts(
    ValidatorStorage storage $,
    address bgt,
    bytes[] memory _pubkeys
) external;

infraredValidators

function infraredValidators(ValidatorStorage storage $, address distributor)
    external
    view
    returns (ValidatorTypes.Validator[] memory validators);

numInfraredValidators

function numInfraredValidators(ValidatorStorage storage $)
    external
    view
    returns (uint256);

_getValidatorAddress

function _getValidatorAddress(
    ValidatorStorage storage,
    address distributor,
    bytes memory pubkey
) internal view returns (address);

Structs

ValidatorStorage

struct ValidatorStorage {
    EnumerableSet.Bytes32Set validatorIds;
    mapping(bytes32 => bytes) validatorPubkeys;
}

ValidatorTypes

Git Source

Structs

Validator

Validator information for validator set

struct Validator {
    bytes pubkey;
    address addr;
}

VaultManagerLib

Git Source

Functions

notPaused

Ensures that new vaults can only be registered while the register vaults are not paused

modifier notPaused(VaultStorage storage $);

registerVault

Registers a new vault for a specific asset.

function registerVault(VaultStorage storage $, address asset)
    external
    notPaused($)
    returns (address);

setVaultRegistrationPauseStatus

Sets new vault registration paused or not

function setVaultRegistrationPauseStatus(VaultStorage storage $, bool pause)
    external;

Parameters

NameTypeDescription
$VaultStorage
pauseboolTrue to pause, False to un pause

toggleVault

Toggles the pause status of a specific vault.

function toggleVault(VaultStorage storage $, address asset) external;

updateWhitelistedRewardTokens

Updates the whitelist status of a reward token.

function updateWhitelistedRewardTokens(
    VaultStorage storage $,
    address token,
    bool whitelisted
) external;

addReward

function addReward(
    VaultStorage storage $,
    address _stakingToken,
    address _rewardsToken,
    uint256 _rewardsDuration
) external;

addIncentives

function addIncentives(
    VaultStorage storage $,
    address _stakingToken,
    address _rewardsToken,
    uint256 _amount
) external;

updateRewardsDuration

Updates the global rewards duration for new vaults.

function updateRewardsDuration(VaultStorage storage $, uint256 newDuration)
    external;

isWhitelisted

Checks if a token is whitelisted as a reward token.

function isWhitelisted(VaultStorage storage $, address token)
    public
    view
    returns (bool);

recoverERC20FromVault

function recoverERC20FromVault(
    VaultStorage storage $,
    address _asset,
    address _to,
    address _token,
    uint256 _amount
) external;

updateRewardsDurationForVault

function updateRewardsDurationForVault(
    VaultStorage storage $,
    address _stakingToken,
    address _rewardsToken,
    uint256 _rewardsDuration
) external;

claimLostRewardsOnVault

function claimLostRewardsOnVault(VaultStorage storage $, address _asset)
    external;

Structs

VaultStorage

struct VaultStorage {
    bool pausedVaultRegistration;
    mapping(address => IInfraredVault) vaultRegistry;
    EnumerableSet.AddressSet whitelistedRewardTokens;
    uint256 rewardsDuration;
}

BribeCollector

Git Source

Inherits: InfraredUpgradeable, IBribeCollector

The Bribe Collector contract is responsible for collecting bribes from Berachain rewards vaults and auctioning them for a Payout token which then is distributed among Infrared validators.

This contract is forked from Berachain POL which is forked from Uniswap V3 Factory Owner contract. https://github.com/uniswapfoundation/UniStaker/blob/main/src/V3FactoryOwner.sol

State Variables

payoutToken

Token used for fee payments when claiming bribes

address public payoutToken;

payoutAmount

The amount of payout token that is required to claim POL bribes for all tokens

This works as first come first serve basis. whoever pays this much amount of the payout amount first will get the fees

uint256 public payoutAmount;

Functions

constructor

constructor(address _infrared) InfraredUpgradeable(_infrared);

initialize

function initialize(address _gov, address _payoutToken, uint256 _payoutAmount)
    external
    initializer;

setPayoutAmount

Update the payout amount to a new value. Must be called by governor

function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;

Parameters

NameTypeDescription
_newPayoutAmountuint256The value that will be the new payout amount

claimFees

Claims accumulated bribes in exchange for payout token

Caller must approve payoutAmount of payout token to this contract.

function claimFees(
    address _recipient,
    address[] calldata _feeTokens,
    uint256[] calldata _feeAmounts
) external;

Parameters

NameTypeDescription
_recipientaddressThe Address to receive claimed tokens
_feeTokensaddress[]Array of token addresses to claim
_feeAmountsuint256[]Array of amounts to claim for each fee token

Infrared

Git Source

Inherits: InfraredUpgradeable, IInfrared

Provides core functionalities for managing validators, vaults, and reward distribution in the Infrared protocol.

Serves as the main entry point for interacting with the Infrared protocol

The contract is upgradeable, ensuring flexibility for governance-led upgrades and chain compatibility.

State Variables

_bgt

The BGT token contract reference

Immutable IBerachainBGT instance of the BGT token

IBerachainBGT internal _bgt;

ibgt

The InfraredBGT liquid staked token

InfraredBGT public ibgt;

rewardsFactory

The Berachain rewards vault factory address

IBerachainRewardsVaultFactory public rewardsFactory;

chef

The Berachain chef contract for distributing validator rewards

IBeraChef public chef;

wbera

Wrapped bera

IWBERA public wbera;

honey

Honey ERC20 token

ERC20 public honey;

collector

bribe collector contract

IBribeCollector public collector;

distributor

Infrared distributor for BGT rewards to validators

IInfraredDistributor public distributor;

voter

IRED voter

IVoter public voter;

ibera

collects all iBERA realted fees and revenue

IInfraredBERA public ibera;

red

The RED token

IRED public red;

ibgtVault

The InfraredBGT vault

IInfraredVault public ibgtVault;

VALIDATOR_STORAGE_LOCATION

Upgradeable ERC-7201 storage for Validator lib

keccak256(abi.encode(uint256(keccak256(bytes("infrared.validatorStorage"))) - 1)) & ~bytes32(uint256(0xff));

bytes32 public constant VALIDATOR_STORAGE_LOCATION =
    0x8ea5a3cc3b9a6be40b16189aeb1b6e6e61492e06efbfbe10619870b5bc1cc500;

VAULT_STORAGE_LOCATION

Upgradeable ERC-7201 storage for Vault lib

keccak256(abi.encode(uint256(keccak256(bytes("infrared.vaultStorage"))) - 1)) & ~bytes32(uint256(0xff));

bytes32 public constant VAULT_STORAGE_LOCATION =
    0x1bb2f1339407e6d63b93b8b490a9d43c5651f6fc4327c66addd5939450742a00;

REWARDS_STORAGE_LOCATION

Upgradeable ERC-7201 storage for Rewards lib

keccak256(abi.encode(uint256(keccak256(bytes("infrared.rewardsStorage"))) - 1)) & ~bytes32(uint256(0xff));

bytes32 public constant REWARDS_STORAGE_LOCATION =
    0xad12e6d08cc0150709acd6eed0bf697c60a83227922ab1d254d1ca4d3072ca00;

Functions

_validatorStorage

function _validatorStorage()
    internal
    pure
    returns (ValidatorManagerLib.ValidatorStorage storage vs);

_vaultStorage

function _vaultStorage()
    internal
    pure
    returns (VaultManagerLib.VaultStorage storage vs);

_rewardsStorage

function _rewardsStorage()
    internal
    pure
    returns (RewardsLib.RewardsStorage storage rs);

onlyCollector

Ensures that only the collector contract can call the function Reverts if the caller is not the collector

modifier onlyCollector();

constructor

constructor() InfraredUpgradeable(address(0));

initialize

function initialize(InitializationData calldata data) external initializer;

_validateInitializationData

function _validateInitializationData(InitializationData memory data)
    internal
    pure;

_initializeCoreContracts

function _initializeCoreContracts(InitializationData memory data) internal;

registerVault

Registers a new vault for a given asset

Infrared.sol must be admin over MINTER_ROLE on InfraredBGT to grant minter role to deployed vault

Note: emits: NewVault with the caller, asset address, and new vault address.

function registerVault(address _asset)
    external
    returns (IInfraredVault vault);

Parameters

NameTypeDescription
_assetaddressThe address of the asset, such as a specific LP token

Returns

NameTypeDescription
vaultIInfraredVaultThe address of the newly created InfraredVault contract

addReward

Adds a new reward token to a specific staking vault

Only callable by governance when contract is initialized

Note: error: ZeroAmount if _rewardsDuration is 0

function addReward(
    address _stakingToken,
    address _rewardsToken,
    uint256 _rewardsDuration
) external onlyGovernor;

Parameters

NameTypeDescription
_stakingTokenaddressThe address of the staking token associated with the vault
_rewardsTokenaddressThe address of the token to be added as a reward
_rewardsDurationuint256The duration period for the rewards distribution, in seconds

addIncentives

Adds reward incentives to a specific staking vault

Transfers reward tokens from caller to this contract, then notifies vault of new rewards

Notes:

  • error: ZeroAmount if _amount is 0

  • access: Callable when contract is initialized

  • security: Requires caller to have approved this contract to spend _rewardsToken

function addIncentives(
    address _stakingToken,
    address _rewardsToken,
    uint256 _amount
) external;

Parameters

NameTypeDescription
_stakingTokenaddressThe address of the staking token associated with the vault
_rewardsTokenaddressThe address of the token being added as incentives
_amountuint256The amount of reward tokens to add as incentives

updateWhiteListedRewardTokens

Updates the whitelist status of a reward token

function updateWhiteListedRewardTokens(address _token, bool _whitelisted)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_tokenaddressThe address of the token to whitelist or remove from whitelist
_whitelistedboolA boolean indicating if the token should be whitelisted

updateRewardsDuration

Sets the new duration for reward distributions in InfraredVaults

Only callable by governance

function updateRewardsDuration(uint256 _rewardsDuration)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_rewardsDurationuint256The new reward duration period, in seconds

updateRewardsDurationForVault

Updates the rewards duration for a specific reward token on a specific vault

Only callable by governance

function updateRewardsDurationForVault(
    address _stakingToken,
    address _rewardsToken,
    uint256 _rewardsDuration
) external onlyGovernor;

Parameters

NameTypeDescription
_stakingTokenaddressThe address of the staking asset associated with the vault
_rewardsTokenaddressThe address of the reward token to update the duration for
_rewardsDurationuint256The new reward duration period, in seconds

toggleVault

Pauses staking functionality on a specific vault

Only callable by governance, will revert if vault doesn't exist

function toggleVault(address _asset) external onlyGovernor;

Parameters

NameTypeDescription
_assetaddressThe address of the staking asset associated with the vault to pause

claimLostRewardsOnVault

Claims lost rewards on a specific vault

Only callable by governance, will revert if vault doesn't exist

function claimLostRewardsOnVault(address _asset) external onlyGovernor;

Parameters

NameTypeDescription
_assetaddressThe address of the staking asset associated with the vault to claim lost rewards on

recoverERC20

Recovers ERC20 tokens sent accidentally to the contract

function recoverERC20(address _to, address _token, uint256 _amount)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_toaddressThe address to receive the recovered tokens
_tokenaddressThe address of the token to recover
_amountuint256The amount of the token to recover

recoverERC20FromVault

Recover ERC20 tokens from a vault.

function recoverERC20FromVault(
    address _asset,
    address _to,
    address _token,
    uint256 _amount
) external onlyGovernor;

Parameters

NameTypeDescription
_assetaddressaddress The address of the staking asset that the vault is for.
_toaddressaddress The address to send the tokens to.
_tokenaddressaddress The address of the token to recover.
_amountuint256uint256 The amount of the token to recover.

delegateBGT

Delegates BGT votes to _delegatee address.

function delegateBGT(address _delegatee) external onlyGovernor;

Parameters

NameTypeDescription
_delegateeaddressaddress The address to delegate votes to

updateInfraredBERABribesWeight

Updates the weight for iBERA bribes

function updateInfraredBERABribesWeight(uint256 _weight)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_weightuint256uint256 The weight value

updateFee

Updates the fee rate charged on different harvest functions

Fee rate in units of 1e6 or hundredths of 1 bip

function updateFee(ConfigTypes.FeeType _t, uint256 _fee)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_tConfigTypes.FeeTypeFeeType The fee type
_feeuint256uint256 The fee rate to update to

claimProtocolFees

Claims accumulated protocol fees in contract

function claimProtocolFees(address _to, address _token, uint256 _amount)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_toaddressaddress The recipient of the fees
_tokenaddressaddress The token to claim fees in
_amountuint256uint256 The amount of accumulated fees to claim

setIBGT

Sets the address of the iBGT contract

Infrared must be granted MINTER_ROLE on IBGT to set the address

function setIBGT(address _ibgt) external;

Parameters

NameTypeDescription
_ibgtaddressThe address of the iBGT contract

setRed

Sets the address of the RED contract

Infrared must be granted MINTER_ROLE on RED to set the address

function setRed(address _red) external;

Parameters

NameTypeDescription
_redaddressThe address of the RED contract

updateRedMintRate

Updates the mint rate for RED

function updateRedMintRate(uint256 _redMintRate) external onlyGovernor;

Parameters

NameTypeDescription
_redMintRateuint256The new mint rate for RED

chargedFeesOnRewards

function chargedFeesOnRewards(
    uint256 _amt,
    uint256 _feeTotal,
    uint256 _feeProtocol
)
    public
    view
    returns (uint256 amtRecipient, uint256 amtVoter, uint256 amtProtocol);

harvestBase

Claims all the BGT base and commission rewards minted to this contract for validators.

function harvestBase() public;

harvestVault

Claims all the BGT rewards for the vault associated with the given staking token.

function harvestVault(address _asset) external;

Parameters

NameTypeDescription
_assetaddressaddress The address of the staking asset that the vault is for.

harvestBribes

Claims all the bribes rewards in the contract forwarded from Berachain POL.

function harvestBribes(address[] calldata _tokens) external;

Parameters

NameTypeDescription
_tokensaddress[]address[] memory The addresses of the tokens to harvest in the contract.

collectBribes

Collects bribes from bribe collector and distributes to wiBERA and iBGT Infrared vaults.

function collectBribes(address _token, uint256 _amount)
    external
    onlyCollector;

harvestOperatorRewards

Credits all accumulated rewards to the operator

function harvestOperatorRewards() public;

harvestBoostRewards

Claims all the BGT staker rewards from boosting validators.

Sends rewards to iBGT vault.

function harvestBoostRewards() external;

addValidators

Adds validators to the set of InfraredValidators.

function addValidators(ValidatorTypes.Validator[] calldata _validators)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_validatorsValidatorTypes.Validator[]Validator[] memory The validators to add.

removeValidators

Removes validators from the set of InfraredValidators.

function removeValidators(bytes[] calldata _pubkeys) external onlyGovernor;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] memory The pubkeys of the validators to remove.

replaceValidator

Replaces a validator in the set of InfraredValidators.

function replaceValidator(bytes calldata _current, bytes calldata _new)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_currentbytesbytes The pubkey of the validator to replace.
_newbytesbytes The new validator pubkey.

queueNewCuttingBoard

Queues a new cutting board on BeraChef for reward weight distribution for validator

function queueNewCuttingBoard(
    bytes calldata _pubkey,
    uint64 _startBlock,
    IBeraChef.Weight[] calldata _weights
) external onlyKeeper;

Parameters

NameTypeDescription
_pubkeybytesbytes The pubkey of the validator to queue the cutting board for
_startBlockuint64uint64 The start block for reward weightings
_weightsIBeraChef.Weight[]IBeraChef.Weight[] calldata The weightings used when distributor calls chef to distribute validator rewards

queueBoosts

Queue _amts of tokens to _validators for boosts.

function queueBoosts(bytes[] calldata _pubkeys, uint128[] calldata _amts)
    external
    onlyKeeper;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] memory The pubkeys of the validators to queue boosts for.
_amtsuint128[]uint128[] memory The amount of BGT to boost with.

cancelBoosts

Removes _amts from previously queued boosts to _validators.

_pubkeys need not be in the current validator set in case just removed but need to cancel.

function cancelBoosts(bytes[] calldata _pubkeys, uint128[] calldata _amts)
    external
    onlyKeeper;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] memory The pubkeys of the validators to remove boosts for.
_amtsuint128[]uint128[] memory The amounts of BGT to remove from the queued boosts.

activateBoosts

Activates queued boosts for _pubkeys.

function activateBoosts(bytes[] calldata _pubkeys) external;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] memory The pubkeys of the validators to activate boosts for.

queueDropBoosts

Queues a drop boost of the validators removing an amount of BGT for sender.

Reverts if user does not have enough boosted balance to cover amount.

function queueDropBoosts(bytes[] calldata _pubkeys, uint128[] calldata _amts)
    external
    onlyKeeper;

Parameters

NameTypeDescription
_pubkeysbytes[]
_amtsuint128[]

cancelDropBoosts

Cancels a queued drop boost of the validator removing an amount of BGT for sender.

function cancelDropBoosts(bytes[] calldata _pubkeys, uint128[] calldata _amts)
    external
    onlyKeeper;

Parameters

NameTypeDescription
_pubkeysbytes[]
_amtsuint128[]

dropBoosts

Drops an amount of BGT from an existing boost of validators by user.

function dropBoosts(bytes[] calldata _pubkeys) external;

Parameters

NameTypeDescription
_pubkeysbytes[]

infraredValidators

Gets the set of infrared validator pubkeys.

function infraredValidators()
    public
    view
    virtual
    returns (ValidatorTypes.Validator[] memory validators);

Returns

NameTypeDescription
validatorsValidatorTypes.Validator[]Validator[] memory The set of infrared validators.

numInfraredValidators

Gets the number of infrared validators in validator set.

function numInfraredValidators() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256num uint256 The number of infrared validators in validator set.

isInfraredValidator

Checks if a validator is an infrared validator.

function isInfraredValidator(bytes calldata _validator)
    public
    view
    returns (bool);

Parameters

NameTypeDescription
_validatorbytes

Returns

NameTypeDescription
<none>bool_isValidator bool Whether the validator is an infrared validator.

getBGTBalance

Gets the BGT balance for this contract

function getBGTBalance() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256bgtBalance The BGT balance held by this address

whitelistedRewardTokens

Mapping of tokens that are whitelisted to be used as rewards or accepted as bribes

serves as central source of truth for whitelisted reward tokens for all Infrared contracts

function whitelistedRewardTokens(address token) public view returns (bool);

vaultRegistry

Mapping of staking token addresses to their corresponding InfraredVault

Each staking token can only have one vault

function vaultRegistry(address _stakingToken)
    public
    view
    returns (IInfraredVault vault);

setVaultRegistrationPauseStatus

Sets new vault registration paused or not

function setVaultRegistrationPauseStatus(bool pause) external onlyGovernor;

Parameters

NameTypeDescription
pauseboolTrue to pause, False to un pause

rewardsDuration

The rewards duration

Used as gloabl variabel to set the rewards duration for all new reward tokens on InfraredVaults

function rewardsDuration() public view returns (uint256 duration);

Returns

NameTypeDescription
durationuint256uint256 The reward duration period, in seconds

fees

Protocol fee rates to charge for various harvest function distributions

function fees(uint256 t) public view override returns (uint256);

Parameters

NameTypeDescription
tuint256

Returns

NameTypeDescription
<none>uint256uint256 The fee rate

protocolFeeAmounts

The unclaimed Infrared protocol fees of token accumulated by contract

function protocolFeeAmounts(address _token) external view returns (uint256);

Parameters

NameTypeDescription
_tokenaddress

Returns

NameTypeDescription
<none>uint256uint256 The amount of accumulated fees

receive

receive() external payable;

Structs

InitializationData

struct InitializationData {
    address _gov;
    address _keeper;
    address __bgt;
    address _rewardsFactory;
    address _chef;
    address payable _wbera;
    address _honey;
    address _collector;
    address _distributor;
    address _voter;
    address _iBERA;
    uint256 _rewardsDuration;
}

InfraredBGT

Git Source

Inherits: ERC20PresetMinterPauser

This contract is the InfraredBGT token.

State Variables

bgt

address public immutable bgt;

Functions

constructor

constructor(address _bgt, address _admin, address _minter, address _pauser)
    ERC20PresetMinterPauser("Infrared BGT", "iBGT", _admin, _minter, _pauser);

Errors

ZeroAddress

error ZeroAddress();

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

InfraredUpgradeable

Git Source

Inherits: Upgradeable

This contract provides base upgradeability functionality for Infrared.

State Variables

infrared

Infrared coordinator contract

IInfrared public immutable infrared;

Functions

onlyInfrared

modifier onlyInfrared();

constructor

constructor(address _infrared);

__InfraredUpgradeable_init

function __InfraredUpgradeable_init() internal onlyInitializing;

InfraredVault

Git Source

Inherits: MultiRewards, IInfraredVault

This contract is the vault for staking tokens, and receiving rewards from the Proof of Liquidity protocol.

This contract uses the MultiRewards contract to distribute rewards to vault stakers, this is taken from curve.fi. (inspired by Synthetix).

Does not support staking tokens with non-standard ERC20 transfer tax behavior.

State Variables

MAX_NUM_REWARD_TOKENS

Maximum number of reward tokens that can be supported

Limited to prevent gas issues with reward calculations

uint256 public constant MAX_NUM_REWARD_TOKENS = 10;

infrared

The infrared contract address acts a vault factory and coordinator

address public immutable infrared;

rewardsVault

IBerachainRewardsVault public immutable rewardsVault;

Functions

onlyInfrared

Modifier to check that the caller is infrared contract

modifier onlyInfrared();

constructor

constructor(address _stakingToken, uint256 _rewardsDuration)
    MultiRewards(_stakingToken);

_createRewardsVaultIfNecessary

Gets or creates the berachain rewards vault for given staking token

function _createRewardsVaultIfNecessary(
    address _infrared,
    address _stakingToken
) private returns (IBerachainRewardsVault);

Parameters

NameTypeDescription
_infraredaddressThe address of Infrared
_stakingTokenaddressThe address of the staking token for this vault

Returns

NameTypeDescription
<none>IBerachainRewardsVaultThe address of the berachain rewards vault

onStake

Transfers to berachain low level module on staking of LP tokens with the vault after transferring tokens in

function onStake(uint256 amount) internal override;

Parameters

NameTypeDescription
amountuint256The amount of staking token transferred in to the contract

onWithdraw

Redeems from berachain low level module on withdraw of LP tokens from the vault before transferring tokens out

function onWithdraw(uint256 amount) internal override;

Parameters

NameTypeDescription
amountuint256The amount of staking token transferred out of the contract

onReward

hook called after the reward is claimed to harvest the rewards from the berachain rewards vault

function onReward() internal override;

updateRewardsDuration

Updates reward duration for a specific reward token

Only callable by Infrared contract

Note: access-control: Requires INFRARED_ROLE

function updateRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
    external
    onlyInfrared;

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the reward token
_rewardsDurationuint256The new duration in seconds

togglePause

Toggles pause state of the vault

Affects all vault operations when paused

Note: access-control: Requires INFRARED_ROLE

function togglePause() external onlyInfrared;

addReward

Adds a new reward token to the vault

Cannot exceed maximum number of reward tokens

Note: access-control: Requires INFRARED_ROLE

function addReward(address _rewardsToken, uint256 _rewardsDuration)
    external
    onlyInfrared;

Parameters

NameTypeDescription
_rewardsTokenaddressThe reward token to add
_rewardsDurationuint256The reward period duration

notifyRewardAmount

Notifies the vault of newly added rewards

Updates internal reward rate calculations

function notifyRewardAmount(address _rewardToken, uint256 _reward)
    external
    onlyInfrared;

Parameters

NameTypeDescription
_rewardTokenaddressThe reward token address
_rewarduint256The amount of new rewards

recoverERC20

Recovers accidentally sent tokens

Cannot recover staking token or active reward tokens

function recoverERC20(address _to, address _token, uint256 _amount)
    external
    onlyInfrared;

Parameters

NameTypeDescription
_toaddressThe address to receive the recovered tokens
_tokenaddressThe token to recover
_amountuint256The amount to recover

getAllRewardTokens

Returns all reward tokens

function getAllRewardTokens() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]An array of reward token addresses

getAllRewardsForUser

Returns all rewards for a user

function getAllRewardsForUser(address _user)
    external
    view
    returns (UserReward[] memory);

Parameters

NameTypeDescription
_useraddressThe address of the user

Returns

NameTypeDescription
<none>UserReward[]An array of UserReward structs

MultiRewards

Git Source

Inherits: ReentrancyGuard, Pausable, IMultiRewards

Fork of https://github.com/curvefi/multi-rewards with hooks on stake/withdraw of LP tokens

State Variables

stakingToken

The token that users stake to earn rewards

This is the base token that users deposit into the contract

ERC20 public immutable stakingToken;

rewardData

Stores reward-related data for each reward token

Maps reward token addresses to their Reward struct containing distribution parameters

mapping(address => Reward) public override rewardData;

rewardTokens

Array of all reward token addresses

Used to iterate through all reward tokens when updating or claiming rewards

address[] public rewardTokens;

userRewardPerTokenPaid

Tracks the reward per token paid to each user for each reward token

Maps user address to reward token address to amount already paid Used to calculate new rewards since last claim

mapping(address => mapping(address => uint256)) public userRewardPerTokenPaid;

rewards

Tracks the unclaimed rewards for each user for each reward token

Maps user address to reward token address to unclaimed amount

mapping(address => mapping(address => uint256)) public rewards;

_totalSupply

The total amount of staking tokens in the contract

Used to calculate rewards per token

uint256 internal _totalSupply;

_balances

Maps user addresses to their staked token balance

Internal mapping used to track individual stake amounts

mapping(address => uint256) internal _balances;

Functions

updateReward

Updates the reward for the given account before executing the function body.

modifier updateReward(address account);

Parameters

NameTypeDescription
accountaddressaddress The account to update the reward for.

constructor

Constructs the MultiRewards contract.

constructor(address _stakingToken);

Parameters

NameTypeDescription
_stakingTokenaddressaddress The token that users stake to earn rewards.

totalSupply

Returns the total amount of staked tokens in the contract

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The total supply of staked tokens

balanceOf

Returns the balance of staked tokens for the given account

function balanceOf(address account) external view returns (uint256 _balance);

Parameters

NameTypeDescription
accountaddressThe account to get the balance for

Returns

NameTypeDescription
_balanceuint256The balance of staked tokens

lastTimeRewardApplicable

Calculates the last time reward is applicable for a given rewards token

function lastTimeRewardApplicable(address _rewardsToken)
    public
    view
    returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The timestamp when the reward was last applicable

rewardPerToken

Calculates the reward per token for a given rewards token

function rewardPerToken(address _rewardsToken) public view returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The reward amount per token

earned

Calculates the earned rewards for a given account and rewards token

function earned(address account, address _rewardsToken)
    public
    view
    returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the account
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The amount of rewards earned

getRewardForDuration

Calculates the total reward for the duration of a given rewards token

function getRewardForDuration(address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The total reward amount for the duration of a given rewards token

stake

Stakes tokens into the contract

Transfers amount of staking tokens from the user to this contract

function stake(uint256 amount)
    external
    nonReentrant
    whenNotPaused
    updateReward(msg.sender);

Parameters

NameTypeDescription
amountuint256The amount of tokens to stake

onStake

Hook called in the stake function after transfering staking token in

function onStake(uint256 amount) internal virtual;

Parameters

NameTypeDescription
amountuint256The amount of staking token transferred in to the contract

withdraw

Withdraws staked tokens from the contract

Transfers amount of staking tokens back to the user

function withdraw(uint256 amount)
    public
    nonReentrant
    updateReward(msg.sender);

Parameters

NameTypeDescription
amountuint256The amount of tokens to withdraw

onWithdraw

Hook called in withdraw function before transferring staking token out

function onWithdraw(uint256 amount) internal virtual;

Parameters

NameTypeDescription
amountuint256The amount of staking token to be transferred out of the contract

getRewardForUser

Claims all pending rewards for a specified user

Iterates through all reward tokens and transfers any accrued rewards to the user

function getRewardForUser(address _user)
    public
    nonReentrant
    updateReward(_user);

Parameters

NameTypeDescription
_useraddressThe address of the user to claim rewards for

onReward

Hook called in getRewardForUser function

function onReward() internal virtual;

getReward

Claims all pending rewards for the caller

Transfers all accrued rewards to the caller

function getReward() public;

exit

Withdraws all staked tokens and claims pending rewards

Combines withdraw and getReward operations

function exit() external;

_addReward

Adds a reward token to the contract.

function _addReward(
    address _rewardsToken,
    address _rewardsDistributor,
    uint256 _rewardsDuration
) internal;

Parameters

NameTypeDescription
_rewardsTokenaddressaddress The address of the reward token.
_rewardsDistributoraddressaddress The address of the rewards distributor.
_rewardsDurationuint256uint256 The duration of the rewards period.

_notifyRewardAmount

Notifies the contract that reward tokens is being sent to the contract.

function _notifyRewardAmount(address _rewardsToken, uint256 reward)
    internal
    whenNotPaused
    updateReward(address(0));

Parameters

NameTypeDescription
_rewardsTokenaddressaddress The address of the reward token.
rewarduint256uint256 The amount of reward tokens is being sent to the contract.

_recoverERC20

Recovers ERC20 tokens sent to the contract.

Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders

function _recoverERC20(address to, address tokenAddress, uint256 tokenAmount)
    internal;

Parameters

NameTypeDescription
toaddressaddress The address to send the tokens to.
tokenAddressaddressaddress The address of the token to withdraw.
tokenAmountuint256uint256 The amount of tokens to withdraw.

_setRewardsDuration

Updates the reward duration for a reward token.

function _setRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
    internal;

Parameters

NameTypeDescription
_rewardsTokenaddressaddress The address of the reward token.
_rewardsDurationuint256uint256 The new duration of the rewards period.

RED

Git Source

Inherits: ERC20PresetMinterPauser

This contract is the RED token.

State Variables

ibgt

address public immutable ibgt;

infrared

address public immutable infrared;

Functions

constructor

constructor(
    address _ibgt,
    address _infrared,
    address _admin,
    address _minter,
    address _pauser
)
    ERC20PresetMinterPauser(
        "Infared Governance Token",
        "RED",
        _admin,
        _minter,
        _pauser
    );

Errors

ZeroAddress

error ZeroAddress();

WrappedVault

Git Source

Inherits: ERC4626

A wrapper vault built on ERC4626 to facilitate staking operations and reward distribution through the Infrared protocol. Each staking token has a corresponding wrapped vault.

deploy 1 wrapped vault per staking token

State Variables

rewardDistributor

Address of the reward distributor, typically a multisig.

address public immutable rewardDistributor;

iVault

Instance of the associated InfraredVault for staking.

InfraredVault public immutable iVault;

deadShares

Inflation attack prevention

uint256 internal constant deadShares = 1e3;

Functions

constructor

Initializes a new WrappedVault contract for a specific staking token.

constructor(
    address _rewardDistributor,
    address _infrared,
    address _stakingToken,
    string memory _name,
    string memory _symbol
) ERC4626(ERC20(_stakingToken), _name, _symbol);

Parameters

NameTypeDescription
_rewardDistributoraddressAddress of the reward distributor (e.g., multisig).
_infraredaddressAddress of the Infrared protocol.
_stakingTokenaddressAddress of the ERC20 staking token.
_namestringName of the wrapped vault token (ERC4626).
_symbolstringSymbol of the wrapped vault token (ERC4626).

totalAssets

Returns the total assets managed by the wrapped vault.

Overrides the ERC4626 totalAssets function to integrate with the InfraredVault balance.

function totalAssets() public view virtual override returns (uint256);

Returns

NameTypeDescription
<none>uint256The total amount of staking tokens held by the InfraredVault.

beforeWithdraw

Hook called before withdrawal operations.

This function ensures that the requested amount of staking tokens is withdrawn from the InfraredVault before being transferred to the user.

function beforeWithdraw(uint256 assets, uint256) internal virtual override;

Parameters

NameTypeDescription
assetsuint256The amount of assets to withdraw.
<none>uint256

afterDeposit

Hook called after deposit operations.

This function stakes the deposited tokens into the InfraredVault.

function afterDeposit(uint256 assets, uint256) internal virtual override;

Parameters

NameTypeDescription
assetsuint256The amount of assets being deposited.
<none>uint256

claimRewards

Claims rewards from the InfraredVault and transfers them to the reward distributor.

Only rewards other than the staking token itself are transferred.

function claimRewards() external;

Events

RewardClaimed

Event emitted when reward tokens claimed

event RewardClaimed(address indexed token, uint256 amount);

Contents

IBerachainBGT

Git Source

Inherits: IBGT

IBerachainBGTStaker

Git Source

Inherits: IBGTStaker

Functions

rewardToken

Temp override of interface to include left out reward token

function rewardToken() external view returns (address);

IBribeCollector

Git Source

Inherits: IPOLErrors

Functions

payoutToken

Token used for fee payments when claiming bribes

function payoutToken() external view returns (address);

Returns

NameTypeDescription
<none>addressAddress of the payout token

payoutAmount

The amount of payout token that is required to claim POL bribes for all tokens

This works as first come first serve basis. whoever pays this much amount of the payout amount first will get the fees

function payoutAmount() external view returns (uint256);

setPayoutAmount

Update the payout amount to a new value. Must be called by governor

function setPayoutAmount(uint256 _newPayoutAmount) external;

Parameters

NameTypeDescription
_newPayoutAmountuint256The value that will be the new payout amount

claimFees

Claims accumulated bribes in exchange for payout token

Caller must approve payoutAmount of payout token to this contract.

function claimFees(
    address _recipient,
    address[] calldata _feeTokens,
    uint256[] calldata _feeAmounts
) external;

Parameters

NameTypeDescription
_recipientaddressThe Address to receive claimed tokens
_feeTokensaddress[]Array of token addresses to claim
_feeAmountsuint256[]Array of amounts to claim for each fee token

Events

PayoutAmountSet

Emitted when the payout amount is updated by the governor

event PayoutAmountSet(
    uint256 indexed oldPayoutAmount, uint256 indexed newPayoutAmount
);

Parameters

NameTypeDescription
oldPayoutAmountuint256Previous payout amount
newPayoutAmountuint256New payout amount set

FeesClaimed

Emitted when the fees are claimed

event FeesClaimed(
    address indexed caller,
    address indexed recipient,
    address indexed feeToken,
    uint256 amount
);

Parameters

NameTypeDescription
calleraddressCaller of the claimFees function
recipientaddressThe address to which collected POL bribes will be transferred
feeTokenaddressThe address of the fee token to collect
amountuint256The amount of fee token to transfer

IERC20Mintable

Git Source

Inherits: IERC20

Functions

MINTER_ROLE

function MINTER_ROLE() external view returns (bytes32);

mint

function mint(address to, uint256 amount) external;

IInfrared

Git Source

Functions

whitelistedRewardTokens

Checks if a token is a whitelisted reward token

function whitelistedRewardTokens(address _token) external view returns (bool);

Parameters

NameTypeDescription
_tokenaddressThe address of the token to check

Returns

NameTypeDescription
<none>boolbool True if the token is whitelisted, false otherwise

vaultRegistry

Returns the infrared vault address for a given staking token

function vaultRegistry(address _asset) external view returns (IInfraredVault);

Parameters

NameTypeDescription
_assetaddressThe address of the staking asset

Returns

NameTypeDescription
<none>IInfraredVaultIInfraredVault The vault associated with the asset

ibgt

The InfraredBGT liquid staked token

function ibgt() external view returns (InfraredBGT);

Returns

NameTypeDescription
<none>InfraredBGTIInfraredBGT The InfraredBGT token contract address

rewardsFactory

The Berachain rewards vault factory address

function rewardsFactory()
    external
    view
    returns (IBerachainRewardsVaultFactory);

Returns

NameTypeDescription
<none>IBerachainRewardsVaultFactoryIBerachainRewardsVaultFactory instance of the rewards factory contract address

chef

The Berachain chef contract for distributing validator rewards

function chef() external view returns (IBeraChef);

Returns

NameTypeDescription
<none>IBeraChefIBeraChef instance of the BeraChef contract address

ibgtVault

The InfraredBGT vault

function ibgtVault() external view returns (IInfraredVault);

Returns

NameTypeDescription
<none>IInfraredVaultIInfraredVault instance of the iBGT vault contract address

protocolFeeAmounts

The unclaimed Infrared protocol fees of token accumulated by contract

function protocolFeeAmounts(address token) external view returns (uint256);

Parameters

NameTypeDescription
tokenaddressaddress The token address for the accumulated fees

Returns

NameTypeDescription
<none>uint256uint256 The amount of accumulated fees

fees

Protocol fee rates to charge for various harvest function distributions

function fees(uint256 i) external view returns (uint256);

Parameters

NameTypeDescription
iuint256The index of the fee rate

Returns

NameTypeDescription
<none>uint256uint256 The fee rate

wbera

Wrapped bera

function wbera() external view returns (IWBERA);

Returns

NameTypeDescription
<none>IWBERAIWBERA The wbera token contract address

honey

Honey ERC20 token

function honey() external view returns (ERC20);

Returns

NameTypeDescription
<none>ERC20ERC20 The honey token contract address

collector

bribe collector contract

function collector() external view returns (IBribeCollector);

Returns

NameTypeDescription
<none>IBribeCollectorIBribeCollector The bribe collector contract address

distributor

Infrared distributor for BGT rewards to validators

function distributor() external view returns (IInfraredDistributor);

Returns

NameTypeDescription
<none>IInfraredDistributorIInfraredDistributor instance of the distributor contract address

voter

IRED voter

function voter() external view returns (IVoter);

Returns

NameTypeDescription
<none>IVoterIVoter instance of the voter contract address

ibera

collects all iBERA realted fees and revenue

function ibera() external view returns (IInfraredBERA);

Returns

NameTypeDescription
<none>IInfraredBERAreturns IInfraredBERAFeeReceivor instanace of iBeraFeeReceivor

red

The RED token

function red() external view returns (IRED);

Returns

NameTypeDescription
<none>IREDIRED instance of the RED token contract address

rewardsDuration

The rewards duration

Used as gloabl variabel to set the rewards duration for all new reward tokens on InfraredVaults

function rewardsDuration() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The reward duration period, in seconds

registerVault

Registers a new vault for a given asset

Infrared.sol must be admin over MINTER_ROLE on InfraredBGT to grant minter role to deployed vault

Note: emits: NewVault with the caller, asset address, and new vault address.

function registerVault(address _asset)
    external
    returns (IInfraredVault vault);

Parameters

NameTypeDescription
_assetaddressThe address of the asset, such as a specific LP token

Returns

NameTypeDescription
vaultIInfraredVaultThe address of the newly created InfraredVault contract

addReward

Adds a new reward token to a specific staking vault

Only callable by governance when contract is initialized

Notes:

  • error: ZeroAmount if _rewardsDuration is 0

  • error: RewardTokenNotWhitelisted if _rewardsToken is not whitelisted

  • error: NoRewardsVault if vault doesn't exist for _stakingToken

function addReward(
    address _stakingToken,
    address _rewardsToken,
    uint256 _rewardsDuration
) external;

Parameters

NameTypeDescription
_stakingTokenaddressThe address of the staking token associated with the vault
_rewardsTokenaddressThe address of the token to be added as a reward
_rewardsDurationuint256The duration period for the rewards distribution, in seconds

addIncentives

Adds reward incentives to a specific staking vault

Transfers reward tokens from caller to this contract, then notifies vault of new rewards

Notes:

  • error: ZeroAmount if _amount is 0

  • error: NoRewardsVault if vault doesn't exist for _stakingToken

  • error: RewardTokenNotWhitelisted if reward token hasn't been configured for the vault

  • access: Callable when contract is initialized

  • security: Requires caller to have approved this contract to spend _rewardsToken

function addIncentives(
    address _stakingToken,
    address _rewardsToken,
    uint256 _amount
) external;

Parameters

NameTypeDescription
_stakingTokenaddressThe address of the staking token associated with the vault
_rewardsTokenaddressThe address of the token being added as incentives
_amountuint256The amount of reward tokens to add as incentives

updateWhiteListedRewardTokens

Updates the whitelist status of a reward token

function updateWhiteListedRewardTokens(address _token, bool _whitelisted)
    external;

Parameters

NameTypeDescription
_tokenaddressThe address of the token to whitelist or remove from whitelist
_whitelistedboolA boolean indicating if the token should be whitelisted

updateRewardsDuration

Sets the new duration for reward distributions in InfraredVaults

Only callable by governance

function updateRewardsDuration(uint256 _rewardsDuration) external;

Parameters

NameTypeDescription
_rewardsDurationuint256The new reward duration period, in seconds

updateRewardsDurationForVault

Updates the rewards duration for a specific reward token on a specific vault

Only callable by governance

function updateRewardsDurationForVault(
    address _stakingToken,
    address _rewardsToken,
    uint256 _rewardsDuration
) external;

Parameters

NameTypeDescription
_stakingTokenaddressThe address of the staking asset associated with the vault
_rewardsTokenaddressThe address of the reward token to update the duration for
_rewardsDurationuint256The new reward duration period, in seconds

toggleVault

Pauses staking functionality on a specific vault

Only callable by governance, will revert if vault doesn't exist

function toggleVault(address _asset) external;

Parameters

NameTypeDescription
_assetaddressThe address of the staking asset associated with the vault to pause

claimLostRewardsOnVault

Claims lost rewards on a specific vault

Only callable by governance, will revert if vault doesn't exist

function claimLostRewardsOnVault(address _asset) external;

Parameters

NameTypeDescription
_assetaddressThe address of the staking asset associated with the vault to claim lost rewards on

recoverERC20

Recovers ERC20 tokens sent accidentally to the contract

function recoverERC20(address _to, address _token, uint256 _amount) external;

Parameters

NameTypeDescription
_toaddressThe address to receive the recovered tokens
_tokenaddressThe address of the token to recover
_amountuint256The amount of the token to recover

recoverERC20FromVault

Recover ERC20 tokens from a vault.

function recoverERC20FromVault(
    address _asset,
    address _to,
    address _token,
    uint256 _amount
) external;

Parameters

NameTypeDescription
_assetaddressaddress The address of the staking asset that the vault is for.
_toaddressaddress The address to send the tokens to.
_tokenaddressaddress The address of the token to recover.
_amountuint256uint256 The amount of the token to recover.

delegateBGT

Delegates BGT votes to _delegatee address.

function delegateBGT(address _delegatee) external;

Parameters

NameTypeDescription
_delegateeaddressaddress The address to delegate votes to

updateInfraredBERABribesWeight

Updates the weight for iBERA bribes

function updateInfraredBERABribesWeight(uint256 _weight) external;

Parameters

NameTypeDescription
_weightuint256uint256 The weight value

updateFee

Updates the fee rate charged on different harvest functions

Please harvest all assosiated rewards for a given type before updating

Fee rate in units of 1e6 or hundredths of 1 bip

function updateFee(ConfigTypes.FeeType _t, uint256 _fee) external;

Parameters

NameTypeDescription
_tConfigTypes.FeeTypeFeeType The fee type
_feeuint256uint256 The fee rate to update to

setRed

Sets the address of the RED contract

Infrared must be granted MINTER_ROLE on RED to set the address

function setRed(address _red) external;

Parameters

NameTypeDescription
_redaddressThe address of the RED contract

setIBGT

Sets the address of the iBGT contract

Infrared must be granted MINTER_ROLE on IBGT to set the address

function setIBGT(address _ibgt) external;

Parameters

NameTypeDescription
_ibgtaddressThe address of the iBGT contract

updateRedMintRate

Updates the mint rate for RED

function updateRedMintRate(uint256 _redMintRate) external;

Parameters

NameTypeDescription
_redMintRateuint256The new mint rate for RED

claimProtocolFees

Claims accumulated protocol fees in contract

function claimProtocolFees(address _to, address _token, uint256 _amount)
    external;

Parameters

NameTypeDescription
_toaddressaddress The recipient of the fees
_tokenaddressaddress The token to claim fees in
_amountuint256uint256 The amount of accumulated fees to claim

harvestBase

Claims all the BGT base and commission rewards minted to this contract for validators.

function harvestBase() external;

harvestOperatorRewards

Credits all accumulated rewards to the operator

function harvestOperatorRewards() external;

harvestVault

Claims all the BGT rewards for the vault associated with the given staking token.

function harvestVault(address _asset) external;

Parameters

NameTypeDescription
_assetaddressaddress The address of the staking asset that the vault is for.

harvestBribes

Claims all the bribes rewards in the contract forwarded from Berachain POL.

function harvestBribes(address[] memory _tokens) external;

Parameters

NameTypeDescription
_tokensaddress[]address[] memory The addresses of the tokens to harvest in the contract.

collectBribes

Collects bribes from bribe collector and distributes to wiBERA and iBGT Infrared vaults.

_token The payout token for the bribe collector.

_amount The amount of payout received from bribe collector.

function collectBribes(address _token, uint256 _amount) external;

harvestBoostRewards

Claims all the BGT staker rewards from boosting validators.

Sends rewards to iBGT vault.

function harvestBoostRewards() external;

addValidators

Adds validators to the set of InfraredValidators.

function addValidators(ValidatorTypes.Validator[] memory _validators)
    external;

Parameters

NameTypeDescription
_validatorsValidatorTypes.Validator[]Validator[] memory The validators to add.

removeValidators

Removes validators from the set of InfraredValidators.

function removeValidators(bytes[] memory _pubkeys) external;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] memory The pubkeys of the validators to remove.

replaceValidator

Replaces a validator in the set of InfraredValidators.

function replaceValidator(bytes calldata _current, bytes calldata _new)
    external;

Parameters

NameTypeDescription
_currentbytesbytes The pubkey of the validator to replace.
_newbytesbytes The new validator pubkey.

queueBoosts

Queue _amts of tokens to _validators for boosts.

function queueBoosts(bytes[] memory _pubkeys, uint128[] memory _amts)
    external;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] memory The pubkeys of the validators to queue boosts for.
_amtsuint128[]uint128[] memory The amount of BGT to boost with.

cancelBoosts

Removes _amts from previously queued boosts to _validators.

_pubkeys need not be in the current validator set in case just removed but need to cancel.

function cancelBoosts(bytes[] memory _pubkeys, uint128[] memory _amts)
    external;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] memory The pubkeys of the validators to remove boosts for.
_amtsuint128[]uint128[] memory The amounts of BGT to remove from the queued boosts.

activateBoosts

Activates queued boosts for _pubkeys.

function activateBoosts(bytes[] memory _pubkeys) external;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] memory The pubkeys of the validators to activate boosts for.

queueDropBoosts

Queues a drop boost of the validators removing an amount of BGT for sender.

Reverts if user does not have enough boosted balance to cover amount.

function queueDropBoosts(bytes[] calldata pubkeys, uint128[] calldata amounts)
    external;

Parameters

NameTypeDescription
pubkeysbytes[]bytes[] memory The pubkeys of the validators to remove boost from.
amountsuint128[]Amounts of BGT to remove from the queued drop boosts.

cancelDropBoosts

Cancels a queued drop boost of the validator removing an amount of BGT for sender.

function cancelDropBoosts(bytes[] calldata pubkeys, uint128[] calldata amounts)
    external;

Parameters

NameTypeDescription
pubkeysbytes[]bytes[] memory The pubkeys of the validators to remove boost from.
amountsuint128[]Amounts of BGT to remove from the queued drop boosts.

dropBoosts

Drops an amount of BGT from an existing boost of validators by user.

function dropBoosts(bytes[] calldata pubkeys) external;

Parameters

NameTypeDescription
pubkeysbytes[]bytes[] memory The pubkeys of the validators to remove boost from.

queueNewCuttingBoard

Queues a new cutting board on BeraChef for reward weight distribution for validator

function queueNewCuttingBoard(
    bytes calldata _pubkey,
    uint64 _startBlock,
    IBeraChef.Weight[] calldata _weights
) external;

Parameters

NameTypeDescription
_pubkeybytesbytes The pubkey of the validator to queue the cutting board for
_startBlockuint64uint64 The start block for reward weightings
_weightsIBeraChef.Weight[]IBeraChef.Weight[] calldata The weightings used when distributor calls chef to distribute validator rewards

infraredValidators

Gets the set of infrared validator pubkeys.

function infraredValidators()
    external
    view
    returns (ValidatorTypes.Validator[] memory validators);

Returns

NameTypeDescription
validatorsValidatorTypes.Validator[]Validator[] memory The set of infrared validators.

numInfraredValidators

Gets the number of infrared validators in validator set.

function numInfraredValidators() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256num uint256 The number of infrared validators in validator set.

isInfraredValidator

Checks if a validator is an infrared validator.

function isInfraredValidator(bytes memory _pubkey)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
_pubkeybytesbytes The pubkey of the validator to check.

Returns

NameTypeDescription
<none>bool_isValidator bool Whether the validator is an infrared validator.

getBGTBalance

Gets the BGT balance for this contract

function getBGTBalance() external view returns (uint256 bgtBalance);

Returns

NameTypeDescription
bgtBalanceuint256The BGT balance held by this address

Events

NewVault

Emitted when a new vault is registered

event NewVault(address _sender, address indexed _asset, address indexed _vault);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the vault registration
_assetaddressThe address of the asset for which the vault is registered
_vaultaddressThe address of the newly created vault

VaultRegistrationPauseStatus

Emitted when pause status for new vault registration has changed

event VaultRegistrationPauseStatus(bool pause);

Parameters

NameTypeDescription
pauseboolTrue if new vault creation is paused

OperatorRewardsDistributed

Emitted when InfraredBGT tokens are supplied to distributor.

event OperatorRewardsDistributed(
    address indexed _ibera, address indexed _distributor, uint256 _amt
);

Parameters

NameTypeDescription
_iberaaddresstoken the rewards are denominated in
_distributoraddressThe address of the distributor receiving the InfraredBGT tokens.
_amtuint256The amount of WBERA tokens supplied to distributor.

InfraredBGTSupplied

Emitted when InfraredBGT tokens are supplied to a vault.

event InfraredBGTSupplied(
    address indexed _vault, uint256 _ibgtAmt, uint256 _iredAmt
);

Parameters

NameTypeDescription
_vaultaddressThe address of the vault receiving the InfraredBGT and IRED tokens.
_ibgtAmtuint256The amount of InfraredBGT tokens supplied to vault.
_iredAmtuint256The amount of IRED tokens supplied to vault as additional reward from protocol.

RewardSupplied

Emitted when rewards are supplied to a vault.

event RewardSupplied(
    address indexed _vault, address indexed _token, uint256 _amt
);

Parameters

NameTypeDescription
_vaultaddressThe address of the vault receiving the reward.
_tokenaddressThe address of the token being supplied as a reward.
_amtuint256The amount of the reward token supplied.

BribeSupplied

Emitted when rewards are supplied to a vault.

event BribeSupplied(
    address indexed _recipient, address indexed _token, uint256 _amt
);

Parameters

NameTypeDescription
_recipientaddressThe address receiving the bribe.
_tokenaddressThe address of the token being supplied as a bribe reward.
_amtuint256The amount of the bribe reward token supplied.

Recovered

Emitted when tokens are recovered from the contract.

event Recovered(address _sender, address indexed _token, uint256 _amount);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the recovery.
_tokenaddressThe address of the token being recovered.
_amountuint256The amount of the token recovered.

RewardTokenNotSupported

Emitted when a reward token is marked as unsupported.

event RewardTokenNotSupported(address _token);

Parameters

NameTypeDescription
_tokenaddressThe address of the reward token.

InfraredBGTUpdated

Emitted when the InfraredBGT token address is updated.

event InfraredBGTUpdated(address _sender, address _oldIbgt, address _newIbgt);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_oldIbgtaddressThe previous address of the InfraredBGT token.
_newIbgtaddressThe new address of the InfraredBGT token.

InfraredBGTVaultUpdated

Emitted when the InfraredBGT vault address is updated.

event InfraredBGTVaultUpdated(
    address _sender, address _oldIbgtVault, address _newIbgtVault
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_oldIbgtVaultaddressThe previous address of the InfraredBGT vault.
_newIbgtVaultaddressThe new address of the InfraredBGT vault.

WhiteListedRewardTokensUpdated

Emitted when reward tokens are whitelisted or unwhitelisted.

event WhiteListedRewardTokensUpdated(
    address _sender,
    address indexed _token,
    bool _wasWhitelisted,
    bool _isWhitelisted
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_tokenaddressThe address of the token being updated.
_wasWhitelistedboolThe previous whitelist status of the token.
_isWhitelistedboolThe new whitelist status of the token.

RewardsDurationUpdated

Emitted when the rewards duration is updated

event RewardsDurationUpdated(
    address _sender, uint256 _oldDuration, uint256 _newDuration
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update
_oldDurationuint256The previous rewards duration
_newDurationuint256The new rewards duration

IredMintRateUpdated

Emitted when the IRED mint rate per unit InfraredBGT is updated.

event IredMintRateUpdated(
    address _sender, uint256 _oldMintRate, uint256 _newMintRate
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_oldMintRateuint256The previous IRED mint rate.
_newMintRateuint256The new IRED mint rate.

InfraredBERABribesWeightUpdated

Emitted when a weight is updated.

event InfraredBERABribesWeightUpdated(
    address _sender, uint256 _oldWeight, uint256 _newWeight
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_oldWeightuint256The old value of the weight.
_newWeightuint256The new value of the weight.

FeeUpdated

Emitted when protocol fee rate is updated.

event FeeUpdated(
    address _sender,
    ConfigTypes.FeeType _feeType,
    uint256 _oldFeeRate,
    uint256 _newFeeRate
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_feeTypeConfigTypes.FeeTypeThe fee type updated.
_oldFeeRateuint256The old protocol fee rate.
_newFeeRateuint256The new protocol fee rate.

ProtocolFeesClaimed

Emitted when protocol fees claimed.

event ProtocolFeesClaimed(
    address _sender, address _to, address _token, uint256 _amount
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the claim.
_toaddressThe address to send protocol fees to.
_tokenaddressThe address of the token protocol fees in.
_amountuint256The amount of protocol fees claimed.

ProtocolFees

Emitted when protocol fees are received.

event ProtocolFees(address indexed _token, uint256 _amt, uint256 _voterAmt);

Parameters

NameTypeDescription
_tokenaddressThe address of the token protocol fees in.
_amtuint256The amount of protocol fees received.
_voterAmtuint256The amount of protocol fees received by the voter.

BaseHarvested

Emitted when base + commission rewards are harvested.

event BaseHarvested(address _sender, uint256 _bgtAmt);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the harvest.
_bgtAmtuint256The amount of BGT harvested.

VaultHarvested

Emitted when a vault harvests its rewards.

event VaultHarvested(
    address _sender,
    address indexed _asset,
    address indexed _vault,
    uint256 _bgtAmt
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the harvest.
_assetaddressThe asset associated with the vault being harvested.
_vaultaddressThe address of the vault being harvested.
_bgtAmtuint256The amount of BGT harvested.

BribesCollected

Emitted when bribes are harvested then collected by collector.

event BribesCollected(
    address _sender,
    address _token,
    uint256 _amtWiberaVault,
    uint256 _amtIbgtVault
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the bribe collection.
_tokenaddressThe payout token from bribe collection.
_amtWiberaVaultuint256The amount of collected bribe sent to the wrapped iBERA vault.
_amtIbgtVaultuint256The amount of collected bribe sent to the iBGT vault.

ValidatorHarvested

Emitted when a validator harvests its rewards.

event ValidatorHarvested(
    address _sender,
    bytes indexed _validator,
    DataTypes.Token[] _rewards,
    uint256 _bgtAmt
);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the harvest.
_validatorbytesThe public key of the validator.
_rewardsDataTypes.Token[]An array of tokens and amounts harvested.
_bgtAmtuint256The amount of BGT included in the rewards.

ValidatorsAdded

Emitted when validators are added.

event ValidatorsAdded(address _sender, ValidatorTypes.Validator[] _validators);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the addition.
_validatorsValidatorTypes.Validator[]An array of validators that were added.

ValidatorsRemoved

Emitted when validators are removed from validator set.

event ValidatorsRemoved(address _sender, bytes[] _pubkeys);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the removal.
_pubkeysbytes[]An array of validators' pubkeys that were removed.

ValidatorReplaced

Emitted when a validator is replaced with a new validator.

event ValidatorReplaced(address _sender, bytes _current, bytes _new);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the replacement.
_currentbytesThe pubkey of the current validator being replaced.
_newbytesThe pubkey of the new validator.

QueuedBoosts

Emitted when BGT tokens are queued for boosts to validators.

event QueuedBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the boost.
_pubkeysbytes[]The addresses of the validators to which tokens are queued for boosts.
_amtsuint128[]The amounts of tokens that were queued.

CancelledBoosts

Emitted when existing queued boosts to validators are cancelled.

event CancelledBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the cancellation.
_pubkeysbytes[]The pubkeys of the validators to which tokens were queued for boosts.
_amtsuint128[]The amounts of tokens to remove from boosts.

ActivatedBoosts

Emitted when an existing boost to a validator is activated.

event ActivatedBoosts(address _sender, bytes[] _pubkeys);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the activation.
_pubkeysbytes[]The addresses of the validators which were boosted.

QueueDropBoosts

Emitted when an user queues a drop boost for a validator.

event QueueDropBoosts(
    address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);

Parameters

NameTypeDescription
useraddressThe address of the user.
pubkeysbytes[]The addresses of the validators to which tokens were queued for boosts.
amountsuint128[]The amounts of tokens to remove from boosts.

CancelDropBoosts

Emitted when an user cancels a queued drop boost for a validator.

event CancelDropBoosts(
    address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);

Parameters

NameTypeDescription
useraddressThe address of the user.
pubkeysbytes[]The addresses of the validators to which tokens were queued for boosts.
amountsuint128[]The amounts of tokens to remove from boosts.

DroppedBoosts

Emitted when sender removes an amount of BGT boost from a validator

event DroppedBoosts(address indexed _sender, bytes[] _pubkeys);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the cancellation.
_pubkeysbytes[]The addresses of the validators to which tokens were queued for boosts.

Undelegated

Emitted when tokens are undelegated from a validator.

event Undelegated(address _sender, bytes _pubkey, uint256 _amt);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the undelegation.
_pubkeybytesThe pubkey of the validator from which tokens are undelegated.
_amtuint256The amount of tokens that were undelegated.

Redelegated

Emitted when tokens are redelegated from one validator to another.

event Redelegated(address _sender, bytes _from, bytes _to, uint256 _amt);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the redelegation.
_frombytesThe public key of the validator from which tokens are redelegated.
_tobytesThe public key of the validator to which tokens are redelegated.
_amtuint256The amount of tokens that were redelegated.

RedSet

Emitted when the RED token is set.

event RedSet(address _sender, address _red);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_redaddressThe address of the RED token.

UpdatedRedMintRate

event UpdatedRedMintRate(
    uint256 oldMintRate, uint256 newMintRate, address sender
);

Parameters

NameTypeDescription
oldMintRateuint256The old mint rate for RED
newMintRateuint256The new mint rate for RED
senderaddressThe address that initiated the update

IBGTSet

Emitted when the iBGT token is set.

event IBGTSet(address _sender, address _ibgt);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_ibgtaddressThe address of the iBGT token.

IInfraredBERA

Git Source

Inherits: IERC20, IAccessControl

Functions

infrared

Address of the Infrared operator contract

function infrared() external view returns (address);

depositor

Address of the depositor that interacts with chain deposit precompile

function depositor() external view returns (address);

withdrawor

Address of the withdrawor that interacts with chain withdraw precompile

function withdrawor() external view returns (address);

receivor

Address of the fee receivor contract that receives tx priority fees + MEV on EL

function receivor() external view returns (address);

deposits

Deposits of BERA backing InfraredBERA intended for use in CL by validators

function deposits() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA for deposits to CL

stakes

Returns the amount of BERA staked in validator with given pubkey

function stakes(bytes calldata pubkey) external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA staked in validator

staked

Returns whether initial deposit has been staked to validator with given pubkey

function staked(bytes calldata pubkey) external view returns (bool);

Returns

NameTypeDescription
<none>boolWhethere initial deposit has been staked to validator

hasExited

Checks if a validator has been force exited from the Consensus Layer

exited validators can no longer be deposited in.

function hasExited(bytes calldata pubkey) external view returns (bool);

Parameters

NameTypeDescription
pubkeybytesThe public key of the validator to check

Returns

NameTypeDescription
<none>boolbool True if the validator has been force exited, false otherwise

signatures

Returns the deposit signature to use for given pubkey

function signatures(bytes calldata pubkey)
    external
    view
    returns (bytes memory);

Returns

NameTypeDescription
<none>bytesThe deposit signature for pubkey

feeDivisorShareholders

Fee taken by the shareholders on yield from EL coinbase priority fees + MEV, represented as an integer denominator (1/x)%

additional fees include POL base rewards, POL comission, POL bribes

function feeDivisorShareholders() external view returns (uint16);

Returns

NameTypeDescription
<none>uint16The fee taken by shareholders as an integer denominator (1/x)%, (25% = 4), (50% = 2), (100% = 1)

pending

Pending deposits yet to be forwarded to CL

function pending() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA yet to be deposited to CL

confirmed

Confirmed deposits sent to CL

function confirmed() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA confirmed to be deposited to CL

keeper

Returns whether given account is an InfraredBERA keeper

function keeper(address account) external view returns (bool);

Returns

NameTypeDescription
<none>boolWhether account is a keeper

governor

Returns whether given account is an InfraredBERA governor

function governor(address account) external view returns (bool);

Returns

NameTypeDescription
<none>boolWhether account is a governor

validator

Returns whether given pubkey is in Infrared validator set

function validator(bytes calldata pubkey) external view returns (bool);

Returns

NameTypeDescription
<none>boolWhether pubkey in Infrared validator set

previewMint

Previews the amount of InfraredBERA shares that would be minted for a given BERA amount

function previewMint(uint256 beraAmount)
    external
    view
    returns (uint256 shares, uint256 fee);

Parameters

NameTypeDescription
beraAmountuint256The amount of BERA to simulate depositing

Returns

NameTypeDescription
sharesuint256The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail
feeuint256The fee that would be charged for the mint operation

previewBurn

Previews the amount of BERA that would be received for burning InfraredBERA shares

function previewBurn(uint256 shares)
    external
    view
    returns (uint256 beraAmount, uint256 fee);

Parameters

NameTypeDescription
sharesuint256The amount of InfraredBERA shares to simulate burning

Returns

NameTypeDescription
beraAmountuint256The amount of BERA that would be received, returns 0 if the operation would fail
feeuint256The fee that would be charged for the burn operation

initialize

Initializes InfraredBERA to allow for future mints and burns

Must be called before InfraredBERA can offer deposits and withdraws

function initialize(
    address _gov,
    address _keeper,
    address _infrared,
    address _depositor,
    address _withdrawor,
    address _receivor
) external payable;

compound

Compounds accumulated EL yield in fee receivor into deposits

Called internally at bof whenever InfraredBERA minted or burned

Only sweeps if amount transferred from fee receivor would exceed min deposit thresholds

function compound() external;

sweep

Sweeps received funds in msg.value as yield into deposits

Fee receivor must call this function in its sweep function for autocompounding

function sweep() external payable;

collect

Collects yield from fee receivor and mints ibera shares to Infrared

Only Infrared can call this function

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of ibera shares minted

mint

Mints ibera shares to receiver for bera paid in by sender

function mint(address receiver)
    external
    payable
    returns (uint256 nonce, uint256 shares);

Parameters

NameTypeDescription
receiveraddressAddress of the receiver of ibera

Returns

NameTypeDescription
nonceuint256The nonce issued to identify the credited bera funds for deposit
sharesuint256The amount of shares of ibera minted

burn

Burns ibera shares from sender for bera to ultimately be transferred to receiver on subsequent call to claim

Sender must pay withdraw precompile fee upfront

function burn(address receiver, uint256 shares)
    external
    payable
    returns (uint256 nonce, uint256 amount);

Parameters

NameTypeDescription
receiveraddressAddress of the receiver of future bera
sharesuint256The amount of shares of ibera burned

Returns

NameTypeDescription
nonceuint256The nonce issued to identify the owed bera funds for claim
amountuint256The amount of bera funds that will be available for claim

register

Registers update to BERA staked in validator with given pubkey at CL

Reverts if not called by depositor or withdrawor

function register(bytes calldata pubkey, int256 delta) external;

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator to update BERA stake for at CL
deltaint256The change in the amount of BERA staked/unstaked (+/-) at CL

setFeeDivisorShareholders

Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV

function setFeeDivisorShareholders(uint16 to) external;

Parameters

NameTypeDescription
touint16The new fee shareholders represented as an integer denominator (1/x)%

setDepositSignature

Sets the deposit signature to be used when depositing to pubkey

function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
    external;

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator receiving the deposit
signaturebytesThe deposit signature to use for pubkey

withdrawalsEnabled

Flag to show whether withdrawals are currently enabled

function withdrawalsEnabled() external view returns (bool);

Returns

NameTypeDescription
<none>boolTrue if withdrawals are enabled

Events

Mint

event Mint(
    address indexed receiver,
    uint256 nonce,
    uint256 amount,
    uint256 shares,
    uint256 fee
);

Burn

event Burn(
    address indexed receiver,
    uint256 nonce,
    uint256 amount,
    uint256 shares,
    uint256 fee
);

Sweep

event Sweep(uint256 amount);

Register

event Register(bytes pubkey, int256 delta, uint256 stake);

SetFeeShareholders

event SetFeeShareholders(uint16 from, uint16 to);

SetDepositSignature

event SetDepositSignature(bytes pubkey, bytes from, bytes to);

WithdrawalFlagSet

event WithdrawalFlagSet(bool flag);

IInfraredBERAClaimor

Git Source

Functions

claims

Outstanding BERA claims for a receiver

function claims(address receiver) external view returns (uint256);

Parameters

NameTypeDescription
receiveraddressThe address of the claims receiver

queue

Queues a new BERA claim for a receiver

Only callable by the InfraredBERAWithdrawor contract

function queue(address receiver) external payable;

Parameters

NameTypeDescription
receiveraddressThe address of the claims receiver

sweep

Sweeps oustanding BERA claims for a receiver to their address

function sweep(address receiver) external;

Parameters

NameTypeDescription
receiveraddressThe address of the claims receiver

Events

Queue

event Queue(address indexed receiver, uint256 amount, uint256 claim);

Sweep

event Sweep(address indexed receiver, uint256 amount);

IInfraredBERADepositor

Git Source

Functions

InfraredBERA

The address of InfraredBERA

function InfraredBERA() external view returns (address);

slips

Outstanding slips for deposits on previously minted ibera

function slips(uint256 nonce)
    external
    view
    returns (uint96 timestamp, uint256 fee, uint256 amount);

Parameters

NameTypeDescription
nonceuint256The nonce associated with the slip

Returns

NameTypeDescription
timestampuint96The block.timestamp at which deposit slip was issued
feeuint256The fee escrow amount set aside for deposit contract request
amountuint256The amount of bera left to be submitted for deposit slip

fees

Amount of BERA internally set aside for deposit contract request fees

function fees() external view returns (uint256);

reserves

Amount of BERA internally set aside to execute deposit contract requests

function reserves() external view returns (uint256);

nonceSlip

The next nonce to issue deposit slip for

function nonceSlip() external view returns (uint256);

nonceSubmit

The next nonce to submit deposit slip for

function nonceSubmit() external view returns (uint256);

queue

Queues a deposit from InfraredBERA for chain deposit precompile escrowing msg.value in contract

function queue(uint256 amount) external payable returns (uint256 nonce);

Parameters

NameTypeDescription
amountuint256The amount of funds to deposit

Returns

NameTypeDescription
nonceuint256The nonce created when queueing the deposit

execute

Executes a deposit to deposit precompile using escrowed funds

function execute(bytes calldata pubkey, uint256 amount) external;

Parameters

NameTypeDescription
pubkeybytesThe pubkey to deposit validator funds to
amountuint256The amount of funds to use from escrow to deposit to validator

Events

Queue

event Queue(uint256 nonce, uint256 amount);

Execute

event Execute(bytes pubkey, uint256 start, uint256 end, uint256 amount);

IInfraredBERAFeeReceivor

Git Source

Functions

InfraredBERA

The address of InfraredBERA

function InfraredBERA() external view returns (address);

shareholderFees

Accumulated protocol fees in contract to be claimed by governor

function shareholderFees() external view returns (uint256);

distribution

Amount of BERA swept to InfraredBERA and fees taken for protool on next call to sweep

function distribution() external view returns (uint256 amount, uint256 fees);

Returns

NameTypeDescription
amountuint256THe amount of BERA forwarded to InfraredBERA on next sweep
feesuint256The protocol fees taken on next sweep

sweep

Sweeps accumulated coinbase priority fees + MEV to InfraredBERA to autocompound principal

function sweep() external returns (uint256 amount, uint256 fees);

collect

Collects accumulated shareholder fees

Reverts if msg.sender is not iBERA contract

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of iBERA shares minted and sent to infrared

Events

Sweep

event Sweep(address indexed receiver, uint256 amount, uint256 fees);

Collect

event Collect(address indexed receiver, uint256 amount, uint256 sharesMinted);

IInfraredBERAWithdrawor

Git Source

Functions

InfraredBERA

The address of InfraredBERA

function InfraredBERA() external view returns (address);

sweep

Sweeps forced withdrawals to InfraredBERA to re-stake principal

function sweep(bytes calldata pubkey) external;

requests

Outstanding requests for claims on previously burnt ibera

function requests(uint256 nonce)
    external
    view
    returns (
        address receiver,
        uint96 timestamp,
        uint256 fee,
        uint256 amountSubmit,
        uint256 amountProcess
    );

Parameters

NameTypeDescription
nonceuint256The nonce associated with the claim

Returns

NameTypeDescription
receiveraddressThe address of the receiver of bera funds to be claimed
timestampuint96The block.timestamp at which withdraw request was issued
feeuint256The fee escrow amount set aside for withdraw precompile request
amountSubmituint256The amount of bera left to be submitted for withdraw request
amountProcessuint256The amount of bera left to be processed for withdraw request

fees

Amount of BERA internally set aside for withdraw precompile request fees

function fees() external view returns (uint256);

reserves

Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests

function reserves() external view returns (uint256);

rebalancing

Amount of BERA internally rebalancing amongst Infrared validators

function rebalancing() external view returns (uint256);

nonceRequest

The next nonce to issue withdraw request for

function nonceRequest() external view returns (uint256);

nonceSubmit

The next nonce to submit withdraw request for

function nonceSubmit() external view returns (uint256);

nonceProcess

The next nonce in queue to process claims for

function nonceProcess() external view returns (uint256);

queue

Queues a withdraw from InfraredBERA for chain withdraw precompile escrowing minimum fees for request to withdraw precompile

function queue(address receiver, uint256 amount)
    external
    payable
    returns (uint256 nonce);

Parameters

NameTypeDescription
receiveraddressThe address to receive withdrawn funds
amountuint256The amount of funds to withdraw

Returns

NameTypeDescription
nonceuint256The nonce created when queueing the withdraw

execute

Executes a withdraw request to withdraw precompile

Payable in case excess bera required to satisfy withdraw precompile fee

function execute(bytes calldata pubkey, uint256 amount) external payable;

Parameters

NameTypeDescription
pubkeybytesThe pubkey to withdraw validator funds from
amountuint256The amount of funds to withdraw from validator

process

Processes the funds received from withdraw precompile to next-to-process request receiver

Reverts if balance has not increased by full amount of request for next-to-process request nonce

function process() external;

Events

Queue

event Queue(address indexed receiver, uint256 nonce, uint256 amount);

Execute

event Execute(bytes pubkey, uint256 start, uint256 end, uint256 amount);

Process

event Process(address indexed receiver, uint256 nonce, uint256 amount);

Sweep

event Sweep(address indexed receiver, uint256 amount);

IInfraredBGT

Git Source

Inherits: IERC20Mintable, IAccessControl

Functions

bgt

The address of the BGT non-transferrable ERC20 token

function bgt() external view returns (address);

IInfraredDistributor

Git Source

Interface for distributing validator commissions and rewards

Handles reward distribution snapshots and claiming logic for validators

Functions

token

Token used for reward distributions

function token() external view returns (ERC20);

Returns

NameTypeDescription
<none>ERC20The ERC20 token interface of the reward token

amountsCumulative

Tracks reward amount accumulation per validator

function amountsCumulative() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Current cumulative amount of 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

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;

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;

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

Notes:

  • error: ZeroAmount if amount is 0

  • error: InvalidValidator if no validators exist

function notifyRewardAmount(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256Amount to distribute equally among validators

claim

Claims outstanding commission rewards

Notes:

  • error: InvalidValidator if caller not authorized

  • error: ZeroAmount if no rewards to claim

function claim(bytes calldata pubkey, address recipient) external;

Parameters

NameTypeDescription
pubkeybytesValidator's public key
recipientaddressAddress to receive the claimed rewards

Events

Added

Emitted when validator is added to commission-eligible set

event Added(bytes pubkey, address operator, uint256 amountCumulative);

Parameters

NameTypeDescription
pubkeybytesValidator's public key
operatoraddressAddress authorized to claim rewards
amountCumulativeuint256Starting point for commission stream

Removed

Emitted when validator is removed from commission-eligible set

event Removed(bytes pubkey, address operator, uint256 amountCumulative);

Parameters

NameTypeDescription
pubkeybytesValidator's public key
operatoraddressAddress previously authorized for claims
amountCumulativeuint256Final point for commission stream

Purged

Emitted when validator is fully purged from registry

event Purged(bytes pubkey, address validator);

Parameters

NameTypeDescription
pubkeybytesValidator's public key
validatoraddressAddress being purged

Notified

Emitted when new commission rewards are added

event Notified(uint256 amount, uint256 num);

Parameters

NameTypeDescription
amountuint256New rewards being distributed
numuint256Current number of eligible validators

Claimed

Emitted when validator claims their commission

event Claimed(
    bytes pubkey, address validator, address recipient, uint256 amount
);

Parameters

NameTypeDescription
pubkeybytesClaiming validator's public key
validatoraddressAddress authorized for claims
recipientaddressAddress receiving the commission
amountuint256Amount of commission claimed

Structs

Snapshot

Reward accumulation checkpoints for validators

Used to calculate claimable rewards between snapshots

struct Snapshot {
    uint256 amountCumulativeLast;
    uint256 amountCumulativeFinal;
}

IInfraredUpgradeable

Git Source

Inherits: IAccessControl

Functions

KEEPER_ROLE

Access control for keeper role

function KEEPER_ROLE() external view returns (bytes32);

GOVERNANCE_ROLE

Access control for governance role

function GOVERNANCE_ROLE() external view returns (bytes32);

infrared

Infrared coordinator contract

function infrared() external view returns (address);

IInfraredVault

Git Source

Inherits: IMultiRewards

Functions

getAllRewardTokens

Returns all reward tokens

function getAllRewardTokens() external view returns (address[] memory);

Returns

NameTypeDescription
<none>address[]An array of reward token addresses

getAllRewardsForUser

Returns all rewards for a user

Only up to date since the lastUpdateTime

function getAllRewardsForUser(address _user)
    external
    view
    returns (UserReward[] memory);

Parameters

NameTypeDescription
_useraddressThe address of the user

Returns

NameTypeDescription
<none>UserReward[]An array of UserReward structs

infrared

Returns the Infrared protocol coordinator

function infrared() external view returns (address);

Returns

NameTypeDescription
<none>addressThe address of the Infrared contract

rewardsVault

Returns the associated Berachain rewards vault

function rewardsVault() external view returns (IBerachainRewardsVault);

Returns

NameTypeDescription
<none>IBerachainRewardsVaultThe rewards vault contract instance

updateRewardsDuration

Updates reward duration for a specific reward token

Only callable by Infrared contract

Note: access-control: Requires INFRARED_ROLE

function updateRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
    external;

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the reward token
_rewardsDurationuint256The new duration in seconds

togglePause

Toggles pause state of the vault

Affects all vault operations when paused

Note: access-control: Requires INFRARED_ROLE

function togglePause() external;

addReward

Adds a new reward token to the vault

Cannot exceed maximum number of reward tokens

Note: access-control: Requires INFRARED_ROLE

function addReward(address _rewardsToken, uint256 _rewardsDuration) external;

Parameters

NameTypeDescription
_rewardsTokenaddressThe reward token to add
_rewardsDurationuint256The reward period duration

notifyRewardAmount

Notifies the vault of newly added rewards

Updates internal reward rate calculations

function notifyRewardAmount(address _rewardToken, uint256 _reward) external;

Parameters

NameTypeDescription
_rewardTokenaddressThe reward token address
_rewarduint256The amount of new rewards

recoverERC20

Recovers accidentally sent tokens

Cannot recover staking token or active reward tokens

function recoverERC20(address _to, address _token, uint256 _amount) external;

Parameters

NameTypeDescription
_toaddressThe address to receive the recovered tokens
_tokenaddressThe token to recover
_amountuint256The amount to recover

Structs

UserReward

A struct to hold a user's reward information

struct UserReward {
    address token;
    uint256 amount;
}

Properties

NameTypeDescription
tokenaddressThe address of the reward token
amountuint256The amount of reward tokens

IMultiRewards

Git Source

Functions

totalSupply

Returns the total amount of staked tokens in the contract

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The total supply of staked tokens

stake

Stakes tokens into the contract

Transfers amount of staking tokens from the user to this contract

function stake(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256The amount of tokens to stake

withdraw

Withdraws staked tokens from the contract

Transfers amount of staking tokens back to the user

function withdraw(uint256 amount) external;

Parameters

NameTypeDescription
amountuint256The amount of tokens to withdraw

getReward

Claims all pending rewards for the caller

Transfers all accrued rewards to the caller

function getReward() external;

exit

Withdraws all staked tokens and claims pending rewards

Combines withdraw and getReward operations

function exit() external;

balanceOf

Returns the balance of staked tokens for the given account

function balanceOf(address account) external view returns (uint256);

Parameters

NameTypeDescription
accountaddressThe account to get the balance for

Returns

NameTypeDescription
<none>uint256The balance of staked tokens

lastTimeRewardApplicable

Calculates the last time reward is applicable for a given rewards token

function lastTimeRewardApplicable(address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The timestamp when the reward was last applicable

rewardPerToken

Calculates the reward per token for a given rewards token

function rewardPerToken(address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The reward amount per token

earned

Calculates the earned rewards for a given account and rewards token

function earned(address account, address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
accountaddressThe address of the account
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The amount of rewards earned

getRewardForDuration

Calculates the total reward for the duration of a given rewards token

function getRewardForDuration(address _rewardsToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
<none>uint256The total reward amount for the duration of a given rewards token

rewardData

Gets the reward data for a given rewards token

function rewardData(address _rewardsToken)
    external
    view
    returns (
        address rewardsDistributor,
        uint256 rewardsDuration,
        uint256 periodFinish,
        uint256 rewardRate,
        uint256 lastUpdateTime,
        uint256 rewardPerTokenStored,
        uint256 rewardResidual
    );

Parameters

NameTypeDescription
_rewardsTokenaddressThe address of the rewards token

Returns

NameTypeDescription
rewardsDistributoraddressThe address authorized to distribute rewards
rewardsDurationuint256The duration of the reward period
periodFinishuint256The timestamp when rewards finish
rewardRateuint256The rate of rewards distributed per second
lastUpdateTimeuint256The last time rewards were updated
rewardPerTokenStoreduint256The last calculated reward per token
rewardResidualuint256

rewardTokens

Returns the reward token address at a specific index

function rewardTokens(uint256 index) external view returns (address);

Parameters

NameTypeDescription
indexuint256The index in the reward tokens array

Returns

NameTypeDescription
<none>addressThe address of the reward token at the given index

getRewardForUser

Claims all pending rewards for a specified user

Iterates through all reward tokens and transfers any accrued rewards to the user

function getRewardForUser(address _user) external;

Parameters

NameTypeDescription
_useraddressThe address of the user to claim rewards for

Events

Staked

Emitted when tokens are staked

event Staked(address indexed user, uint256 amount);

Parameters

NameTypeDescription
useraddressThe address of the user who staked
amountuint256The amount of tokens staked

Withdrawn

Emitted when tokens are withdrawn

event Withdrawn(address indexed user, uint256 amount);

Parameters

NameTypeDescription
useraddressThe address of the user who withdrew
amountuint256The amount of tokens withdrawn

RewardPaid

Emitted when rewards are claimed

event RewardPaid(
    address indexed user, address indexed rewardsToken, uint256 reward
);

Parameters

NameTypeDescription
useraddressThe address of the user claiming the reward
rewardsTokenaddressThe address of the reward token
rewarduint256The amount of rewards claimed

RewardAdded

Emitted when rewards are added to the contract

event RewardAdded(address indexed rewardsToken, uint256 reward);

Parameters

NameTypeDescription
rewardsTokenaddressThe address of the reward token
rewarduint256The amount of rewards added

RewardsDistributorUpdated

Emitted when a rewards distributor is updaRewardAddedd

event RewardsDistributorUpdated(
    address indexed rewardsToken, address indexed newDistributor
);

Parameters

NameTypeDescription
rewardsTokenaddressThe address of the reward token
newDistributoraddressThe address of the new distributor

RewardsDurationUpdated

Emitted when the rewards duration for a token is updated

event RewardsDurationUpdated(address token, uint256 newDuration);

Parameters

NameTypeDescription
tokenaddressThe reward token address whose duration was updated
newDurationuint256The new duration set for the rewards period

Recovered

Emitted when tokens are recovered from the contract

event Recovered(address token, uint256 amount);

Parameters

NameTypeDescription
tokenaddressThe address of the token that was recovered
amountuint256The amount of tokens that were recovered

RewardStored

Emitted when new reward data is stored

event RewardStored(address rewardsToken, uint256 rewardsDuration);

Parameters

NameTypeDescription
rewardsTokenaddressThe address of the reward token
rewardsDurationuint256The duration set for the reward period

Structs

Reward

Reward data for a particular reward token

Struct containing all relevant information for reward distribution

struct Reward {
    address rewardsDistributor;
    uint256 rewardsDuration;
    uint256 periodFinish;
    uint256 rewardRate;
    uint256 lastUpdateTime;
    uint256 rewardPerTokenStored;
    uint256 rewardResidual;
}

IRED

Git Source

Inherits: IERC20Mintable, IAccessControl

Functions

ibgt

The address of the InfraredBGT token

function ibgt() external view returns (address);

infrared

The address of the Infrared contract

function infrared() external view returns (address);

IWBERA

Git Source

Inherits: IERC20

The deposit function allows users to deposit EVM balance (BERA) into the contract. It mints an equivalent amount of WBERA tokens and assigns them to the sender.

Functions

deposit

function deposit() external payable;

withdraw

function withdraw(uint256 amount) external;

Contents

InfraredBERA

Git Source

Inherits: ERC20Upgradeable, Upgradeable, IInfraredBERA

Infrared liquid staking token for BERA

Assumes BERA balances do not change at the CL

State Variables

withdrawalsEnabled

Flag to show whether withdrawals are currently enabled

bool public withdrawalsEnabled;

_initialized

Whether initial mint to address(this) has happened

bool private _initialized;

feeDivisorShareholders

Fee taken by the shareholders on yield from EL coinbase priority fees + MEV, represented as an integer denominator (1/x)%

uint16 public feeDivisorShareholders;

infrared

Address of the Infrared operator contract

address public infrared;

depositor

Address of the depositor that interacts with chain deposit precompile

address public depositor;

withdrawor

Address of the withdrawor that interacts with chain withdraw precompile

address public withdrawor;

receivor

Address of the fee receivor contract that receives tx priority fees + MEV on EL

address public receivor;

deposits

Deposits of BERA backing InfraredBERA intended for use in CL by validators

uint256 public deposits;

_stakes

mapping(bytes32 pubkeyHash => uint256 stake) internal _stakes;

_staked

mapping(bytes32 pubkeyHash => bool isStaked) internal _staked;

_exited

mapping(bytes32 pubkeyHash => bool hasExited) internal _exited;

_signatures

mapping(bytes32 pubkeyHash => bytes) internal _signatures;

Functions

initialize

Initializes InfraredBERA to allow for future mints and burns

Must be called before InfraredBERA can offer deposits and withdraws

function initialize(
    address _gov,
    address _keeper,
    address _infrared,
    address _depositor,
    address _withdrawor,
    address _receivor
) external payable initializer;

setWithdrawalsEnabled

function setWithdrawalsEnabled(bool flag) external onlyGovernor;

_deposit

function _deposit(uint256 value)
    private
    returns (uint256 nonce, uint256 amount, uint256 fee);

_withdraw

function _withdraw(address receiver, uint256 amount, uint256 fee)
    private
    returns (uint256 nonce);

pending

Pending deposits yet to be forwarded to CL

function pending() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA yet to be deposited to CL

confirmed

Confirmed deposits sent to CL

function confirmed() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA confirmed to be deposited to CL

keeper

Returns whether given account is an InfraredBERA keeper

function keeper(address account) public view returns (bool);

Returns

NameTypeDescription
<none>boolWhether account is a keeper

governor

Returns whether given account is an InfraredBERA governor

function governor(address account) public view returns (bool);

Returns

NameTypeDescription
<none>boolWhether account is a governor

validator

Returns whether given pubkey is in Infrared validator set

function validator(bytes calldata pubkey) external view returns (bool);

Returns

NameTypeDescription
<none>boolWhether pubkey in Infrared validator set

compound

Compounds accumulated EL yield in fee receivor into deposits

Called internally at bof whenever InfraredBERA minted or burned

function compound() public;

sweep

Sweeps received funds in msg.value as yield into deposits

Fee receivor must call this function in its sweep function for autocompounding

function sweep() external payable;

mint

Mints ibera shares to receiver for bera paid in by sender

function mint(address receiver)
    public
    payable
    returns (uint256 nonce, uint256 shares);

Parameters

NameTypeDescription
receiveraddressAddress of the receiver of ibera

Returns

NameTypeDescription
nonceuint256The nonce issued to identify the credited bera funds for deposit
sharesuint256The amount of shares of ibera minted

burn

Burns ibera shares from sender for bera to ultimately be transferred to receiver on subsequent call to claim

Sender must pay withdraw precompile fee upfront

function burn(address receiver, uint256 shares)
    external
    payable
    returns (uint256 nonce, uint256 amount);

Parameters

NameTypeDescription
receiveraddressAddress of the receiver of future bera
sharesuint256The amount of shares of ibera burned

Returns

NameTypeDescription
nonceuint256The nonce issued to identify the owed bera funds for claim
amountuint256The amount of bera funds that will be available for claim

register

Registers update to BERA staked in validator with given pubkey at CL

Reverts if not called by depositor or withdrawor

function register(bytes calldata pubkey, int256 delta) external;

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator to update BERA stake for at CL
deltaint256The change in the amount of BERA staked/unstaked (+/-) at CL

setFeeDivisorShareholders

Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV

function setFeeDivisorShareholders(uint16 to) external onlyGovernor;

Parameters

NameTypeDescription
touint16The new fee shareholders represented as an integer denominator (1/x)%

setDepositSignature

Sets the deposit signature to be used when depositing to pubkey

function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
    external
    onlyGovernor;

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator receiving the deposit
signaturebytesThe deposit signature to use for pubkey

collect

Collects yield from fee receivor and mints ibera shares to Infrared

Only Infrared can call this function

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of ibera shares minted

previewMint

Previews the amount of InfraredBERA shares that would be minted for a given BERA amount

function previewMint(uint256 beraAmount)
    public
    view
    returns (uint256 shares, uint256 fee);

Parameters

NameTypeDescription
beraAmountuint256The amount of BERA to simulate depositing

Returns

NameTypeDescription
sharesuint256The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail
feeuint256The fee that would be charged for the mint operation

previewBurn

Previews the amount of BERA that would be received for burning InfraredBERA shares

function previewBurn(uint256 shareAmount)
    public
    view
    returns (uint256 beraAmount, uint256 fee);

Parameters

NameTypeDescription
shareAmountuint256

Returns

NameTypeDescription
beraAmountuint256The amount of BERA that would be received, returns 0 if the operation would fail
feeuint256The fee that would be charged for the burn operation

stakes

Returns the amount of BERA staked in validator with given pubkey

function stakes(bytes calldata pubkey) external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA staked in validator

staked

Returns whether initial deposit has been staked to validator with given pubkey

function staked(bytes calldata pubkey) external view returns (bool);

Returns

NameTypeDescription
<none>boolWhethere initial deposit has been staked to validator

hasExited

Checks if a validator has been force exited from the Consensus Layer

exited validators can no longer be deposited in.

function hasExited(bytes calldata pubkey) external view returns (bool);

Parameters

NameTypeDescription
pubkeybytesThe public key of the validator to check

Returns

NameTypeDescription
<none>boolbool True if the validator has been force exited, false otherwise

signatures

Returns the deposit signature to use for given pubkey

function signatures(bytes calldata pubkey)
    external
    view
    returns (bytes memory);

Returns

NameTypeDescription
<none>bytesThe deposit signature for pubkey

InfraredBERAClaimor

Git Source

Inherits: Upgradeable, IInfraredBERAClaimor

Claimor to claim BERA withdrawn from CL for Infrared liquid staking token

Separate contract so withdrawor process has trusted contract to forward funds to so no issue with naked bera transfer and receive function

State Variables

claims

Outstanding BERA claims for a receiver

mapping(address => uint256) public claims;

ibera

IInfraredBERA public ibera;

Functions

initialize

Initializer function (replaces constructor)

function initialize(address _gov, address _keeper, address _ibera)
    external
    initializer;

Parameters

NameTypeDescription
_govaddressAddress of the initial admin / gov
_keeperaddressAddress of the initial keeper
_iberaaddressAddress of InfraredBera proxy contract

queue

Queues a new BERA claim for a receiver

Only callable by the InfraredBERAWithdrawor contract

function queue(address receiver) external payable;

Parameters

NameTypeDescription
receiveraddressThe address of the claims receiver

sweep

Sweeps oustanding BERA claims for a receiver to their address

function sweep(address receiver) external;

Parameters

NameTypeDescription
receiveraddressThe address of the claims receiver

InfraredBERAConstants

Git Source

State Variables

INITIAL_DEPOSIT

uint256 public constant INITIAL_DEPOSIT = 10000 ether;

MINIMUM_DEPOSIT

uint256 public constant MINIMUM_DEPOSIT = 10 ether;

MINIMUM_DEPOSIT_FEE

uint256 public constant MINIMUM_DEPOSIT_FEE = 1 ether;

MINIMUM_WITHDRAW_FEE

uint256 public constant MINIMUM_WITHDRAW_FEE = 1 ether;

FORCED_MIN_DELAY

uint256 public constant FORCED_MIN_DELAY = 7 days;

InfraredBERADepositor

Git Source

Inherits: Upgradeable, IInfraredBERADepositor

Depositor to deposit BERA to CL for Infrared liquid staking token

State Variables

ETH1_ADDRESS_WITHDRAWAL_PREFIX

uint8 public constant ETH1_ADDRESS_WITHDRAWAL_PREFIX = 0x01;

DEPOSIT_CONTRACT

address public DEPOSIT_CONTRACT;

InfraredBERA

The address of InfraredBERA

address public InfraredBERA;

slips

Outstanding slips for deposits on previously minted ibera

mapping(uint256 => Slip) public slips;

fees

Amount of BERA internally set aside for deposit contract request fees

uint256 public fees;

nonceSlip

The next nonce to issue deposit slip for

uint256 public nonceSlip;

nonceSubmit

The next nonce to submit deposit slip for

uint256 public nonceSubmit;

Functions

initialize

Initialize the contract (replaces the constructor)

function initialize(
    address _gov,
    address _keeper,
    address ibera,
    address _depositContract
) public initializer;

Parameters

NameTypeDescription
_govaddressAddress for admin / gov to upgrade
_keeperaddressAddress for keeper
iberaaddressThe initial IBERA address
_depositContractaddressThe ETH2 (Berachain) Deposit Contract Address

_enoughtime

Checks whether enough time has passed beyond min delay

function _enoughtime(uint96 then, uint96 current)
    private
    pure
    returns (bool has);

Parameters

NameTypeDescription
thenuint96The block timestamp in past
currentuint96The current block timestamp now

Returns

NameTypeDescription
hasboolWhether time between then and now exceeds forced min delay

reserves

Amount of BERA internally set aside to execute deposit contract requests

function reserves() public view returns (uint256);

queue

Queues a deposit from InfraredBERA for chain deposit precompile escrowing msg.value in contract

function queue(uint256 amount) external payable returns (uint256 nonce);

Parameters

NameTypeDescription
amountuint256The amount of funds to deposit

Returns

NameTypeDescription
nonceuint256The nonce created when queueing the deposit

execute

Executes a deposit to deposit precompile using escrowed funds

function execute(bytes calldata pubkey, uint256 amount) external;

Parameters

NameTypeDescription
pubkeybytesThe pubkey to deposit validator funds to
amountuint256The amount of funds to use from escrow to deposit to validator

Structs

Slip

struct Slip {
    uint96 timestamp;
    uint256 fee;
    uint256 amount;
}

InfraredBERAFeeReceivor

Git Source

Inherits: Upgradeable, IInfraredBERAFeeReceivor

Fee receivor receives coinbase priority fees + MEV credited to contract on EL upon block validation also receives collected validator bribe share.

CL validators should set fee_recipient to the address of this contract

State Variables

InfraredBERA

The address of InfraredBERA

address public InfraredBERA;

infrared

IInfrared public infrared;

shareholderFees

Accumulated protocol fees in contract to be claimed by governor

uint256 public shareholderFees;

Functions

initialize

Initializer function (replaces constructor)

function initialize(
    address _gov,
    address _keeper,
    address ibera,
    address _infrared
) external initializer;

Parameters

NameTypeDescription
_govaddressAddress for admin / gov to upgrade
_keeperaddressAddress for keeper
iberaaddressAddress for InfraredBERA
_infraredaddressAddress for Infrared

distribution

Amount of BERA swept to InfraredBERA and fees taken for protool on next call to sweep

function distribution() public view returns (uint256 amount, uint256 fees);

Returns

NameTypeDescription
amountuint256THe amount of BERA forwarded to InfraredBERA on next sweep
feesuint256The protocol fees taken on next sweep

sweep

Sweeps accumulated coinbase priority fees + MEV to InfraredBERA to autocompound principal

function sweep() external returns (uint256 amount, uint256 fees);

collect

Collects accumulated shareholder fees

Reverts if msg.sender is not iBERA contract

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of iBERA shares minted and sent to infrared

receive

receive() external payable;

InfraredBERAWithdrawor

Git Source

Inherits: Upgradeable, IInfraredBERAWithdrawor

Withdrawor to withdraw BERA from CL for Infrared liquid staking token

Assumes ETH returned via withdraw precompile credited to contract so receive unnecessary

State Variables

WITHDRAW_REQUEST_TYPE

uint8 public constant WITHDRAW_REQUEST_TYPE = 0x01;

WITHDRAW_PRECOMPILE

address public WITHDRAW_PRECOMPILE;

InfraredBERA

The address of InfraredBERA

address public InfraredBERA;

claimor

address public claimor;

requests

Outstanding requests for claims on previously burnt ibera

mapping(uint256 => Request) public requests;

fees

Amount of BERA internally set aside for withdraw precompile request fees

uint256 public fees;

rebalancing

Amount of BERA internally rebalancing amongst Infrared validators

uint256 public rebalancing;

nonceRequest

The next nonce to issue withdraw request for

uint256 public nonceRequest;

nonceSubmit

The next nonce to submit withdraw request for

uint256 public nonceSubmit;

nonceProcess

The next nonce in queue to process claims for

uint256 public nonceProcess;

Functions

initializeV2

function initializeV2(address _claimor, address _withdraw_precompile)
    external
    onlyGovernor;

_enoughtime

Checks whether enough time has passed beyond min delay

function _enoughtime(uint96 then, uint96 current)
    private
    pure
    returns (bool has);

Parameters

NameTypeDescription
thenuint96The block timestamp in past
currentuint96The current block timestamp now

Returns

NameTypeDescription
hasboolWhether time between then and now exceeds forced min delay

reserves

Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests

function reserves() public view returns (uint256);

queue

Queues a withdraw from InfraredBERA for chain withdraw precompile escrowing minimum fees for request to withdraw precompile

function queue(address receiver, uint256 amount)
    external
    payable
    returns (uint256 nonce);

Parameters

NameTypeDescription
receiveraddressThe address to receive withdrawn funds
amountuint256The amount of funds to withdraw

Returns

NameTypeDescription
nonceuint256The nonce created when queueing the withdraw

execute

Executes a withdraw request to withdraw precompile

Payable in case excess bera required to satisfy withdraw precompile fee

function execute(bytes calldata pubkey, uint256 amount) external payable;

Parameters

NameTypeDescription
pubkeybytesThe pubkey to withdraw validator funds from
amountuint256The amount of funds to withdraw from validator

process

Processes the funds received from withdraw precompile to next-to-process request receiver

Reverts if balance has not increased by full amount of request for next-to-process request nonce

function process() external;

sweep

Sweeps forced withdrawals to InfraredBERA to re-stake principal

function sweep(bytes calldata pubkey) external;

receive

receive() external payable;

Structs

Request

struct Request {
    address receiver;
    uint96 timestamp;
    uint256 fee;
    uint256 amountSubmit;
    uint256 amountProcess;
}

InfraredBERAWithdraworLite

Git Source

Inherits: Upgradeable, IInfraredBERAWithdrawor

Withdrawor Lite to be upgraded when voluntary exits are enabled

State Variables

WITHDRAW_REQUEST_TYPE

uint8 public constant WITHDRAW_REQUEST_TYPE = 0x01;

WITHDRAW_PRECOMPILE

address public WITHDRAW_PRECOMPILE;

InfraredBERA

The address of InfraredBERA

address public InfraredBERA;

claimor

address public claimor;

requests

Outstanding requests for claims on previously burnt ibera

mapping(uint256 => Request) public requests;

fees

Amount of BERA internally set aside for withdraw precompile request fees

uint256 public fees;

rebalancing

Amount of BERA internally rebalancing amongst Infrared validators

uint256 public rebalancing;

nonceRequest

The next nonce to issue withdraw request for

uint256 public nonceRequest;

nonceSubmit

The next nonce to submit withdraw request for

uint256 public nonceSubmit;

nonceProcess

The next nonce in queue to process claims for

uint256 public nonceProcess;

Functions

initialize

Initialize the contract (replaces the constructor)

function initialize(address _gov, address _keeper, address ibera)
    public
    initializer;

Parameters

NameTypeDescription
_govaddressAddress for admin / gov to upgrade
_keeperaddressAddress for keeper
iberaaddressThe initial InfraredBERA address

_enoughtime

Checks whether enough time has passed beyond min delay

function _enoughtime(uint96 then, uint96 current)
    private
    pure
    returns (bool has);

Parameters

NameTypeDescription
thenuint96The block timestamp in past
currentuint96The current block timestamp now

Returns

NameTypeDescription
hasboolWhether time between then and now exceeds forced min delay

reserves

Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests

function reserves() public view returns (uint256);

queue

Queues a withdraw from InfraredBERA for chain withdraw precompile escrowing minimum fees for request to withdraw precompile

function queue(address receiver, uint256 amount)
    external
    payable
    returns (uint256 nonce);

Parameters

NameTypeDescription
receiveraddressThe address to receive withdrawn funds
amountuint256The amount of funds to withdraw

Returns

NameTypeDescription
nonceuint256The nonce created when queueing the withdraw

execute

Executes a withdraw request to withdraw precompile

Payable in case excess bera required to satisfy withdraw precompile fee

function execute(bytes calldata pubkey, uint256 amount) external payable;

Parameters

NameTypeDescription
pubkeybytesThe pubkey to withdraw validator funds from
amountuint256The amount of funds to withdraw from validator

process

Processes the funds received from withdraw precompile to next-to-process request receiver

Reverts if balance has not increased by full amount of request for next-to-process request nonce

function process() external;

sweep

Sweeps forced withdrawals to InfraredBERA to re-stake principal

function sweep(bytes calldata pubkey) external;

receive

receive() external payable;

Structs

Request

struct Request {
    address receiver;
    uint96 timestamp;
    uint256 fee;
    uint256 amountSubmit;
    uint256 amountProcess;
}

Contents

DataTypes

Git Source

State Variables

NATIVE_ASSET

The address of the native asset as of EIP-7528.

address public constant NATIVE_ASSET =
    0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

Structs

Token

struct Token {
    address tokenAddress;
    uint256 amount;
}

Errors

Git Source

Errors

ZeroAddress

error ZeroAddress();

ZeroAmount

error ZeroAmount();

UnderFlow

error UnderFlow();

InvalidArrayLength

error InvalidArrayLength();

AlreadySet

error AlreadySet();

ValidatorAlreadyExists

error ValidatorAlreadyExists();

FailedToAddValidator

error FailedToAddValidator();

ValidatorDoesNotExist

error ValidatorDoesNotExist();

MaxNumberOfRewards

error MaxNumberOfRewards();

Unauthorized

error Unauthorized(address sender);

IBGTNotRewardToken

error IBGTNotRewardToken();

IREDNotRewardToken

error IREDNotRewardToken();

IBGTNotStakingToken

error IBGTNotStakingToken();

StakedInRewardsVault

error StakedInRewardsVault();

NoRewardsVault

error NoRewardsVault();

RegistrationPaused

error RegistrationPaused();

RewardTokenNotWhitelisted

error RewardTokenNotWhitelisted();

InvalidValidator

error InvalidValidator();

InvalidOperator

error InvalidOperator();

InvalidDepositAmount

error InvalidDepositAmount();

ValidatorAlreadyRemoved

error ValidatorAlreadyRemoved();

VaultNotSupported

error VaultNotSupported();

InvalidNonce

error InvalidNonce();

VaultNotStaked

error VaultNotStaked();

ClaimDistrRewardsFailed

error ClaimDistrRewardsFailed();

ClaimableRewardsExist

error ClaimableRewardsExist();

DuplicateAssetAddress

error DuplicateAssetAddress();

VaultDeploymentFailed

error VaultDeploymentFailed();

RewardTokenNotSupported

error RewardTokenNotSupported();

BGTBalanceMismatch

error BGTBalanceMismatch();

NotInfrared

error NotInfrared();

NotInitialized

error NotInitialized();

InvalidFee

error InvalidFee();

InvalidCommissionRate

error InvalidCommissionRate();

InvalidDelegatee

error InvalidDelegatee();

InvalidWeight

error InvalidWeight();

MaxProtocolFeeAmount

error MaxProtocolFeeAmount();

BoostExceedsSupply

error BoostExceedsSupply();

ETHTransferFailed

error ETHTransferFailed();

TokensReservedForProtocolFees

error TokensReservedForProtocolFees();

NoRewardsToClaim

error NoRewardsToClaim();

InvalidAmount

error InvalidAmount();

InvalidShares

error InvalidShares();

WithdrawalsNotEnabled

error WithdrawalsNotEnabled();

InvalidSignature

error InvalidSignature();

InvalidReceiver

error InvalidReceiver();

CallFailed

error CallFailed();

InvalidReserves

error InvalidReserves();

UnauthorizedOperator

error UnauthorizedOperator();

ValidatorForceExited

error ValidatorForceExited();

InfraredVaultDeployer

Git Source

Functions

deploy

Deploys a new InfraredVault or InfraredBGTVault contract.

If _stakingToken == InfraredBGT, then deploys InfraredBGTVault.

function deploy(address _stakingToken, uint256 _rewardsDuration)
    public
    returns (address _new);

Parameters

NameTypeDescription
_stakingTokenaddressaddress The address of the staking token.
_rewardsDurationuint256The duration of the rewards for the vault.

Returns

NameTypeDescription
_newaddressaddress The address of the new InfraredVault contract.

Upgradeable

Git Source

Inherits: UUPSUpgradeable, AccessControlUpgradeable

Provides base upgradeability functionality using UUPS and access control.

State Variables

KEEPER_ROLE

bytes32 public constant KEEPER_ROLE = keccak256("KEEPER_ROLE");

GOVERNANCE_ROLE

bytes32 public constant GOVERNANCE_ROLE = keccak256("GOVERNANCE_ROLE");

Functions

onlyKeeper

Modifier to restrict access to KEEPER_ROLE.

modifier onlyKeeper();

onlyGovernor

Modifier to restrict access to GOVERNANCE_ROLE.

modifier onlyGovernor();

whenInitialized

modifier whenInitialized();

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

__Upgradeable_init

Initialize the upgradeable contract.

function __Upgradeable_init() internal onlyInitializing;

_authorizeUpgrade

Restrict upgrades to only the governor.

function _authorizeUpgrade(address newImplementation)
    internal
    override
    onlyGovernor;

currentImplementation

Returns the current implementation address.

function currentImplementation() external view returns (address);

implementation

Alias for currentImplementation for clarity.

function implementation() external view returns (address);

Contents

ERC20PresetMinterPauser

Git Source

Inherits: Context, AccessControlEnumerable, ERC20Burnable, ERC20Pausable

*{ERC20} token, including:

  • ability for holders to burn (destroy) their tokens
  • a minter role that allows for token minting (creation)
  • a pauser role that allows to stop all token transfers This contract uses {AccessControl} to lock permissioned functions using the different roles - head to its documentation for details. The account that deploys the contract will be granted the minter and pauser roles, as well as the default admin role, which will let it grant both minter and pauser roles to other accounts. Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard].*

State Variables

MINTER_ROLE

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

PAUSER_ROLE

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

Functions

constructor

Grants DEFAULT_ADMIN_ROLE, MINTER_ROLE and PAUSER_ROLE to the account that deploys the contract. See ERC20-constructor.

constructor(
    string memory name,
    string memory symbol,
    address _admin,
    address _minter,
    address _pauser
) ERC20(name, symbol);

mint

*Creates amount new tokens for to. See ERC20-_mint. Requirements:

  • the caller must have the MINTER_ROLE.*
function mint(address to, uint256 amount) public virtual;

pause

*Pauses all token transfers. See {ERC20Pausable} and {Pausable-_pause}. Requirements:

  • the caller must have the PAUSER_ROLE.*
function pause() public virtual;

unpause

*Unpauses all token transfers. See {ERC20Pausable} and {Pausable-_unpause}. Requirements:

  • the caller must have the PAUSER_ROLE.*
function unpause() public virtual;

_update

function _update(address from, address to, uint256 value)
    internal
    virtual
    override(ERC20, ERC20Pausable)
    whenNotPaused;

Contents

Contents

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

IVeArtProxy

Git Source

Functions

tokenURI

Generate a SVG based on veNFT metadata

function tokenURI(uint256 _tokenId)
    external
    view
    returns (string memory output);

Parameters

NameTypeDescription
_tokenIduint256Unique veNFT identifier

Returns

NameTypeDescription
outputstringSVG metadata as HTML tag

lineArtPathsOnly

Generate only the foreground elements of the line art for an NFT (excluding SVG header), for flexibility purposes.

function lineArtPathsOnly(uint256 _tokenId)
    external
    view
    returns (bytes memory output);

Parameters

NameTypeDescription
_tokenIduint256Unique veNFT identifier

Returns

NameTypeDescription
outputbytesEncoded output of generateShape()

generateConfig

Generate the master art config metadata for a veNFT

function generateConfig(uint256 _tokenId)
    external
    view
    returns (Config memory cfg);

Parameters

NameTypeDescription
_tokenIduint256Unique veNFT identifier

Returns

NameTypeDescription
cfgConfigConfig struct

twoStripes

Generate the points for two stripe lines based on the config generated for a veNFT

function twoStripes(Config memory cfg, int256 l)
    external
    pure
    returns (Point[100] memory Line);

Parameters

NameTypeDescription
cfgConfigMaster art config metadata of a veNFT
lint256Number of line drawn

Returns

NameTypeDescription
LinePoint[100](x, y) coordinates of the drawn stripes

circles

Generate the points for circles based on the config generated for a veNFT

function circles(Config memory cfg, int256 l)
    external
    pure
    returns (Point[100] memory Line);

Parameters

NameTypeDescription
cfgConfigMaster art config metadata of a veNFT
lint256Number of circles drawn

Returns

NameTypeDescription
LinePoint[100](x, y) coordinates of the drawn circles

interlockingCircles

Generate the points for interlocking circles based on the config generated for a veNFT

function interlockingCircles(Config memory cfg, int256 l)
    external
    pure
    returns (Point[100] memory Line);

Parameters

NameTypeDescription
cfgConfigMaster art config metadata of a veNFT
lint256Number of interlocking circles drawn

Returns

NameTypeDescription
LinePoint[100](x, y) coordinates of the drawn interlocking circles

corners

Generate the points for corners based on the config generated for a veNFT

function corners(Config memory cfg, int256 l)
    external
    pure
    returns (Point[100] memory Line);

Parameters

NameTypeDescription
cfgConfigMaster art config metadata of a veNFT
lint256Number of corners drawn

Returns

NameTypeDescription
LinePoint[100](x, y) coordinates of the drawn corners

curves

Generate the points for a curve based on the config generated for a veNFT

function curves(Config memory cfg, int256 l)
    external
    pure
    returns (Point[100] memory Line);

Parameters

NameTypeDescription
cfgConfigMaster art config metadata of a veNFT
lint256Number of curve drawn

Returns

NameTypeDescription
LinePoint[100](x, y) coordinates of the drawn curve

spiral

Generate the points for a spiral based on the config generated for a veNFT

function spiral(Config memory cfg, int256 l)
    external
    pure
    returns (Point[100] memory Line);

Parameters

NameTypeDescription
cfgConfigMaster art config metadata of a veNFT
lint256Number of spiral drawn

Returns

NameTypeDescription
LinePoint[100](x, y) coordinates of the drawn spiral

explosion

Generate the points for an explosion based on the config generated for a veNFT

function explosion(Config memory cfg, int256 l)
    external
    pure
    returns (Point[100] memory Line);

Parameters

NameTypeDescription
cfgConfigMaster art config metadata of a veNFT
lint256Number of explosion drawn

Returns

NameTypeDescription
LinePoint[100](x, y) coordinates of the drawn explosion

wormhole

Generate the points for a wormhole based on the config generated for a veNFT

function wormhole(Config memory cfg, int256 l)
    external
    pure
    returns (Point[100] memory Line);

Parameters

NameTypeDescription
cfgConfigMaster art config metadata of a veNFT
lint256Number of wormhole drawn

Returns

NameTypeDescription
LinePoint[100](x, y) coordinates of the drawn wormhole

Structs

Config

Art configuration

struct Config {
    int256 _tokenId;
    int256 _balanceOf;
    int256 _lockedEnd;
    int256 _lockedAmount;
    int256 shape;
    uint256 palette;
    int256 maxLines;
    int256 dash;
    int256 seed1;
    int256 seed2;
    int256 seed3;
}

lineConfig

Individual line art path variables.

struct lineConfig {
    bytes8 color;
    uint256 stroke;
    uint256 offset;
    uint256 offsetHalf;
    uint256 offsetDashSum;
    uint256 pathLength;
}

Point

Represents an (x,y) coordinate in a line.

struct Point {
    int256 x;
    int256 y;
}

IVoter

Git Source

Interface for Infrared's voting system that manages votes for POL CuttingBoard allocation and bribe vault creation

Handles voting power allocation, managed veNFT deposits, and bribe distribution

Functions

ve

Returns the VotingEscrow contract address

function ve() external view returns (address);

Returns

NameTypeDescription
<none>addressAddress of the VE token that governs these contracts

totalWeight

Returns total voting weight across all votes

function totalWeight() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Total weight sum of all active votes

maxVotingNum

Returns maximum number of staking tokens one voter can vote for

function maxVotingNum() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Maximum number of allowed votes per voter

feeVault

Returns global fee distribution vault address

function feeVault() external view returns (address);

Returns

NameTypeDescription
<none>addressAddress of the fee vault

bribeVaults

Returns bribe vault address for a given staking token

function bribeVaults(address stakingToken) external view returns (address);

Parameters

NameTypeDescription
stakingTokenaddressAddress of staking token

Returns

NameTypeDescription
<none>addressAddress of associated bribe vault

weights

Returns total weight allocated to a staking token

function weights(address stakingToken) external view returns (uint256);

Parameters

NameTypeDescription
stakingTokenaddressAddress of staking token

Returns

NameTypeDescription
<none>uint256Total voting weight for the token

votes

Returns vote weight allocated by token ID for specific staking token

function votes(uint256 tokenId, address stakingToken)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
tokenIduint256NFT token ID
stakingTokenaddressAddress of staking token

Returns

NameTypeDescription
<none>uint256Vote weight allocated

usedWeights

Returns total vote weight used by specific token ID

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

Parameters

NameTypeDescription
tokenIduint256NFT token ID

Returns

NameTypeDescription
<none>uint256Total used voting weight

lastVoted

Returns timestamp of last vote for a token ID

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

Parameters

NameTypeDescription
tokenIduint256NFT token ID

Returns

NameTypeDescription
<none>uint256Timestamp of last vote

isWhitelistedToken

Checks if a token is whitelisted for rewards

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

Parameters

NameTypeDescription
tokenaddressAddress of token to check

Returns

NameTypeDescription
<none>boolTrue if token is whitelisted

isWhitelistedNFT

Checks if NFT is whitelisted for special voting

function isWhitelistedNFT(uint256 tokenId) external view returns (bool);

Parameters

NameTypeDescription
tokenIduint256NFT token ID to check

Returns

NameTypeDescription
<none>boolTrue if NFT is whitelisted

isAlive

Checks if bribe vault is active

function isAlive(address bribeVault) external view returns (bool);

Parameters

NameTypeDescription
bribeVaultaddressAddress of bribe vault to check

Returns

NameTypeDescription
<none>boolTrue if vault is active

length

Returns number of staking tokens with active bribe vaults

function length() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Count of staking tokens with bribe vaults

epochStart

Calculates start of epoch containing timestamp

function epochStart(uint256 _timestamp) external pure returns (uint256);

Parameters

NameTypeDescription
_timestampuint256Input timestamp

Returns

NameTypeDescription
<none>uint256Start of epoch time

epochNext

Calculates start of next epoch after timestamp

function epochNext(uint256 _timestamp) external pure returns (uint256);

Parameters

NameTypeDescription
_timestampuint256Input timestamp

Returns

NameTypeDescription
<none>uint256Start of next epoch time

epochVoteStart

Calculates start of voting window for epoch containing timestamp

function epochVoteStart(uint256 _timestamp) external pure returns (uint256);

Parameters

NameTypeDescription
_timestampuint256Input timestamp

Returns

NameTypeDescription
<none>uint256Vote window start time

epochVoteEnd

Calculates end of voting window for epoch containing timestamp

function epochVoteEnd(uint256 _timestamp) external pure returns (uint256);

Parameters

NameTypeDescription
_timestampuint256Input timestamp

Returns

NameTypeDescription
<none>uint256Vote window end time

poke

Updates voting balances in rewards contracts for a token ID

Should be called after any action that affects vote weight

function poke(uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to update

vote

Distributes voting weight to multiple staking tokens

Weight is allocated proportionally based on provided weights

function vote(
    uint256 _tokenId,
    address[] calldata _stakingTokenVote,
    uint256[] calldata _weights
) external;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID voting with
_stakingTokenVoteaddress[]Array of staking token addresses receiving votes
_weightsuint256[]Array of weights to allocate to each token

reset

Resets voting state for a token ID

Required before making changes to veNFT state

function reset(uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to reset

depositManaged

Deposits veNFT into a managed NFT

NFT will be re-locked to max time on withdrawal

function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to deposit
_mTokenIduint256Managed NFT token ID to deposit into

withdrawManaged

Withdraws veNFT from a managed NFT

Withdrawing locks NFT to max lock time

function withdrawManaged(uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to withdraw

claimBribes

Claims bribes from multiple sources for a veNFT

function claimBribes(
    address[] memory _bribes,
    address[][] memory _tokens,
    uint256 _tokenId
) external;

Parameters

NameTypeDescription
_bribesaddress[]Array of bribe vault addresses to claim from
_tokensaddress[][]Array of reward tokens to claim for each vault
_tokenIduint256veNFT token ID to claim for

claimFees

Claims fee rewards for a veNFT

function claimFees(address[] memory _tokens, uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokensaddress[]Array of fee tokens to claim
_tokenIduint256veNFT token ID to claim for

setMaxVotingNum

Updates maximum allowed votes per voter

function setMaxVotingNum(uint256 _maxVotingNum) external;

Parameters

NameTypeDescription
_maxVotingNumuint256New maximum number of allowed votes

whitelistNFT

Updates whitelist status for veNFT for privileged voting

function whitelistNFT(uint256 _tokenId, bool _bool) external;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to update
_boolboolNew whitelist status

createBribeVault

Creates new bribe vault for staking token

function createBribeVault(
    address _stakingToken,
    address[] calldata _rewardTokens
) external returns (address);

Parameters

NameTypeDescription
_stakingTokenaddressAddress of staking token
_rewardTokensaddress[]Array of reward token addresses

Returns

NameTypeDescription
<none>addressAddress of created bribe vault

killBribeVault

Disables a bribe vault

function killBribeVault(address _stakingToken) external;

Parameters

NameTypeDescription
_stakingTokenaddressAddress of staking token for vault to disable

reviveBribeVault

Re-enables a disabled bribe vault

function reviveBribeVault(address _stakingToken) external;

Parameters

NameTypeDescription
_stakingTokenaddressAddress of staking token for vault to re-enable

Events

BribeVaultCreated

Emitted when a new bribe vault is created

event BribeVaultCreated(
    address stakingToken, address bribeVault, address creator
);

Parameters

NameTypeDescription
stakingTokenaddressThe staking token address for which the vault was created
bribeVaultaddressThe address of the newly created bribe vault
creatoraddressThe address that created the bribe vault

BribeVaultKilled

Emitted when a bribe vault is killed (disabled)

event BribeVaultKilled(address indexed bribeVault);

Parameters

NameTypeDescription
bribeVaultaddressThe address of the killed bribe vault

BribeVaultRevived

Emitted when a killed bribe vault is revived (re-enabled)

event BribeVaultRevived(address indexed bribeVault);

Parameters

NameTypeDescription
bribeVaultaddressThe address of the revived bribe vault

Voted

Emitted when votes are cast for a staking token

event Voted(
    address indexed voter,
    address indexed stakingToken,
    uint256 indexed tokenId,
    uint256 weight,
    uint256 totalWeight,
    uint256 timestamp
);

Parameters

NameTypeDescription
voteraddressAddress of the account casting the vote
stakingTokenaddressThe staking token being voted for
tokenIduint256ID of the veNFT used to vote
weightuint256Vote weight allocated
totalWeightuint256New total vote weight for the staking token
timestampuint256Block timestamp when vote was cast

Abstained

Emitted when votes are withdrawn/reset

event Abstained(
    address indexed voter,
    address indexed stakingToken,
    uint256 indexed tokenId,
    uint256 weight,
    uint256 totalWeight,
    uint256 timestamp
);

Parameters

NameTypeDescription
voteraddressAddress of the account withdrawing votes
stakingTokenaddressThe staking token votes are withdrawn from
tokenIduint256ID of the veNFT used to vote
weightuint256Vote weight withdrawn
totalWeightuint256New total vote weight for the staking token
timestampuint256Block timestamp when votes were withdrawn

WhitelistNFT

Emitted when an NFT's whitelist status changes

event WhitelistNFT(
    address indexed whitelister, uint256 indexed tokenId, bool indexed _bool
);

Parameters

NameTypeDescription
whitelisteraddressAddress making the whitelist change
tokenIduint256ID of the NFT being whitelisted/unwhitelisted
_boolboolNew whitelist status

SkipKilledBribeVault

Emitted when a killed bribe vault is skipped

event SkipKilledBribeVault(
    address indexed stakingToken, uint256 indexed tokenId
);

Parameters

NameTypeDescription
stakingTokenaddressAddress of staking token for vault to skip
tokenIduint256ID of the veNFT used to vote

MaxVotingNumSet

Emitted when maximum voting number is set

event MaxVotingNumSet(uint256 indexed maxVotingNum);

Parameters

NameTypeDescription
maxVotingNumuint256New maximum number of allowed votes

Errors

AlreadyVotedOrDeposited

error AlreadyVotedOrDeposited();

BribeVaultAlreadyKilled

error BribeVaultAlreadyKilled();

BribeVaultAlreadyRevived

error BribeVaultAlreadyRevived();

BribeVaultExists

error BribeVaultExists();

BribeVaultDoesNotExist

error BribeVaultDoesNotExist(address _stakingToken);

BribeVaultNotAlive

error BribeVaultNotAlive(address _stakingToken);

InactiveManagedNFT

error InactiveManagedNFT();

MaximumVotingNumberTooLow

error MaximumVotingNumberTooLow();

NonZeroVotes

error NonZeroVotes();

NotAStakingToken

error NotAStakingToken();

NotApprovedOrOwner

error NotApprovedOrOwner();

NotWhitelistedNFT

error NotWhitelistedNFT();

NotWhitelistedToken

error NotWhitelistedToken();

SameValue

error SameValue();

SpecialVotingWindow

error SpecialVotingWindow();

TooManyStakingTokens

error TooManyStakingTokens();

UnequalLengths

error UnequalLengths();

ZeroBalance

error ZeroBalance();

ZeroAddress

error ZeroAddress();

VaultNotRegistered

error VaultNotRegistered();

NotGovernor

error NotGovernor();

DistributeWindow

error DistributeWindow();

IVotes

Git Source

Modified IVotes interface for tokenId based voting

Functions

getPastVotes

Returns the amount of votes that tokenId had at a specific moment in the past. If the account passed in is not the owner, returns 0.

function getPastVotes(address account, uint256 tokenId, uint256 timepoint)
    external
    view
    returns (uint256);

getPastTotalSupply

Returns the total supply of votes available at a specific moment in the past. If the clock() is configured to use block numbers, this will return the value the end of the corresponding block. NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes. Votes that have not been delegated are still part of total supply, even though they would not participate in a vote.

function getPastTotalSupply(uint256 timepoint)
    external
    view
    returns (uint256);

delegates

Returns the delegate that tokenId has chosen. Can never be equal to the delegator's tokenId. Returns 0 if not delegated.

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

delegate

Delegates votes from the sender to delegatee.

function delegate(uint256 delegator, uint256 delegatee) external;

delegateBySig

Delegates votes from delegator to delegatee. Signer must own delegator.

function delegateBySig(
    uint256 delegator,
    uint256 delegatee,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
) external;

Events

DelegateChanged

Emitted when an account changes their delegate.

event DelegateChanged(
    address indexed delegator,
    uint256 indexed fromDelegate,
    uint256 indexed toDelegate
);

DelegateVotesChanged

Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.

event DelegateVotesChanged(
    address indexed delegate, uint256 previousBalance, uint256 newBalance
);

IVotingEscrow

Git Source

Inherits: IVotes, IERC4906, IERC6372, IERC721Metadata

Functions

token

Address of token (RED) used to create a veNFT

function token() external view returns (address);

distributor

Address of RewardsDistributor.sol

function distributor() external view returns (address);

voter

Address of Voter.sol

function voter() external view returns (address);

artProxy

Address of art proxy used for on-chain art generation

function artProxy() external view returns (address);

allowedManager

address which can create managed NFTs

function allowedManager() external view returns (address);

tokenId

Current count of token

function tokenId() external view returns (uint256);

infrared

Address of Infrared contract

function infrared() external view returns (IInfraredUpgradeable);

Returns

NameTypeDescription
<none>IInfraredUpgradeableIInfrared instance of contract address

escrowType

Mapping of token id to escrow type Takes advantage of the fact default value is EscrowType.NORMAL

function escrowType(uint256 tokenId) external view returns (EscrowType);

idToManaged

Mapping of token id to managed id

function idToManaged(uint256 tokenId)
    external
    view
    returns (uint256 managedTokenId);

weights

Mapping of user token id to managed token id to weight of token id

function weights(uint256 tokenId, uint256 managedTokenId)
    external
    view
    returns (uint256 weight);

deactivated

Mapping of managed id to deactivated state

function deactivated(uint256 tokenId) external view returns (bool inactive);

createManagedLockFor

Create managed NFT (a permanent lock) for use within ecosystem.

Throws if address already owns a managed NFT.

function createManagedLockFor(address _to)
    external
    returns (uint256 _mTokenId);

Returns

NameTypeDescription
_mTokenIduint256managed token id.

depositManaged

Delegates balance to managed nft Note that NFTs deposited into a managed NFT will be re-locked to the maximum lock time on withdrawal. Permanent locks that are deposited will automatically unlock.

Managed nft will remain max-locked as long as there is at least one deposit or withdrawal per week. Throws if deposit nft is managed. Throws if recipient nft is not managed. Throws if deposit nft is already locked. Throws if not called by voter.

function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;

Parameters

NameTypeDescription
_tokenIduint256tokenId of NFT being deposited
_mTokenIduint256tokenId of managed NFT that will receive the deposit

withdrawManaged

Retrieves locked rewards and withdraws balance from managed nft. Note that the NFT withdrawn is re-locked to the maximum lock time.

Throws if NFT not locked. Throws if not called by voter.

function withdrawManaged(uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokenIduint256tokenId of NFT being deposited.

setAllowedManager

Permit one address to call createManagedLockFor() that is not Voter.governor()

function setAllowedManager(address _allowedManager) external;

setManagedState

Set Managed NFT state. Inactive NFTs cannot be deposited into.

function setManagedState(uint256 _mTokenId, bool _state) external;

Parameters

NameTypeDescription
_mTokenIduint256managed nft state to set
_statebooltrue => inactive, false => active

name

function name() external view returns (string memory);

symbol

function symbol() external view returns (string memory);

version

function version() external view returns (string memory);

decimals

function decimals() external view returns (uint8);

setArtProxy

function setArtProxy(address _proxy) external;

tokenURI

A distinct Uniform Resource Identifier (URI) for a given asset.

Throws if _tokenId is not a valid NFT. URIs are defined in RFC 3986. The URI may point to a JSON file that conforms to the "ERC721 Metadata JSON Schema".

function tokenURI(uint256 tokenId) external view returns (string memory);

ownerToNFTokenIdList

Mapping from owner address to mapping of index to tokenId

function ownerToNFTokenIdList(address _owner, uint256 _index)
    external
    view
    returns (uint256 _tokenId);

ownerOf

Find the owner of an NFT

NFTs assigned to zero address are considered invalid, and queries about them do throw.

function ownerOf(uint256 tokenId) external view returns (address owner);

Parameters

NameTypeDescription
tokenIduint256

Returns

NameTypeDescription
owneraddressThe address of the owner of the NFT

balanceOf

Count all NFTs assigned to an owner

NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.

function balanceOf(address owner) external view returns (uint256 balance);

Parameters

NameTypeDescription
owneraddress

Returns

NameTypeDescription
balanceuint256The number of NFTs owned by _owner, possibly zero

getApproved

Get the approved address for a single NFT

Throws if _tokenId is not a valid NFT.

function getApproved(uint256 _tokenId)
    external
    view
    returns (address operator);

Parameters

NameTypeDescription
_tokenIduint256The NFT to find the approved address for

Returns

NameTypeDescription
operatoraddressThe approved address for this NFT, or the zero address if there is none

isApprovedForAll

Query if an address is an authorized operator for another address

function isApprovedForAll(address owner, address operator)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
owneraddress
operatoraddress

Returns

NameTypeDescription
<none>boolTrue if _operator is an approved operator for _owner, false otherwise

isApprovedOrOwner

Check whether spender is owner or an approved user for a given veNFT

function isApprovedOrOwner(address _spender, uint256 _tokenId)
    external
    returns (bool);

Parameters

NameTypeDescription
_spenderaddress.
_tokenIduint256.

approve

Change or reaffirm the approved address for an NFT

The zero address indicates there is no approved address. Throws unless msg.sender is the current NFT owner, or an authorized operator of the current owner.

function approve(address to, uint256 tokenId) external;

Parameters

NameTypeDescription
toaddress
tokenIduint256

setApprovalForAll

Enable or disable approval for a third party ("operator") to manage all of msg.sender's assets

Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.

function setApprovalForAll(address operator, bool approved) external;

Parameters

NameTypeDescription
operatoraddress
approvedbool

transferFrom

Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE THEY MAY BE PERMANENTLY LOST

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT.

function transferFrom(address from, address to, uint256 tokenId) external;

Parameters

NameTypeDescription
fromaddress
toaddress
tokenIduint256

safeTransferFrom

Transfers the ownership of an NFT from one address to another address

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT. When transfer is complete, this function checks if _to is a smart contract (code size > 0). If so, it calls onERC721Received on _to and throws if the return value is not bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).

function safeTransferFrom(address from, address to, uint256 tokenId) external;

Parameters

NameTypeDescription
fromaddress
toaddress
tokenIduint256

safeTransferFrom

Transfers the ownership of an NFT from one address to another address

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT. When transfer is complete, this function checks if _to is a smart contract (code size > 0). If so, it calls onERC721Received on _to and throws if the return value is not bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).

function safeTransferFrom(
    address from,
    address to,
    uint256 tokenId,
    bytes calldata data
) external;

Parameters

NameTypeDescription
fromaddress
toaddress
tokenIduint256
databytesAdditional data with no specified format, sent in call to _to

supportsInterface

Query if a contract implements an interface

Interface identification is specified in ERC-165. This function uses less than 30,000 gas.

function supportsInterface(bytes4 _interfaceID) external view returns (bool);

Parameters

NameTypeDescription
_interfaceIDbytes4

Returns

NameTypeDescription
<none>booltrue if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise

epoch

Total count of epochs witnessed since contract creation

function epoch() external view returns (uint256);

supply

Total amount of token() deposited

function supply() external view returns (uint256);

permanentLockBalance

Aggregate permanent locked balances

function permanentLockBalance() external view returns (uint256);

userPointEpoch

function userPointEpoch(uint256 _tokenId)
    external
    view
    returns (uint256 _epoch);

slopeChanges

time -> signed slope change

function slopeChanges(uint256 _timestamp) external view returns (int128);

canSplit

account -> can split

function canSplit(address _account) external view returns (bool);

pointHistory

Global point history at a given index

function pointHistory(uint256 _loc)
    external
    view
    returns (GlobalPoint memory);

locked

Get the LockedBalance (amount, end) of a _tokenId

function locked(uint256 _tokenId)
    external
    view
    returns (LockedBalance memory);

Parameters

NameTypeDescription
_tokenIduint256.

Returns

NameTypeDescription
<none>LockedBalanceLockedBalance of _tokenId

userPointHistory

User -> UserPoint[userEpoch]

function userPointHistory(uint256 _tokenId, uint256 _loc)
    external
    view
    returns (UserPoint memory);

checkpoint

Record global data to checkpoint

function checkpoint() external;

depositFor

Deposit _value tokens for _tokenId and add to the lock

Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user

function depositFor(uint256 _tokenId, uint256 _value) external;

Parameters

NameTypeDescription
_tokenIduint256lock NFT
_valueuint256Amount to add to user's lock

createLock

Deposit _value tokens for msg.sender and lock for _lockDuration

function createLock(uint256 _value, uint256 _lockDuration)
    external
    returns (uint256);

Parameters

NameTypeDescription
_valueuint256Amount to deposit
_lockDurationuint256Number of seconds to lock tokens for (rounded down to nearest week)

Returns

NameTypeDescription
<none>uint256TokenId of created veNFT

createLockFor

Deposit _value tokens for _to and lock for _lockDuration

function createLockFor(uint256 _value, uint256 _lockDuration, address _to)
    external
    returns (uint256);

Parameters

NameTypeDescription
_valueuint256Amount to deposit
_lockDurationuint256Number of seconds to lock tokens for (rounded down to nearest week)
_toaddressAddress to deposit

Returns

NameTypeDescription
<none>uint256TokenId of created veNFT

increaseAmount

Deposit _value additional tokens for _tokenId without modifying the unlock time

function increaseAmount(uint256 _tokenId, uint256 _value) external;

Parameters

NameTypeDescription
_tokenIduint256
_valueuint256Amount of tokens to deposit and add to the lock

increaseUnlockTime

Extend the unlock time for _tokenId Cannot extend lock time of permanent locks

function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external;

Parameters

NameTypeDescription
_tokenIduint256
_lockDurationuint256New number of seconds until tokens unlock

withdraw

Withdraw all tokens for _tokenId

Only possible if the lock is both expired and not permanent This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.

function withdraw(uint256 _tokenId) external;

merge

Merges _from into _to.

Cannot merge _from locks that are permanent or have already voted this epoch. Cannot merge _to locks that have already expired. This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.

function merge(uint256 _from, uint256 _to) external;

Parameters

NameTypeDescription
_fromuint256VeNFT to merge from.
_touint256VeNFT to merge into.

split

Splits veNFT into two new veNFTS - one with oldLocked.amount - _amount, and the second with _amount

This burns the tokenId of the target veNFT Callable by approved or owner If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs Returns the two new split veNFTs to owner If from is permanent, will automatically dedelegate. This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.

function split(uint256 _from, uint256 _amount)
    external
    returns (uint256 _tokenId1, uint256 _tokenId2);

Parameters

NameTypeDescription
_fromuint256VeNFT to split.
_amountuint256Amount to split from veNFT.

Returns

NameTypeDescription
_tokenId1uint256Return tokenId of veNFT with oldLocked.amount - _amount.
_tokenId2uint256Return tokenId of veNFT with _amount.

toggleSplit

Toggle split for a specific address.

Toggle split for address(0) to enable or disable for all.

function toggleSplit(address _account, bool _bool) external;

Parameters

NameTypeDescription
_accountaddressAddress to toggle split permissions
_boolboolTrue to allow, false to disallow

lockPermanent

Permanently lock a veNFT. Voting power will be equal to LockedBalance.amount with no decay. Required to delegate.

Only callable by unlocked normal veNFTs.

function lockPermanent(uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokenIduint256tokenId to lock.

unlockPermanent

Unlock a permanently locked veNFT. Voting power will decay. Will automatically dedelegate if delegated.

Only callable by permanently locked veNFTs. Cannot unlock if already voted this epoch.

function unlockPermanent(uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokenIduint256tokenId to unlock.

balanceOfNFT

Get the voting power for _tokenId at the current timestamp

Returns 0 if called in the same block as a transfer.

function balanceOfNFT(uint256 _tokenId) external view returns (uint256);

Parameters

NameTypeDescription
_tokenIduint256.

Returns

NameTypeDescription
<none>uint256Voting power

balanceOfNFTAt

Get the voting power for _tokenId at a given timestamp

function balanceOfNFTAt(uint256 _tokenId, uint256 _t)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_tokenIduint256.
_tuint256Timestamp to query voting power

Returns

NameTypeDescription
<none>uint256Voting power

totalSupply

Calculate total voting power at current timestamp

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Total voting power at current timestamp

totalSupplyAt

Calculate total voting power at a given timestamp

function totalSupplyAt(uint256 _t) external view returns (uint256);

Parameters

NameTypeDescription
_tuint256Timestamp to query total voting power

Returns

NameTypeDescription
<none>uint256Total voting power at given timestamp

voted

See if a queried _tokenId has actively voted

function voted(uint256 _tokenId) external view returns (bool);

Parameters

NameTypeDescription
_tokenIduint256.

Returns

NameTypeDescription
<none>boolTrue if voted, else false

setVoterAndDistributor

Set the global state voter and distributor

This is only called once, at setup

function setVoterAndDistributor(address _voter, address _distributor)
    external;

voting

Set voted for _tokenId to true or false

Only callable by voter

function voting(uint256 _tokenId, bool _voted) external;

Parameters

NameTypeDescription
_tokenIduint256.
_votedbool.

numCheckpoints

The number of checkpoints for each tokenId

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

nonces

A record of states for signing / validating signatures

function nonces(address account) external view returns (uint256);

delegates

Returns the delegate that tokenId has chosen. Can never be equal to the delegator's tokenId. Returns 0 if not delegated.

function delegates(uint256 delegator) external view returns (uint256);

checkpoints

A record of delegated token checkpoints for each account, by index

function checkpoints(uint256 tokenId, uint48 index)
    external
    view
    returns (Checkpoint memory);

Parameters

NameTypeDescription
tokenIduint256.
indexuint48.

Returns

NameTypeDescription
<none>CheckpointCheckpoint

getPastVotes

Returns the amount of votes that tokenId had at a specific moment in the past. If the account passed in is not the owner, returns 0.

function getPastVotes(address account, uint256 tokenId, uint256 timestamp)
    external
    view
    returns (uint256);

getPastTotalSupply

Returns the total supply of votes available at a specific moment in the past. If the clock() is configured to use block numbers, this will return the value the end of the corresponding block. NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes. Votes that have not been delegated are still part of total supply, even though they would not participate in a vote.

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

delegate

Delegates votes from the sender to delegatee.

function delegate(uint256 delegator, uint256 delegatee) external;

delegateBySig

Delegates votes from delegator to delegatee. Signer must own delegator.

function delegateBySig(
    uint256 delegator,
    uint256 delegatee,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
) external;

clock

Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).

function clock() external view returns (uint48);

CLOCK_MODE

Description of the clock

function CLOCK_MODE() external view returns (string memory);

Events

Deposit

event Deposit(
    address indexed provider,
    uint256 indexed tokenId,
    DepositType indexed depositType,
    uint256 value,
    uint256 locktime,
    uint256 ts
);

Withdraw

event Withdraw(
    address indexed provider, uint256 indexed tokenId, uint256 value, uint256 ts
);

LockPermanent

event LockPermanent(
    address indexed _owner,
    uint256 indexed _tokenId,
    uint256 amount,
    uint256 _ts
);

UnlockPermanent

event UnlockPermanent(
    address indexed _owner,
    uint256 indexed _tokenId,
    uint256 amount,
    uint256 _ts
);

Supply

event Supply(uint256 prevSupply, uint256 supply);

Merge

event Merge(
    address indexed _sender,
    uint256 indexed _from,
    uint256 indexed _to,
    uint256 _amountFrom,
    uint256 _amountTo,
    uint256 _amountFinal,
    uint256 _locktime,
    uint256 _ts
);

Split

event Split(
    uint256 indexed _from,
    uint256 indexed _tokenId1,
    uint256 indexed _tokenId2,
    address _sender,
    uint256 _splitAmount1,
    uint256 _splitAmount2,
    uint256 _locktime,
    uint256 _ts
);

CreateManaged

event CreateManaged(
    address indexed _to, uint256 indexed _mTokenId, address indexed _from
);

DepositManaged

event DepositManaged(
    address indexed _owner,
    uint256 indexed _tokenId,
    uint256 indexed _mTokenId,
    uint256 _weight,
    uint256 _ts
);

WithdrawManaged

event WithdrawManaged(
    address indexed _owner,
    uint256 indexed _tokenId,
    uint256 indexed _mTokenId,
    uint256 _weight,
    uint256 _ts
);

SetAllowedManager

event SetAllowedManager(address indexed _allowedManager);

ToggleSplit

event ToggleSplit(address indexed account, bool indexed canSplit);

VoterAndDistributorSet

event VoterAndDistributorSet(
    address indexed voter, address indexed distributor
);

Errors

AlreadyVoted

error AlreadyVoted();

AmountTooBig

error AmountTooBig();

ERC721ReceiverRejectedTokens

error ERC721ReceiverRejectedTokens();

ERC721TransferToNonERC721ReceiverImplementer

error ERC721TransferToNonERC721ReceiverImplementer();

InvalidNonce

error InvalidNonce();

InvalidSignature

error InvalidSignature();

InvalidSignatureS

error InvalidSignatureS();

InvalidManagedNFTId

error InvalidManagedNFTId();

LockDurationNotInFuture

error LockDurationNotInFuture();

LockDurationTooLong

error LockDurationTooLong();

LockExpired

error LockExpired();

LockNotExpired

error LockNotExpired();

NoLockFound

error NoLockFound();

NonExistentToken

error NonExistentToken();

NotApprovedOrOwner

error NotApprovedOrOwner();

NotDistributor

error NotDistributor();

NotEmergencyCouncilOrGovernor

error NotEmergencyCouncilOrGovernor();

NotGovernor

error NotGovernor();

NotGovernorOrManager

error NotGovernorOrManager();

NotManagedNFT

error NotManagedNFT();

NotManagedOrNormalNFT

error NotManagedOrNormalNFT();

NotLockedNFT

error NotLockedNFT();

NotNormalNFT

error NotNormalNFT();

NotPermanentLock

error NotPermanentLock();

NotOwner

error NotOwner();

NotTeam

error NotTeam();

NotVoter

error NotVoter();

OwnershipChange

error OwnershipChange();

PermanentLock

error PermanentLock();

SameAddress

error SameAddress();

SameNFT

error SameNFT();

SameState

error SameState();

SplitNoOwner

error SplitNoOwner();

SplitNotAllowed

error SplitNotAllowed();

SignatureExpired

error SignatureExpired();

TooManyTokenIDs

error TooManyTokenIDs();

ZeroAddress

error ZeroAddress();

ZeroAmount

error ZeroAmount();

ZeroBalance

error ZeroBalance();

Structs

LockedBalance

Represents a locked token balance in the voting escrow system

struct LockedBalance {
    int128 amount;
    uint256 end;
    bool isPermanent;
}

Properties

NameTypeDescription
amountint128The amount of tokens locked by the user
enduint256The expiration timestamp for the lock
isPermanentboolFlag indicating if the lock is permanent

UserPoint

Represents a snapshot of a user's voting power at a given point

struct UserPoint {
    int128 bias;
    int128 slope;
    uint256 ts;
    uint256 blk;
    uint256 permanent;
}

Properties

NameTypeDescription
biasint128Voting power, decaying over time
slopeint128Rate of decay of voting power
tsuint256Timestamp of this snapshot
blkuint256Block number of this snapshot
permanentuint256Amount locked permanently without decay

GlobalPoint

Tracks cumulative voting power and its decay across all users

struct GlobalPoint {
    int128 bias;
    int128 slope;
    uint256 ts;
    uint256 blk;
    uint256 permanentLockBalance;
}

Properties

NameTypeDescription
biasint128Total voting power, decaying over time
slopeint128Global decay rate of voting power
tsuint256Timestamp of this global checkpoint
blkuint256Block number of this global checkpoint
permanentLockBalanceuint256Cumulative balance of permanently locked tokens

Checkpoint

Snapshot of delegated voting weights at a particular timestamp

struct Checkpoint {
    uint256 fromTimestamp;
    address owner;
    uint256 delegatedBalance;
    uint256 delegatee;
}

Properties

NameTypeDescription
fromTimestampuint256Timestamp when the delegation was made
owneraddressAddress of the NFT owner
delegatedBalanceuint256Balance that has been delegated
delegateeuint256Address receiving the delegated voting power

Enums

DepositType

Types of deposits supported in the voting escrow contract

enum DepositType {
    DEPOSIT_FOR_TYPE,
    CREATE_LOCK_TYPE,
    INCREASE_LOCK_AMOUNT,
    INCREASE_UNLOCK_TIME
}

EscrowType

Specifies the type of voting escrow NFT (veNFT)

enum EscrowType {
    NORMAL,
    LOCKED,
    MANAGED
}

Contents

BalanceLogicLibrary

Git Source

State Variables

WEEK

uint256 internal constant WEEK = 1 weeks;

Functions

getPastUserPointIndex

Binary search to get the user point index for a token id at or prior to a given timestamp

If a user point does not exist prior to the timestamp, this will return 0.

function getPastUserPointIndex(
    mapping(uint256 => uint256) storage _userPointEpoch,
    mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage
        _userPointHistory,
    uint256 _tokenId,
    uint256 _timestamp
) internal view returns (uint256);

Parameters

NameTypeDescription
_userPointEpochmapping(uint256 => uint256)State of all user point epochs
_userPointHistorymapping(uint256 => IVotingEscrow.UserPoint[1000000000])State of all user point history
_tokenIduint256.
_timestampuint256.

Returns

NameTypeDescription
<none>uint256User point index

getPastGlobalPointIndex

Binary search to get the global point index at or prior to a given timestamp

If a checkpoint does not exist prior to the timestamp, this will return 0.

function getPastGlobalPointIndex(
    uint256 _epoch,
    mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,
    uint256 _timestamp
) internal view returns (uint256);

Parameters

NameTypeDescription
_epochuint256Current global point epoch
_pointHistorymapping(uint256 => IVotingEscrow.GlobalPoint)State of all global point history
_timestampuint256.

Returns

NameTypeDescription
<none>uint256Global point index

balanceOfNFTAt

Get the current voting power for _tokenId

Adheres to the ERC20 balanceOf interface for Aragon compatibility Although only true of curve, but not solidly and its forks. Fetches last user point prior to a certain timestamp, then walks forward to timestamp.

function balanceOfNFTAt(
    mapping(uint256 => uint256) storage _userPointEpoch,
    mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage
        _userPointHistory,
    uint256 _tokenId,
    uint256 _t
) external view returns (uint256);

Parameters

NameTypeDescription
_userPointEpochmapping(uint256 => uint256)State of all user point epochs
_userPointHistorymapping(uint256 => IVotingEscrow.UserPoint[1000000000])State of all user point history
_tokenIduint256NFT for lock
_tuint256Epoch time to return voting power at

Returns

NameTypeDescription
<none>uint256User voting power

supplyAt

Calculate total voting power at some point in the past

function supplyAt(
    mapping(uint256 => int128) storage _slopeChanges,
    mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,
    uint256 _epoch,
    uint256 _t
) external view returns (uint256);

Parameters

NameTypeDescription
_slopeChangesmapping(uint256 => int128)State of all slopeChanges
_pointHistorymapping(uint256 => IVotingEscrow.GlobalPoint)State of all global point history
_epochuint256The epoch to start search from
_tuint256Time to calculate the total voting power at

Returns

NameTypeDescription
<none>uint256Total voting power at that time

DelegationLogicLibrary

Git Source

Functions

checkpointDelegator

Used by _mint, _transferFrom, _burn and delegate to update delegator voting checkpoints. Automatically dedelegates, then updates checkpoint.

This function depends on _locked and must be called prior to token state changes. If you wish to dedelegate only, use _delegate(tokenId, 0) instead.

function checkpointDelegator(
    mapping(uint256 => IVotingEscrow.LockedBalance) storage _locked,
    mapping(uint256 => uint48) storage _numCheckpoints,
    mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
        _checkpoints,
    mapping(uint256 => uint256) storage _delegates,
    uint256 _delegator,
    uint256 _delegatee,
    address _owner
) external;

Parameters

NameTypeDescription
_lockedmapping(uint256 => IVotingEscrow.LockedBalance)State of all locked balances
_numCheckpointsmapping(uint256 => uint48)State of all user checkpoint counts
_checkpointsmapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint))State of all user checkpoints
_delegatesmapping(uint256 => uint256)State of all user delegatees
_delegatoruint256The delegator to update checkpoints for
_delegateeuint256The new delegatee for the delegator. Cannot be equal to _delegator (use 0 instead).
_owneraddressThe new (or current) owner for the delegator

checkpointDelegatee

Update delegatee's delegatedBalance by balance. Only updates if delegating to a new delegatee.

If used with balance == _locked[_tokenId].amount, then this is the same as delegating or dedelegating from _tokenId If used with balance < _locked[_tokenId].amount, then this is used to adjust delegatedBalance when a user's balance is modified (e.g. increaseAmount, merge etc). If delegatee is 0 (i.e. user is not delegating), then do nothing.

function checkpointDelegatee(
    mapping(uint256 => uint48) storage _numCheckpoints,
    mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
        _checkpoints,
    uint256 _delegatee,
    uint256 balance_,
    bool _increase
) public;

Parameters

NameTypeDescription
_numCheckpointsmapping(uint256 => uint48)State of all user checkpoint counts
_checkpointsmapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint))State of all user checkpoints
_delegateeuint256The delegatee's tokenId
balance_uint256The delta in balance change
_increaseboolTrue if balance is increasing, false if decreasing

_isCheckpointInNewBlock

function _isCheckpointInNewBlock(
    mapping(uint256 => uint48) storage _numCheckpoints,
    mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
        _checkpoints,
    uint256 _tokenId
) internal view returns (bool);

getPastVotesIndex

Binary search to get the voting checkpoint for a token id at or prior to a given timestamp.

If a checkpoint does not exist prior to the timestamp, this will return 0.

function getPastVotesIndex(
    mapping(uint256 => uint48) storage _numCheckpoints,
    mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
        _checkpoints,
    uint256 _tokenId,
    uint256 _timestamp
) internal view returns (uint48);

Parameters

NameTypeDescription
_numCheckpointsmapping(uint256 => uint48)State of all user checkpoint counts
_checkpointsmapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint))State of all user checkpoints
_tokenIduint256.
_timestampuint256.

Returns

NameTypeDescription
<none>uint48The index of the checkpoint.

getPastVotes

Retrieves historical voting balance for a token id at a given timestamp.

If a checkpoint does not exist prior to the timestamp, this will return 0. The user must also own the token at the time in order to receive a voting balance.

function getPastVotes(
    mapping(uint256 => uint48) storage _numCheckpoints,
    mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
        _checkpoints,
    address _account,
    uint256 _tokenId,
    uint256 _timestamp
) external view returns (uint256);

Parameters

NameTypeDescription
_numCheckpointsmapping(uint256 => uint48)State of all user checkpoint counts
_checkpointsmapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint))State of all user checkpoints
_accountaddress.
_tokenIduint256.
_timestampuint256.

Returns

NameTypeDescription
<none>uint256Total voting balance including delegations at a given timestamp.

VelodromeTimeLibrary

Git Source

State Variables

WEEK

uint256 internal constant WEEK = 7 days;

Functions

epochStart

Calculate the start of the current epoch based on the timestamp provided

Epochs are aligned to weekly intervals, with each epoch starting at midnight UTC.

function epochStart(uint256 timestamp) internal pure returns (uint256);

Parameters

NameTypeDescription
timestampuint256The current timestamp to align

Returns

NameTypeDescription
<none>uint256The start timestamp of the epoch week

epochNext

Calculate the start of the next epoch or end of the current epoch

Returns the timestamp at the start of the next weekly epoch following the given timestamp.

function epochNext(uint256 timestamp) internal pure returns (uint256);

Parameters

NameTypeDescription
timestampuint256The current timestamp

Returns

NameTypeDescription
<none>uint256The start timestamp of the next epoch

epochVoteStart

Determine the start of the voting window for the current epoch

Voting windows start one hour into the weekly epoch.

function epochVoteStart(uint256 timestamp) internal pure returns (uint256);

Parameters

NameTypeDescription
timestampuint256The timestamp to calculate from

Returns

NameTypeDescription
<none>uint256The start timestamp of the voting window within the epoch

epochVoteEnd

Calculate the end of the voting window within the current epoch

Voting windows close one hour before the next epoch begins.

function epochVoteEnd(uint256 timestamp) internal pure returns (uint256);

Parameters

NameTypeDescription
timestampuint256The timestamp to calculate from

Returns

NameTypeDescription
<none>uint256The end timestamp of the voting window within the epoch

Contents

BribeVotingReward

Git Source

Inherits: VotingReward

Implementation of voting rewards for bribes based on user votes

Final implementation of voting rewards specifically for bribe distribution

Functions

constructor

Initializes bribe voting rewards

constructor(address _voter, address[] memory _rewards)
    VotingReward(_voter, _rewards);

Parameters

NameTypeDescription
_voteraddressAddress of voter contract
_rewardsaddress[]Initial array of reward token addresses

notifyRewardAmount

Validates and whitelists reward tokens before processing

function notifyRewardAmount(address token, uint256 amount)
    external
    override
    nonReentrant;

removeNoLongerWhitelistedTokens

Removes tokens from the rewards list that are no longer whitelisted

function removeNoLongerWhitelistedTokens(address[] calldata tokens) external;

Parameters

NameTypeDescription
tokensaddress[]The list of tokens to remove

Events

NoLongerWhitelistedTokenRemoved

event NoLongerWhitelistedTokenRemoved(address indexed token);

Reward

Git Source

Inherits: IReward, ReentrancyGuard

Author: velodrome.finance, @figs999, @pegahcarter

Base implementation for reward distribution contracts

Abstract contract providing core reward distribution functionality

State Variables

DURATION

Duration of each reward epoch in seconds

uint256 public constant DURATION = 7 days;

voter

Address of the Voter contract that manages rewards

address public immutable voter;

ve

Address of the VotingEscrow contract that manages veNFTs

address public immutable ve;

authorized

Address permitted to call privileged state-changing functions

address public immutable authorized;

totalSupply

Total amount of staking tokens locked in contract

uint256 public totalSupply;

supplyNumCheckpoints

Total number of supply checkpoints recorded

uint256 public supplyNumCheckpoints;

rewards

List of all reward tokens supported by this contract

Used for token enumeration and management

address[] public rewards;

balanceOf

Retrieves current staked balance for a veNFT

mapping(uint256 => uint256) public balanceOf;

tokenRewardsPerEpoch

Gets reward amount allocated for a specific epoch

mapping(address => mapping(uint256 => uint256)) public tokenRewardsPerEpoch;

lastEarn

Retrieves timestamp of last reward claim for a veNFT

mapping(address => mapping(uint256 => uint256)) public lastEarn;

isReward

Checks if a token is configured as a reward token

mapping(address => bool) public isReward;

checkpoints

A record of balance checkpoints for each account, by index

mapping(uint256 => mapping(uint256 => Checkpoint)) public checkpoints;

numCheckpoints

Number of balance checkpoints for a veNFT

mapping(uint256 => uint256) public numCheckpoints;

supplyCheckpoints

A record of balance checkpoints for each token, by index

mapping(uint256 => SupplyCheckpoint) public supplyCheckpoints;

Functions

constructor

Initializes reward contract with voter address

constructor(address _voter);

Parameters

NameTypeDescription
_voteraddressAddress of voter contract managing rewards

getPriorBalanceIndex

Gets historical balance index for a veNFT at timestamp

Uses binary search to find checkpoint index

function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp)
    public
    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) public view returns (uint256);

Parameters

NameTypeDescription
timestampuint256Time to query supply at

Returns

NameTypeDescription
<none>uint256Index of nearest checkpoint before timestamp

_writeCheckpoint

Writes user checkpoint with updated balance

Updates or creates checkpoint based on epoch timing

function _writeCheckpoint(uint256 tokenId, uint256 balance) internal;

Parameters

NameTypeDescription
tokenIduint256ID of veNFT to checkpoint
balanceuint256New balance to record

_writeSupplyCheckpoint

Writes global supply checkpoint

Updates or creates checkpoint based on epoch timing

function _writeSupplyCheckpoint() internal;

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) public 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
    virtual
    nonReentrant;

Parameters

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

_getReward

Internal helper for processing reward claims

Calculates and transfers earned rewards to recipient

function _getReward(address recipient, uint256 tokenId, address[] memory tokens)
    internal;

Parameters

NameTypeDescription
recipientaddressAddress to receive claimed rewards
tokenIduint256ID of veNFT claiming rewards
tokensaddress[]Array of reward tokens to claim

notifyRewardAmount

Adds new reward tokens for distribution

Transfers tokens from caller and updates reward accounting

function notifyRewardAmount(address token, uint256 amount)
    external
    virtual
    nonReentrant;

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

_notifyRewardAmount

Internal helper for adding rewards

Transfers tokens and updates reward accounting

function _notifyRewardAmount(address sender, address token, uint256 amount)
    internal;

Parameters

NameTypeDescription
senderaddressAddress providing reward tokens
tokenaddressAddress of reward token
amountuint256Amount of tokens to add as rewards

VotingReward

Git Source

Inherits: Reward

Base contract for rewards distributed based on voting power

Extends Reward with voting-specific reward logic

Functions

constructor

Configures voting rewards with initial reward tokens

constructor(address _voter, address[] memory _rewards) Reward(_voter);

Parameters

NameTypeDescription
_voteraddressAddress of voter contract
_rewardsaddress[]Initial array of reward token addresses

getReward

Validates caller is token owner or voter before processing claim

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

notifyRewardAmount

function notifyRewardAmount(address token, uint256 amount)
    external
    virtual
    override
    nonReentrant;

Voter

Git Source

Inherits: IVoter, InfraredUpgradeable, ReentrancyGuardUpgradeable

Author: Modified from Velodrome (https://github.com/velodrome-finance/contracts/blob/main/contracts/Voter.sol)

Ensure new epoch before voting and manage staking tokens and bribe vaults.

This contract manages votes for POL CuttingBoard allocation and respective bribeVault creation. It also provides support for depositing and withdrawing from managed veNFTs. Inspired by Velodrome V2 Voter.

State Variables

ve

Returns the VotingEscrow contract address

address public ve;

totalWeight

Returns total voting weight across all votes

uint256 public totalWeight;

maxVotingNum

Returns maximum number of staking tokens one voter can vote for

uint256 public maxVotingNum;

MIN_MAXVOTINGNUM

Minimum allowed value for maximum voting number

Used as validation threshold in setMaxVotingNum

uint256 internal constant MIN_MAXVOTINGNUM = 1;

feeVault

Returns global fee distribution vault address

address public feeVault;

stakingTokens

Internal array of all staking tokens with active bribe vaults Used for token enumeration and state tracking

address[] public stakingTokens;

bribeVaults

Returns bribe vault address for a given staking token

mapping(address => address) public bribeVaults;

weights

Returns total weight allocated to a staking token

mapping(address => uint256) public weights;

votes

Returns vote weight allocated by token ID for specific staking token

mapping(uint256 => mapping(address => uint256)) public votes;

stakingTokenVote

NFT => List of stakingTokens voted for by NFT

mapping(uint256 => address[]) public stakingTokenVote;

usedWeights

Returns total vote weight used by specific token ID

mapping(uint256 => uint256) public usedWeights;

lastVoted

Returns timestamp of last vote for a token ID

mapping(uint256 => uint256) public lastVoted;

isWhitelistedNFT

Checks if NFT is whitelisted for special voting

mapping(uint256 => bool) public isWhitelistedNFT;

isAlive

Checks if bribe vault is active

mapping(address => bool) public isAlive;

Functions

onlyNewEpoch

Ensures operations only occur in new epochs and outside distribution window

Validates both epoch transition and proper timing within epoch

modifier onlyNewEpoch(uint256 _tokenId);

Parameters

NameTypeDescription
_tokenIduint256The token ID to check last vote timestamp for

epochStart

Calculates start of epoch containing timestamp

function epochStart(uint256 _timestamp) external pure returns (uint256);

Parameters

NameTypeDescription
_timestampuint256Input timestamp

Returns

NameTypeDescription
<none>uint256Start of epoch time

epochNext

Calculates start of next epoch after timestamp

function epochNext(uint256 _timestamp) external pure returns (uint256);

Parameters

NameTypeDescription
_timestampuint256Input timestamp

Returns

NameTypeDescription
<none>uint256Start of next epoch time

epochVoteStart

Calculates start of voting window for epoch containing timestamp

function epochVoteStart(uint256 _timestamp) external pure returns (uint256);

Parameters

NameTypeDescription
_timestampuint256Input timestamp

Returns

NameTypeDescription
<none>uint256Vote window start time

epochVoteEnd

Calculates end of voting window for epoch containing timestamp

function epochVoteEnd(uint256 _timestamp) external pure returns (uint256);

Parameters

NameTypeDescription
_timestampuint256Input timestamp

Returns

NameTypeDescription
<none>uint256Vote window end time

constructor

Constructor for Voter contract

Reverts if infrared address is zero

constructor(address _infrared) InfraredUpgradeable(_infrared);

Parameters

NameTypeDescription
_infraredaddressAddress of the Infrared contract

initialize

Initializes the Voter contract with the voting escrow and fee vault

Sets up initial state including fee vault with configured reward tokens

function initialize(address _ve, address _gov, address _keeper)
    external
    initializer;

Parameters

NameTypeDescription
_veaddressAddress of the voting escrow contract
_govaddressAddress of the governance multisig
_keeperaddressAddress of the keeper

setMaxVotingNum

Updates maximum allowed votes per voter

function setMaxVotingNum(uint256 _maxVotingNum) external onlyGovernor;

Parameters

NameTypeDescription
_maxVotingNumuint256New maximum number of allowed votes

reset

Resets voting state for a token ID

Required before making changes to veNFT state

function reset(uint256 _tokenId) external onlyNewEpoch(_tokenId) nonReentrant;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to reset

_reset

Resets vote state for a token ID

Cleans up all vote accounting and emits appropriate events

function _reset(uint256 _tokenId) internal;

Parameters

NameTypeDescription
_tokenIduint256Token ID to reset voting state for

poke

Updates voting balances in rewards contracts for a token ID

Should be called after any action that affects vote weight

function poke(uint256 _tokenId) external nonReentrant;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to update

_poke

Updates voting power for a token ID

Recalculates and updates all vote weightings

function _poke(uint256 _tokenId, uint256 _weight) internal;

Parameters

NameTypeDescription
_tokenIduint256Token ID to update voting power for
_weightuint256New voting power weight to apply

_vote

Core voting logic to allocate weights to staking tokens

Handles vote accounting, reward deposits and event emissions

*Implementation sequence:

  1. Reset all existing votes and accounting via _reset
  2. Calculate total vote weight for normalizing allocations
  3. For each staking token:
  • Validate bribe vault exists and is active
  • Calculate and apply normalized vote weight
  • Update token-specific accounting
  • Deposit into bribe vault
  1. Update global vote accounting if votes were cast
  2. If _isPoke is true, skip processing for tokens with killed bribe vaults*
function _vote(
    uint256 _tokenId,
    uint256 _weight,
    address[] memory _stakingTokenVote,
    uint256[] memory _weights,
    bool _isPoke
) internal;

Parameters

NameTypeDescription
_tokenIduint256Token ID that is voting
_weightuint256Total voting power weight available
_stakingTokenVoteaddress[]Array of staking tokens to vote for
_weightsuint256[]Array of weights to allocate to each token
_isPokeboolif fees should be deposited in addition to marking tokenId as voted

vote

Distributes voting weight to multiple staking tokens

Weight is allocated proportionally based on provided weights

function vote(
    uint256 _tokenId,
    address[] calldata _stakingTokenVote,
    uint256[] calldata _weights
) external onlyNewEpoch(_tokenId) nonReentrant;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID voting with
_stakingTokenVoteaddress[]Array of staking token addresses receiving votes
_weightsuint256[]Array of weights to allocate to each token

depositManaged

Deposits veNFT into a managed NFT

NFT will be re-locked to max time on withdrawal

function depositManaged(uint256 _tokenId, uint256 _mTokenId)
    external
    nonReentrant
    onlyNewEpoch(_tokenId);

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to deposit
_mTokenIduint256Managed NFT token ID to deposit into

withdrawManaged

Withdraws veNFT from a managed NFT

Withdrawing locks NFT to max lock time

function withdrawManaged(uint256 _tokenId)
    external
    nonReentrant
    onlyNewEpoch(_tokenId);

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to withdraw

isWhitelistedToken

Checks if a token is whitelisted for rewards

function isWhitelistedToken(address _token) external view returns (bool);

Parameters

NameTypeDescription
_tokenaddress

Returns

NameTypeDescription
<none>boolTrue if token is whitelisted

whitelistNFT

Updates whitelist status for veNFT for privileged voting

function whitelistNFT(uint256 _tokenId, bool _bool) external onlyGovernor;

Parameters

NameTypeDescription
_tokenIduint256veNFT token ID to update
_boolboolNew whitelist status

createBribeVault

Creates new bribe vault for staking token

function createBribeVault(address _stakingToken, address[] calldata _rewards)
    external
    onlyKeeper
    nonReentrant
    whenInitialized
    returns (address);

Parameters

NameTypeDescription
_stakingTokenaddressAddress of staking token
_rewardsaddress[]

Returns

NameTypeDescription
<none>addressAddress of created bribe vault

killBribeVault

Disables a bribe vault

function killBribeVault(address _stakingToken) external onlyGovernor;

Parameters

NameTypeDescription
_stakingTokenaddressAddress of staking token for vault to disable

reviveBribeVault

Re-enables a disabled bribe vault

function reviveBribeVault(address _stakingToken) external onlyGovernor;

Parameters

NameTypeDescription
_stakingTokenaddressAddress of staking token for vault to re-enable

length

Returns number of staking tokens with active bribe vaults

function length() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Count of staking tokens with bribe vaults

claimBribes

Claims bribes from multiple sources for a veNFT

function claimBribes(
    address[] memory _bribes,
    address[][] memory _tokens,
    uint256 _tokenId
) external;

Parameters

NameTypeDescription
_bribesaddress[]Array of bribe vault addresses to claim from
_tokensaddress[][]Array of reward tokens to claim for each vault
_tokenIduint256veNFT token ID to claim for

claimFees

Claims fee rewards for a veNFT

function claimFees(address[] memory _tokens, uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokensaddress[]Array of fee tokens to claim
_tokenIduint256veNFT token ID to claim for

getStakingTokenWeights

Returns all staking tokens and their current voting weights

Helper function that aggregates staking token data

function getStakingTokenWeights()
    public
    view
    returns (
        address[] memory _stakingTokens,
        uint256[] memory _weights,
        uint256 _totalWeight
    );

Returns

NameTypeDescription
_stakingTokensaddress[]Array of staking token addresses
_weightsuint256[]Array of voting weights corresponding to each token
_totalWeightuint256Sum of all voting weights

VotingEscrow

Git Source

Inherits: IVotingEscrow, ReentrancyGuard

Authors: Modified from Solidly (https://github.com/solidlyexchange/solidly/blob/master/contracts/ve.sol), Modified from Curve (https://github.com/curvefi/curve-dao-contracts/blob/master/contracts/VotingEscrow.vy), Modified from velodrome.finance (https://github.com/velodrome-finance/contracts/blob/main/contracts/VotingEscrow.sol)

veNFT implementation that escrows ERC-20 tokens in the form of an ERC-721 NFT

Votes have a weight depending on time, so that users are committed to the future of (whatever they are voting for)

Vote weight decays linearly over time. Lock time cannot be more than MAXTIME (4 years).

State Variables

keeper

address public immutable keeper;

token

Address of token (RED) used to create a veNFT

address public immutable token;

distributor

Address of RewardsDistributor.sol

address public distributor;

voter

Address of Voter.sol

address public voter;

artProxy

Address of art proxy used for on-chain art generation

address public artProxy;

allowedManager

address which can create managed NFTs

address public allowedManager;

_pointHistory

mapping(uint256 => GlobalPoint) internal _pointHistory;

supportedInterfaces

Mapping of interface id to bool about whether or not it's supported

mapping(bytes4 => bool) internal supportedInterfaces;

ERC165_INTERFACE_ID

ERC165 interface ID of ERC165

bytes4 internal constant ERC165_INTERFACE_ID = 0x01ffc9a7;

ERC721_INTERFACE_ID

ERC165 interface ID of ERC721

bytes4 internal constant ERC721_INTERFACE_ID = 0x80ac58cd;

ERC721_METADATA_INTERFACE_ID

ERC165 interface ID of ERC721Metadata

bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f;

ERC4906_INTERFACE_ID

ERC165 interface ID of ERC4906

bytes4 internal constant ERC4906_INTERFACE_ID = 0x49064906;

ERC6372_INTERFACE_ID

ERC165 interface ID of ERC6372

bytes4 internal constant ERC6372_INTERFACE_ID = 0xda287a1d;

tokenId

Current count of token

uint256 public tokenId;

infrared

Address of Infrared contract

IInfraredUpgradeable public immutable infrared;

escrowType

Mapping of token id to escrow type Takes advantage of the fact default value is EscrowType.NORMAL

mapping(uint256 => EscrowType) public escrowType;

idToManaged

Mapping of token id to managed id

mapping(uint256 => uint256) public idToManaged;

weights

Mapping of user token id to managed token id to weight of token id

mapping(uint256 => mapping(uint256 => uint256)) public weights;

deactivated

Mapping of managed id to deactivated state

mapping(uint256 => bool) public deactivated;

name

string public constant name = "veNFT";

symbol

string public constant symbol = "veNFT";

version

string public constant version = "2.0.0";

decimals

uint8 public constant decimals = 18;

idToOwner

Mapping from NFT ID to the address that owns it.

mapping(uint256 => address) internal idToOwner;

ownerToNFTokenCount

Mapping from owner address to count of his tokens.

mapping(address => uint256) internal ownerToNFTokenCount;

idToApprovals

Mapping from NFT ID to approved address.

mapping(uint256 => address) internal idToApprovals;

ownerToOperators

Mapping from owner address to mapping of operator addresses.

mapping(address => mapping(address => bool)) internal ownerToOperators;

ownershipChange

mapping(uint256 => uint256) internal ownershipChange;

ownerToNFTokenIdList

Mapping from owner address to mapping of index to tokenId

mapping(address => mapping(uint256 => uint256)) public ownerToNFTokenIdList;

tokenToOwnerIndex

Mapping from NFT ID to index of owner

mapping(uint256 => uint256) internal tokenToOwnerIndex;

WEEK

uint256 internal constant WEEK = 1 weeks;

MAXTIME

uint256 internal constant MAXTIME = 4 * 365 * 86400;

iMAXTIME

int128 internal constant iMAXTIME = 4 * 365 * 86400;

MULTIPLIER

uint256 internal constant MULTIPLIER = 1 ether;

epoch

Total count of epochs witnessed since contract creation

uint256 public epoch;

supply

Total amount of token() deposited

uint256 public supply;

_locked

mapping(uint256 => LockedBalance) internal _locked;

_userPointHistory

mapping(uint256 => UserPoint[1000000000]) internal _userPointHistory;

userPointEpoch

mapping(uint256 => uint256) public userPointEpoch;

slopeChanges

time -> signed slope change

mapping(uint256 => int128) public slopeChanges;

canSplit

account -> can split

mapping(address => bool) public canSplit;

permanentLockBalance

Aggregate permanent locked balances

uint256 public permanentLockBalance;

voted

See if a queried _tokenId has actively voted

mapping(uint256 => bool) public voted;

DOMAIN_TYPEHASH

The EIP-712 typehash for the contract's domain

bytes32 public constant DOMAIN_TYPEHASH = keccak256(
    "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);

DELEGATION_TYPEHASH

The EIP-712 typehash for the delegation struct used by the contract

bytes32 public constant DELEGATION_TYPEHASH = keccak256(
    "Delegation(uint256 delegator,uint256 delegatee,uint256 nonce,uint256 expiry)"
);

_delegates

A record of each accounts delegate

mapping(uint256 => uint256) private _delegates;

_checkpoints

A record of delegated token checkpoints for each tokenId, by index

mapping(uint256 => mapping(uint48 => Checkpoint)) private _checkpoints;

numCheckpoints

The number of checkpoints for each tokenId

mapping(uint256 => uint48) public numCheckpoints;

nonces

A record of states for signing / validating signatures

mapping(address => uint256) public nonces;

Functions

constructor

Initializes VotingEscrow contract

constructor(address _keeper, address _token, address _voter, address _infrared);

Parameters

NameTypeDescription
_keeperaddressAddress of keeper contract
_tokenaddressAddress of token (RED) used to create a veNFT
_voteraddressAddress of Voter contract
_infraredaddressAddress of Infrared contract

createManagedLockFor

Create managed NFT (a permanent lock) for use within ecosystem.

Throws if address already owns a managed NFT.

function createManagedLockFor(address _to)
    external
    nonReentrant
    returns (uint256 _mTokenId);

Returns

NameTypeDescription
_mTokenIduint256managed token id.

depositManaged

Delegates balance to managed nft Note that NFTs deposited into a managed NFT will be re-locked to the maximum lock time on withdrawal. Permanent locks that are deposited will automatically unlock.

Managed nft will remain max-locked as long as there is at least one deposit or withdrawal per week. Throws if deposit nft is managed. Throws if recipient nft is not managed. Throws if deposit nft is already locked. Throws if not called by voter.

function depositManaged(uint256 _tokenId, uint256 _mTokenId)
    external
    nonReentrant;

Parameters

NameTypeDescription
_tokenIduint256tokenId of NFT being deposited
_mTokenIduint256tokenId of managed NFT that will receive the deposit

withdrawManaged

Retrieves locked rewards and withdraws balance from managed nft. Note that the NFT withdrawn is re-locked to the maximum lock time.

Throws if NFT not locked. Throws if not called by voter.

function withdrawManaged(uint256 _tokenId) external nonReentrant;

Parameters

NameTypeDescription
_tokenIduint256tokenId of NFT being deposited.

setAllowedManager

Permit one address to call createManagedLockFor() that is not Voter.governor()

function setAllowedManager(address _allowedManager) external;

setManagedState

Set Managed NFT state. Inactive NFTs cannot be deposited into.

function setManagedState(uint256 _mTokenId, bool _state) external;

Parameters

NameTypeDescription
_mTokenIduint256managed nft state to set
_statebooltrue => inactive, false => active

setArtProxy

function setArtProxy(address _proxy) external;

tokenURI

function tokenURI(uint256 _tokenId) external view returns (string memory);

_ownerOf

function _ownerOf(uint256 _tokenId) internal view returns (address);

ownerOf

function ownerOf(uint256 _tokenId) external view returns (address);

balanceOf

function balanceOf(address _owner) external view returns (uint256);

getApproved

function getApproved(uint256 _tokenId) external view returns (address);

isApprovedForAll

function isApprovedForAll(address _owner, address _operator)
    external
    view
    returns (bool);

isApprovedOrOwner

Check whether spender is owner or an approved user for a given veNFT

function isApprovedOrOwner(address _spender, uint256 _tokenId)
    external
    view
    returns (bool);

Parameters

NameTypeDescription
_spenderaddress.
_tokenIduint256.

_isApprovedOrOwner

function _isApprovedOrOwner(address _spender, uint256 _tokenId)
    internal
    view
    returns (bool);

approve

function approve(address _approved, uint256 _tokenId) external;

setApprovalForAll

function setApprovalForAll(address _operator, bool _approved) external;

_transferFrom

function _transferFrom(
    address _from,
    address _to,
    uint256 _tokenId,
    address _sender
) internal;

transferFrom

function transferFrom(address _from, address _to, uint256 _tokenId) external;

safeTransferFrom

function safeTransferFrom(address _from, address _to, uint256 _tokenId)
    external;

_isContract

function _isContract(address account) internal view returns (bool);

safeTransferFrom

function safeTransferFrom(
    address _from,
    address _to,
    uint256 _tokenId,
    bytes memory _data
) public;

supportsInterface

function supportsInterface(bytes4 _interfaceID) external view returns (bool);

_addTokenToOwnerList

Add a NFT to an index mapping to a given address

function _addTokenToOwnerList(address _to, uint256 _tokenId) internal;

Parameters

NameTypeDescription
_toaddressaddress of the receiver
_tokenIduint256uint ID Of the token to be added

_addTokenTo

Add a NFT to a given address Throws if _tokenId is owned by someone.

function _addTokenTo(address _to, uint256 _tokenId) internal;

_mint

Function to mint tokens Throws if _to is zero address. Throws if _tokenId is owned by someone.

function _mint(address _to, uint256 _tokenId) internal returns (bool);

Parameters

NameTypeDescription
_toaddressThe address that will receive the minted tokens.
_tokenIduint256The token id to mint.

Returns

NameTypeDescription
<none>boolA boolean that indicates if the operation was successful.

_removeTokenFromOwnerList

Remove a NFT from an index mapping to a given address

function _removeTokenFromOwnerList(address _from, uint256 _tokenId) internal;

Parameters

NameTypeDescription
_fromaddressaddress of the sender
_tokenIduint256uint ID Of the token to be removed

_removeTokenFrom

Remove a NFT from a given address Throws if _from is not the current owner.

function _removeTokenFrom(address _from, uint256 _tokenId) internal;

_burn

Must be called prior to updating LockedBalance

function _burn(uint256 _tokenId) internal;

locked

Get the LockedBalance (amount, end) of a _tokenId

function locked(uint256 _tokenId)
    external
    view
    returns (LockedBalance memory);

Parameters

NameTypeDescription
_tokenIduint256.

Returns

NameTypeDescription
<none>LockedBalanceLockedBalance of _tokenId

userPointHistory

User -> UserPoint[userEpoch]

function userPointHistory(uint256 _tokenId, uint256 _loc)
    external
    view
    returns (UserPoint memory);

pointHistory

Global point history at a given index

function pointHistory(uint256 _loc)
    external
    view
    returns (GlobalPoint memory);

_checkpoint

Record global and per-user data to checkpoints. Used by VotingEscrow system.

function _checkpoint(
    uint256 _tokenId,
    LockedBalance memory _oldLocked,
    LockedBalance memory _newLocked
) internal;

Parameters

NameTypeDescription
_tokenIduint256NFT token ID. No user checkpoint if 0
_oldLockedLockedBalancePevious locked amount / end lock time for the user
_newLockedLockedBalanceNew locked amount / end lock time for the user

_depositFor

Deposit and lock tokens for a user

function _depositFor(
    uint256 _tokenId,
    uint256 _value,
    uint256 _unlockTime,
    LockedBalance memory _oldLocked,
    DepositType _depositType
) internal;

Parameters

NameTypeDescription
_tokenIduint256NFT that holds lock
_valueuint256Amount to deposit
_unlockTimeuint256New time when to unlock the tokens, or 0 if unchanged
_oldLockedLockedBalancePrevious locked amount / timestamp
_depositTypeDepositTypeThe type of deposit

checkpoint

Record global data to checkpoint

function checkpoint() external nonReentrant;

depositFor

Deposit _value tokens for _tokenId and add to the lock

Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user

function depositFor(uint256 _tokenId, uint256 _value) external nonReentrant;

Parameters

NameTypeDescription
_tokenIduint256lock NFT
_valueuint256Amount to add to user's lock

_createLock

Deposit _value tokens for _to and lock for _lockDuration

function _createLock(uint256 _value, uint256 _lockDuration, address _to)
    internal
    returns (uint256);

Parameters

NameTypeDescription
_valueuint256Amount to deposit
_lockDurationuint256Number of seconds to lock tokens for (rounded down to nearest week)
_toaddressAddress to deposit

createLock

Deposit _value tokens for msg.sender and lock for _lockDuration

function createLock(uint256 _value, uint256 _lockDuration)
    external
    nonReentrant
    returns (uint256);

Parameters

NameTypeDescription
_valueuint256Amount to deposit
_lockDurationuint256Number of seconds to lock tokens for (rounded down to nearest week)

Returns

NameTypeDescription
<none>uint256TokenId of created veNFT

createLockFor

Deposit _value tokens for _to and lock for _lockDuration

function createLockFor(uint256 _value, uint256 _lockDuration, address _to)
    external
    nonReentrant
    returns (uint256);

Parameters

NameTypeDescription
_valueuint256Amount to deposit
_lockDurationuint256Number of seconds to lock tokens for (rounded down to nearest week)
_toaddressAddress to deposit

Returns

NameTypeDescription
<none>uint256TokenId of created veNFT

_increaseAmountFor

function _increaseAmountFor(
    uint256 _tokenId,
    uint256 _value,
    DepositType _depositType
) internal;

increaseAmount

Deposit _value additional tokens for _tokenId without modifying the unlock time

function increaseAmount(uint256 _tokenId, uint256 _value)
    external
    nonReentrant;

Parameters

NameTypeDescription
_tokenIduint256
_valueuint256Amount of tokens to deposit and add to the lock

increaseUnlockTime

Extend the unlock time for _tokenId Cannot extend lock time of permanent locks

function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration)
    external
    nonReentrant;

Parameters

NameTypeDescription
_tokenIduint256
_lockDurationuint256New number of seconds until tokens unlock

withdraw

Withdraw all tokens for _tokenId

Only possible if the lock is both expired and not permanent This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.

function withdraw(uint256 _tokenId) external nonReentrant;

merge

Merges _from into _to.

Cannot merge _from locks that are permanent or have already voted this epoch. Cannot merge _to locks that have already expired. This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.

function merge(uint256 _from, uint256 _to) external nonReentrant;

Parameters

NameTypeDescription
_fromuint256VeNFT to merge from.
_touint256VeNFT to merge into.

split

Splits veNFT into two new veNFTS - one with oldLocked.amount - _amount, and the second with _amount

This burns the tokenId of the target veNFT Callable by approved or owner If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs Returns the two new split veNFTs to owner If from is permanent, will automatically dedelegate. This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.

function split(uint256 _from, uint256 _amount)
    external
    nonReentrant
    returns (uint256 _tokenId1, uint256 _tokenId2);

Parameters

NameTypeDescription
_fromuint256VeNFT to split.
_amountuint256Amount to split from veNFT.

Returns

NameTypeDescription
_tokenId1uint256Return tokenId of veNFT with oldLocked.amount - _amount.
_tokenId2uint256Return tokenId of veNFT with _amount.

_createSplitNFT

function _createSplitNFT(address _to, LockedBalance memory _newLocked)
    private
    returns (uint256 _tokenId);

toggleSplit

Toggle split for a specific address.

Toggle split for address(0) to enable or disable for all.

function toggleSplit(address _account, bool _bool) external;

Parameters

NameTypeDescription
_accountaddressAddress to toggle split permissions
_boolboolTrue to allow, false to disallow

lockPermanent

Permanently lock a veNFT. Voting power will be equal to LockedBalance.amount with no decay. Required to delegate.

Only callable by unlocked normal veNFTs.

function lockPermanent(uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokenIduint256tokenId to lock.

unlockPermanent

Unlock a permanently locked veNFT. Voting power will decay. Will automatically dedelegate if delegated.

Only callable by permanently locked veNFTs. Cannot unlock if already voted this epoch.

function unlockPermanent(uint256 _tokenId) external;

Parameters

NameTypeDescription
_tokenIduint256tokenId to unlock.

_balanceOfNFTAt

function _balanceOfNFTAt(uint256 _tokenId, uint256 _t)
    internal
    view
    returns (uint256);

_supplyAt

function _supplyAt(uint256 _timestamp) internal view returns (uint256);

balanceOfNFT

Get the voting power for _tokenId at the current timestamp

Returns 0 if called in the same block as a transfer.

function balanceOfNFT(uint256 _tokenId) public view returns (uint256);

Parameters

NameTypeDescription
_tokenIduint256.

Returns

NameTypeDescription
<none>uint256Voting power

balanceOfNFTAt

Get the voting power for _tokenId at a given timestamp

function balanceOfNFTAt(uint256 _tokenId, uint256 _t)
    external
    view
    returns (uint256);

Parameters

NameTypeDescription
_tokenIduint256.
_tuint256Timestamp to query voting power

Returns

NameTypeDescription
<none>uint256Voting power

totalSupply

Calculate total voting power at current timestamp

function totalSupply() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256Total voting power at current timestamp

totalSupplyAt

Calculate total voting power at a given timestamp

function totalSupplyAt(uint256 _timestamp) external view returns (uint256);

Parameters

NameTypeDescription
_timestampuint256

Returns

NameTypeDescription
<none>uint256Total voting power at given timestamp

setVoterAndDistributor

Set the global state voter and distributor

This is only called once, at setup

function setVoterAndDistributor(address _voter, address _distributor)
    external;

voting

Set voted for _tokenId to true or false

Only callable by voter

function voting(uint256 _tokenId, bool _voted) external;

Parameters

NameTypeDescription
_tokenIduint256.
_votedbool.

delegates

function delegates(uint256 delegator) external view returns (uint256);

checkpoints

A record of delegated token checkpoints for each account, by index

function checkpoints(uint256 _tokenId, uint48 _index)
    external
    view
    returns (Checkpoint memory);

Parameters

NameTypeDescription
_tokenIduint256
_indexuint48

Returns

NameTypeDescription
<none>CheckpointCheckpoint

getPastVotes

function getPastVotes(address _account, uint256 _tokenId, uint256 _timestamp)
    external
    view
    returns (uint256);

getPastTotalSupply

function getPastTotalSupply(uint256 _timestamp)
    external
    view
    returns (uint256);

_checkpointDelegator

function _checkpointDelegator(
    uint256 _delegator,
    uint256 _delegatee,
    address _owner
) internal;

_checkpointDelegatee

function _checkpointDelegatee(
    uint256 _delegatee,
    uint256 balance_,
    bool _increase
) internal;

_delegate

Record user delegation checkpoints. Used by voting system.

Skips delegation if already delegated to delegatee.

function _delegate(uint256 _delegator, uint256 _delegatee) internal;

delegate

function delegate(uint256 delegator, uint256 delegatee) external;

delegateBySig

function delegateBySig(
    uint256 delegator,
    uint256 delegatee,
    uint256 nonce,
    uint256 expiry,
    uint8 v,
    bytes32 r,
    bytes32 s
) external;

clock

function clock() external view returns (uint48);

CLOCK_MODE

function CLOCK_MODE() external pure returns (string memory);