Infrared
Inherits: InfraredUpgradeable, IInfrared
Provides core functionalities for managing validators, vaults, and reward distribution in the Infrared protocol.
Serves as the main entry point for interacting with the Infrared protocol
The contract is upgradeable, ensuring flexibility for governance-led upgrades and chain compatibility.
State Variables
_bgt
The BGT token contract reference
Immutable IBerachainBGT instance of the BGT token
IBerachainBGT internal _bgt;
ibgt
The InfraredBGT liquid staked token
InfraredBGT public ibgt;
rewardsFactory
The Berachain rewards vault factory address
IBerachainRewardsVaultFactory public rewardsFactory;
chef
The Berachain chef contract for distributing validator rewards
IBeraChef public chef;
wbera
Wrapped bera
IWBERA public wbera;
honey
Honey ERC20 token
ERC20 public honey;
collector
bribe collector contract
IBribeCollector public collector;
distributor
Infrared distributor for BGT rewards to validators
IInfraredDistributor public distributor;
voter
IRED voter
IVoter public voter;
ibera
collects all iBERA realted fees and revenue
IInfraredBERA public ibera;
red
The RED token
IRED public red;
ibgtVault
The InfraredBGT vault
IInfraredVault public ibgtVault;
VALIDATOR_STORAGE_LOCATION
Upgradeable ERC-7201 storage for Validator lib
keccak256(abi.encode(uint256(keccak256(bytes("infrared.validatorStorage"))) - 1)) & ~bytes32(uint256(0xff));
bytes32 public constant VALIDATOR_STORAGE_LOCATION =
0x8ea5a3cc3b9a6be40b16189aeb1b6e6e61492e06efbfbe10619870b5bc1cc500;
VAULT_STORAGE_LOCATION
Upgradeable ERC-7201 storage for Vault lib
keccak256(abi.encode(uint256(keccak256(bytes("infrared.vaultStorage"))) - 1)) & ~bytes32(uint256(0xff));
bytes32 public constant VAULT_STORAGE_LOCATION =
0x1bb2f1339407e6d63b93b8b490a9d43c5651f6fc4327c66addd5939450742a00;
REWARDS_STORAGE_LOCATION
Upgradeable ERC-7201 storage for Rewards lib
keccak256(abi.encode(uint256(keccak256(bytes("infrared.rewardsStorage"))) - 1)) & ~bytes32(uint256(0xff));
bytes32 public constant REWARDS_STORAGE_LOCATION =
0xad12e6d08cc0150709acd6eed0bf697c60a83227922ab1d254d1ca4d3072ca00;
Functions
_validatorStorage
function _validatorStorage()
internal
pure
returns (ValidatorManagerLib.ValidatorStorage storage vs);
_vaultStorage
function _vaultStorage()
internal
pure
returns (VaultManagerLib.VaultStorage storage vs);
_rewardsStorage
function _rewardsStorage()
internal
pure
returns (RewardsLib.RewardsStorage storage rs);
onlyCollector
Ensures that only the collector contract can call the function Reverts if the caller is not the collector
modifier onlyCollector();
constructor
constructor() InfraredUpgradeable(address(0));
initialize
function initialize(InitializationData calldata data) external initializer;
_validateInitializationData
function _validateInitializationData(InitializationData memory data)
internal
pure;
_initializeCoreContracts
function _initializeCoreContracts(InitializationData memory data) internal;
registerVault
Registers a new vault for a given asset
Infrared.sol must be admin over MINTER_ROLE on InfraredBGT to grant minter role to deployed vault
Note: emits: NewVault with the caller, asset address, and new vault address.
function registerVault(address _asset)
external
returns (IInfraredVault vault);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the asset, such as a specific LP token |
Returns
Name | Type | Description |
---|---|---|
vault | IInfraredVault | The address of the newly created InfraredVault contract |
addReward
Adds a new reward token to a specific staking vault
Only callable by governance when contract is initialized
Note: error: ZeroAmount if _rewardsDuration is 0
function addReward(
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking token associated with the vault |
_rewardsToken | address | The address of the token to be added as a reward |
_rewardsDuration | uint256 | The duration period for the rewards distribution, in seconds |
addIncentives
Adds reward incentives to a specific staking vault
Transfers reward tokens from caller to this contract, then notifies vault of new rewards
Notes:
-
error: ZeroAmount if _amount is 0
-
access: Callable when contract is initialized
-
security: Requires caller to have approved this contract to spend _rewardsToken
function addIncentives(
address _stakingToken,
address _rewardsToken,
uint256 _amount
) external;
Parameters
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking token associated with the vault |
_rewardsToken | address | The address of the token being added as incentives |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_token | address | The address of the token to whitelist or remove from whitelist |
_whitelisted | bool | A 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
Name | Type | Description |
---|---|---|
_rewardsDuration | uint256 | The 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
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking asset associated with the vault |
_rewardsToken | address | The address of the reward token to update the duration for |
_rewardsDuration | uint256 | The new reward duration period, in seconds |
toggleVault
Pauses staking functionality on a specific vault
Only callable by governance, will revert if vault doesn't exist
function toggleVault(address _asset) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The address of the staking asset associated with the vault to pause |
claimLostRewardsOnVault
Claims lost rewards on a specific vault
Only callable by governance, will revert if vault doesn't exist
function claimLostRewardsOnVault(address _asset) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | The 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
Name | Type | Description |
---|---|---|
_to | address | The address to receive the recovered tokens |
_token | address | The address of the token to recover |
_amount | uint256 | The 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
Name | Type | Description |
---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
_to | address | address The address to send the tokens to. |
_token | address | address The address of the token to recover. |
_amount | uint256 | uint256 The amount of the token to recover. |
delegateBGT
Delegates BGT votes to _delegatee
address.
function delegateBGT(address _delegatee) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_delegatee | address | address The address to delegate votes to |
updateInfraredBERABribesWeight
Updates the weight for iBERA bribes
function updateInfraredBERABribesWeight(uint256 _weight)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_weight | uint256 | uint256 The weight value |
updateFee
Updates the fee rate charged on different harvest functions
Fee rate in units of 1e6 or hundredths of 1 bip
function updateFee(ConfigTypes.FeeType _t, uint256 _fee)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_t | ConfigTypes.FeeType | FeeType The fee type |
_fee | uint256 | uint256 The fee rate to update to |
claimProtocolFees
Claims accumulated protocol fees in contract
function claimProtocolFees(address _to, address _token, uint256 _amount)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_to | address | address The recipient of the fees |
_token | address | address The token to claim fees in |
_amount | uint256 | uint256 The amount of accumulated fees to claim |
setIBGT
Sets the address of the iBGT contract
Infrared must be granted MINTER_ROLE on IBGT to set the address
function setIBGT(address _ibgt) external;
Parameters
Name | Type | Description |
---|---|---|
_ibgt | address | The address of the iBGT contract |
setRed
Sets the address of the RED contract
Infrared must be granted MINTER_ROLE on RED to set the address
function setRed(address _red) external;
Parameters
Name | Type | Description |
---|---|---|
_red | address | The address of the RED contract |
updateRedMintRate
Updates the mint rate for RED
function updateRedMintRate(uint256 _redMintRate) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_redMintRate | uint256 | The new mint rate for RED |
chargedFeesOnRewards
function chargedFeesOnRewards(
uint256 _amt,
uint256 _feeTotal,
uint256 _feeProtocol
)
public
view
returns (uint256 amtRecipient, uint256 amtVoter, uint256 amtProtocol);
harvestBase
Claims all the BGT base and commission rewards minted to this contract for validators.
function harvestBase() public;
harvestVault
Claims all the BGT rewards for the vault associated with the given staking token.
function harvestVault(address _asset) external;
Parameters
Name | Type | Description |
---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
harvestBribes
Claims all the bribes rewards in the contract forwarded from Berachain POL.
function harvestBribes(address[] calldata _tokens) external;
Parameters
Name | Type | Description |
---|---|---|
_tokens | address[] | address[] memory The addresses of the tokens to harvest in the contract. |
collectBribes
Collects bribes from bribe collector and distributes to wiBERA and iBGT Infrared vaults.
function collectBribes(address _token, uint256 _amount)
external
onlyCollector;
harvestOperatorRewards
Credits all accumulated rewards to the operator
function harvestOperatorRewards() public;
harvestBoostRewards
Claims all the BGT staker rewards from boosting validators.
Sends rewards to iBGT vault.
function harvestBoostRewards() external;
addValidators
Adds validators to the set of InfraredValidators
.
function addValidators(ValidatorTypes.Validator[] calldata _validators)
external
onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_validators | ValidatorTypes.Validator[] | Validator[] memory The validators to add. |
removeValidators
Removes validators from the set of InfraredValidators
.
function removeValidators(bytes[] calldata _pubkeys) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | 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
Name | Type | Description |
---|---|---|
_current | bytes | bytes The pubkey of the validator to replace. |
_new | bytes | bytes 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
Name | Type | Description |
---|---|---|
_pubkey | bytes | bytes The pubkey of the validator to queue the cutting board for |
_startBlock | uint64 | uint64 The start block for reward weightings |
_weights | IBeraChef.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
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to queue boosts for. |
_amts | uint128[] | 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
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boosts for. |
_amts | uint128[] | 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
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | 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
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | |
_amts | uint128[] |
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
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | |
_amts | uint128[] |
dropBoosts
Drops an amount of BGT from an existing boost of validators by user.
function dropBoosts(bytes[] calldata _pubkeys) external;
Parameters
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] |
infraredValidators
Gets the set of infrared validator pubkeys.
function infraredValidators()
public
view
virtual
returns (ValidatorTypes.Validator[] memory validators);
Returns
Name | Type | Description |
---|---|---|
validators | ValidatorTypes.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
Name | Type | Description |
---|---|---|
<none> | uint256 | num uint256 The number of infrared validators in validator set. |
isInfraredValidator
Checks if a validator is an infrared validator.
function isInfraredValidator(bytes calldata _validator)
public
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_validator | bytes |
Returns
Name | Type | Description |
---|---|---|
<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
Name | Type | Description |
---|---|---|
<none> | uint256 | bgtBalance The BGT balance held by this address |
whitelistedRewardTokens
Mapping of tokens that are whitelisted to be used as rewards or accepted as bribes
serves as central source of truth for whitelisted reward tokens for all Infrared contracts
function whitelistedRewardTokens(address token) public view returns (bool);
vaultRegistry
Mapping of staking token addresses to their corresponding InfraredVault
Each staking token can only have one vault
function vaultRegistry(address _stakingToken)
public
view
returns (IInfraredVault vault);
setVaultRegistrationPauseStatus
Sets new vault registration paused or not
function setVaultRegistrationPauseStatus(bool pause) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
pause | bool | True to pause, False to un pause |
rewardsDuration
The rewards duration
Used as gloabl variabel to set the rewards duration for all new reward tokens on InfraredVaults
function rewardsDuration() public view returns (uint256 duration);
Returns
Name | Type | Description |
---|---|---|
duration | uint256 | uint256 The reward duration period, in seconds |
fees
Protocol fee rates to charge for various harvest function distributions
function fees(uint256 t) public view override returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
t | uint256 |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The fee rate |
protocolFeeAmounts
The unclaimed Infrared protocol fees of token accumulated by contract
function protocolFeeAmounts(address _token) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
_token | address |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 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;
}