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;