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

IRateProvider

Git Source

Functions

getRate

getRate()

Returns the current rate of a given asset.

function getRate() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256uint256 The current rate of the asset.

InfraredBERARateProvider

Git Source

Inherits: IRateProvider

Returns the value of iBERA in terms of BERA

State Variables

ibera

The address of the ibera contract

IInfraredBERA public immutable ibera;

Functions

constructor

Constructs the MevETHRateProvider contract, setting the mevETH address

constructor(IInfraredBERA _ibera);

getRate

Returns the value of iBERA in terms of BERA

function getRate() external view override returns (uint256);

Returns

NameTypeDescription
<none>uint256amount the value of iBERA in terms of BERA

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

UNIT_DENOMINATOR

Unit denominotor for calculating all fees and rates in the system

All fees and rates are calculated out of 1e6

uint256 internal constant UNIT_DENOMINATOR = 1e6;

Functions

harvestOperatorRewards

Harvest rewards given to our operators for setting their cuttingboard weights ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/staking/InfraredBERAFeeReceivor.sol#L83

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

Parameters

NameTypeDescription
$RewardsStorageThe storage pointer for all rewards accumulators
iberaaddressThe address of the InfraredBERA token
voteraddressThe address of the voter (address(0) if IR token is not live)
distributoraddressThe address of the distributor

Returns

NameTypeDescription
_amtuint256The amount of rewards harvested

chargedFeesOnRewards

The amount of rewards going to the protocol treasury

Generic function to calculate the fees charged on rewards, returning the amount owed to the recipient, protocol, and voter.

the recepient is the amount of rewards being sent forward into the protocol for example a vault

function chargedFeesOnRewards(
    uint256 amount,
    uint256 totalFeeRate,
    uint256 protocolFeeRate
)
    public
    pure
    returns (uint256 recepient, uint256 voterFees, uint256 protocolFees);

Parameters

NameTypeDescription
amountuint256The amount of rewards to calculate fees on
totalFeeRateuint256The total fee rate to charge on rewards (protocol + voter)
protocolFeeRateuint256The rate to charge for protocol fees

Returns

NameTypeDescription
recepientuint256The amount of rewards to send to the recipient
voterFeesuint256The amount of rewards to send to the voter
protocolFeesuint256The amount of rewards to send to the protocol

_distributeFeesOnRewards

Distributes fees on rewards to the protocol, voter, and recipient.

_protocolFeeAmounts The accumulator for protocol fees per token

_voter The address of the voter

_token The address of the reward token

_amtVoter The amount of rewards for the voter

_amtProtocol The amount of rewards for the protocol

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

_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
$RewardsStorageRewardsStorage The storage pointer for all rewards accumulators.
_vaultIInfraredVaultIInfraredVault The address of the vault.
_tokenaddressaddress The reward token.
voteraddressaddress The address of the voter.
_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.
rewardsDurationuint256uint256 The duration of the rewards.

updateIRMintRate

Update the IR minting rate for the protocol.

This rate determines how many IR tokens are minted whenever BGT rewards are harvested.

For example, if the rate is 500,000 (0.5 * UNIT_DENOMINATOR), 0.5 IR is minted per BGT.

If the rate is 2,000,000 (2 * UNIT_DENOMINATOR), 2 IR are minted per BGT.

The actuall calculation is done in the harvestVault function when BGT rewards are harvested and IR tokens are minted accordingly.

function updateIRMintRate(RewardsStorage storage $, uint256 newRate) external;

Parameters

NameTypeDescription
$RewardsStorageThe storage pointer for all rewards accumulators
newRateuint256The new IR minting rate out of UNIT_DENOMINATOR(1e6 being 100% or a 1:1 rate)

delegateBGT

Delegates Berachain Governance Voting Power to a delegatee

function delegateBGT(address _delegatee, address bgt) external;

Parameters

NameTypeDescription
_delegateeaddressThe address to delegate voting power to
bgtaddressThe address of the BGT token

updateInfraredBERABribeSplit

Update the split ratio for iBERA and iBGT rewards

function updateInfraredBERABribeSplit(RewardsStorage storage $, uint256 _split)
    external;

Parameters

NameTypeDescription
$RewardsStorageThe storage pointer for all rewards accumulators
_splituint256The ratio for splitting received bribes to be iBERA and iBGT, weighted towards iBERA

updateFee

Update the fee rate for a given fee type

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

Parameters

NameTypeDescription
$RewardsStorageThe storage pointer for all rewards accumulators
_tConfigTypes.FeeTypeThe fee type to update
_feeuint256The new fee rate

claimProtocolFees

Claim protocol fees for a given token

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

Parameters

NameTypeDescription
$RewardsStorageThe storage pointer for all rewards accumulators
_toaddressThe address to send the protocol fees to
_tokenaddressThe token to claim protocol fees for

harvestBase

Harvet's base rewards from the BGT contract, ie rewards from Distributor, given in BGT ref - https://github.com/berachain/contracts-monorepo/blob/main/src/pol/rewards/Distributor.sol#L160

The BGT accumilates in the contract, therfore can check balance(this) since all other BGT rewards are claimed and harvested atomically

Reward paid out to validators proposing a block, MUST be forwarded to IBERA.receivor, the fees are handled there. TODO: Link here.

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

Parameters

NameTypeDescription
ibgtaddressThe address of the InfraredBGT toke
bgtaddressThe address of the BGT token
iberaaddressThe address of the InfraredBERA token

Returns

NameTypeDescription
bgtAmtuint256The amount of BGT rewards harvested

harvestVault

Harvests the accrued BGT rewards to a vault.

BGT transferred here directly to the user https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L404

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

Parameters

NameTypeDescription
$RewardsStorage
vaultIInfraredVaultThe address of the InfraredRewardVault, wrapping an underlying RewardVault
bgtaddressThe address of the BGT token
ibgtaddressThe address of the InfraredBGT token
voteraddressThe address of the voter (0 until IR token is live)
iraddressThe address of the Infrared token
rewardsDurationuint256The duration of the rewards

Returns

NameTypeDescription
bgtAmtuint256The amount of BGT rewards harvested

harvestOldVault

Harvests the accrued BGT rewards to a vault.

BGT transferred here directly to the user https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L404

function harvestOldVault(
    RewardsStorage storage $,
    IInfraredVault vault,
    IInfraredVault newVault,
    address bgt,
    address ibgt,
    address voter
) external returns (uint256 bgtAmt);

Parameters

NameTypeDescription
$RewardsStorage
vaultIInfraredVaultThe address of the InfraredRewardVault, wrapping an underlying RewardVault
newVaultIInfraredVault
bgtaddressThe address of the BGT token
ibgtaddressThe address of the InfraredBGT token
voteraddressThe address of the voter (0 until IR token is live)

Returns

NameTypeDescription
bgtAmtuint256The amount of BGT rewards harvested

harvestBribes

Harvest Bribes in tokens from RewardVault, sent to us via processIncentive ref - https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L421

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

Parameters

NameTypeDescription
$RewardsStorageThe storage pointer for all rewards accumulators
collectoraddressThe address of the bribe collector, which will auction off fees for WBERA
_tokensaddress[]The array of token addresses to harvest
whitelistedbool[]The array of booleans indicating if the token is whitelisted, and should be collected

harvestBoostRewards

Harvest boost rewards from the BGT staker (in HONEY -- likely)

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

Parameters

NameTypeDescription
$RewardsStorageThe storage pointer for all rewards accumulators
bgtaddressThe address of the BGT token
ibgtVaultaddressThe address of the InfraredBGT vault
voteraddressThe address of the voter (address(0) if IR token is not live)
rewardsDurationuint256The duration of the rewards

Returns

NameTypeDescription
_tokenaddressThe rewards token harvested (likely hunny)
_amountuint256The amount of rewards harvested

collectBribesInWBERA

Callback from the BribeCollector to payout the WBERA bribes were auctioned off for ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/core/BribeCollector.sol#L87

WBERA is split between the iBERA product (where it is redeemed for BERA) and the rest is sent to the IBGT vault.

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

Parameters

NameTypeDescription
$RewardsStorageStorage pointer for reward accumulators
_amountuint256The amount of WBERA our bribes were auctioned off for
wberaaddressThe address of the WBERA token
iberaaddressThe address of the InfraredBERA token
ibgtVaultaddressThe address of the InfraredBGT vault
voteraddressThe address of the voter (address(0) if IR token is not live)
rewardsDurationuint256The duration of the rewards

Returns

NameTypeDescription
amtInfraredBERAuint256The amount of WBERA sent to the iBERA product
amtIbgtVaultuint256The amount of WBERA sent to the IBGT vault

Events

ErrorMisconfiguredIRMinting

Emitted when protocol wants to mint IR but fails.

event ErrorMisconfiguredIRMinting(uint256 amount);

Parameters

NameTypeDescription
amountuint256uint256 The amount of IR that failed to mint

Structs

RewardsStorage

struct RewardsStorage {
    mapping(address => uint256) protocolFeeAmounts;
    uint256 irMintRate;
    uint256 bribeSplitRatio;
    mapping(uint256 => uint256) fees;
}

ValidatorManagerLib

Git Source

Library for managing validator storage

*This library is used by the Infrared contract for:

  • Adding and removing validators (to the set of validators and distributor contract)
  • Queuing/Activating Boosts and Drop/Activate Boosts in BGT contract: https://github.com/berachain/contracts-monorepo/blob/main/src/pol/BGT.sol
  • Getting the number of validators
  • Checking if validator is an Infrared validator*

Ownership of Operator rewards is tied to the number of validators an operator has, which should be linear to their operating costs hence share of fees. ie if an operator has 10 validators and total validators is 100, they should receive 10% of the fees even if Effective Balances are not super equal.

Functions

isValidator

Checks if a validator is an Infrared validator, ie if the validator ID is in the set of validator IDs

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

Parameters

NameTypeDescription
$ValidatorStorageStorage pinter for validator storage
pubkeybytesThe CL pubkey of validator

_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

Adds validator to the set of validators, and maps the validator ID to the public key.

Also adds the validator to a public key set in the distributor contract, for receiving operator rewards. (ie Commissions for running nodeds).address

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

Parameters

NameTypeDescription
$ValidatorStorageStorage pointer to the validator storage
distributoraddressaddress of the distributor contract
_validatorsValidatorTypes.Validator[]array of Validator structs containing the CL public key and address of the validator and their associated fee collecting address

removeValidators

Removes validators from the set of validators and also removes the validator from the distributor contract.

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

replaceValidator

Replaces a validator in the set of validators and also updates the validator in the distributor contract.

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

Parameters

NameTypeDescription
$ValidatorStorageStorage pointer to the validator storage
distributoraddressaddress of the distributor contract
_currentbytesPublic key of the current validator
_newbytesPublic key of the new validator

queueBoosts

Queues boosts for validators in the BGT smart contract

The sum of the boosts must be less than or equal to the total supply of iBGT

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

Parameters

NameTypeDescription
$ValidatorStorageStorage pointer to the validator storage
bgtaddressaddress of the BGT contract
ibgtaddress
_pubkeysbytes[]array of public keys of validators
_amtsuint128[]array of amounts of boosts to queue

cancelBoosts

Cancels boosts for validators in the BGT smart contract before they are activated

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

Parameters

NameTypeDescription
bgtaddressaddress of the BGT contract
_pubkeysbytes[]array of public keys of validators
_amtsuint128[]array of amounts of boosts to cancel

activateBoosts

Activates boosts for validators in the BGT smart contract

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

Parameters

NameTypeDescription
$ValidatorStorageStorage pointer to the validator storage
bgtaddressaddress of the BGT contract
_pubkeysbytes[]array of public keys of validators

queueDropBoosts

Queues to drop the boosts for validators in the BGT smart contract

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

Parameters

NameTypeDescription
bgtaddressaddress of the BGT contract
_pubkeysbytes[]array of public keys of validators
_amtsuint128[]array of amounts of boosts to drop

cancelDropBoosts

Cancels drop boosts for validators in the BGT smart contract before they are activated

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

Parameters

NameTypeDescription
$ValidatorStorageStorage pointer to the validator storage
bgtaddressaddress of the BGT contract
_pubkeysbytes[]array of public keys of validators
_amtsuint128[]array of amounts of boosts to cancel

dropBoosts

Activates drop boosts for validators in the BGT smart contract

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

Parameters

NameTypeDescription
bgtaddressaddress of the BGT contract
_pubkeysbytes[]array of public keys of validators

infraredValidators

Returns the list of validators in the validator storage

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

Parameters

NameTypeDescription
$ValidatorStorageStorage pointer to the validator storage
distributoraddressaddress of the distributor contract

Returns

NameTypeDescription
validatorsValidatorTypes.Validator[]array of Validator structs containing the CL public key and address of the validators fee collecting address

numInfraredValidators

Returns the number of validators in the validator storage

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

Parameters

NameTypeDescription
$ValidatorStorageStorage pointer to the validator storage

Returns

NameTypeDescription
<none>uint256number of validators

_getValidatorAddress

helper function to get the vlaidator fee collecting address via the CL pubkey

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

Parameters

NameTypeDescription
distributoraddressaddress of the distributor contract
pubkeybytesCL pubkey of the validator

Returns

NameTypeDescription
<none>addressaddress of the validator fee collecting address

Structs

ValidatorStorage

Storage structure for validator storage

This structure is used to store validator IDs and public keys

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

Properties

NameTypeDescription
validatorIdsEnumerableSet.Bytes32SetSet of validator IDs which are keccak256 hashes of public keys.
validatorPubkeysmapping(bytes32 => bytes)Maps validator ID to public key

ValidatorTypes

Git Source

Structs

Validator

Validator information for validator set

struct Validator {
    bytes pubkey;
    address addr;
}

VaultManagerLib

Git Source

Library for managing:

  • Vault registration
  • Vault pausing
  • Reward token whitelisting
  • Default reward duration

Functions

vaultRegistrationNotPaused

Modifier to check if vault registration is paused.

modifier vaultRegistrationNotPaused(VaultStorage storage $);

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.

pauseStaking

Pauses staking functionality on a specific vault

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
assetaddressaddress of the asset to pause the vault for.

unpauseStaking

Un-pauses staking functionality on a specific vault

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
assetaddressaddress of the asset to un-pause the vault for.

pauseOldStaking

Pauses staking functionality on an old vault

function pauseOldStaking(address _vault) external;

Parameters

NameTypeDescription
_vaultaddressaddress of the vault to pause

unpauseOldStaking

Un-pauses staking functionality on an old vault

function unpauseOldStaking(address _vault) external;

Parameters

NameTypeDescription
_vaultaddressaddress of the vault to un-pause

updateWhitelistedRewardTokens

Updates the whitelist status of a reward token.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
tokenaddressaddress of the reward token to update the whitelist status for.
whitelistedboolNew whitelist status for the reward token.

addReward

Adds a reward to a vault, if the reward token is whitelisted.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_stakingTokenaddressaddress of the asset to add the reward to.
_rewardsTokenaddressaddress of the reward token to add.
_rewardsDurationuint256

removeReward

function removeReward(
    VaultStorage storage $,
    address _stakingToken,
    address _rewardsToken
) external;

updateRewardsDuration

Updates the global rewards duration for new vaults.

The rewards duration is used as the default duration for new vaults. Existing vaults will not be affected by this change.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
newDurationuint256New rewards duration.

recoverERC20FromVault

Recovers ERC20 tokens from a vault.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_assetaddressaddress of the asset to recover from.
_toaddressaddress to recover the tokens to.
_tokenaddressaddress of the token to recover.
_amountuint256uint256 amount of tokens to recover.

recoverERC20FromOldVault

Recovers ERC20 tokens from old vault.

removes reward token, cutting user claims. This should be a one time last ditch call for recovery after all users exited

function recoverERC20FromOldVault(
    address _vault,
    address _to,
    address _token,
    uint256 _amount
) external;

Parameters

NameTypeDescription
_vaultaddressaddress of the asset to recover from.
_toaddressaddress to recover the tokens to.
_tokenaddressaddress of the token to recover.
_amountuint256uint256 amount of tokens to recover.

updateRewardsDurationForVault

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

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_stakingTokenaddressaddress of the asset to update the rewards duration for.
_rewardsTokenaddressaddress of the reward token to update the rewards duration for.
_rewardsDurationuint256New rewards duration.

setVaultRegistrationPauseStatus

Pauses or unpauses the registration of new vaults.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
pauseboolFlag to pause or unpause vault registration.

claimLostRewardsOnVault

Claims lost rewards from a vault.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_assetaddressaddress of the asset to claim lost rewards from.

addIncentives

Adds a reward to a vault, if the reward token is whitelisted.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
_stakingTokenaddressaddress The asset to add the reward to.
_rewardsTokenaddressaddress The the reward token to add.
_amountuint256uint256 amount of the reward token to add.

registerVault

Registers a new vault for a specific asset.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
assetaddressaddress of the asset to register a vault for.

Returns

NameTypeDescription
<none>addressaddress of the newly created vault.

isWhitelisted

Checks if a token is whitelisted as a reward token.

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

Parameters

NameTypeDescription
$VaultStorageStorage pointer to the VaultStorage struct.
tokenaddressaddress of the token to check.

Returns

NameTypeDescription
<none>boolbool indicating if the token is whitelisted.

Structs

VaultStorage

Storage structure for the VaultManagerLib

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

Properties

NameTypeDescription
pausedVaultRegistrationboolFlag to pause or unpause vault registration
vaultRegistrymapping(address => IInfraredVault)
whitelistedRewardTokensEnumerableSet.AddressSetSet of whitelisted reward tokens that can be called into.
rewardsDurationuint256Default duration for rewards
vaultVersionsmapping(address => uint8)

Contents

BribeCollectorV1_2

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

Payout token, required to be WBERA token as its unwrapped and used to compound rewards in the iBera system.

address public payoutToken;

payoutAmount

Payout amount is a constant value that is paid by the caller of the claimFees function.

uint256 public payoutAmount;

__gap

uint256[40] private __gap;

Functions

setPayoutAmount

Set the payout amount for the bribe collector.

function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;

Parameters

NameTypeDescription
_newPayoutAmountuint256updated 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

sweepPayoutToken

function sweepPayoutToken() external;

InfraredV1_2

Git Source

Inherits: InfraredUpgradeable, IInfraredV1_2

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 Canonical BGT token Contract

IBerachainBGT internal _bgt;

ibgt

The InfraredBGT liquid staked token

InfraredBGT public ibgt;

rewardsFactory

IBerachainRewardsVaultFactory instance of the rewards factory contract address

IBerachainRewardsVaultFactory public rewardsFactory;

chef

The Berachain chef contract for distributing validator rewards

IBeraChef public chef;

wbera

The WBERA token contract

IWBERA public wbera;

honey

The Honey token contract

ERC20 public honey;

collector

The Berachain Bribe Collector

IBribeCollector public collector;

distributor

The InfraredDistributor contract

IInfraredDistributor public distributor;

voter

The Infrared Voter contract

IVoter public voter;

ibera

iBera Contract Instance

IInfraredBERA public ibera;

ir

The Infrared Governance Token

IInfraredGovernanceToken public ir;

ibgtVault

The Infrared BGT 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;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

Functions

_validatorStorage

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

Returns

NameTypeDescription
vsValidatorManagerLib.ValidatorStorageThe validator storage struct

_vaultStorage

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

Returns

NameTypeDescription
vsVaultManagerLib.VaultStorageThe vault storage struct

_rewardsStorage

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

Returns

NameTypeDescription
rsRewardsLib.RewardsStorageThe rewards storage struct

onlyCollector

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

modifier onlyCollector();

initializeV1_2

function initializeV1_2(address[] calldata _stakingTokens)
    external
    onlyGovernor;

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

setVaultRegistrationPauseStatus

Sets new vault registration paused or not

function setVaultRegistrationPauseStatus(bool pause) external onlyGovernor;

Parameters

NameTypeDescription
pauseboolTrue to pause, False to un pause

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 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

removeReward

Removes a malicious or failing reward token from a staking vault

CAUTION: This is an emergency function that will result in loss of unclaimed rewards.

*Only callable by governance when:

  1. The reward token is malfunctioning (e.g., transfers failing)
  2. The reward token is malicious
  3. The reward distribution needs to be forcefully terminated*

*Consequences:

  • All unclaimed rewards will be permanently lost
  • Users will not be able to claim outstanding rewards
  • Remaining reward tokens will need to be recovered separately*
function removeReward(address _stakingToken, address _rewardsToken)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_stakingTokenaddressThe address of the staking token associated with the vault
_rewardsTokenaddressThe address of the reward token to be removed

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

migrateVault

Migrates reward vault from old v0 to new v1

function migrateVault(address _asset, uint8 versionToUpgradeTo)
    external
    onlyGovernor
    returns (address newVault);

Parameters

NameTypeDescription
_assetaddressStaking asset of vault
versionToUpgradeTouint8Vault version number to update to (initial version is 0)

_migrateVault

function _migrateVault(address _asset, uint8 versionToUpgradeTo)
    internal
    returns (address newVault);

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

pauseStaking

Pauses staking functionality on a specific vault

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

function pauseStaking(address _asset) external onlyPauser;

Parameters

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

unpauseStaking

Un-pauses staking functionality on a specific vault

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

function unpauseStaking(address _asset) external onlyGovernor;

Parameters

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

pauseOldStaking

Pauses staking functionality on an old vault

function pauseOldStaking(address _vault) external onlyGovernor;

Parameters

NameTypeDescription
_vaultaddressThe address of the vault to pause

unpauseOldStaking

Un-pauses staking functionality on an old vault

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

function unpauseOldStaking(address _vault) external onlyGovernor;

Parameters

NameTypeDescription
_vaultaddressThe address of the vault to unpause

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.

recoverERC20FromOldVault

Recover ERC20 tokens from old vault.

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

Parameters

NameTypeDescription
_vaultaddressaddress The address of the old vault.
_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

updateInfraredBERABribeSplit

Updates the weight for iBERA bribes

function updateInfraredBERABribeSplit(uint256 _weight) external onlyGovernor;

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
    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) external onlyGovernor;

Parameters

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

setIR

Sets the address of the IR contract

Infrared must be granted MINTER_ROLE on IR to set the address

function setIR(address _ir) external onlyGovernor;

Parameters

NameTypeDescription
_iraddressThe address of the IR contract

setVoter

Sets the address of the Voter contract

function setVoter(address _voter) external onlyGovernor;

Parameters

NameTypeDescription
_voteraddressThe address of the IR contract

updateIRMintRate

Updates the mint rate for IR

function updateIRMintRate(uint256 _irMintRate) external onlyGovernor;

Parameters

NameTypeDescription
_irMintRateuint256The new mint rate for IR

chargedFeesOnRewards

function chargedFeesOnRewards(
    uint256 _amt,
    uint256 _feeTotal,
    uint256 _feeProtocol
)
    public
    pure
    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 whenNotPaused;

harvestVault

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

function harvestVault(address _asset) external whenNotPaused;

Parameters

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

harvestOldVault

Claims all the BGT rewards for the old vault

function harvestOldVault(address _vault, address _asset)
    external
    onlyKeeper
    whenNotPaused;

Parameters

NameTypeDescription
_vaultaddressThe address of the old vault
_assetaddress

harvestBribes

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

This should be called right before the collector claimFees function.

1. harvestBribes(), 2. collector.claimFees(), 3. collectBribes() (which handles the wBERA -> iBERA + fees distribution)

function harvestBribes(address[] calldata _tokens) external whenNotPaused;

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.

Check against the whitelisted tokens so that we dont interact with non-whitelisted transfer method.

pass down the total list of _tokens and the whitelisted status of each token returning tokens and amounts harvested.

indexes should match for tokens,amounts, and whitelisted status.

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

harvestOperatorRewards

Credits all accumulated rewards to the operator

function harvestOperatorRewards() public whenNotPaused;

harvestBoostRewards

Claims all the BGT staker rewards from boosting validators.

Sends rewards to iBGT vault.

function harvestBoostRewards() external whenNotPaused;

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

do not harvest if no validators in the system since Distributor::notifyRewardAmount will revert if there are rewards.

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[]bytes[] calldata The pubkeys of the validators to remove boost from.
_amtsuint128[]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 _amts)
    external
    onlyKeeper;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] calldata The pubkeys of the validators to remove boost from.
_amtsuint128[]uint128[] calldata 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.

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 _pubkey)
    public
    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() 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);

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 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
tuint256The index of the fee rate

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
_tokenaddressaddress The token address for the accumulated fees

Returns

NameTypeDescription
<none>uint256uint256 The amount of accumulated fees

receive

receive() external payable;

InfraredV1_3

Git Source

Inherits: InfraredV1_2, IInfraredV1_3

Extension of V1.2 with validator commission management functionality

This upgrade adds support for queuing and activating validator commission changes

Functions

queueValCommission

Queues a commission rate change for a validator on incentive tokens.

Only the governor can call this function.

Reverts if a commission rate change is already queued.

function queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_pubkeybytesThe validator's pubkey.
_commissionRateuint96The commission rate of the validator on the incentive tokens.

_queueValCommission

function _queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
    internal;

queueMultipleValCommissions

Queues commission rate changes for multiple validators on incentive tokens.

Only the governor can call this function.

Reverts if any validator is invalid or if any have a commission rate change already queued.

function queueMultipleValCommissions(
    bytes[] calldata _pubkeys,
    uint96 _commissionRate
) external onlyGovernor;

Parameters

NameTypeDescription
_pubkeysbytes[]The array of validator pubkeys.
_commissionRateuint96The commission rate to set for all validators in the array.

activateQueuedValCommission

Activates the queued commission rate of a validator on incentive tokens.

Anyone can call this function once the queued commission is ready.

function activateQueuedValCommission(bytes calldata _pubkey) external;

Parameters

NameTypeDescription
_pubkeybytesThe validator's pubkey.

InfraredV1_4

Git Source

Inherits: InfraredV1_3, IInfraredV1_4

Upgrade adds integration with BGTIncentiveDistributor for claiming booster rewards.

Implements IInfrared_V1_4, inheriting from InfraredV1_3. Maintains UUPS upgradeability. Uses potentially updated ValidatorManagerLib to allow external validator boosting via existing functions.

Functions

claimBGTIncentives

Claims BGT incentive rewards via BGTIncentiveDistributor.

Relays call for msg.sender. Distributor address is set once during initialization.

function claimBGTIncentives(IBGTIncentiveDistributor.Claim[] calldata _claims)
    external
    onlyKeeper;

Parameters

NameTypeDescription
_claimsIBGTIncentiveDistributor.Claim[]Array of claim data compatible with IBGTIncentiveDistributor.

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

Payout token, required to be WBERA token as its unwrapped and used to compound rewards in the iBera system.

address public payoutToken;

payoutAmount

Payout amount is a constant value that is paid out the caller of the claimFees function.

uint256 public payoutAmount;

__gap

uint256[40] private __gap;

Functions

initialize

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

setPayoutAmount

Set the payout token for the bribe collector.

Only callable by the governor and should be set to WBERA token since iBERA requires BERA to compound rewards.

function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;

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 Canonical BGT token Contract

IBerachainBGT internal _bgt;

ibgt

The InfraredBGT liquid staked token

InfraredBGT public ibgt;

rewardsFactory

IBerachainRewardsVaultFactory instance of the rewards factory contract address

IBerachainRewardsVaultFactory public rewardsFactory;

chef

The Berachain chef contract for distributing validator rewards

IBeraChef public chef;

wbera

The WBERA token contract

IWBERA public wbera;

honey

The Honey token contract

ERC20 public honey;

collector

The Berachain Bribe Collector

IBribeCollector public collector;

distributor

The InfraredDistributor contract

IInfraredDistributor public distributor;

voter

The Infrared Voter contract

IVoter public voter;

ibera

iBera Contract Instance

IInfraredBERA public ibera;

ir

The Infrared Governance Token

IInfraredGovernanceToken public ir;

ibgtVault

The Infrared BGT 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;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

Functions

_validatorStorage

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

Returns

NameTypeDescription
vsValidatorManagerLib.ValidatorStorageThe validator storage struct

_vaultStorage

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

Returns

NameTypeDescription
vsVaultManagerLib.VaultStorageThe vault storage struct

_rewardsStorage

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

Returns

NameTypeDescription
rsRewardsLib.RewardsStorageThe rewards storage struct

onlyCollector

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

modifier onlyCollector();

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

setVaultRegistrationPauseStatus

Sets new vault registration paused or not

function setVaultRegistrationPauseStatus(bool pause) external onlyGovernor;

Parameters

NameTypeDescription
pauseboolTrue to pause, False to un pause

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 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

removeReward

Removes a malicious or failing reward token from a staking vault

CAUTION: This is an emergency function that will result in loss of unclaimed rewards.

*Only callable by governance when:

  1. The reward token is malfunctioning (e.g., transfers failing)
  2. The reward token is malicious
  3. The reward distribution needs to be forcefully terminated*

*Consequences:

  • All unclaimed rewards will be permanently lost
  • Users will not be able to claim outstanding rewards
  • Remaining reward tokens will need to be recovered separately*
function removeReward(address _stakingToken, address _rewardsToken)
    external
    onlyGovernor;

Parameters

NameTypeDescription
_stakingTokenaddressThe address of the staking token associated with the vault
_rewardsTokenaddressThe address of the reward token to be removed

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
    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

pauseStaking

Pauses staking functionality on a specific vault

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

function pauseStaking(address _asset) external onlyPauser;

Parameters

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

unpauseStaking

Un-pauses staking functionality on a specific vault

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

function unpauseStaking(address _asset) external onlyGovernor;

Parameters

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

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

updateInfraredBERABribeSplit

Updates the weight for iBERA bribes

function updateInfraredBERABribeSplit(uint256 _weight) external onlyGovernor;

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
    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) external onlyGovernor;

Parameters

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

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

setIR

Sets the address of the IR contract

Infrared must be granted MINTER_ROLE on IR to set the address

function setIR(address _ir) external onlyGovernor;

Parameters

NameTypeDescription
_iraddressThe address of the IR contract

setVoter

Sets the address of the Voter contract

function setVoter(address _voter) external onlyGovernor;

Parameters

NameTypeDescription
_voteraddressThe address of the IR contract

updateIRMintRate

Updates the mint rate for IR

function updateIRMintRate(uint256 _irMintRate) external onlyGovernor;

Parameters

NameTypeDescription
_irMintRateuint256The new mint rate for IR

chargedFeesOnRewards

function chargedFeesOnRewards(
    uint256 _amt,
    uint256 _feeTotal,
    uint256 _feeProtocol
)
    public
    pure
    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 whenNotPaused;

harvestVault

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

function harvestVault(address _asset) external whenNotPaused;

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.

This should be called right before the collector claimFees function.

1. harvestBribes(), 2. collector.claimFees(), 3. collectBribes() (which handles the wBERA -> iBERA + fees distribution)

function harvestBribes(address[] calldata _tokens) external whenNotPaused;

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.

Check against the whitelisted tokens so that we dont interact with non-whitelisted transfer method.

pass down the total list of _tokens and the whitelisted status of each token returning tokens and amounts harvested.

indexes should match for tokens,amounts, and whitelisted status.

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

harvestOperatorRewards

Credits all accumulated rewards to the operator

function harvestOperatorRewards() public whenNotPaused;

harvestBoostRewards

Claims all the BGT staker rewards from boosting validators.

Sends rewards to iBGT vault.

function harvestBoostRewards() external whenNotPaused;

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

do not harvest if no validators in the system since Distributor::notifyRewardAmount will revert if there are rewards.

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[]bytes[] calldata The pubkeys of the validators to remove boost from.
_amtsuint128[]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 _amts)
    external
    onlyKeeper;

Parameters

NameTypeDescription
_pubkeysbytes[]bytes[] calldata The pubkeys of the validators to remove boost from.
_amtsuint128[]uint128[] calldata 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.

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 _pubkey)
    public
    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() 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);

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 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
tuint256The index of the fee rate

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
_tokenaddressaddress The token address for the accumulated fees

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.

Functions

constructor

Constructor for InfraredBGT

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

Parameters

NameTypeDescription
_adminaddressThe admin address to controll the roles of the contract
_minteraddressThe minter address of the contract
_pauseraddressThe pauser address of the contract
_burneraddressThe burner address of the contract

InfraredDistributor

Git Source

Inherits: InfraredUpgradeable, IInfraredDistributor

Distributes rewards to validators.

*Validator pubkeys are mapped to an EVM address and the pool of rewards from which they claim is porportional to the number of validators.

  • for example, if there are 10 validators and 100 tokens are notified, each validator can claim 10 tokens.*

State Variables

token

Token used for reward distributions

ERC20 public token;

amountsCumulative

Tracks reward amount accumulation per validator

uint256 public amountsCumulative;

residualAmount

uint256 private residualAmount;

_snapshots

mapping(bytes32 pubkeyHash => Snapshot) internal _snapshots;

_validators

mapping(bytes32 pubkeyHash => address) internal _validators;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

Functions

initialize

function initialize(address _infrared, address _gov, address _token)
    external
    initializer;

add

Register new validator for rewards

Only callable by Infrared contract

Notes:

  • access-control: Requires INFRARED_ROLE

  • error: ValidatorAlreadyExists if validator already registered

function add(bytes calldata pubkey, address validator) external onlyInfrared;

Parameters

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 onlyGovernor;

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

InfraredGovernanceToken

Git Source

Inherits: ERC20PresetMinterPauser

This contract is the IR token.

State Variables

infrared

address public immutable infrared;

Functions

constructor

Construct the Infrared Governance Token contract

constructor(
    address _infrared,
    address _admin,
    address _minter,
    address _pauser,
    address _burner
)
    ERC20PresetMinterPauser(
        "Infrared Governance Token",
        "IR",
        _admin,
        _minter,
        _pauser,
        _burner
    );

Parameters

NameTypeDescription
_infraredaddressThe address of the Infrared contract
_adminaddressThe address of the admin
_minteraddressThe address of the minter
_pauseraddressThe address of the pauser
_burneraddressThe burner address of the contract

Errors

ZeroAddress

error ZeroAddress();

InfraredUpgradeable

Git Source

Inherits: Upgradeable

This contract provides base upgradeability functionality for Infrared.

State Variables

infrared

Infrared coordinator contract

IInfrared public infrared;

__gap

uint256[10] private __gap;

Functions

onlyInfrared

modifier onlyInfrared();

constructor

constructor();

__InfraredUpgradeable_init

function __InfraredUpgradeable_init(address _infrared)
    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

unpauseStaking

Un-pauses staking functionality on a specific vault

Note: access-control: Requires INFRARED_ROLE

function unpauseStaking() external onlyInfrared;

pauseStaking

Pauses staking functionality on a specific vault

Note: access-control: Requires INFRARED_ROLE

function pauseStaking() 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

removeReward

Used to remove malicious or unused reward tokens

Note: access-control: Requires INFRARED_ROLE

function removeReward(address _rewardsToken) external onlyInfrared;

Parameters

NameTypeDescription
_rewardsTokenaddressThe reward token to remove

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.

_removeReward

Removes a reward token from the contract.

function _removeReward(address _rewardsToken) internal;

Parameters

NameTypeDescription
_rewardsTokenaddressaddress The address of the reward token.

_notifyRewardAmount

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

function _notifyRewardAmount(address _rewardsToken, uint256 reward)
    internal
    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.

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

Contents

IInfraredV1_2

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

IR 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

ir

The IR token

function ir() external view returns (IInfraredGovernanceToken);

Returns

NameTypeDescription
<none>IInfraredGovernanceTokenIR instance of the IR 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

pauseStaking

Pauses staking functionality on a specific vault

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

function pauseStaking(address _asset) external;

Parameters

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

unpauseStaking

Un-pauses staking functionality on a specific vault

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

function unpauseStaking(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

updateInfraredBERABribeSplit

Updates the weight for iBERA bribes

function updateInfraredBERABribeSplit(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

setIR

Sets the address of the IR contract

Infrared must be granted MINTER_ROLE on IR to set the address

function setIR(address _IR) external;

Parameters

NameTypeDescription
_IRaddressThe address of the IR contract

updateIRMintRate

Updates the mint rate for IR

function updateIRMintRate(uint256 _IRMintRate) external;

Parameters

NameTypeDescription
_IRMintRateuint256The new mint rate for IR

claimProtocolFees

Claims accumulated protocol fees in contract

function claimProtocolFees(address _to, address _token) external;

Parameters

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

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

migrateVault

function migrateVault(address _asset, uint8 versionToUpgradeTo)
    external
    returns (address newVault);

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 IR tokens.
_ibgtAmtuint256The amount of InfraredBGT tokens supplied to vault.
_iredAmtuint256The amount of IR 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

InfraredBERABribeSplitUpdated

Emitted when a weight is updated.

event InfraredBERABribeSplitUpdated(
    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.

IRSet

Emitted when the IR token is set.

event IRSet(address _sender, address _IR);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_IRaddressThe address of the IRdd token.

UpdatedIRMintRate

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

Parameters

NameTypeDescription
oldMintRateuint256The old mint rate for IR
newMintRateuint256The new mint rate for IR
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.

VoterSet

Emitted when the voter contract is set.

event VoterSet(address _sender, address _voter);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_voteraddressThe address of the voter contract.

VaultMigrated

Emitted when vault has migrated.

event VaultMigrated(
    address indexed sender,
    address indexed asset,
    address indexed oldVault,
    address newVault
);

Parameters

NameTypeDescription
senderaddressThe address that initiated the update.
assetaddressThe address of the staking token.
oldVaultaddressThe address of the old vault.
newVaultaddressThe address of the new vault.

IInfraredV1_3

Git Source

Inherits: IInfraredV1_2

Interface for V1.3 of the Infrared protocol

Extends V1.2 with validator commission management functionality

Functions

queueValCommission

Queues a commission rate change for a validator on incentive tokens

function queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
    external;

Parameters

NameTypeDescription
_pubkeybytesThe validator's pubkey
_commissionRateuint96The commission rate to set

queueMultipleValCommissions

Queues commission rate changes for multiple validators on incentive tokens

function queueMultipleValCommissions(
    bytes[] calldata _pubkeys,
    uint96 _commissionRate
) external;

Parameters

NameTypeDescription
_pubkeysbytes[]The array of validator pubkeys
_commissionRateuint96The commission rate to set for all validators

activateQueuedValCommission

Activates the queued commission rate of a validator on incentive tokens

function activateQueuedValCommission(bytes calldata _pubkey) external;

Parameters

NameTypeDescription
_pubkeybytesThe validator's pubkey

Events

ValidatorCommissionQueued

Emitted when a validator's commission rate is queued

event ValidatorCommissionQueued(
    address indexed operator, bytes pubkey, uint96 commissionRate
);

Parameters

NameTypeDescription
operatoraddressThe address that queued the commission change
pubkeybytesThe validator's pubkey
commissionRateuint96The queued commission rate

ValidatorCommissionActivated

Emitted when a validator's queued commission rate is activated

event ValidatorCommissionActivated(
    address indexed operator, bytes pubkey, uint96 commissionRate
);

Parameters

NameTypeDescription
operatoraddressThe address that activated the commission change
pubkeybytesThe validator's pubkey
commissionRateuint96The new active commission rate

IInfraredV1_4

Git Source

Inherits: IInfraredV1_3

Interface for Infrared V1.4 upgrade. Adds BGT incentive claims.

Defines external functions and events for V1.4. Inherits from IInfraredV1_3.

Functions

claimBGTIncentives

Claims BGT incentive rewards via the BGTIncentiveDistributor.

function claimBGTIncentives(IBGTIncentiveDistributor.Claim[] calldata _claims)
    external;

Parameters

NameTypeDescription
_claimsIBGTIncentiveDistributor.Claim[]Array of claim data.

Events

BGTIncentivesClaimAttempted

Emitted when claimBGTIncentives is called.

event BGTIncentivesClaimAttempted(
    address indexed caller, address indexed distributor, uint256 numClaims
);

Parameters

NameTypeDescription
calleraddressAddress initiating the claim.
distributoraddressBGTIncentiveDistributor contract called.
numClaimsuint256Number of claims submitted.

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

IR 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

ir

The IR token

function ir() external view returns (IInfraredGovernanceToken);

Returns

NameTypeDescription
<none>IInfraredGovernanceTokenIR instance of the IR 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

pauseStaking

Pauses staking functionality on a specific vault

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

function pauseStaking(address _asset) external;

Parameters

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

unpauseStaking

Un-pauses staking functionality on a specific vault

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

function unpauseStaking(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

updateInfraredBERABribeSplit

Updates the weight for iBERA bribes

function updateInfraredBERABribeSplit(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

setIR

Sets the address of the IR contract

Infrared must be granted MINTER_ROLE on IR to set the address

function setIR(address _IR) external;

Parameters

NameTypeDescription
_IRaddressThe address of the IR 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

updateIRMintRate

Updates the mint rate for IR

function updateIRMintRate(uint256 _IRMintRate) external;

Parameters

NameTypeDescription
_IRMintRateuint256The new mint rate for IR

claimProtocolFees

Claims accumulated protocol fees in contract

function claimProtocolFees(address _to, address _token) external;

Parameters

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

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 IR tokens.
_ibgtAmtuint256The amount of InfraredBGT tokens supplied to vault.
_iredAmtuint256The amount of IR 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

InfraredBERABribeSplitUpdated

Emitted when a weight is updated.

event InfraredBERABribeSplitUpdated(
    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.

IRSet

Emitted when the IR token is set.

event IRSet(address _sender, address _IR);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_IRaddressThe address of the IRdd token.

UpdatedIRMintRate

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

Parameters

NameTypeDescription
oldMintRateuint256The old mint rate for IR
newMintRateuint256The new mint rate for IR
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.

VoterSet

Emitted when the voter contract is set.

event VoterSet(address _sender, address _voter);

Parameters

NameTypeDescription
_senderaddressThe address that initiated the update.
_voteraddressThe address of the voter contract.

IInfraredBERA

Git Source

Inherits: IERC20, IAccessControl

Functions

infrared

The Infrared.sol smart contract

function infrared() external view returns (address);

depositor

The InfraredBERADepositor.sol smart contract

function depositor() external view returns (address);

withdrawor

The InfraredBERAWithdrawor.sol smart contract

function withdrawor() external view returns (address);

receivor

The InfraredBERAFeeReceivor.sol smart contract

function receivor() external view returns (address);

deposits

The total amount of BERA deposited by the system

function deposits() external view returns (uint256);

stakes

Returns the amount of BERA staked in validator with given pubkey

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

staked

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

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

hasExited

Returns whether a validator pubkey has exited

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

signatures

Returns the deposit signature to use for given pubkey

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

feeDivisorShareholders

The fee divisor for protocol + operator + voter fees. 1/N, where N is the divisor. example 100 = 1/100 = 1%

function feeDivisorShareholders() external view returns (uint16);

pending

Pending deposits yet to be forwarded to CL

function pending() external view returns (uint256);

confirmed

Confirmed deposits sent to CL, total - future deposits

function confirmed() external view returns (uint256);

keeper

Checks if account has the keeper role

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

Parameters

NameTypeDescription
accountaddressThe address to check

Returns

NameTypeDescription
<none>boolTrue if the account has the keeper role

governor

Checks if account has the governance role

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

Parameters

NameTypeDescription
accountaddressThe address to check

Returns

NameTypeDescription
<none>boolTrue if the account has the governance role

validator

Checks if a given pubkey is a validator in the Infrared contract

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

Parameters

NameTypeDescription
pubkeybytesThe pubkey to check

Returns

NameTypeDescription
<none>boolTrue if the pubkey is a validator

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);

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

previewBurn

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

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

Parameters

NameTypeDescription
shareAmountuint256The 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

Initiializer for InfraredBERA

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

Parameters

NameTypeDescription
_govaddressThe address of the governance contract
_keeperaddressThe address of the keeper contract
_infraredaddressThe address of the Infrared.sol contract
_depositoraddressThe address of the InfraredBERADepositor.sol contract
_withdraworaddressThe address of the InfraredBERAWithdrawor.sol contract
_receivoraddressThe address of the InfraredBERAFeeReceivor.sol contract

compound

Internal function to update top level accounting and compound rewards

function compound() external;

sweep

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 sweep() external payable;

collect

Collects yield from fee receivor and mints ibera shares to Infrared

Called in RewardsLib::harvestOperatorRewards() in Infrared.sol

Only Infrared can call this function

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of ibera shares

mint

Mints ibera to the receiver in exchange for bera

takes in msg.value as amount to mint ibera with

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

Parameters

NameTypeDescription
receiveraddressThe address to mint ibera to

Returns

NameTypeDescription
sharesuint256The amount of ibera minted

burn

Burns ibera from the msg.sender and sets a receiver to get the BERA in exchange for iBERA

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

Parameters

NameTypeDescription
receiveraddressThe address to send the BERA to
sharesuint256The amount of ibera to burn

Returns

NameTypeDescription
nonceuint256The nonce of the withdrawal. Queue based system for withdrawals
amountuint256The amount of BERA withdrawn for the exchange of iBERA

register

Updates the accounted for stake of a validator pubkey

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

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator
deltaint256The change in stake

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 for a given pubkey. Ensure that the pubkey has signed the correct deposit amount of INITIAL_DEPOSIT

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

Parameters

NameTypeDescription
pubkeybytesThe pubkey to set the deposit signature for
signaturebytesThe signature to set for the pubkey

withdrawalsEnabled

Whether withdrawals are currently enabled

function withdrawalsEnabled() external view returns (bool);

Events

Mint

Emitted when InfraredBERA is minted

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

Parameters

NameTypeDescription
receiveraddressThe address receiving the minted shares
amountuint256The amount of BERA deposited
sharesuint256The amount of shares minted

Burn

Emitted when InfraredBERA is burned

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

Parameters

NameTypeDescription
receiveraddressThe address receiving the withdrawn BERA
nonceuint256The withdrawal nonce
amountuint256The amount of BERA to withdraw
sharesuint256The amount of shares burned
feeuint256The fee paid for withdrawal

Sweep

Emitted when accumulated rewards are swept

event Sweep(uint256 amount);

Parameters

NameTypeDescription
amountuint256The amount of BERA swept

Register

Emitted when validator stake is registered

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

Parameters

NameTypeDescription
pubkeybytesThe validator's public key
deltaint256The change in stake amount
stakeuint256The new total stake amount

SetFeeShareholders

Emitted when fee shareholders rate is updated

event SetFeeShareholders(uint16 from, uint16 to);

Parameters

NameTypeDescription
fromuint16Previous fee rate
touint16New fee rate

SetDepositSignature

Emitted when deposit signature is updated

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

Parameters

NameTypeDescription
pubkeybytesThe validator's public key
frombytesPrevious signature
tobytesNew signature

WithdrawalFlagSet

Emitted when withdrawal flag is updated

event WithdrawalFlagSet(bool flag);

Parameters

NameTypeDescription
flagboolNew withdrawal flag value

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 main InfraredBERA contract address

function InfraredBERA() external view returns (address);

reserves

the queued amount of BERA to be deposited

function reserves() external view returns (uint256);

queue

Queues a deposit by sending BERA to this contract and storing the amount in the pending deposits acculimator

function queue() external payable;

execute

Executes a deposit to the deposit contract for the specified pubkey and amount

Only callable by the keeper

Only callable if the deposits are enabled

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

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator to deposit for
amountuint256The amount of BERA to deposit

initialize

Initialize the contract (replaces the constructor)

function initialize(
    address _gov,
    address _keeper,
    address ibera,
    address _depositContract
) external;

Parameters

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

DEPOSIT_CONTRACT

The Deposit Contract Address for Berachain

function DEPOSIT_CONTRACT() external view returns (address);

ETH1_ADDRESS_WITHDRAWAL_PREFIX

https://eth2book.info/capella/part2/deposits-withdrawals/withdrawal-processing/

function ETH1_ADDRESS_WITHDRAWAL_PREFIX() external view returns (uint8);

Events

Queue

Emitted when BERA is queued for deposit

event Queue(uint256 amount);

Parameters

NameTypeDescription
amountuint256The amount of BERA queued

Execute

Emitted when a deposit is executed to the deposit contract

event Execute(bytes pubkey, uint256 amount);

Parameters

NameTypeDescription
pubkeybytesThe validator's public key
amountuint256The amount of BERA deposited

IInfraredBERAFeeReceivor

Git Source

Functions

InfraredBERA

The address of the InfraredBERA.sol contract

function InfraredBERA() external view returns (address);

infrared

The Infrared.sol contract address

function infrared() external view returns (IInfrared);

shareholderFees

Accumulated protocol fees in contract to be claimed

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);

Returns

NameTypeDescription
amountuint256The amount of BERA forwarded to InfraredBERA
feesuint256The total fees taken

collect

Collects accumulated shareholder fees

Reverts if msg.sender is not InfraredBera.sol contract

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of iBERA shares minted and sent to the Infrared.sol

initialize

Initializer function (replaces constructor)

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

Parameters

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

Events

Sweep

Emitted when accumulated rewards are swept to InfraredBERA

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

Parameters

NameTypeDescription
receiveraddressThe address receiving the swept BERA
amountuint256The amount of BERA swept
feesuint256The amount of fees taken

Collect

Emitted when shareholder fees are collected

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

Parameters

NameTypeDescription
receiveraddressThe address receiving the collected fees
amountuint256The amount of fees collected
sharesMinteduint256The amount of iBERA shares minted

IInfraredBERAWithdrawor

Git Source

Functions

InfraredBERA

The address of the InfraredBERA contract

function InfraredBERA() external view returns (address);

sweep

Sweeps forced withdrawals to InfraredBERA to re-stake principal

Only callable when withdrawals are disabled and by keeper

function sweep(bytes calldata pubkey) external;

Parameters

NameTypeDescription
pubkeybytesThe validator's public key to sweep funds from

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 request from InfraredBERA

Requires msg.value to cover minimum withdrawal fee

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 unique identifier for this withdrawal request

execute

Executes a withdraw request to withdraw precompile

Payable to cover any additional fees required by precompile

Only callable by keeper

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

Parameters

NameTypeDescription
pubkeybytesThe validator's public key to withdraw from
amountuint256The amount of BERA to withdraw

process

Processes the funds received from withdraw precompile

Reverts if balance has not increased by full amount of request

Processes requests in FIFO order based on nonce

function process() external;

Events

Queue

Emitted when a withdrawal is queued

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

Parameters

NameTypeDescription
receiveraddressThe address that will receive the withdrawn BERA
nonceuint256The unique identifier for this withdrawal request
amountuint256The amount of BERA to be withdrawn

Execute

Emitted when a withdrawal is executed

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

Parameters

NameTypeDescription
pubkeybytesThe validator's public key
startuint256The starting nonce
enduint256The ending nonce
amountuint256The amount of BERA withdrawn

Process

Emitted when a withdrawal is processed

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

Parameters

NameTypeDescription
receiveraddressThe address receiving the withdrawn BERA
nonceuint256The nonce of the processed withdrawal
amountuint256The amount of BERA processed

Sweep

Emitted when funds are swept from a force-exited validator

event Sweep(address indexed receiver, uint256 amount);

Parameters

NameTypeDescription
receiveraddressThe address receiving the swept BERA
amountuint256The amount of BERA swept

IInfraredBGT

Git Source

Inherits: IERC20Mintable, IAccessControl

Functions

burn

function burn(uint256 amount) external;

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;
}

IInfraredGovernanceToken

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);

paused

returns paused status of the contract

function paused() external view returns (bool);

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

pauseStaking

Pauses staking functionality on a specific vault

Note: access-control: Requires INFRARED_ROLE

function pauseStaking() external;

unpauseStaking

Un-pauses staking functionality on a specific vault

Note: access-control: Requires INFRARED_ROLE

function unpauseStaking() 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

removeReward

Used to remove malicious or unused reward tokens

Note: access-control: Requires INFRARED_ROLE

function removeReward(address _rewardsToken) external;

Parameters

NameTypeDescription
_rewardsTokenaddressThe reward token to remove

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

RewardRemoved

Emitted when a reward is removed from the contract

event RewardRemoved(address indexed rewardsToken);

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 BERA is a liquid staking token for Berachain

This is the main "Front-End" contract for the whole BERA staking system.

State Variables

withdrawalsEnabled

Withdrawals are not enabled by default, not supported by https://github.com/berachain/beacon-kit yet.

bool public withdrawalsEnabled;

_initialized

Whether the contract has been initialized

bool private _initialized;

feeDivisorShareholders

The fee divisor for protocol + operator + voter fees. 1/N, where N is the divisor. example 100 = 1/100 = 1%

uint16 public feeDivisorShareholders;

infrared

The Infrared.sol smart contract.

address public infrared;

depositor

The InfraredBERADepositor.sol smart contract.

address public depositor;

withdrawor

The InfraredBERAWithdrawor.sol smart contract.

address public withdrawor;

receivor

The InfraredBERAFeeReceivor.sol smart contract.

address public receivor;

deposits

The total amount of BERA deposited by the system.

uint256 public deposits;

_stakes

Mapping of validator pubkeyHash to their stake in BERA.

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

_staked

Mapping of validator pubkeyHash to whether they have recieved stake from this contract.

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

_exited

Mapping of validator pubkeyHash to whether they have exited from this contract. (voluntarily or force).

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

_signatures

Mapping of validator pubkeyHash to their deposit signature. All validators MUST have their signiture amounts set to INITIAL_DEPOSIT to be valid.

mapping(bytes32 pubkeyHash => bytes) internal _signatures;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

Functions

initialize

Initiializer for InfraredBERA.

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

Parameters

NameTypeDescription
_govaddressThe address of the governance contract.
_keeperaddressThe address of the keeper contract.
_infraredaddressThe address of the Infrared.sol contract.
_depositoraddressThe address of the InfraredBERADepositor.sol contract.
_withdraworaddressThe address of the InfraredBERAWithdrawor.sol contract.
_receivoraddressThe address of the InfraredBERAFeeReceivor.sol contract.

governor

Checks if account has the governance role.

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

Parameters

NameTypeDescription
accountaddressThe address to check.

Returns

NameTypeDescription
<none>boolTrue if the account has the governance role.

keeper

Checks if account has the keeper role.

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

Parameters

NameTypeDescription
accountaddressThe address to check.

Returns

NameTypeDescription
<none>boolTrue if the account has the keeper role.

validator

Checks if a given pubkey is a validator in the Infrared contract.

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

Parameters

NameTypeDescription
pubkeybytesThe pubkey to check.

Returns

NameTypeDescription
<none>boolTrue if the pubkey is a validator.

setWithdrawalsEnabled

Allows withdrawals to be enabled or disabled.

Only callable by the governor.

function setWithdrawalsEnabled(bool flag) external onlyGovernor;

Parameters

NameTypeDescription
flagboolThe flag to set for withdrawals.

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 for a given pubkey. Ensure that the pubkey has signed the correct deposit amount of INITIAL_DEPOSIT.

Only callable by the governor.

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

Parameters

NameTypeDescription
pubkeybytesThe pubkey to set the deposit signature for.
signaturebytesThe signature to set for the pubkey.

mint

Mints ibera to the receiver in exchange for bera.

takes in msg.value as amount to mint ibera with.

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

Parameters

NameTypeDescription
receiveraddressThe address to mint ibera to.

Returns

NameTypeDescription
sharesuint256The amount of ibera minted.

burn

Burns ibera from the msg.sender and sets a receiver to get the BERA in exchange for iBERA.

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

Parameters

NameTypeDescription
receiveraddressThe address to send the BERA to.
sharesuint256The amount of ibera to burn.

Returns

NameTypeDescription
nonceuint256The nonce of the withdrawal. Queue based system for withdrawals.
amountuint256The amount of BERA withdrawn for the exchange of iBERA.

_deposit

Internal function to update top level accounting and minimum deposit.

function _deposit(uint256 amount) internal;

Parameters

NameTypeDescription
amountuint256The amount of BERA to deposit.

_withdraw

Internal function to update top level accounting.

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

Parameters

NameTypeDescription
receiveraddressThe address to withdraw BERA to.
amountuint256The amount of BERA to withdraw.
feeuint256The fee to pay for the withdrawal.

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);

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

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
shareAmountuint256The 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

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

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, total - future deposits

function confirmed() external view returns (uint256);

Returns

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

compound

Internal function to update top level accounting and compound rewards

function compound() public;

sweep

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 sweep() external payable;

collect

Collects yield from fee receivor and mints ibera shares to Infrared

Called in RewardsLib::harvestOperatorRewards() in Infrared.sol

Only Infrared can call this function

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of ibera shares

register

Updates the accounted for stake of a validator pubkey.

This does NOT mean its the balance on the CL, edge case is if another user has staked to the pubkey.

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

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator.
deltaint256The change in stake.

hasExited

Returns whether a validator pubkey has exited.

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

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;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

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_WITHDRAW_FEE

uint256 public constant MINIMUM_WITHDRAW_FEE = 1 ether;

FORCED_MIN_DELAY

uint256 public constant FORCED_MIN_DELAY = 7 days;

MAX_EFFECTIVE_BALANCE

uint256 public constant MAX_EFFECTIVE_BALANCE = 10_000_000 ether;

InfraredBERADepositor

Git Source

Inherits: Upgradeable

Depositor to deposit BERA to CL for Infrared liquid staking token

State Variables

ETH1_ADDRESS_WITHDRAWAL_PREFIX

https://eth2book.info/capella/part2/deposits-withdrawals/withdrawal-processing/

uint8 public constant ETH1_ADDRESS_WITHDRAWAL_PREFIX = 0x01;

DEPOSIT_CONTRACT

The Deposit Contract Address for Berachain

address public DEPOSIT_CONTRACT;

InfraredBERA

the main InfraredBERA contract address

address public InfraredBERA;

reserves

the queued amount of BERA to be deposited

uint256 public reserves;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

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

queue

Queues a deposit by sending BERA to this contract and storing the amount in the pending deposits acculimator

function queue() external payable;

execute

Executes a deposit to the deposit contract for the specified pubkey and amount.

can only be called by InfraredBERA for adding to the reserves and by withdrawor for rebalancing when validators get kicked out of the set, TODO: link the set kickout code.

Only callable by the keeper

Only callable if the deposits are enabled

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

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator to deposit for
amountuint256The amount of BERA to deposit

Events

Queue

event Queue(uint256 amount);

Execute

event Execute(bytes pubkey, uint256 amount);

InfraredBERAFeeReceivor

Git Source

Inherits: Upgradeable, IInfraredBERAFeeReceivor

Receivor for fees from InfraredBERA from tips and share of the proof-of-liquidity incentive system.

Validators need to set this address as their coinbase(fee_recepient on most clients).

State Variables

InfraredBERA

The address of the InfraredBERA.sol contract.

address public InfraredBERA;

infrared

The Infrared.sol contract address.

IInfrared public infrared;

shareholderFees

Accumulated protocol fees in contract to be claimed.

uint256 public shareholderFees;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

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);

Returns

NameTypeDescription
amountuint256The amount of BERA forwarded to InfraredBERA.
feesuint256The total fees taken.

collect

Collects accumulated shareholder fees

Reverts if msg.sender is not InfraredBera.sol contract

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of iBERA shares minted and sent to the Infrared.sol

receive

Fallback function to receive BERA

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 the InfraredBERA contract

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;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

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 request from InfraredBERA

Requires msg.value to cover minimum withdrawal fee

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 unique identifier for this withdrawal request

execute

Executes a withdraw request to withdraw precompile

Payable to cover any additional fees required by precompile

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

Parameters

NameTypeDescription
pubkeybytesThe validator's public key to withdraw from
amountuint256The amount of BERA to withdraw

process

Processes the funds received from withdraw precompile

Reverts if balance has not increased by full amount of request

function process() external;

sweep

Sweeps forced withdrawals to InfraredBERA to re-stake principal

Only callable when withdrawals are disabled and by keeper

function sweep(bytes calldata pubkey) external;

Parameters

NameTypeDescription
pubkeybytesThe validator's public key to sweep funds from

receive

receive() external payable;

Structs

Request

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

InfraredBERAWithdraworLite

Git Source

Inherits: Upgradeable, IInfraredBERAWithdrawor

This contract is only responsible for handling involuntary exits from the CL. It is a light version of the InfraredBERAWithdrawor contract.

This contract should be upgraded once withdrawals are enabled by https://github.com/berachain/beacon-kit.

expects compliance of https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7002.md

State Variables

WITHDRAW_REQUEST_TYPE

The withdrawal request type, execution layer withdrawal.

uint8 public constant WITHDRAW_REQUEST_TYPE = 0x01;

WITHDRAW_PRECOMPILE

The address of the Withdraw Precompile settable in the next upgrade.

address public WITHDRAW_PRECOMPILE;

InfraredBERA

The address of the InfraredBERA.sol contract.

address public InfraredBERA;

claimor

The address of the InfraredBERAClaimor.sol contract.

This contract will be set in the next upgrade.

address public claimor;

requests

Outstanding requests for claims on previously burnt ibera The key = nonce associated with the claim

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;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

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

not used until next upgrade.

function queue(address, uint256) external payable returns (uint256);

execute

Executes a withdraw request to withdraw precompile

not used until next upgrade.

function execute(bytes calldata, uint256) external payable;

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

not used until next upgrade.

function process() external pure;

sweep

Handles Forced withdrawals from the CL.

*RESTRICTED USAGE: This function should ONLY be called when:

  • A validator has been forced to exit from the CL.*

The funds will enter the IBERA system as a deposit via the InfraredBERADepositor.

function sweep(bytes calldata pubkey) external onlyGovernor;

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator that has been forced to exit.

sweepUnaccountedForFunds

Handles excess stake that was refunded from a validator due to non-IBERA deposits exceeding MAX_EFFECTIVE_BALANCE

*RESTRICTED USAGE: This function should ONLY be called when:

  • A non-IBERA entity deposits to our validator, pushing total stake above MAX_EFFECTIVE_BALANCE
  • The excess stake is refunded by the CL to this contract*

The funds will enter the IBERA system as yield via the FeeReceivor

*This should NEVER be used for:

  • Validators exited due to falling out of the validator set*

Note: access: Only callable by governance

function sweepUnaccountedForFunds(uint256 amount) external onlyGovernor;

Parameters

NameTypeDescription
amountuint256The amount of excess stake to sweep

receive

receive() external payable;

Structs

Request

The request struct for withdrawal requests.

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

Properties

NameTypeDescription
receiveraddressThe address of the receiver of the withdrawn BERA funds.
timestampuint96The block.timestamp at which the withdraw request was issued.
feeuint256The fee escrow for the withdraw precompile request.
amountSubmituint256The amount of withdrawn BERA funds left to submit request to withdraw precompile.
amountProcessuint256The amount of withdrawn BERA funds left to process from funds received via withdraw request.

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();

NotPauser

error NotPauser();

InsufficientBalance

error InsufficientBalance();

InvalidFeeToken

error InvalidFeeToken();

FeeTokenNotWhitelisted

error FeeTokenNotWhitelisted();

InsufficientFeeTokenBalance

error InsufficientFeeTokenBalance();

ValidatorAlreadyExists

error ValidatorAlreadyExists();

FailedToAddValidator

error FailedToAddValidator();

ValidatorDoesNotExist

error ValidatorDoesNotExist();

MaxNumberOfRewards

error MaxNumberOfRewards();

Unauthorized

error Unauthorized(address sender);

IBGTNotRewardToken

error IBGTNotRewardToken();

IBGTNotStakingToken

error IBGTNotStakingToken();

StakedInRewardsVault

error StakedInRewardsVault();

NoRewardsVault

error NoRewardsVault();

RewardRateDecreased

error RewardRateDecreased();

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();

VaultAlreadyUpToDate

error VaultAlreadyUpToDate();

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();

CanNotCompoundAccumuldatedBERA

error CanNotCompoundAccumuldatedBERA();

ExceedsMaxEffectiveBalance

error ExceedsMaxEffectiveBalance();

HandleForceExitsBeforeDeposits

error HandleForceExitsBeforeDeposits();

OperatorAlreadySet

error OperatorAlreadySet();

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, PausableUpgradeable, 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");

PAUSER_ROLE

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

__gap

uint256[20] private __gap;

Functions

onlyKeeper

Modifier to restrict access to KEEPER_ROLE.

modifier onlyKeeper();

onlyGovernor

Modifier to restrict access to GOVERNANCE_ROLE.

modifier onlyGovernor();

onlyPauser

Modifier to restrict access to PAUSER_ROLE.

modifier onlyPauser();

whenInitialized

modifier whenInitialized();

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

__Upgradeable_init

Initialize the upgradeable contract.

function __Upgradeable_init() internal onlyInitializing;

pause

function pause() public;

unpause

function unpause() public onlyGovernor;

_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

CustomPausable

Git Source

Inherits: ERC20, Pausable

ERC-20 token with pausable token transfers, minting and burning. Useful for scenarios such as preventing trades until the end of an evaluation period, or having an emergency switch for freezing all token transfers in the event of a large bug. IMPORTANT: This contract does not include public pause and unpause functions. In addition to inheriting this contract, you must define both functions, invoking the Pausable-_pause and {Pausable-_unpause} internal functions, with appropriate access control, e.g. using {AccessControl} or {Ownable}. Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable.

Functions

_update

*See ERC20-_update. This contract modifies the default behavior of ERC20Pausable.

  • When paused, transfers are not paused.
  • The whenNotPaused modifier has been removed to allow transfers even when the contract is paused.
  • Only minting and burning operations are paused when the contract is paused.*
function _update(address from, address to, uint256 value)
    internal
    virtual
    override;

ERC20PresetMinterPauser

Git Source

Inherits: Context, AccessControlEnumerable, CustomPausable

*{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");

BURNER_ROLE

bytes32 public constant BURNER_ROLE = keccak256("BURNER_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,
    address _burner
) 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 whenNotPaused;

burn

*Burn amount new tokens from from. See ERC20-_burn. Requirements:

  • the caller must have the BURNER_ROLE.*
function burn(uint256 amount) public virtual whenNotPaused;

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(CustomPausable);

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 (IR) 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;

__gap

Reserve storage slots for future upgrades for safety

uint256[40] private __gap;

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

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 _infrared,
    address _ve,
    address _gov,
    address _keeper
) external initializer;

Parameters

NameTypeDescription
_infraredaddressAddress of the Infrared contract
_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 (IR) 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 (IR) 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);