Smart contract APIs

Infrared.sol

Git source coming soon

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

Parameters

NameTypeDescription
_assetaddressaddress The address of the asset, e.g. Honey:Bera LP token.
_rewardTokensaddress[]

Returns

NameTypeDescription
<none>IInfraredVaultvault 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;

Parameters

NameTypeDescription
_tokenaddressaddress The address of the token to whitelist.
_whitelistedboolbool 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;

Parameters

NameTypeDescription
_rewardsDurationuint256uint256 The new rewards duration.

pauseVault

Pauses staking functionality on this vault.

function pauseVault(address _asset) external onlyGovernor whenInitialized;

Parameters

NameTypeDescription
_assetaddressaddress 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;

Parameters

NameTypeDescription
_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
    whenInitialized;

Parameters

NameTypeDescription
_delegateeaddressaddress The address to delegate votes to

updateWeight

Updates the weight for a weight type.

function updateWeight(WeightType _t, uint256 _weight)
    external
    onlyGovernor
    whenInitialized;

Parameters

NameTypeDescription
_tWeightTypeWeightType The weight type
_weightuint256uint256 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;

Parameters

NameTypeDescription
_tFeeTypeFeeType The fee type
_feeuint256uint256 The fee rate to update to

claimProtocolFees

Claims accumulated protocol fees in contract

function claimProtocolFees(address _to, address _token, uint256 _amount)
    external
    onlyGovernor
    whenInitialized;

Parameters

NameTypeDescription
_toaddressaddress The recipient of the fees
_tokenaddressaddress The token to claim fees in
_amountuint256uint256 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;

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

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.

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;

Parameters

NameTypeDescription
_vaultIInfraredVaultIInfraredVault The address of the vault.
_tokenaddressaddress The reward token.
_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.

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

Parameters

NameTypeDescription
_recipientaddressaddress The address of the recipient.
_tokenaddressaddress The address of the token to forward to recipient.
_amountuint256

_handleBGTRewardsForVault

Handles BGT token rewards, minting IBGT and supplying to the vault.

function _handleBGTRewardsForVault(
    IInfraredVault _vault,
    uint256 _bgtAmt,
    uint256 _feeTotal,
    uint256 _feeProtocol
) internal;

Parameters

NameTypeDescription
_vaultIInfraredVaultaddress The address of the vault.
_bgtAmtuint256uint256 The BGT reward amount.
_feeTotaluint256uint256 The rate to charge for total fees on iBGT _bgtAmt.
_feeProtocoluint256uint256 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;

Parameters

NameTypeDescription
_bgtAmtuint256uint256 The BGT reward amount.
_feeTotaluint256uint256 The rate to charge for total fees on _bgtAmt.
_feeProtocoluint256uint256 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);

Parameters

NameTypeDescription
pubkeybytesThe 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;

Parameters

NameTypeDescription
_validatorsValidator[]Validator[] memory The validators to add.

removeValidators

Removes validators from the set of InfraredValidators.

function removeValidators(bytes[] memory _pubkeys)
    external
    onlyGovernor
    whenInitialized;

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

Parameters

NameTypeDescription
_currentbytesbytes The pubkey of the validator to replace.
_newbytesbytes 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;

Parameters

NameTypeDescription
_pubkeybytesbytes The pubkey of the validator to update commission rate for.
_commissionuint256uint256 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;

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[] memory _pubkeys, uint128[] memory _amts)
    external
    onlyKeeper
    whenInitialized;

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
    onlyKeeper
    whenInitialized;

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

Parameters

NameTypeDescription
_pubkeysbytes[]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;

Parameters

NameTypeDescription
_pubkeysbytes[]address[] memory The pubkeys of the validator to remove boost from.
_amtsuint128[]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);

Returns

NameTypeDescription
validatorsValidator[]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 _validator)
    public
    view
    returns (bool);

Parameters

NameTypeDescription
_validatorbytes

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