Infrared
Inherits: InfraredUpgradeable, IInfrared A contract for managing the set of infrared validators, infrared vaults, and interacting with all forms of staking, delegating, incentive rewards. This contract is the main entry point for interacting with the Infrared protocol.
State Variables
whitelistedRewardTokens
mapping(address => bool) public whitelistedRewardTokens;
vaultRegistry
mapping(address => IInfraredVault) public vaultRegistry;
_infraredValidatorIds
EnumerableSet.Bytes32Set internal _infraredValidatorIds;
_infraredValidatorPubkeys
mapping(bytes32 id => bytes pub) internal _infraredValidatorPubkeys;
_bgt
IBerachainBGT internal immutable _bgt;
ibgt
The IBGT liquid staked token
IIBGT public immutable ibgt;
wibera
The wrapped Infrared bera token
IERC20 public immutable wibera;
rewardsFactory
The Berachain rewards vault factory address
IBerachainRewardsVaultFactory public immutable rewardsFactory;
chef
inheritdoc IInfrared
IBeraChef public immutable chef;
wbera
Wrapped bera
IWBERA public immutable wbera;
honey
Honey ERC20 token
IERC20 public immutable honey;
collector
bribe collector contract
IBribeCollector public collector;
distributor
Infrared distributor for BGT rewards to validators
IInfraredDistributor public distributor;
IVoter public voter;
rewardsDuration
The rewards duration
uint256 public rewardsDuration;
ibgtVault
The IBGT vault
IInfraredVault public ibgtVault;
wiberaVault
The wrapped IBERA vault
IInfraredVault public wiberaVault;
protocolFeeAmounts
The unclaimed Infrared protocol fees of token accumulated by contract
mapping(address => uint256) public protocolFeeAmounts;
weights
Weights for various harvest function distributions
mapping(uint256 => uint256) public weights;
fees
Protocol fee rates to charge for various harvest function distributions
mapping(uint256 => uint256) public fees;
WEIGHT_UNIT
Weight units when partitioning reward amounts in hundredths of 1 bip
uint256 internal constant WEIGHT_UNIT = 1e6;
FEE_UNIT
Protocol fee rate in hundredths of 1 bip
uint256 internal constant FEE_UNIT = 1e6;
uint256 internal constant RATE_UNIT = 1e6;
COMMISSION_MAX
Commission rate in units of 1 bip
uint256 internal constant COMMISSION_MAX = 1e3;
Functions
onlyCollector
modifier onlyCollector();
constructor
constructor(
address _ibgt,
address _rewardsFactory,
address _chef,
address _wbera,
address _honey,
address _wibera
) InfraredUpgradeable(address(0));
initialize
function initialize(
address _admin,
address _collector,
address _distributor,
address _voter,
uint256 _rewardsDuration
) external initializer;
_registerVault
Registers a new vault
function _registerVault(address _asset, address[] memory _rewardTokens)
private
returns (address _new);
registerVault
Registers a new vault.
Infrared.sol must be admin over MINTER_ROLE on IBGT to grant minter role to deployed vault.
function registerVault(address _asset, address[] memory _rewardTokens)
external
onlyKeeper
whenInitialized
returns (IInfraredVault);
Name | Type | Description |
---|---|---|
_asset | address | address The address of the asset, e.g. Honey LP token. |
_rewardTokens | address[] |
Name | Type | Description |
---|---|---|
<none> | IInfraredVault | vault IInfraredVault The address of the new InfraredVault contract. |
_updateWhiteListedRewardTokens
Updates whitelisted reward tokens
function _updateWhiteListedRewardTokens(address _token, bool _whitelisted)
private;
updateWhiteListedRewardTokens
whitelists a reward token
function updateWhiteListedRewardTokens(address _token, bool _whitelisted)
external
onlyGovernor
whenInitialized;
Name | Type | Description |
---|---|---|
_token | address | address The address of the token to whitelist. |
_whitelisted | bool | bool Whether the token is whitelisted or not. |
updateRewardsDuration
Updates the period that rewards will be distributed over in InfraredVaults.
function updateRewardsDuration(uint256 _rewardsDuration)
external
onlyGovernor
whenInitialized;
Name | Type | Description |
---|---|---|
_rewardsDuration | uint256 | uint256 The new rewards duration. |
pauseVault
Pauses staking functionality on this vault.
function pauseVault(address _asset) external onlyGovernor whenInitialized;
Name | Type | Description |
---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
recoverERC20
Recover ERC20 tokens that were accidentally sent to the contract or where not whitelisted.
function recoverERC20(address _to, address _token, uint256 _amount)
external
onlyGovernor
whenInitialized;
Name | Type | Description |
---|---|---|
_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
whenInitialized;
Name | Type | Description |
---|---|---|
_delegatee | address | address The address to delegate votes to |
updateWeight
Updates the weight for a weight type.
function updateWeight(WeightType _t, uint256 _weight)
external
onlyGovernor
whenInitialized;
Name | Type | Description |
---|---|---|
_t | WeightType | WeightType The weight type |
_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(FeeType _t, uint256 _fee)
external
onlyGovernor
whenInitialized;
Name | Type | Description |
---|---|---|
_t | 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
whenInitialized;
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 |
chargedFeesOnRewards
function chargedFeesOnRewards(
uint256 _amt,
uint256 _feeTotal,
uint256 _feeProtocol
)
public
view
returns (uint256 amtRecipient, uint256 amtVoter, uint256 amtProtocol);
_distributeFeesOnRewards
function _distributeFeesOnRewards(
address _token,
uint256 _amtVoter,
uint256 _amtProtocol
) internal;
harvestBase
Claims all the BGT base and commission rewards minted to this contract for validators.
function harvestBase() external whenInitialized;
harvestVault
Claims all the BGT rewards for the vault associated with the given staking token.
function harvestVault(address _asset) external whenInitialized;
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[] memory _tokens) external whenInitialized;
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
whenInitialized;
harvestBoostRewards
Claims all the BGT staker rewards from boosting validators.
Sends rewards to iBGT vault.
function harvestBoostRewards() external whenInitialized;
_handleTokenRewardsForVault
Handles non-IBGT token rewards to the vault.
function _handleTokenRewardsForVault(
IInfraredVault _vault,
address _token,
uint256 _amount,
uint256 _feeTotal,
uint256 _feeProtocol
) internal;
Name | Type | Description |
---|---|---|
_vault | IInfraredVault | IInfraredVault The address of the vault. |
_token | address | address The reward token. |
_amount | uint256 | uint256 The amount of reward token to send to vault. |
_feeTotal | uint256 | uint256 The rate to charge for total fees on _amount . |
_feeProtocol | uint256 | uint256 The rate to charge for protocol treasury on total fees. |
_handleTokenBribesForReceiver
Handles non-IBGT token bribe rewards to a non-vault receiver address.
Does not take protocol fee on bribe coin, as taken on bribe collector payout token in eventual callback.
function _handleTokenBribesForReceiver(
address _recipient,
address _token,
uint256 _amount
) internal;
Name | Type | Description |
---|---|---|
_recipient | address | address The address of the recipient. |
_token | address | address The address of the token to forward to recipient. |
_amount | uint256 |
_handleBGTRewardsForVault
Handles BGT token rewards, minting IBGT and supplying to the vault.
function _handleBGTRewardsForVault(
IInfraredVault _vault,
uint256 _bgtAmt,
uint256 _feeTotal,
uint256 _feeProtocol
) internal;
Name | Type | Description |
---|---|---|
_vault | IInfraredVault | address The address of the vault. |
_bgtAmt | uint256 | uint256 The BGT reward amount. |
_feeTotal | uint256 | uint256 The rate to charge for total fees on iBGT _bgtAmt . |
_feeProtocol | uint256 | uint256 The rate to charge for protocol treasury on total iBGT fees. |
_handleBGTRewardsForDistributor
Handles BGT base rewards supplied to validator distributor.
function _handleBGTRewardsForDistributor(
uint256 _bgtAmt,
uint256 _feeTotal,
uint256 _feeProtocol
) internal;
Name | Type | Description |
---|---|---|
_bgtAmt | uint256 | uint256 The BGT reward amount. |
_feeTotal | uint256 | uint256 The rate to charge for total fees on _bgtAmt . |
_feeProtocol | uint256 | uint256 The rate to charge for protocol treasury on total fees. |
_getValidatorId
Gets the validator ID for associated CL pubkey
function _getValidatorId(bytes memory pubkey) internal pure returns (bytes32);
Name | Type | Description |
---|---|---|
pubkey | bytes | The CL pubkey of validator |
_addValidatorToSet
Adds validator pubkey to validator set
Reverts if already exists in set
function _addValidatorToSet(bytes memory pubkey) private;
_removeValidatorFromSet
Removes validator pubkey from validator set
Reverts if does not already exist in set
function _removeValidatorFromSet(bytes memory pubkey) private;
addValidators
Adds validators to the set of InfraredValidators
.
function addValidators(Validator[] memory _validators)
external
onlyGovernor
whenInitialized;
Name | Type | Description |
---|---|---|
_validators | Validator[] | Validator[] memory The validators to add. |
removeValidators
Removes validators from the set of InfraredValidators
.
function removeValidators(bytes[] memory _pubkeys)
external
onlyGovernor
whenInitialized;
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
whenInitialized;
Name | Type | Description |
---|---|---|
_current | bytes | bytes The pubkey of the validator to replace. |
_new | bytes | bytes The new validator pubkey. |
_getValidatorCommission
Gets the current validator commission rate by calling BGT.
function _getValidatorCommission(bytes memory _pubkey)
internal
view
returns (uint256 rate);
_getValidatorAddress
Gets the validator address for claiming on distributor associated with pubkey
function _getValidatorAddress(bytes memory _pubkey)
internal
view
returns (address);
_updateValidatorCommission
Updates validator commission rate calling BGT to set.
function _updateValidatorCommission(bytes memory _pubkey, uint256 _commission)
private;
updateValidatorCommission
Updates a validator commission rate in the set of InfraredValidators
.
function updateValidatorCommission(bytes calldata _pubkey, uint256 _commission)
external
onlyGovernor
whenInitialized;
Name | Type | Description |
---|---|---|
_pubkey | bytes | bytes The pubkey of the validator to update commission rate for. |
_commission | uint256 | uint256 The commission rate to update to. |
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;
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[] memory _pubkeys, uint128[] memory _amts)
external
onlyKeeper
whenInitialized;
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[] memory _pubkeys, uint128[] memory _amts)
external
onlyKeeper
whenInitialized;
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[] memory _pubkeys) external whenInitialized;
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to activate boosts for. |
dropBoosts
Removes boost _amt
of BGT boost from _pubkey
.
function dropBoosts(bytes[] memory _pubkeys, uint128[] memory _amts)
external
onlyKeeper
whenInitialized;
Name | Type | Description |
---|---|---|
_pubkeys | bytes[] | address[] memory The pubkeys of the validator to remove boost from. |
_amts | uint128[] | uint128[] memory The amounts of BGT to remove from the boost. |
infraredValidators
Gets the set of infrared validator pubkeys.
function infraredValidators()
public
view
virtual
returns (Validator[] memory validators);
Name | Type | Description |
---|---|---|
validators | Validator[] | Validator[] memory The set of infrared validators. |
numInfraredValidators
Gets the number of infrared validators in validator set.
function numInfraredValidators() external view returns (uint256);
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 memory _validator)
public
view
returns (bool);
Name | Type | Description |
---|---|---|
_validator | bytes |
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);
Name | Type | Description |
---|---|---|
<none> | uint256 | bgtBalance The BGT balance held by this address |