InfraredV1_2
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
Name | Type | Description |
---|---|---|
vs | ValidatorManagerLib.ValidatorStorage | The validator storage struct |
_vaultStorage
function _vaultStorage()
internal
pure
returns (VaultManagerLib.VaultStorage storage vs);
Returns
Name | Type | Description |
---|---|---|
vs | VaultManagerLib.VaultStorage | The vault storage struct |
_rewardsStorage
function _rewardsStorage()
internal
pure
returns (RewardsLib.RewardsStorage storage rs);
Returns
Name | Type | Description |
---|---|---|
rs | RewardsLib.RewardsStorage | The 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
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 |
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 |
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
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 |
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:
- The reward token is malfunctioning (e.g., transfers failing)
- The reward token is malicious
- 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
Name | Type | Description |
---|---|---|
_stakingToken | address | The address of the staking token associated with the vault |
_rewardsToken | address | The 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
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 |
migrateVault
Migrates reward vault from old v0 to new v1
function migrateVault(address _asset, uint8 versionToUpgradeTo)
external
onlyGovernor
returns (address newVault);
Parameters
Name | Type | Description |
---|---|---|
_asset | address | Staking asset of vault |
versionToUpgradeTo | uint8 | Vault 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
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 |
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
Name | Type | Description |
---|---|---|
_asset | address | The 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
Name | Type | Description |
---|---|---|
_asset | address | The 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
Name | Type | Description |
---|---|---|
_vault | address | The 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
Name | Type | Description |
---|---|---|
_vault | address | The 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
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. |
recoverERC20FromOldVault
Recover ERC20 tokens from old vault.
function recoverERC20FromOldVault(
address _vault,
address _to,
address _token,
uint256 _amount
) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_vault | address | address The address of the old vault. |
_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 |
updateInfraredBERABribeSplit
Updates the weight for iBERA bribes
function updateInfraredBERABribeSplit(uint256 _weight) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_weight | uint256 | uint256 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
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) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_to | address | address The recipient of the fees |
_token | address | address 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
Name | Type | Description |
---|---|---|
_ir | address | The address of the IR contract |
setVoter
Sets the address of the Voter contract
function setVoter(address _voter) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_voter | address | The address of the IR contract |
updateIRMintRate
Updates the mint rate for IR
function updateIRMintRate(uint256 _irMintRate) external onlyGovernor;
Parameters
Name | Type | Description |
---|---|---|
_irMintRate | uint256 | The 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
Name | Type | Description |
---|---|---|
_asset | address | address 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
Name | Type | Description |
---|---|---|
_vault | address | The address of the old vault |
_asset | address |
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
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.
_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
Name | Type | Description |
---|---|---|
_validators | ValidatorTypes.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
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[] | bytes[] calldata The pubkeys of the validators to remove boost from. |
_amts | uint128[] | 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
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] calldata The pubkeys of the validators to remove boost from. |
_amts | uint128[] | 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
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | 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
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 _pubkey)
public
view
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
_pubkey | bytes | bytes The pubkey of the validator to check. |
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);
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 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 | The index of the fee rate |
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 | address The token address for the accumulated fees |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | uint256 The amount of accumulated fees |
receive
receive() external payable;