Infrared Protocol 🔴
Liquid Staking Infrastructure for Berachain's Proof-of-Liquidity
Infrared Protocol revolutionizes staking on Berachain by providing liquid staking derivatives (LSDs) that unlock the full potential of BGT and BERA while maintaining exposure to Proof-of-Liquidity rewards.
📋 Table of Contents
- Overview
- Key Features
- Documentation
- Architecture
- Getting Started
- Development
- Integration Guide
- Testing
- Security
- Contributing
- License
Overview
The Infrared Protocol addresses critical limitations in Berachain's native staking system:
The Problem
- BGT (Berachain Governance Token) lacks transferability and liquidity
- Validator staking requires technical expertise and significant capital
- Staked assets are locked, reducing capital efficiency
Our Solution
- IBGT: A liquid staked representation of BGT that's fully transferable
- IBERA: Democratized validator staking through liquid staking tokens
- Seamless Integration: Tight coupling with Berachain's Proof-of-Liquidity system
Key Features
- ✅ Liquid Staking: Convert BGT to IBGT and BERA to IBERA without lockups
- ✅ POL Rewards: Continue earning Proof-of-Liquidity inflation while staked
- ✅ Validator Democratization: Access validator rewards without running infrastructure
- ✅ Composability: Use liquid staking tokens across DeFi protocols
- ✅ Governance: Vote-escrowed NFTs (veNFTs) for protocol governance
- ✅ Bribes & Incentives: Sophisticated reward distribution and bribe collection system
Documentation
| Resource | Description |
|---|---|
| 📚 Documentation | Complete protocol documentation |
| 🏗️ Architecture | Technical architecture overview |
| 📍 Deployments | Contract addresses by network |
| 🔍 Audits | Security audit reports |
| 📖 NatSpec Docs | Auto-generated contract documentation |
Architecture
Contract Modules
🔵 Core Contracts - POL Integration & BGT Management
The core module facilitates interaction with Berachain's Proof-of-Liquidity reward system, managing BGT accumulation, iBGT issuance, and reward distribution.
| Contract | Purpose | Key Features |
|---|---|---|
Infrared.sol | Main coordination contract | • Validator registration & RewardAllocation configuration • Centralized BGT claiming and iBGT conversion • Manages harvestBase and harvestBoostRewards functions |
InfraredVault.sol | User staking management | • Stakes assets into BerachainRewardsVaults • Accumulates BGT rewards for conversion to iBGT • Extends MultiRewards for diverse token support |
InfraredDistributor.sol | Validator reward distribution | • Distributes iBGT rewards to Infrared validators • Tracks rewards via snapshots for easy claiming • Manages cumulative reward totals per validator |
BribeCollector.sol | POL bribe management | • Collects bribes from BerachainRewardsVaults • Auctions bribes with proceeds to validators & iBGT holders • Governance-configurable parameters |
MultiRewards.sol | Multi-token rewards base | • Supports up to 10 reward tokens per vault • Enables varied incentive structures |
Key Flows: Users deposit → InfraredVaults stake into BerachainRewardsVaults → BGT rewards accumulate → Infrared claims & converts to iBGT → Distribution to stakers
🟢 Staking Contracts - BERA Liquid Staking
The staking module enables liquid staking of BERA (native gas token) through iBERA tokens, maintaining liquidity while participating in consensus.
| Contract | Purpose | Key Features |
|---|---|---|
IBERA.sol | Liquid staking coordinator | • Mints/burns iBERA tokens representing staked BERA • Manages validator stakes and autocompounding • Configures protocol fee parameters |
IBERADepositor.sol | Deposit queue management | • Queues and executes BERA deposits • Interacts with Berachain's deposit precompile • Distributes deposits across validators |
IBERAWithdrawor.sol | Withdrawal processing | • Manages withdrawal queue and requests • Handles validator stake rebalancing • Coordinates with IBERAClaimor for claims |
IBERAClaimor.sol | Secure claim mechanism | • Tracks user claim records • Enables safe BERA transfers to users • Supports batch processing |
IBERAFeeReceivor.sol | Fee & MEV collection | • Receives priority fees and MEV from validators • Splits between treasury and autocompounding • Periodic fee sweeping into protocol |
Key Flows:
- Deposit: BERA → IBERA contract → Queue → Validator staking → Receive iBERA
- Withdraw: Burn iBERA → Queue withdrawal → Process from validators → Claim BERA
- Fees: Validator rewards → IBERAFeeReceivor → Treasury/Autocompound split
🟣 Voting Contracts - veTokenomics & Governance
The voting module implements a voting escrow (ve) system for allocating IBGT rewards and validator resources through community governance.
| Contract | Purpose | Key Features |
|---|---|---|
VotingEscrow.sol | veNFT token locking | • Issues veNFTs for locked tokens • Voting power based on lock duration • Power decay over time mechanism |
Voter.sol | Allocation voting system | • Manages cutting board distribution votes • Whitelisted token bribe system • Epoch-based voting windows • Weight tallying and updates |
VelodromeTimeLibrary | Time management | • Weekly epoch calculations • Voting window enforcement • Synchronized voting cycles |
Key Concepts:
- Voting Power: Proportional to tokens locked and duration (with decay)
- Cutting Board: Validator resource allocation across vaults
- Bribes: Whitelisted tokens used to incentivize specific votes
- Epochs: Weekly voting periods with defined windows
Key Flows: Lock tokens → Receive veNFT → Vote on allocations → Influence rewards → Claim bribes
Getting Started
Prerequisites
- Foundry toolkit
- Git
- Make (optional, for using Makefile commands)
Installation
# Clone the repository
git clone https://github.com/infrared-dao/infrared-contracts.git
cd infrared-contracts
# Install dependencies
forge install
# Setup environment variables
cp .env.example .env
# Edit .env with your configuration
# Build contracts
forge build
Development
Build & Compile
# Build contracts
forge build
# Build with optimization
forge build --optimize --optimizer-runs 200
# Clean build artifacts
forge clean
Code Quality
# Format code
forge fmt
# Check formatting
forge fmt --check
# Run static analysis
slither .
Integration Guide
Installation for External Projects
Add Infrared to your Foundry project:
forge install infrared-dao/infrared-contracts
Update foundry.toml:
[dependencies]
infrared-contracts = { version = "1.0.0" }
[remappings]
"@infrared/=lib/infrared-contracts/contracts/"
Basic Integration Example
pragma solidity ^0.8.19;
import {IInfrared} from '@infrared/interfaces/IInfrared.sol';
import {IInfraredVault} from '@infrared/interfaces/IInfraredVault.sol';
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract MyIntegration {
IInfrared public immutable infrared;
constructor(address _infrared) {
infrared = IInfrared(_infrared);
}
function stakeAssets(address asset, uint256 amount) external {
// Get the vault for this asset
IInfraredVault vault = IInfrared(infrared).vaultRegistry(asset);
require(address(vault) != address(0), "Vault not found");
// Approve and stake
IERC20(asset).transferFrom(msg.sender, address(this), amount);
IERC20(asset).approve(address(vault), amount);
vault.stake(amount);
}
function checkRewards(address user, address asset) external view
returns (IInfraredVault.RewardData[] memory) {
IInfraredVault vault = IInfrared(infrared).vaultRegistry(asset);
return vault.getUserRewardsEarned(user);
}
function harvestRewards(address asset) external {
IInfraredVault vault = IInfrared(infrared).vaultRegistry(asset);
vault.getReward();
}
function exitPosition(address asset) external {
IInfraredVault vault = IInfrared(infrared).vaultRegistry(asset);
vault.exit(); // Withdraws all + harvests rewards
}
}
Testing
Run Tests
# Run all tests
forge test
# Run with gas reporting
forge test --gas-report
# Run specific test file
forge test --match-path test/InfraredVault.t.sol
# Run specific test function
forge test --match-test testStakeFunction
# Run with verbosity (1-5)
forge test -vvv
# Run fork tests
forge test --fork-url $RPC_URL --fork-block-number 12345678
Test Coverage
# Generate coverage report
forge coverage
# Generate detailed coverage report
forge coverage --report lcov
# Generate HTML coverage report
forge coverage --report lcov && genhtml lcov.info -o coverage
Security
Audits
All audit reports are available in the audits directory and on our documentation site.
Bug Bounty
We have an active bug bounty program. Please review our security policy for details on:
- Scope and rewards
- Responsible disclosure process
- Out-of-scope vulnerabilities
Security Contact
For security concerns, please email: security@infrared.finance
DO NOT open public issues for security vulnerabilities.
Contributing
We welcome contributions! Please see our Contributing Guide for details on:
- Code of Conduct
- Development process
- Pull request process
- Coding standards
Quick Contribution Guide
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Community & Support
License
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ by the Infrared team
Contents
IRateProvider
Functions
getRate
getRate()
Returns the current rate of a given asset.
function getRate() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The current rate of the asset. |
InfraredBERARateProvider
Inherits: IRateProvider
Returns the value of iBERA in terms of BERA
State Variables
ibera
The address of the ibera contract
IInfraredBERAV2 public immutable ibera;
Functions
constructor
Constructs the MevETHRateProvider contract, setting the mevETH address
constructor(IInfraredBERAV2 _ibera);
getRate
Returns the value of iBERA in terms of BERA
function getRate() external view override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | amount the value of iBERA in terms of BERA |
Contents
- libraries
- upgrades
- BribeCollector
- Infrared
- InfraredBGT
- InfraredDistributor
- InfraredGovernanceToken
- InfraredUpgradeable
- InfraredVault
- MultiRewards
- WrappedVault
Contents
ConfigTypes
Enums
FeeType
Fee type enum for determining rates to charge on reward distribution.
enum FeeType {
HarvestOperatorFeeRate,
HarvestOperatorProtocolRate,
HarvestVaultFeeRate,
HarvestVaultProtocolRate,
HarvestBribesFeeRate,
HarvestBribesProtocolRate,
HarvestBoostFeeRate,
HarvestBoostProtocolRate
}
RewardsLib
State Variables
UNIT_DENOMINATOR
Unit denominotor for calculating all fees and rates in the system
All fees and rates are calculated out of 1e6
uint256 internal constant UNIT_DENOMINATOR = 1e6;
Functions
harvestOperatorRewards
Harvest rewards given to our operators for setting their cuttingboard weights ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/staking/InfraredBERAFeeReceivor.sol#L83
function harvestOperatorRewards(
RewardsStorage storage $,
address ibera,
address voter,
address distributor
) external returns (uint256 _amt);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
ibera | address | The address of the InfraredBERA token |
voter | address | The address of the voter (address(0) if IR token is not live) |
distributor | address | The address of the distributor |
Returns
| Name | Type | Description |
|---|---|---|
_amt | uint256 | The amount of rewards harvested |
chargedFeesOnRewards
Generic function to calculate the fees charged on rewards, returning the amount owed to the recipient, protocol, and voter.
the recipient is the amount of rewards being sent forward into the protocol for example a vault
function chargedFeesOnRewards(
uint256 amount,
uint256 totalFeeRate,
uint256 protocolFeeRate
)
public
pure
returns (uint256 recipient, uint256 voterFees, uint256 protocolFees);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of rewards to calculate fees on |
totalFeeRate | uint256 | The total fee rate to charge on rewards (protocol + voter) |
protocolFeeRate | uint256 | The rate to charge for protocol fees |
Returns
| Name | Type | Description |
|---|---|---|
recipient | uint256 | The amount of rewards to send to the recipient |
voterFees | uint256 | The amount of rewards to send to the voter |
protocolFees | uint256 | The amount of rewards to send to the protocol |
_distributeFeesOnRewards
Distributes fees on rewards to the protocol, voter, and recipient.
_protocolFeeAmounts The accumulator for protocol fees per token
_voter The address of the voter
_token The address of the reward token
_amtVoter The amount of rewards for the voter
_amtProtocol The amount of rewards for the protocol
function _distributeFeesOnRewards(
mapping(address => uint256) storage protocolFeeAmounts,
address _voter,
address _token,
uint256 _amtVoter,
uint256 _amtProtocol
) internal;
_handleTokenRewardsForVault
Handles non-InfraredBGT token rewards to the vault.
function _handleTokenRewardsForVault(
RewardsStorage storage $,
IInfraredVault _vault,
address _token,
address voter,
uint256 _amount,
uint256 _feeTotal,
uint256 _feeProtocol,
uint256 rewardsDuration
) internal;
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | RewardsStorage The storage pointer for all rewards accumulators. |
_vault | IInfraredVault | IInfraredVault The address of the vault. |
_token | address | address The reward token. |
voter | address | address The address of the voter. |
_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. |
rewardsDuration | uint256 | uint256 The duration of the rewards. |
updateIRMintRate
Update the IR minting rate for the protocol.
This rate determines how many IR tokens are minted whenever BGT rewards are harvested.
For example, if the rate is 500,000 (0.5 * UNIT_DENOMINATOR), 0.5 IR is minted per BGT.
If the rate is 2,000,000 (2 * UNIT_DENOMINATOR), 2 IR are minted per BGT.
The actuall calculation is done in the harvestVault function when BGT rewards are harvested and IR tokens are minted accordingly.
function updateIRMintRate(RewardsStorage storage $, uint256 newRate) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
newRate | uint256 | The new IR minting rate out of UNIT_DENOMINATOR(1e6 being 100% or a 1:1 rate) |
delegateBGT
Delegates Berachain Governance Voting Power to a delegatee
function delegateBGT(address _delegatee, address bgt) external;
Parameters
| Name | Type | Description |
|---|---|---|
_delegatee | address | The address to delegate voting power to |
bgt | address | The address of the BGT token |
updateInfraredBERABribeSplit
Update the split ratio for iBERA and iBGT rewards
function updateInfraredBERABribeSplit(RewardsStorage storage $, uint256 _split)
external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
_split | uint256 | The ratio for splitting received bribes to be iBERA and iBGT, weighted towards iBERA |
updateFee
Update the fee rate for a given fee type
function updateFee(
RewardsStorage storage $,
ConfigTypes.FeeType _t,
uint256 _fee
) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
_t | ConfigTypes.FeeType | The fee type to update |
_fee | uint256 | The new fee rate |
claimProtocolFees
Claim protocol fees for a given token
function claimProtocolFees(
RewardsStorage storage $,
address _to,
address _token
) external returns (uint256 _amountClaimed);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
_to | address | The address to send the protocol fees to |
_token | address | The token to claim protocol fees for |
harvestBase
Harvet's base rewards from the BGT contract, ie rewards from Distributor, given in BGT ref - https://github.com/berachain/contracts-monorepo/blob/main/src/pol/rewards/Distributor.sol#L160
The BGT accumilates in the contract, therfore can check balance(this) since all other BGT rewards are claimed and harvested atomically
Reward paid out to validators proposing a block, MUST be forwarded to IBERA.receivor, the fees are handled there. TODO: Link here.
function harvestBase(address ibgt, address bgt, address ibera)
external
returns (uint256 bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
ibgt | address | The address of the InfraredBGT toke |
bgt | address | The address of the BGT token |
ibera | address | The address of the InfraredBERA token |
Returns
| Name | Type | Description |
|---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested |
auctionBase
Alternative to Harvet base rewards, auctioning iBGT on harvestBaseCollector, from BGT rewards from Distributor ref - https://github.com/berachain/contracts-monorepo/blob/main/src/pol/rewards/Distributor.sol#L160
The BGT accumilates in the contract, therfore can check balance(this) since all other BGT rewards are claimed and harvested atomically
function auctionBase(address ibgt, address bgt, address harvestBaseCollector)
external
returns (uint256 bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
ibgt | address | The address of the InfraredBGT toke |
bgt | address | The address of the BGT token |
harvestBaseCollector | address | The address of the harvestBaseCollector contract |
Returns
| Name | Type | Description |
|---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested |
harvestVault
Harvests the accrued BGT rewards to a vault.
BGT transferred here directly to the user https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L404
function harvestVault(
RewardsStorage storage $,
IInfraredVault vault,
address bgt,
address ibgt,
address voter,
address ir,
uint256 rewardsDuration
) external returns (uint256 bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | |
vault | IInfraredVault | The address of the InfraredRewardVault, wrapping an underlying RewardVault |
bgt | address | The address of the BGT token |
ibgt | address | The address of the InfraredBGT token |
voter | address | The address of the voter (0 until IR token is live) |
ir | address | The address of the Infrared token |
rewardsDuration | uint256 | The duration of the rewards |
Returns
| Name | Type | Description |
|---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested |
harvestVaultForUser
Harvests berachain reward vault as operator for user.
BGT transferred here, iBGT minted to user
function harvestVaultForUser(
RewardsStorage storage $,
IBerachainRewardsVault vault,
address bgt,
address ibgt,
address voter,
address user
) external returns (uint256 bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | |
vault | IBerachainRewardsVault | The address of the Berachain reward vault |
bgt | address | The address of the BGT token |
ibgt | address | The address of the InfraredBGT token |
voter | address | The address of the voter (0 until IR token is live) |
user | address | The address of the User to claim bgt on behalf of |
Returns
| Name | Type | Description |
|---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested = amount of iBGT minted |
externalVaultRewards
View rewards to claim for berachain reward vault as operator for user.
function externalVaultRewards(
RewardsStorage storage $,
IBerachainRewardsVault vault,
address user
) external view returns (uint256 iBgtAmount);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | |
vault | IBerachainRewardsVault | The address of the Berachain reward vault |
user | address | The address of the User to claim bgt on behalf of |
Returns
| Name | Type | Description |
|---|---|---|
iBgtAmount | uint256 | The amount of BGT rewards harvested = amount of iBGT minted |
harvestOldVault
Harvests the accrued BGT rewards to a vault.
BGT transferred here directly to the user https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L404
function harvestOldVault(
RewardsStorage storage $,
IInfraredVault vault,
IInfraredVault newVault,
address bgt,
address ibgt,
address voter
) external returns (uint256 bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | |
vault | IInfraredVault | The address of the InfraredRewardVault, wrapping an underlying RewardVault |
newVault | IInfraredVault | |
bgt | address | The address of the BGT token |
ibgt | address | The address of the InfraredBGT token |
voter | address | The address of the voter (0 until IR token is live) |
Returns
| Name | Type | Description |
|---|---|---|
bgtAmt | uint256 | The amount of BGT rewards harvested |
harvestBribes
Harvest Bribes in tokens from RewardVault, sent to us via processIncentive ref - https://github.com/berachain/contracts-monorepo/blob/c374de32077ede0147985cf2bf6ed89570244a7e/src/pol/rewards/RewardVault.sol#L421
function harvestBribes(
RewardsStorage storage $,
address collector,
address[] memory _tokens,
bool[] memory whitelisted
) external returns (address[] memory tokens, uint256[] memory amounts);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
collector | address | The address of the bribe collector, which will auction off fees for WBERA |
_tokens | address[] | The array of token addresses to harvest |
whitelisted | bool[] | The array of booleans indicating if the token is whitelisted, and should be collected |
harvestBoostRewards
Harvest boost rewards from the BGT staker (in HONEY -- likely)
function harvestBoostRewards(
RewardsStorage storage $,
address bgt,
address ibgtVault,
address voter,
uint256 rewardsDuration
) external returns (address _token, uint256 _amount);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | The storage pointer for all rewards accumulators |
bgt | address | The address of the BGT token |
ibgtVault | address | The address of the InfraredBGT vault |
voter | address | The address of the voter (address(0) if IR token is not live) |
rewardsDuration | uint256 | The duration of the rewards |
Returns
| Name | Type | Description |
|---|---|---|
_token | address | The rewards token harvested (likely hunny) |
_amount | uint256 | The amount of rewards harvested |
redeemIbgtForBera
redeem ibgt for bera
function redeemIbgtForBera(address bgt, address ibgt, uint256 amount)
external;
Parameters
| Name | Type | Description |
|---|---|---|
bgt | address | The address of the BGT token |
ibgt | address | The address of the iBGT token |
amount | uint256 | Amount of ibgt to redeem |
collectBribesInWBERA
Callback from the BribeCollector to payout the WBERA bribes were auctioned off for ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/core/BribeCollector.sol#L87
WBERA is split between the iBERA product (where it is redeemed for BERA) and the rest is sent to the IBGT vault.
function collectBribesInWBERA(
RewardsStorage storage $,
uint256 _amount,
address wbera,
address ibera,
address ibgtVault,
address voter,
uint256 rewardsDuration
) external returns (uint256 amtInfraredBERA, uint256 amtIbgtVault);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | Storage pointer for reward accumulators |
_amount | uint256 | The amount of WBERA our bribes were auctioned off for |
wbera | address | The address of the WBERA token |
ibera | address | The address of the InfraredBERA token |
ibgtVault | address | The address of the InfraredBGT vault |
voter | address | The address of the voter (address(0) if IR token is not live) |
rewardsDuration | uint256 | The duration of the rewards |
Returns
| Name | Type | Description |
|---|---|---|
amtInfraredBERA | uint256 | The amount of WBERA sent to the iBERA product |
amtIbgtVault | uint256 | The amount of WBERA sent to the IBGT vault |
collectBribesInIBGT
Callback from the BribeCollector to payout the iBGT bribes were auctioned off for ref - https://github.com/infrared-dao/infrared-contracts/blob/develop/src/core/BribeCollector.sol#L87
iBGT is split between the iBERA product (where it is redeemed for BERA) and the rest is sent to the IBGT vault.
function collectBribesInIBGT(
RewardsStorage storage $,
uint256 _amount,
address ibgt,
address ibgtVault,
address voter,
address harvestBaseCollector,
uint256 rewardsDuration
) external returns (uint256 amtInfraredBERA, uint256 amtIbgtVault);
Parameters
| Name | Type | Description |
|---|---|---|
$ | RewardsStorage | Storage pointer for reward accumulators |
_amount | uint256 | The amount of iBGT our bribes were auctioned off for |
ibgt | address | The address of the iBGT token |
ibgtVault | address | The address of the InfraredBGT vault |
voter | address | The address of the voter (address(0) if IR token is not live) |
harvestBaseCollector | address | The address of base collector auction contract |
rewardsDuration | uint256 | The duration of the rewards |
Returns
| Name | Type | Description |
|---|---|---|
amtInfraredBERA | uint256 | The amount of iBGT sent to the iBERA product |
amtIbgtVault | uint256 | The amount of iBGT sent to the IBGT vault |
Events
ErrorMisconfiguredIRMinting
Emitted when protocol wants to mint IR but fails.
event ErrorMisconfiguredIRMinting(uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | uint256 The amount of IR that failed to mint |
Structs
RewardsStorage
struct RewardsStorage {
mapping(address => uint256) protocolFeeAmounts;
uint256 irMintRate;
uint256 bribeSplitRatio;
mapping(uint256 => uint256) fees;
}
ValidatorManagerLib
Library for managing validator storage
*This library is used by the Infrared contract for:
- Adding and removing validators (to the set of validators and distributor contract)
- Queuing/Activating Boosts and Drop/Activate Boosts in BGT contract: https://github.com/berachain/contracts-monorepo/blob/main/src/pol/BGT.sol
- Getting the number of validators
- Checking if validator is an Infrared validator*
Ownership of Operator rewards is tied to the number of validators an operator has, which should be linear to their operating costs hence share of fees. ie if an operator has 10 validators and total validators is 100, they should receive 10% of the fees even if Effective Balances are not super equal.
Functions
isValidator
Checks if a validator is an Infrared validator, ie if the validator ID is in the set of validator IDs
function isValidator(ValidatorStorage storage $, bytes memory pubkey)
external
view
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
$ | ValidatorStorage | Storage pinter for validator storage |
pubkey | bytes | The CL pubkey of validator |
_getValidatorId
Gets the validator ID for associated CL pubkey
function _getValidatorId(bytes memory pubkey) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The CL pubkey of validator |
addValidators
Adds validator to the set of validators, and maps the validator ID to the public key.
Also adds the validator to a public key set in the distributor contract, for receiving operator rewards. (ie Commissions for running nodeds).address
function addValidators(
ValidatorStorage storage $,
address distributor,
ValidatorTypes.Validator[] memory _validators
) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | ValidatorStorage | Storage pointer to the validator storage |
distributor | address | address of the distributor contract |
_validators | ValidatorTypes.Validator[] | array of Validator structs containing the CL public key and address of the validator and their associated fee collecting address |
removeValidators
Removes validators from the set of validators and also removes the validator from the distributor contract.
function removeValidators(
ValidatorStorage storage $,
address distributor,
bytes[] memory _pubkeys
) external;
replaceValidator
Replaces a validator in the set of validators and also updates the validator in the distributor contract.
function replaceValidator(
ValidatorStorage storage $,
address distributor,
bytes calldata _current,
bytes calldata _new
) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | ValidatorStorage | Storage pointer to the validator storage |
distributor | address | address of the distributor contract |
_current | bytes | Public key of the current validator |
_new | bytes | Public key of the new validator |
queueBoosts
Queues boosts for validators in the BGT smart contract
The sum of the boosts must be less than or equal to the total supply of iBGT
function queueBoosts(
address bgt,
address ibgt,
bytes[] memory _pubkeys,
uint128[] memory _amts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
bgt | address | address of the BGT contract |
ibgt | address | |
_pubkeys | bytes[] | array of public keys of validators |
_amts | uint128[] | array of amounts of boosts to queue |
cancelBoosts
Cancels boosts for validators in the BGT smart contract before they are activated
function cancelBoosts(
address bgt,
bytes[] memory _pubkeys,
uint128[] memory _amts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
bgt | address | address of the BGT contract |
_pubkeys | bytes[] | array of public keys of validators |
_amts | uint128[] | array of amounts of boosts to cancel |
activateBoosts
Activates boosts for validators in the BGT smart contract
function activateBoosts(address bgt, bytes[] memory _pubkeys) external;
Parameters
| Name | Type | Description |
|---|---|---|
bgt | address | address of the BGT contract |
_pubkeys | bytes[] | array of public keys of validators |
queueDropBoosts
Queues to drop the boosts for validators in the BGT smart contract
function queueDropBoosts(
address bgt,
bytes[] memory _pubkeys,
uint128[] memory _amts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
bgt | address | address of the BGT contract |
_pubkeys | bytes[] | array of public keys of validators |
_amts | uint128[] | array of amounts of boosts to drop |
cancelDropBoosts
Cancels drop boosts for validators in the BGT smart contract before they are activated
function cancelDropBoosts(
address bgt,
bytes[] memory _pubkeys,
uint128[] memory _amts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
bgt | address | address of the BGT contract |
_pubkeys | bytes[] | array of public keys of validators |
_amts | uint128[] | array of amounts of boosts to cancel |
dropBoosts
Activates drop boosts for validators in the BGT smart contract
function dropBoosts(address bgt, bytes[] memory _pubkeys) external;
Parameters
| Name | Type | Description |
|---|---|---|
bgt | address | address of the BGT contract |
_pubkeys | bytes[] | array of public keys of validators |
infraredValidators
Returns the list of validators in the validator storage
function infraredValidators(ValidatorStorage storage $, address distributor)
external
view
returns (ValidatorTypes.Validator[] memory validators);
Parameters
| Name | Type | Description |
|---|---|---|
$ | ValidatorStorage | Storage pointer to the validator storage |
distributor | address | address of the distributor contract |
Returns
| Name | Type | Description |
|---|---|---|
validators | ValidatorTypes.Validator[] | array of Validator structs containing the CL public key and address of the validators fee collecting address |
numInfraredValidators
Returns the number of validators in the validator storage
function numInfraredValidators(ValidatorStorage storage $)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
$ | ValidatorStorage | Storage pointer to the validator storage |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | number of validators |
_getValidatorAddress
helper function to get the vlaidator fee collecting address via the CL pubkey
function _getValidatorAddress(address distributor, bytes memory pubkey)
internal
view
returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
distributor | address | address of the distributor contract |
pubkey | bytes | CL pubkey of the validator |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | address of the validator fee collecting address |
Structs
ValidatorStorage
Storage structure for validator storage
This structure is used to store validator IDs and public keys
struct ValidatorStorage {
EnumerableSet.Bytes32Set validatorIds;
mapping(bytes32 => bytes) validatorPubkeys;
}
Properties
| Name | Type | Description |
|---|---|---|
validatorIds | EnumerableSet.Bytes32Set | Set of validator IDs which are keccak256 hashes of public keys. |
validatorPubkeys | mapping(bytes32 => bytes) | Maps validator ID to public key |
ValidatorTypes
Structs
Validator
Validator information for validator set
struct Validator {
bytes pubkey;
address addr;
}
VaultManagerLib
Library for managing:
- Vault registration
- Vault pausing
- Reward token whitelisting
- Default reward duration
Functions
vaultRegistrationNotPaused
Modifier to check if vault registration is paused.
modifier vaultRegistrationNotPaused(VaultStorage storage $);
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
pauseStaking
Pauses staking functionality on a specific vault
function pauseStaking(VaultStorage storage $, address asset) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
asset | address | address of the asset to pause the vault for. |
unpauseStaking
Un-pauses staking functionality on a specific vault
function unpauseStaking(VaultStorage storage $, address asset) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
asset | address | address of the asset to un-pause the vault for. |
pauseOldStaking
Pauses staking functionality on an old vault
function pauseOldStaking(address _vault) external;
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | address of the vault to pause |
unpauseOldStaking
Un-pauses staking functionality on an old vault
function unpauseOldStaking(address _vault) external;
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | address of the vault to un-pause |
updateWhitelistedRewardTokens
Updates the whitelist status of a reward token.
function updateWhitelistedRewardTokens(
VaultStorage storage $,
address token,
bool whitelisted
) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
token | address | address of the reward token to update the whitelist status for. |
whitelisted | bool | New whitelist status for the reward token. |
addReward
Adds a reward to a vault, if the reward token is whitelisted.
function addReward(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_stakingToken | address | address of the asset to add the reward to. |
_rewardsToken | address | address of the reward token to add. |
_rewardsDuration | uint256 |
removeReward
function removeReward(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken
) external;
updateRewardsDuration
Updates the global rewards duration for new vaults.
The rewards duration is used as the default duration for new vaults. Existing vaults will not be affected by this change.
function updateRewardsDuration(VaultStorage storage $, uint256 newDuration)
external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
newDuration | uint256 | New rewards duration. |
recoverERC20FromVault
Recovers ERC20 tokens from a vault.
function recoverERC20FromVault(
VaultStorage storage $,
address _asset,
address _to,
address _token,
uint256 _amount
) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_asset | address | address of the asset to recover from. |
_to | address | address to recover the tokens to. |
_token | address | address of the token to recover. |
_amount | uint256 | uint256 amount of tokens to recover. |
recoverERC20FromOldVault
Recovers ERC20 tokens from old vault.
removes reward token, cutting user claims. This should be a one time last ditch call for recovery after all users exited
function recoverERC20FromOldVault(
address _vault,
address _to,
address _token,
uint256 _amount
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | address of the asset to recover from. |
_to | address | address to recover the tokens to. |
_token | address | address of the token to recover. |
_amount | uint256 | uint256 amount of tokens to recover. |
updateRewardsDurationForVault
Updates the rewards duration for a specific reward token on a vault.
function updateRewardsDurationForVault(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _rewardsDuration
) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_stakingToken | address | address of the asset to update the rewards duration for. |
_rewardsToken | address | address of the reward token to update the rewards duration for. |
_rewardsDuration | uint256 | New rewards duration. |
setVaultRegistrationPauseStatus
Pauses or unpauses the registration of new vaults.
function setVaultRegistrationPauseStatus(VaultStorage storage $, bool pause)
external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
pause | bool | Flag to pause or unpause vault registration. |
claimLostRewardsOnVault
Claims lost rewards from a vault.
function claimLostRewardsOnVault(VaultStorage storage $, address _asset)
external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_asset | address | address of the asset to claim lost rewards from. |
addIncentives
Adds a reward to a vault, if the reward token is whitelisted.
function addIncentives(
VaultStorage storage $,
address _stakingToken,
address _rewardsToken,
uint256 _amount
) external;
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
_stakingToken | address | address The asset to add the reward to. |
_rewardsToken | address | address The the reward token to add. |
_amount | uint256 | uint256 amount of the reward token to add. |
registerVault
Registers a new vault for a specific asset.
function registerVault(VaultStorage storage $, address asset)
external
vaultRegistrationNotPaused($)
returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
asset | address | address of the asset to register a vault for. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | address of the newly created vault. |
isWhitelisted
Checks if a token is whitelisted as a reward token.
function isWhitelisted(VaultStorage storage $, address token)
public
view
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
$ | VaultStorage | Storage pointer to the VaultStorage struct. |
token | address | address of the token to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | bool indicating if the token is whitelisted. |
Structs
VaultStorage
Storage structure for the VaultManagerLib
struct VaultStorage {
bool pausedVaultRegistration;
mapping(address => IInfraredVault) vaultRegistry;
EnumerableSet.AddressSet whitelistedRewardTokens;
uint256 rewardsDuration;
mapping(address => uint8) vaultVersions;
}
Properties
| Name | Type | Description |
|---|---|---|
pausedVaultRegistration | bool | Flag to pause or unpause vault registration |
vaultRegistry | mapping(address => IInfraredVault) | |
whitelistedRewardTokens | EnumerableSet.AddressSet | Set of whitelisted reward tokens that can be called into. |
rewardsDuration | uint256 | Default duration for rewards |
vaultVersions | mapping(address => uint8) |
Contents
- BribeCollectorV1_2
- BribeCollectorV1_3
- BribeCollectorV1_4
- InfraredV1_2
- InfraredV1_3
- InfraredV1_4
- InfraredV1_5
- InfraredV1_7
- InfraredV1_8
- InfraredV1_9
BribeCollectorV1_2
Inherits: InfraredUpgradeable, IBribeCollector
The Bribe Collector contract is responsible for collecting bribes from Berachain rewards vaults and auctioning them for a Payout token which then is distributed among Infrared validators.
This contract is forked from Berachain POL which is forked from Uniswap V3 Factory Owner contract. https://github.com/uniswapfoundation/UniStaker/blob/main/src/V3FactoryOwner.sol
State Variables
payoutToken
Payout token, required to be WBERA token as its unwrapped and used to compound rewards in the iBera system.
address public payoutToken;
payoutAmount
Payout amount is a constant value that is paid by the caller of the claimFees function.
uint256 public payoutAmount;
__gap
uint256[40] private __gap;
Functions
setPayoutAmount
Set the payout amount for the bribe collector.
function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_newPayoutAmount | uint256 | updated payout amount |
claimFees
Claims accumulated bribes in exchange for payout token
Caller must approve payoutAmount of payout token to this contract.
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
sweepPayoutToken
function sweepPayoutToken() external;
BribeCollectorV1_3
Inherits: InfraredUpgradeable, IBribeCollector
The Bribe Collector contract is responsible for collecting bribes from Berachain rewards vaults and auctioning them for a Payout token which then is distributed among Infrared validators.
This contract is forked from Berachain POL which is forked from Uniswap V3 Factory Owner contract. https://github.com/uniswapfoundation/UniStaker/blob/main/src/V3FactoryOwner.sol
v1.3 adds a permission check to require KEEPER_ROLE for claiming fees. This is necessary because Infrared now boosts external validators and collects POL incentives from them. Since Merkle proofs for these incentives are only updated periodically, this can lead to unpredictable value inflow. If timed unfortunately, this could create a significant loss for the protocol if the value far exceeds the payout amount. The onlyKeeper modifier is a temporary security measure until a smoothing mechanism for available tokens to claim is implemented.
State Variables
payoutToken
Payout token, required to be WBERA token as its unwrapped and used to compound rewards in the iBera system.
address public payoutToken;
payoutAmount
Payout amount is a constant value that is paid by the caller of the claimFees function.
uint256 public payoutAmount;
__gap
uint256[40] private __gap;
Functions
setPayoutAmount
Set the payout amount for the bribe collector.
function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_newPayoutAmount | uint256 | updated payout amount |
claimFees
Claims accumulated bribes in exchange for payout token
Only callable by accounts with the KEEPER_ROLE for security to prevent potential economic losses from unpredictable external validator incentives
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
sweepPayoutToken
function sweepPayoutToken() external;
BribeCollectorV1_4
Inherits: InfraredUpgradeable, IBribeCollectorV1_4
The Bribe Collector contract is responsible for collecting bribes from Berachain rewards vaults and auctioning them for a Payout token which then is distributed among Infrared validators.
This contract is forked from Berachain POL which is forked from Uniswap V3 Factory Owner contract. https://github.com/uniswapfoundation/UniStaker/blob/main/src/V3FactoryOwner.sol
v1.4 adds a payout token setter and initializes payout token as iBGT
State Variables
payoutToken
Payout token, required to be WBERA token as its unwrapped and used to compound rewards in the iBera system.
address public payoutToken;
payoutAmount
Payout amount is a constant value that is paid by the caller of the claimFees function.
uint256 public payoutAmount;
__gap
uint256[40] private __gap;
Functions
setPayoutAmount
Set the payout amount for the bribe collector.
function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_newPayoutAmount | uint256 | updated payout amount |
setPayoutToken
Set the payout token for the bribe collector.
function setPayoutToken(address _newPayoutToken) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_newPayoutToken | address | updated payout token |
claimFees
Claims accumulated bribes in exchange for payout token
Only callable by accounts with the KEEPER_ROLE for security to prevent potential economic losses from unpredictable external validator incentives
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
sweepPayoutToken
function sweepPayoutToken() external;
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.
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
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;
InfraredV1_3
Inherits: InfraredV1_2, IInfraredV1_3
Extension of V1.2 with validator commission management functionality
This upgrade adds support for queuing and activating validator commission changes
Functions
queueValCommission
Queues a commission rate change for a validator on incentive tokens.
Only the governor can call this function.
Reverts if a commission rate change is already queued.
function queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
external
onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey. |
_commissionRate | uint96 | The commission rate of the validator on the incentive tokens. |
_queueValCommission
function _queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
internal;
queueMultipleValCommissions
Queues commission rate changes for multiple validators on incentive tokens.
Only the governor can call this function.
Reverts if any validator is invalid or if any have a commission rate change already queued.
function queueMultipleValCommissions(
bytes[] calldata _pubkeys,
uint96 _commissionRate
) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkeys | bytes[] | The array of validator pubkeys. |
_commissionRate | uint96 | The commission rate to set for all validators in the array. |
activateQueuedValCommission
Activates the queued commission rate of a validator on incentive tokens.
Anyone can call this function once the queued commission is ready.
function activateQueuedValCommission(bytes calldata _pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey. |
InfraredV1_4
Inherits: InfraredV1_3, IInfraredV1_4
Upgrade adds integration with BGTIncentiveDistributor for claiming booster rewards.
Implements IInfrared_V1_4, inheriting from InfraredV1_3. Maintains UUPS upgradeability. Uses potentially updated ValidatorManagerLib to allow external validator boosting via existing functions.
Functions
claimBGTIncentives
Claims BGT incentive rewards via BGTIncentiveDistributor.
Relays call for msg.sender. Distributor address is set once during initialization.
function claimBGTIncentives(IBGTIncentiveDistributor.Claim[] calldata _claims)
external
onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
_claims | IBGTIncentiveDistributor.Claim[] | Array of claim data compatible with IBGTIncentiveDistributor. |
InfraredV1_5
Inherits: InfraredV1_4, IInfraredV1_5
Upgrade adds claiming BGT on behalf of external user using berachain reward vaults directly, minting iBGT to user.
Implements IInfrared_V1_5, inheriting from InfraredV1_4. Maintains UUPS upgradeability. Uses updated RewardLib to allow external validator boosting via existing functions.
Functions
claimExternalVaultRewards
Claims all the BGT rewards for the user associated with the berachain vault given staking token.
function claimExternalVaultRewards(address _asset, address user)
external
whenNotPaused;
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
externalVaultRewards
View expected iBGT rewards to claim for the user associated with the berachain vault given staking token.
function externalVaultRewards(address _asset, address user)
external
view
returns (uint256 iBgtAmount);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
Returns
| Name | Type | Description |
|---|---|---|
iBgtAmount | uint256 | amount of iBGT to be minted to user |
InfraredV1_7
Inherits: InfraredUpgradeable, IInfraredV1_7
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.
Note: oz-upgrades-from: src/core/upgrades/InfraredV1_5.sol:InfraredV1_5
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;
harvestBaseCollector
address of harvest base collector for ibgt auction
address public harvestBaseCollector;
auctionBase
flag to indicate whether to auction base rewards for bera or redeem
bool public auctionBase;
__gap
Reserve storage slots for future upgrades for safety
uint256[39] 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_7
function initializeV1_7(address _harvestBaseCollector) 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 |
toggleAuctionBase
Admin function to toggle the auction base flag
should be true while iBGT is worth more than BERA
function toggleAuctionBase() external onlyKeeper;
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.
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;
redeemIbgtForBera
Redeem iBGT for BERA via BGT redeem
Only Keeper is allowed to execute
function redeemIbgtForBera(uint256 amount) external onlyKeeper;
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[] | 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;
claimExternalVaultRewards
Claims all the BGT rewards for the user associated with the berachain vault given staking token.
function claimExternalVaultRewards(address _asset, address user)
external
whenNotPaused;
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
externalVaultRewards
View expected iBGT rewards to claim for the user associated with the berachain vault given staking token.
function externalVaultRewards(address _asset, address user)
external
view
returns (uint256 iBgtAmount);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
Returns
| Name | Type | Description |
|---|---|---|
iBgtAmount | uint256 | amount of iBGT to be minted to user |
queueValCommission
Queues a commission rate change for a validator on incentive tokens.
Only the governor can call this function.
Reverts if a commission rate change is already queued.
function queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
external
onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey. |
_commissionRate | uint96 | The commission rate of the validator on the incentive tokens. |
_queueValCommission
function _queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
internal;
queueMultipleValCommissions
Queues commission rate changes for multiple validators on incentive tokens.
Only the governor can call this function.
Reverts if any validator is invalid or if any have a commission rate change already queued.
function queueMultipleValCommissions(
bytes[] calldata _pubkeys,
uint96 _commissionRate
) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkeys | bytes[] | The array of validator pubkeys. |
_commissionRate | uint96 | The commission rate to set for all validators in the array. |
activateQueuedValCommission
Activates the queued commission rate of a validator on incentive tokens.
Anyone can call this function once the queued commission is ready.
function activateQueuedValCommission(bytes calldata _pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey. |
InfraredV1_8
Inherits: InfraredUpgradeable, IInfraredV1_7
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.
Note: oz-upgrades-from: src/core/upgrades/InfraredV1_7.sol:InfraredV1_7
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;
harvestBaseCollector
address of harvest base collector for ibgt auction
address public harvestBaseCollector;
auctionBase
flag to indicate whether to auction base rewards for bera or redeem
bool public auctionBase;
__gap
Reserve storage slots for future upgrades for safety
uint256[39] 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();
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 onlyKeeper;
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 |
toggleAuctionBase
Admin function to toggle the auction base flag
should be true while iBGT is worth more than BERA
function toggleAuctionBase() external onlyKeeper;
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.
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;
redeemIbgtForBera
Redeem iBGT for BERA via BGT redeem
Only Keeper is allowed to execute
function redeemIbgtForBera(uint256 amount) external onlyKeeper;
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[] | 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;
claimExternalVaultRewards
Claims all the BGT rewards for the user associated with the berachain vault given staking token.
function claimExternalVaultRewards(address _asset, address user)
external
whenNotPaused;
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
externalVaultRewards
View expected iBGT rewards to claim for the user associated with the berachain vault given staking token.
function externalVaultRewards(address _asset, address user)
external
view
returns (uint256 iBgtAmount);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
Returns
| Name | Type | Description |
|---|---|---|
iBgtAmount | uint256 | amount of iBGT to be minted to user |
queueValCommission
Queues a commission rate change for a validator on incentive tokens.
Only the governor can call this function.
Reverts if a commission rate change is already queued.
function queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
external
onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey. |
_commissionRate | uint96 | The commission rate of the validator on the incentive tokens. |
_queueValCommission
function _queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
internal;
queueMultipleValCommissions
Queues commission rate changes for multiple validators on incentive tokens.
Only the governor can call this function.
Reverts if any validator is invalid or if any have a commission rate change already queued.
function queueMultipleValCommissions(
bytes[] calldata _pubkeys,
uint96 _commissionRate
) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkeys | bytes[] | The array of validator pubkeys. |
_commissionRate | uint96 | The commission rate to set for all validators in the array. |
activateQueuedValCommission
Activates the queued commission rate of a validator on incentive tokens.
Anyone can call this function once the queued commission is ready.
function activateQueuedValCommission(bytes calldata _pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey. |
InfraredV1_9
Inherits: InfraredUpgradeable, IInfraredV1_9
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.
Note: oz-upgrades-from: src/core/upgrades/InfraredV1_8.sol:InfraredV1_8
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;
harvestBaseCollector
address of harvest base collector for ibgt auction
address public harvestBaseCollector;
auctionBase
flag to indicate whether to auction base rewards for bera or redeem
bool public auctionBase;
wiBGT
address of wrapped ibgtVault
address public wiBGT;
__gap
Reserve storage slots for future upgrades for safety
uint256[38] 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_9
function initializeV1_9(address _wiBGT) 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 onlyKeeper;
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 |
toggleAuctionBase
Admin function to toggle the auction base flag
should be true while iBGT is worth more than BERA
function toggleAuctionBase() external onlyKeeper;
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.
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;
redeemIbgtForBera
Redeem iBGT for BERA via BGT redeem
Only Keeper is allowed to execute
function redeemIbgtForBera(uint256 amount) external onlyKeeper;
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[] | 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;
claimExternalVaultRewards
Claims all the BGT rewards for the user associated with the berachain vault given staking token.
function claimExternalVaultRewards(address _asset, address user)
external
whenNotPaused;
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
externalVaultRewards
View expected iBGT rewards to claim for the user associated with the berachain vault given staking token.
function externalVaultRewards(address _asset, address user)
external
view
returns (uint256 iBgtAmount);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
Returns
| Name | Type | Description |
|---|---|---|
iBgtAmount | uint256 | amount of iBGT to be minted to user |
queueValCommission
Queues a commission rate change for a validator on incentive tokens.
Only the governor can call this function.
Reverts if a commission rate change is already queued.
function queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
external
onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey. |
_commissionRate | uint96 | The commission rate of the validator on the incentive tokens. |
_queueValCommission
function _queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
internal;
queueMultipleValCommissions
Queues commission rate changes for multiple validators on incentive tokens.
Only the governor can call this function.
Reverts if any validator is invalid or if any have a commission rate change already queued.
function queueMultipleValCommissions(
bytes[] calldata _pubkeys,
uint96 _commissionRate
) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkeys | bytes[] | The array of validator pubkeys. |
_commissionRate | uint96 | The commission rate to set for all validators in the array. |
activateQueuedValCommission
Activates the queued commission rate of a validator on incentive tokens.
Anyone can call this function once the queued commission is ready.
function activateQueuedValCommission(bytes calldata _pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey. |
BribeCollector
Inherits: InfraredUpgradeable, IBribeCollector
The Bribe Collector contract is responsible for collecting bribes from Berachain rewards vaults and auctioning them for a Payout token which then is distributed among Infrared validators.
This contract is forked from Berachain POL which is forked from Uniswap V3 Factory Owner contract. https://github.com/uniswapfoundation/UniStaker/blob/main/src/V3FactoryOwner.sol
State Variables
payoutToken
Payout token, required to be WBERA token as its unwrapped and used to compound rewards in the iBera system.
address public payoutToken;
payoutAmount
Payout amount is a constant value that is paid out the caller of the claimFees function.
uint256 public payoutAmount;
__gap
uint256[40] private __gap;
Functions
initialize
function initialize(
address _infrared,
address _gov,
address _payoutToken,
uint256 _payoutAmount
) external initializer;
setPayoutAmount
Set the payout token for the bribe collector.
Only callable by the governor and should be set to WBERA token since iBERA requires BERA to compound rewards.
function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;
claimFees
Claims accumulated bribes in exchange for payout token
Caller must approve payoutAmount of payout token to this contract.
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
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 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();
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 |
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 |
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 |
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 |
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 |
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 |
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. |
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.
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
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;
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;
}
InfraredBGT
Inherits: ERC20PresetMinterPauser
This contract is the InfraredBGT token.
Functions
constructor
Constructor for InfraredBGT
constructor(address _admin, address _minter, address _pauser, address _burner)
ERC20PresetMinterPauser(
"Infrared BGT",
"iBGT",
_admin,
_minter,
_pauser,
_burner
);
Parameters
| Name | Type | Description |
|---|---|---|
_admin | address | The admin address to controll the roles of the contract |
_minter | address | The minter address of the contract |
_pauser | address | The pauser address of the contract |
_burner | address | The burner address of the contract |
InfraredDistributor
Inherits: InfraredUpgradeable, IInfraredDistributor
Distributes rewards to validators.
*Validator pubkeys are mapped to an EVM address and the pool of rewards from which they claim is porportional to the number of validators.
- for example, if there are 10 validators and 100 tokens are notified, each validator can claim 10 tokens.*
State Variables
token
Token used for reward distributions
ERC20 public token;
amountsCumulative
Tracks reward amount accumulation per validator
uint256 public amountsCumulative;
residualAmount
uint256 private residualAmount;
_snapshots
mapping(bytes32 pubkeyHash => Snapshot) internal _snapshots;
_validators
mapping(bytes32 pubkeyHash => address) internal _validators;
__gap
Reserve storage slots for future upgrades for safety
uint256[40] private __gap;
Functions
initialize
function initialize(address _infrared, address _gov, address _token)
external
initializer;
add
Register new validator for rewards
Only callable by Infrared contract
Notes:
-
access-control: Requires INFRARED_ROLE
-
error: ValidatorAlreadyExists if validator already registered
function add(bytes calldata pubkey, address validator) external onlyInfrared;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
validator | address | Address authorized to claim rewards |
remove
Removes validator from reward-eligible set
Only callable by Infrared contract
Note: access-control: Requires INFRARED_ROLE
function remove(bytes calldata pubkey) external onlyInfrared;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
purge
Purges validator from registry completely
Only possible after all rewards are claimed
Note: error: ClaimableRewardsExist if unclaimed rewards remain
function purge(bytes calldata pubkey) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
notifyRewardAmount
Distributes new commission rewards to validator set
Note: error: ZeroAmount if amount is 0
function notifyRewardAmount(uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | Amount to distribute equally among validators |
claim
Claims outstanding commission rewards
Note: error: InvalidValidator if caller not authorized
function claim(bytes calldata pubkey, address recipient) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
recipient | address | Address to receive the claimed rewards |
getSnapshot
Get validator's reward snapshots
Returns (0,0) if validator doesn't exist
function getSnapshot(bytes calldata pubkey)
external
view
returns (uint256 amountCumulativeLast, uint256 amountCumulativeFinal);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
Returns
| Name | Type | Description |
|---|---|---|
amountCumulativeLast | uint256 | Last claimed accumulator value |
amountCumulativeFinal | uint256 | Final accumulator value if removed |
getValidator
Get validator's registered claim address
function getValidator(bytes calldata pubkey) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address authorized to claim validator rewards |
InfraredGovernanceToken
Inherits: ERC20PresetMinterPauser
This contract is the IR token.
State Variables
infrared
address public immutable infrared;
Functions
constructor
Construct the Infrared Governance Token contract
constructor(
address _infrared,
address _admin,
address _minter,
address _pauser,
address _burner
)
ERC20PresetMinterPauser(
"Infrared Governance Token",
"IR",
_admin,
_minter,
_pauser,
_burner
);
Parameters
| Name | Type | Description |
|---|---|---|
_infrared | address | The address of the Infrared contract |
_admin | address | The address of the admin |
_minter | address | The address of the minter |
_pauser | address | The address of the pauser |
_burner | address | The burner address of the contract |
Errors
ZeroAddress
error ZeroAddress();
InfraredUpgradeable
Inherits: Upgradeable
This contract provides base upgradeability functionality for Infrared.
State Variables
infrared
Infrared coordinator contract
IInfrared public infrared;
__gap
uint256[10] private __gap;
Functions
onlyInfrared
modifier onlyInfrared();
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor();
__InfraredUpgradeable_init
function __InfraredUpgradeable_init(address _infrared)
internal
onlyInitializing;
InfraredVault
Inherits: MultiRewards, IInfraredVault
This contract is the vault for staking tokens, and receiving rewards from the Proof of Liquidity protocol.
This contract uses the MultiRewards contract to distribute rewards to vault stakers, this is taken from curve.fi. (inspired by Synthetix).
Does not support staking tokens with non-standard ERC20 transfer tax behavior.
State Variables
MAX_NUM_REWARD_TOKENS
Maximum number of reward tokens that can be supported
Limited to prevent gas issues with reward calculations
uint256 public constant MAX_NUM_REWARD_TOKENS = 10;
infrared
The infrared contract address acts a vault factory and coordinator
address public immutable infrared;
rewardsVault
IBerachainRewardsVault public immutable rewardsVault;
Functions
onlyInfrared
Modifier to check that the caller is infrared contract
modifier onlyInfrared();
constructor
constructor(address _stakingToken, uint256 _rewardsDuration)
MultiRewards(_stakingToken);
_createRewardsVaultIfNecessary
Gets or creates the berachain rewards vault for given staking token
function _createRewardsVaultIfNecessary(
address _infrared,
address _stakingToken
) private returns (IBerachainRewardsVault);
Parameters
| Name | Type | Description |
|---|---|---|
_infrared | address | The address of Infrared |
_stakingToken | address | The address of the staking token for this vault |
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBerachainRewardsVault | The address of the berachain rewards vault |
onStake
Transfers to berachain low level module on staking of LP tokens with the vault after transferring tokens in
function onStake(uint256 amount) internal override;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of staking token transferred in to the contract |
onWithdraw
Redeems from berachain low level module on withdraw of LP tokens from the vault before transferring tokens out
function onWithdraw(uint256 amount) internal override;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of staking token transferred out of the contract |
onReward
hook called after the reward is claimed to harvest the rewards from the berachain rewards vault
function onReward() internal override;
updateRewardsDuration
Updates reward duration for a specific reward token
Only callable by Infrared contract
Note: access-control: Requires INFRARED_ROLE
function updateRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
external
onlyInfrared;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the reward token |
_rewardsDuration | uint256 | The new duration in seconds |
unpauseStaking
Un-pauses staking functionality on a specific vault
Note: access-control: Requires INFRARED_ROLE
function unpauseStaking() external onlyInfrared;
pauseStaking
Pauses staking functionality on a specific vault
Note: access-control: Requires INFRARED_ROLE
function pauseStaking() external onlyInfrared;
addReward
Adds a new reward token to the vault
Cannot exceed maximum number of reward tokens
Note: access-control: Requires INFRARED_ROLE
function addReward(address _rewardsToken, uint256 _rewardsDuration)
external
onlyInfrared;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The reward token to add |
_rewardsDuration | uint256 | The reward period duration |
removeReward
Used to remove malicious or unused reward tokens
Note: access-control: Requires INFRARED_ROLE
function removeReward(address _rewardsToken) external onlyInfrared;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The reward token to remove |
notifyRewardAmount
Notifies the vault of newly added rewards
Updates internal reward rate calculations
function notifyRewardAmount(address _rewardToken, uint256 _reward)
external
onlyInfrared;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardToken | address | The reward token address |
_reward | uint256 | The amount of new rewards |
recoverERC20
Recovers accidentally sent tokens
Cannot recover staking token or active reward tokens
function recoverERC20(address _to, address _token, uint256 _amount)
external
onlyInfrared;
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | The address to receive the recovered tokens |
_token | address | The token to recover |
_amount | uint256 | The amount to recover |
getAllRewardTokens
Returns all reward tokens
function getAllRewardTokens() external view returns (address[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address[] | An array of reward token addresses |
getAllRewardsForUser
Returns all rewards for a user
function getAllRewardsForUser(address _user)
external
view
returns (UserReward[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
_user | address | The address of the user |
Returns
| Name | Type | Description |
|---|---|---|
<none> | UserReward[] | An array of UserReward structs |
MultiRewards
Inherits: ReentrancyGuard, Pausable, IMultiRewards
Based on fork of https://github.com/curvefi/multi-rewards with hooks on stake/withdraw of LP tokens
Upgraded version of MultiRewards with dynamic precision, residual accumulation, and improved recovery.
State Variables
stakingToken
The token that users stake to earn rewards
This is the base token that users deposit into the contract
ERC20 public immutable stakingToken;
rewardData
Stores reward-related data for each reward token
Maps reward token addresses to their Reward struct containing distribution parameters
mapping(address => Reward) public override rewardData;
rewardTokens
Array of all reward token addresses
Used to iterate through all reward tokens when updating or claiming rewards
address[] public rewardTokens;
userRewardPerTokenPaid
Tracks the reward per token paid to each user for each reward token
Maps user address to reward token address to amount already paid Used to calculate new rewards since last claim
mapping(address => mapping(address => uint256)) public userRewardPerTokenPaid;
rewards
Tracks the unclaimed rewards for each user for each reward token
Maps user address to reward token address to unclaimed amount
mapping(address => mapping(address => uint256)) public rewards;
_totalSupply
The total amount of staking tokens in the contract
Used to calculate rewards per token
uint256 internal _totalSupply;
_balances
Maps user addresses to their staked token balance
Internal mapping used to track individual stake amounts
mapping(address => uint256) internal _balances;
rewardDecimals
Per-reward-token decimals cache (set on addReward)
mapping(address => uint8) public rewardDecimals;
Functions
updateReward
Updates the reward for the given account before executing the function body.
modifier updateReward(address account);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | address The account to update the reward for. |
constructor
Constructs the MultiRewards contract.
constructor(address _stakingToken);
Parameters
| Name | Type | Description |
|---|---|---|
_stakingToken | address | address The token that users stake to earn rewards. |
totalSupply
Returns the total amount of staked tokens in the contract
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The total supply of staked tokens |
balanceOf
Returns the balance of staked tokens for the given account
function balanceOf(address account) external view returns (uint256 _balance);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The account to get the balance for |
Returns
| Name | Type | Description |
|---|---|---|
_balance | uint256 | The balance of staked tokens |
lastTimeRewardApplicable
Calculates the last time reward is applicable for a given rewards token
function lastTimeRewardApplicable(address _rewardsToken)
public
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The timestamp when the reward was last applicable |
rewardPerToken
Calculates the reward per token for a given rewards token
function rewardPerToken(address _rewardsToken)
public
view
returns (uint256 perToken);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
perToken | uint256 | The reward amount per token |
earned
Calculates the earned rewards for a given account and rewards token
function earned(address account, address _rewardsToken)
public
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address of the account |
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of rewards earned |
getRewardForDuration
Calculates the total reward for the duration of a given rewards token
function getRewardForDuration(address _rewardsToken)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The total reward amount for the duration of a given rewards token |
stake
Stakes tokens into the contract
Transfers amount of staking tokens from the user to this contract
function stake(uint256 amount)
external
nonReentrant
whenNotPaused
updateReward(msg.sender);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of tokens to stake |
onStake
Hook called in the stake function after transfering staking token in
function onStake(uint256 amount) internal virtual;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of staking token transferred in to the contract |
withdraw
Withdraws staked tokens from the contract
Transfers amount of staking tokens back to the user
function withdraw(uint256 amount)
public
nonReentrant
updateReward(msg.sender);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of tokens to withdraw |
onWithdraw
Hook called in withdraw function before transferring staking token out
function onWithdraw(uint256 amount) internal virtual;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of staking token to be transferred out of the contract |
getRewardForUser
Claims all pending rewards for a specified user
Iterates through all reward tokens and transfers any accrued rewards to the user
function getRewardForUser(address _user)
public
nonReentrant
updateReward(_user);
Parameters
| Name | Type | Description |
|---|---|---|
_user | address | The address of the user to claim rewards for |
onReward
Hook called in getRewardForUser function
function onReward() internal virtual;
getReward
Claims all pending rewards for the caller
Transfers all accrued rewards to the caller
function getReward() public;
exit
Withdraws all staked tokens and claims pending rewards
Combines withdraw and getReward operations
function exit() external;
_addReward
Adds a reward token to the contract.
function _addReward(
address _rewardsToken,
address _rewardsDistributor,
uint256 _rewardsDuration
) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | address The address of the reward token. |
_rewardsDistributor | address | address The address of the rewards distributor. |
_rewardsDuration | uint256 | uint256 The duration of the rewards period. |
_removeReward
Removes a reward token from the contract.
function _removeReward(address _rewardsToken) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | address The address of the reward token. |
_notifyRewardAmount
Notifies the contract that reward tokens is being sent to the contract.
function _notifyRewardAmount(address _rewardsToken, uint256 reward)
internal
updateReward(address(0));
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | address The address of the reward token. |
reward | uint256 | uint256 The amount of reward tokens is being sent to the contract. |
_recoverERC20
Recovers ERC20 tokens, including residuals for reward tokens after periodFinish.
Upgraded to allow recovery for removed/reward tokens if period finished, sweeping undistributed. For active tokens, only non-reward tokens.
function _recoverERC20(address to, address tokenAddress, uint256 tokenAmount)
internal;
Parameters
| Name | Type | Description |
|---|---|---|
to | address | Address to send tokens. |
tokenAddress | address | Token to recover. |
tokenAmount | uint256 | Amount to recover (up to available balance minus pending claims approximation). |
_setRewardsDuration
Updates the reward duration for a reward token.
function _setRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
internal
updateReward(address(0));
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | address The address of the reward token. |
_rewardsDuration | uint256 | uint256 The new duration of the rewards period. |
WrappedVault
Inherits: ERC4626
A wrapper vault built on ERC4626 to facilitate staking operations and reward distribution through the Infrared protocol. Each staking token has a corresponding wrapped vault.
deploy 1 wrapped vault per staking token
State Variables
rewardDistributor
Address of the reward distributor, typically a multisig.
address public immutable rewardDistributor;
iVault
Instance of the associated InfraredVault for staking.
InfraredVault public immutable iVault;
deadShares
Inflation attack prevention
uint256 internal constant deadShares = 1e3;
Functions
constructor
Initializes a new WrappedVault contract for a specific staking token.
constructor(
address _rewardDistributor,
address _infrared,
address _stakingToken,
string memory _name,
string memory _symbol
) ERC4626(ERC20(_stakingToken), _name, _symbol);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardDistributor | address | Address of the reward distributor (e.g., multisig). |
_infrared | address | Address of the Infrared protocol. |
_stakingToken | address | Address of the ERC20 staking token. |
_name | string | Name of the wrapped vault token (ERC4626). |
_symbol | string | Symbol of the wrapped vault token (ERC4626). |
totalAssets
Returns the total assets managed by the wrapped vault.
Overrides the ERC4626 totalAssets function to integrate with the InfraredVault balance.
function totalAssets() public view virtual override returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The total amount of staking tokens held by the InfraredVault. |
beforeWithdraw
Hook called before withdrawal operations.
This function ensures that the requested amount of staking tokens is withdrawn from the InfraredVault before being transferred to the user.
function beforeWithdraw(uint256 assets, uint256) internal virtual override;
Parameters
| Name | Type | Description |
|---|---|---|
assets | uint256 | The amount of assets to withdraw. |
<none> | uint256 |
afterDeposit
Hook called after deposit operations.
This function stakes the deposited tokens into the InfraredVault.
function afterDeposit(uint256 assets, uint256) internal virtual override;
Parameters
| Name | Type | Description |
|---|---|---|
assets | uint256 | The amount of assets being deposited. |
<none> | uint256 |
claimRewards
Claims rewards from the InfraredVault and transfers them to the reward distributor.
Only rewards other than the staking token itself are transferred.
function claimRewards() external;
Events
RewardClaimed
Event emitted when reward tokens claimed
event RewardClaimed(address indexed token, uint256 amount);
Contents
- upgrades
- IBerachainBGT
- IBerachainBGTStaker
- IBribeCollector
- IERC20Mintable
- IInfrared
- IInfraredBERA
- IInfraredBERAClaimor
- IInfraredBERADepositor
- IInfraredBERAFeeReceivor
- IInfraredBERAWithdrawor
- IInfraredBERAWithdraworLite
- IInfraredBGT
- IInfraredDistributor
- IInfraredGovernanceToken
- IInfraredUpgradeable
- IInfraredVault
- IMultiRewards
- IRED
- IWBERA
Contents
- IBribeCollectorV1_4
- IInfraredBERAV2
- IInfraredBERAWithdrawor
- IInfraredV1_2
- IInfraredV1_3
- IInfraredV1_4
- IInfraredV1_5
- IInfraredV1_7
- IInfraredV1_9
IBribeCollectorV1_4
Inherits: IPOLErrors
Functions
payoutToken
Token used for fee payments when claiming bribes
function payoutToken() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of the payout token |
payoutAmount
The amount of payout token that is required to claim POL bribes for all tokens
This works as first come first serve basis. whoever pays this much amount of the payout amount first will get the fees
function payoutAmount() external view returns (uint256);
setPayoutAmount
Update the payout amount to a new value. Must be called by governor
function setPayoutAmount(uint256 _newPayoutAmount) external;
Parameters
| Name | Type | Description |
|---|---|---|
_newPayoutAmount | uint256 | The value that will be the new payout amount |
claimFees
Claims accumulated bribes in exchange for payout token
Caller must approve payoutAmount of payout token to this contract.
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
Events
PayoutAmountSet
Emitted when the payout amount is updated by the governor
event PayoutAmountSet(
uint256 indexed oldPayoutAmount, uint256 indexed newPayoutAmount
);
Parameters
| Name | Type | Description |
|---|---|---|
oldPayoutAmount | uint256 | Previous payout amount |
newPayoutAmount | uint256 | New payout amount set |
PayoutTokenSet
Emitted when the payout token is updated by the governor
event PayoutTokenSet(
address indexed oldPayoutToken, address indexed newPayoutToken
);
Parameters
| Name | Type | Description |
|---|---|---|
oldPayoutToken | address | Previous payout token |
newPayoutToken | address | New payout token set |
FeesClaimed
Emitted when the fees are claimed
event FeesClaimed(
address indexed caller,
address indexed recipient,
address indexed feeToken,
uint256 amount
);
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | Caller of the claimFees function |
recipient | address | The address to which collected POL bribes will be transferred |
feeToken | address | The address of the fee token to collect |
amount | uint256 | The amount of fee token to transfer |
IInfraredBERAV2
Inherits: IERC20, IAccessControl
Functions
infrared
The Infrared.sol smart contract
function infrared() external view returns (address);
depositor
The InfraredBERADepositor.sol smart contract
function depositor() external view returns (address);
withdrawor
The InfraredBERAWithdrawor.sol smart contract
function withdrawor() external view returns (address);
receivor
The InfraredBERAFeeReceivor.sol smart contract
function receivor() external view returns (address);
deposits
The total amount of BERA deposited by the system
function deposits() external view returns (uint256);
stakes
Returns the amount of BERA staked in validator with given pubkey
function stakes(bytes calldata pubkey) external view returns (uint256);
staked
Returns whether initial deposit has been staked to validator with given pubkey
function staked(bytes calldata pubkey) external view returns (bool);
hasExited
Returns whether a validator pubkey has exited
function hasExited(bytes calldata pubkey) external view returns (bool);
signatures
Returns the deposit signature to use for given pubkey
function signatures(bytes calldata pubkey)
external
view
returns (bytes memory);
feeDivisorShareholders
The fee divisor for protocol + operator + voter fees. 1/N, where N is the divisor. example 100 = 1/100 = 1%
function feeDivisorShareholders() external view returns (uint16);
pending
Pending deposits yet to be forwarded to CL
function pending() external view returns (uint256);
confirmed
Confirmed deposits sent to CL, total - future deposits
function confirmed() external view returns (uint256);
proofTimestampBuffer
Time, in seconds, allowed for staleness of proof data relative to current head
function proofTimestampBuffer() external view returns (uint256);
keeper
Checks if account has the keeper role
function keeper(address account) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the keeper role |
governor
Checks if account has the governance role
function governor(address account) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the governance role |
validator
Checks if a given pubkey is a validator in the Infrared contract
function validator(bytes calldata pubkey) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the pubkey is a validator |
previewMint
Previews the amount of InfraredBERA shares that would be minted for a given BERA amount
function previewMint(uint256 beraAmount)
external
view
returns (uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
beraAmount | uint256 | The amount of BERA to simulate depositing |
Returns
| Name | Type | Description |
|---|---|---|
shares | uint256 | The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail |
previewBurn
Previews the amount of BERA that would be received for burning InfraredBERA shares
function previewBurn(uint256 shareAmount)
external
view
returns (uint256 beraAmount, uint256 fee);
Parameters
| Name | Type | Description |
|---|---|---|
shareAmount | uint256 | The amount of InfraredBERA shares to simulate burning |
Returns
| Name | Type | Description |
|---|---|---|
beraAmount | uint256 | The amount of BERA that would be received, returns 0 if the operation would fail |
fee | uint256 | The fee that would be charged for the burn operation in iBERA |
compound
Internal function to update top level accounting and compound rewards
function compound() external;
sweep
Compounds accumulated EL yield in fee receivor into deposits
Called internally at bof whenever InfraredBERA minted or burned
Only sweeps if amount transferred from fee receivor would exceed min deposit thresholds
function sweep() external payable;
collect
Collects yield from fee receivor and mints ibera shares to Infrared
Called in RewardsLib::harvestOperatorRewards() in Infrared.sol
Only Infrared can call this function
function collect() external returns (uint256 sharesMinted);
Returns
| Name | Type | Description |
|---|---|---|
sharesMinted | uint256 | The amount of ibera shares |
mint
Mints ibera to the receiver in exchange for bera
takes in msg.value as amount to mint ibera with
function mint(address receiver) external payable returns (uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to mint ibera to |
Returns
| Name | Type | Description |
|---|---|---|
shares | uint256 | The amount of ibera minted |
burn
Burns ibera from the msg.sender and sets a receiver to get the BERA in exchange for iBERA
function burn(address receiver, uint256 shares)
external
returns (uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to send the BERA to |
shares | uint256 | The amount of ibera to burn |
Returns
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The nonce of the withdrawal. Queue based system for withdrawals |
amount | uint256 | The amount of BERA withdrawn for the exchange of iBERA |
register
Updates the accounted for stake of a validator pubkey
function register(bytes calldata pubkey, int256 delta) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey of the validator |
delta | int256 | The change in stake |
setFeeDivisorShareholders
Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV
function setFeeDivisorShareholders(uint16 to) external;
Parameters
| Name | Type | Description |
|---|---|---|
to | uint16 | The new fee shareholders represented as an integer denominator (1/x)% |
setDepositSignature
Sets the deposit signature for a given pubkey. Ensure that the pubkey has signed the correct deposit amount of INITIAL_DEPOSIT
function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey to set the deposit signature for |
signature | bytes | The signature to set for the pubkey |
withdrawalsEnabled
Whether withdrawals are currently enabled
function withdrawalsEnabled() external view returns (bool);
Events
Mint
Emitted when InfraredBERA is minted
event Mint(address indexed receiver, uint256 amount, uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the minted shares |
amount | uint256 | The amount of BERA deposited |
shares | uint256 | The amount of shares minted |
Burn
Emitted when InfraredBERA is burned
event Burn(
address indexed receiver,
uint256 nonce,
uint256 amount,
uint256 shares,
uint256 fee
);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the withdrawn BERA |
nonce | uint256 | The withdrawal nonce |
amount | uint256 | The amount of BERA to withdraw |
shares | uint256 | The amount of shares burned |
fee | uint256 | The fee paid for withdrawal |
Sweep
Emitted when accumulated rewards are swept
event Sweep(uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of BERA swept |
Register
Emitted when validator stake is registered
event Register(bytes pubkey, int256 delta, uint256 stake);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
delta | int256 | The change in stake amount |
stake | uint256 | The new total stake amount |
RegisterViaProof
Emitted when validator stake is registered via proofs
event RegisterViaProof(bytes pubkey, uint256 effectiveBalance, uint256 stake);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
effectiveBalance | uint256 | CL effective balance |
stake | uint256 | The previous internal balance |
SetFeeShareholders
Emitted when fee shareholders rate is updated
event SetFeeShareholders(uint16 from, uint16 to);
Parameters
| Name | Type | Description |
|---|---|---|
from | uint16 | Previous fee rate |
to | uint16 | New fee rate |
SetDepositSignature
Emitted when deposit signature is updated
event SetDepositSignature(bytes pubkey, bytes from, bytes to);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
from | bytes | Previous signature |
to | bytes | New signature |
WithdrawalFlagSet
Emitted when withdrawal flag is updated
event WithdrawalFlagSet(bool flag);
Parameters
| Name | Type | Description |
|---|---|---|
flag | bool | New withdrawal flag value |
ExitFeesCollected
Emitted when exit fees are claimed by governance
event ExitFeesCollected(uint256 amount, address to);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of iBERA fees collected |
to | address | Address iBERA sent sent to |
BurnFeeUpdated
Emitted when buen fee updated by governance
event BurnFeeUpdated(uint256 fee);
Parameters
| Name | Type | Description |
|---|---|---|
fee | uint256 | The amount of iBERA fee to charge on burns |
RateProviderUpdated
Emitted when rate provider updated by governance
event RateProviderUpdated(address provider);
Parameters
| Name | Type | Description |
|---|---|---|
provider | address | New rate provider address |
ProofTimestampBufferUpdated
Emitted when proof time buffer updated by governance
event ProofTimestampBufferUpdated(uint256 newBuffer);
Parameters
| Name | Type | Description |
|---|---|---|
newBuffer | uint256 | new timespan in seconds to allow staleness of proof data relative to current head |
IInfraredBERAWithdrawor
Functions
InfraredBERA
The address of the InfraredBERA contract
function InfraredBERA() external view returns (address);
requests
Mapping of request IDs to withdrawal request tickets.
Key is the requestId (starting at 1), and value is the WithdrawalRequest struct.
function requests(uint256 nonce)
external
view
returns (
RequestState state,
uint88 timestamp,
address receiver,
uint128 amount,
uint128 accumulatedAmount
);
getTotalPendingWithdrawals
Sums all current pending withdrawals as helper for keeper to calculate how much needs to be executed next
Iterates through pending withdrawals, counting only those that have not expired (fulfilled)
function getTotalPendingWithdrawals(bytes32 pubkeyHash)
external
view
returns (uint256 total);
Parameters
| Name | Type | Description |
|---|---|---|
pubkeyHash | bytes32 | keccak256 of public key for validator to get pending withdrawals for |
Returns
| Name | Type | Description |
|---|---|---|
total | uint256 | Sum amount in bera, pending on CL to return to contract |
reserves
Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests
function reserves() external view returns (uint256);
getFee
Retrieves the current fee required by the withdrawal precompile.
Performs a static call to the precompile. Reverts if the call fails or the response is invalid (not 32 bytes).
function getFee() external view returns (uint256 fee);
Returns
| Name | Type | Description |
|---|---|---|
fee | uint256 | The fee (in wei) required for a withdrawal request. |
getQueuedAmount
Returns the total amount of BERA queued for withdrawal across all unprocessed tickets.
Calculates the difference between the cumulative amount at requestLength and requestsFinalisedUntil.
Returns 0 if requestLength == requestsFinalisedUntil (no unprocessed tickets) or requestLength == 0 (no tickets queued).
Assumes tickets from requestsFinalisedUntil + 1 to requestLength are in QUEUED state, as enforced by process.
function getQueuedAmount() external view returns (uint256 queuedAmount);
Returns
| Name | Type | Description |
|---|---|---|
queuedAmount | uint256 | The total amount of BERA (in wei) in QUEUED tickets from requestsFinalisedUntil + 1 to requestLength. |
getRequestsToProcess
Calculates the highest request ID that can be finalized by process given the current reserves.
Iterates through unprocessed tickets (requestsFinalisedUntil + 1 to requestLength) to find the maximum number of requests whose cumulative amount does not exceed reserves().
Returns requestsFinalisedUntil if no additional tickets can be processed due to insufficient reserves.
function getRequestsToProcess()
external
view
returns (uint256 newRequestsFinalisedUntil);
Returns
| Name | Type | Description |
|---|---|---|
newRequestsFinalisedUntil | uint256 | The highest requestId (inclusive) that can be processed without exceeding available reserves, or 0 if no tickets can be processed. |
queue
Queues a withdraw request from InfraredBERA
Requires msg.value to cover minimum withdrawal fee
function queue(address receiver, uint256 amount)
external
returns (uint256 nonce);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to receive withdrawn funds |
amount | uint256 | The amount of funds to withdraw |
Returns
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The unique identifier for this withdrawal request |
process
Executes a withdraw request to withdraw precompile
Finalizes a range of withdrawal requests, marking them as claimable or rebalancing to the depositor.
Payable to cover any additional fees required by precompile
Only callable by keeper
*Reverts if:
newRequestsFinalisedUntilexceedsrequestLength.newRequestsFinalisedUntilis less than or equal torequestsFinalisedUntil.- Available reserves are insufficient for the total amount to finalize.*
Accumulates amounts for depositor rebalancing into a single call to InfraredBERADepositor.queue.
Updates totalClaimable for non-depositor tickets.
function process(uint256 newRequestsFinalisedUntil) external;
Parameters
| Name | Type | Description |
|---|---|---|
newRequestsFinalisedUntil | uint256 | The highest requestId to finalize (inclusive). |
claim
Claims a finalized withdrawal request for a user.
*Reverts if:
requestIdexceedsrequestsFinalisedUntil(not finalized).- Ticket is not in
PROCESSEDstate or belongs to the depositor.*
Transitions the ticket to CLAIMED and transfers the amount to the receiver.
function claim(uint256 requestId) external;
Parameters
| Name | Type | Description |
|---|---|---|
requestId | uint256 | The ID of the withdrawal request to claim. |
claimBatch
Claims multiple finalized withdrawal requests in a single transaction.
*Reverts if:
- Any
requestIdexceedsrequestsFinalisedUntil(not finalized). - Any ticket is not in
PROCESSEDstate or belongs to the depositor.*
Transitions each ticket to CLAIMED and transfers the total amount to the caller.
Emits a Claimed event for each claimed ticket.
function claimBatch(uint256[] calldata requestIds, address receiver) external;
Parameters
| Name | Type | Description |
|---|---|---|
requestIds | uint256[] | An array of request IDs to claim. |
receiver | address | recipient address of all requestId's |
Events
Queue
Emitted when a withdrawal is queued
event Queue(address indexed receiver, uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address that will receive the withdrawn BERA |
nonce | uint256 | The unique identifier for this withdrawal request |
amount | uint256 | The amount of BERA to be withdrawn |
Execute
Emitted when a withdrawal is executed
event Execute(bytes pubkey, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
amount | uint256 | The amount of BERA withdrawn |
Process
Emitted when a queue is processed
event Process(address indexed receiver, uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the withdrawn BERA |
nonce | uint256 | The nonce of the processed withdrawal |
amount | uint256 | The amount of BERA processed |
ProcessRange
Emitted when a withdrawal request range is processed
event ProcessRange(uint256 startRequestId, uint256 finishRequestId);
Parameters
| Name | Type | Description |
|---|---|---|
startRequestId | uint256 | First request processed |
finishRequestId | uint256 | Last request processed |
Claimed
Emitted when a claim is processed
event Claimed(address indexed receiver, uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the withdrawn BERA |
nonce | uint256 | The nonce of the processed withdrawal |
amount | uint256 | The amount of BERA processed |
Sweep
Emitted when funds are swept from a force-exited validator
event Sweep(address indexed receiver, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the swept BERA |
amount | uint256 | The amount of BERA swept |
MinActivationBalanceUpdated
Emitted when min activation balance is updated by governance
event MinActivationBalanceUpdated(uint256 newMinActivationBalance);
Parameters
| Name | Type | Description |
|---|---|---|
newMinActivationBalance | uint256 | New value for min activation balance to maintain activity |
Structs
WithdrawalRequest
The request struct for withdrawal requests.
struct WithdrawalRequest {
RequestState state;
uint88 timestamp;
address receiver;
uint128 amount;
uint128 accumulatedAmount;
}
Properties
| Name | Type | Description |
|---|---|---|
state | RequestState | records whether queued, processed or claimed |
timestamp | uint88 | The block.timestamp at which the withdraw request was issued. |
receiver | address | The address of the receiver of the withdrawn BERA funds. |
amount | uint128 | The amount of BERA to be claimed by receiver. |
accumulatedAmount | uint128 | Running total amount withdrawn inclusive of this ticket. |
PendingWithdrawal
Struct to track pending withdrawals with expiry
struct PendingWithdrawal {
uint160 amount;
uint96 expiryBlock;
bytes32 pubkeyHash;
}
Enums
RequestState
Sweeps forced withdrawals to InfraredBERA to re-stake principal
State of a withdrawal request ticket.
Only callable when withdrawals are disabled and by keeper
QUEUED: Ticket is queued and awaiting processing. PROCESSED: Ticket is finalized and claimable (or rebalanced for depositor). CLAIMED: Ticket has been claimed by the receiver.
enum RequestState {
QUEUED,
PROCESSED,
CLAIMED
}
IInfraredV1_2
Functions
whitelistedRewardTokens
Checks if a token is a whitelisted reward token
function whitelistedRewardTokens(address _token) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the token to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | bool True if the token is whitelisted, false otherwise |
vaultRegistry
Returns the infrared vault address for a given staking token
function vaultRegistry(address _asset) external view returns (IInfraredVault);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | The address of the staking asset |
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredVault | IInfraredVault The vault associated with the asset |
ibgt
The InfraredBGT liquid staked token
function ibgt() external view returns (InfraredBGT);
Returns
| Name | Type | Description |
|---|---|---|
<none> | InfraredBGT | IInfraredBGT The InfraredBGT token contract address |
rewardsFactory
The Berachain rewards vault factory address
function rewardsFactory()
external
view
returns (IBerachainRewardsVaultFactory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBerachainRewardsVaultFactory | IBerachainRewardsVaultFactory instance of the rewards factory contract address |
chef
The Berachain chef contract for distributing validator rewards
function chef() external view returns (IBeraChef);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBeraChef | IBeraChef instance of the BeraChef contract address |
ibgtVault
The InfraredBGT vault
function ibgtVault() external view returns (IInfraredVault);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredVault | IInfraredVault instance of the iBGT vault contract address |
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 |
fees
Protocol fee rates to charge for various harvest function distributions
function fees(uint256 i) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
i | uint256 | The index of the fee rate |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The fee rate |
wbera
Wrapped bera
function wbera() external view returns (IWBERA);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IWBERA | IWBERA The wbera token contract address |
honey
Honey ERC20 token
function honey() external view returns (ERC20);
Returns
| Name | Type | Description |
|---|---|---|
<none> | ERC20 | ERC20 The honey token contract address |
collector
bribe collector contract
function collector() external view returns (IBribeCollector);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBribeCollector | IBribeCollector The bribe collector contract address |
distributor
Infrared distributor for BGT rewards to validators
function distributor() external view returns (IInfraredDistributor);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredDistributor | IInfraredDistributor instance of the distributor contract address |
voter
IR voter
function voter() external view returns (IVoter);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IVoter | IVoter instance of the voter contract address |
ibera
collects all iBERA realted fees and revenue
function ibera() external view returns (IInfraredBERA);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredBERA | returns IInfraredBERAFeeReceivor instanace of iBeraFeeReceivor |
ir
The IR token
function ir() external view returns (IInfraredGovernanceToken);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredGovernanceToken | IR instance of the IR token contract address |
rewardsDuration
The rewards duration
Used as gloabl variabel to set the rewards duration for all new reward tokens on InfraredVaults
function rewardsDuration() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The reward duration period, in seconds |
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
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;
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
-
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 |
updateWhiteListedRewardTokens
Updates the whitelist status of a reward token
function updateWhiteListedRewardTokens(address _token, bool _whitelisted)
external;
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;
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;
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 or governance, will revert if vault doesn't exist
function pauseStaking(address _asset) external;
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;
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;
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;
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;
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;
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;
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;
Parameters
| Name | Type | Description |
|---|---|---|
_t | ConfigTypes.FeeType | FeeType The fee type |
_fee | uint256 | uint256 The fee rate to update to |
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;
Parameters
| Name | Type | Description |
|---|---|---|
_IR | address | The address of the IR contract |
updateIRMintRate
Updates the mint rate for IR
function updateIRMintRate(uint256 _IRMintRate) external;
Parameters
| Name | Type | Description |
|---|---|---|
_IRMintRate | uint256 | The new mint rate for IR |
claimProtocolFees
Claims accumulated protocol fees in contract
function claimProtocolFees(address _to, address _token) external;
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | address The recipient of the fees |
_token | address | address The token to claim fees in |
harvestBase
Claims all the BGT base and commission rewards minted to this contract for validators.
function harvestBase() external;
harvestOperatorRewards
Credits all accumulated rewards to the operator
function harvestOperatorRewards() external;
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[] memory _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.
_token The payout token for the bribe collector.
_amount The amount of payout received from bribe collector.
function collectBribes(address _token, uint256 _amount) external;
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[] memory _validators)
external;
Parameters
| Name | Type | Description |
|---|---|---|
_validators | ValidatorTypes.Validator[] | Validator[] memory The validators to add. |
removeValidators
Removes validators from the set of InfraredValidators.
function removeValidators(bytes[] memory _pubkeys) external;
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;
Parameters
| Name | Type | Description |
|---|---|---|
_current | bytes | bytes The pubkey of the validator to replace. |
_new | bytes | bytes The new validator pubkey. |
queueBoosts
Queue _amts of tokens to _validators for boosts.
function queueBoosts(bytes[] memory _pubkeys, uint128[] memory _amts)
external;
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[] memory _pubkeys, uint128[] memory _amts)
external;
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[] memory _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 amounts)
external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
amounts | 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 amounts)
external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
amounts | uint128[] | 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. |
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;
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 |
infraredValidators
Gets the set of infrared validator pubkeys.
function infraredValidators()
external
view
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 memory _pubkey)
external
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() external view returns (uint256 bgtBalance);
Returns
| Name | Type | Description |
|---|---|---|
bgtBalance | uint256 | The BGT balance held by this address |
migrateVault
function migrateVault(address _asset, uint8 versionToUpgradeTo)
external
returns (address newVault);
Events
NewVault
Emitted when a new vault is registered
event NewVault(address _sender, address indexed _asset, address indexed _vault);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the vault registration |
_asset | address | The address of the asset for which the vault is registered |
_vault | address | The address of the newly created vault |
VaultRegistrationPauseStatus
Emitted when pause status for new vault registration has changed
event VaultRegistrationPauseStatus(bool pause);
Parameters
| Name | Type | Description |
|---|---|---|
pause | bool | True if new vault creation is paused |
OperatorRewardsDistributed
Emitted when InfraredBGT tokens are supplied to distributor.
event OperatorRewardsDistributed(
address indexed _ibera, address indexed _distributor, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_ibera | address | token the rewards are denominated in |
_distributor | address | The address of the distributor receiving the InfraredBGT tokens. |
_amt | uint256 | The amount of WBERA tokens supplied to distributor. |
InfraredBGTSupplied
Emitted when InfraredBGT tokens are supplied to a vault.
event InfraredBGTSupplied(
address indexed _vault, uint256 _ibgtAmt, uint256 _iredAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | The address of the vault receiving the InfraredBGT and IR tokens. |
_ibgtAmt | uint256 | The amount of InfraredBGT tokens supplied to vault. |
_iredAmt | uint256 | The amount of IR tokens supplied to vault as additional reward from protocol. |
RewardSupplied
Emitted when rewards are supplied to a vault.
event RewardSupplied(
address indexed _vault, address indexed _token, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | The address of the vault receiving the reward. |
_token | address | The address of the token being supplied as a reward. |
_amt | uint256 | The amount of the reward token supplied. |
BribeSupplied
Emitted when rewards are supplied to a vault.
event BribeSupplied(
address indexed _recipient, address indexed _token, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The address receiving the bribe. |
_token | address | The address of the token being supplied as a bribe reward. |
_amt | uint256 | The amount of the bribe reward token supplied. |
Recovered
Emitted when tokens are recovered from the contract.
event Recovered(address _sender, address indexed _token, uint256 _amount);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the recovery. |
_token | address | The address of the token being recovered. |
_amount | uint256 | The amount of the token recovered. |
RewardTokenNotSupported
Emitted when a reward token is marked as unsupported.
event RewardTokenNotSupported(address _token);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the reward token. |
InfraredBGTUpdated
Emitted when the InfraredBGT token address is updated.
event InfraredBGTUpdated(address _sender, address _oldIbgt, address _newIbgt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldIbgt | address | The previous address of the InfraredBGT token. |
_newIbgt | address | The new address of the InfraredBGT token. |
InfraredBGTVaultUpdated
Emitted when the InfraredBGT vault address is updated.
event InfraredBGTVaultUpdated(
address _sender, address _oldIbgtVault, address _newIbgtVault
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldIbgtVault | address | The previous address of the InfraredBGT vault. |
_newIbgtVault | address | The new address of the InfraredBGT vault. |
WhiteListedRewardTokensUpdated
Emitted when reward tokens are whitelisted or unwhitelisted.
event WhiteListedRewardTokensUpdated(
address _sender,
address indexed _token,
bool _wasWhitelisted,
bool _isWhitelisted
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_token | address | The address of the token being updated. |
_wasWhitelisted | bool | The previous whitelist status of the token. |
_isWhitelisted | bool | The new whitelist status of the token. |
RewardsDurationUpdated
Emitted when the rewards duration is updated
event RewardsDurationUpdated(
address _sender, uint256 _oldDuration, uint256 _newDuration
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update |
_oldDuration | uint256 | The previous rewards duration |
_newDuration | uint256 | The new rewards duration |
InfraredBERABribeSplitUpdated
Emitted when a weight is updated.
event InfraredBERABribeSplitUpdated(
address _sender, uint256 _oldWeight, uint256 _newWeight
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldWeight | uint256 | The old value of the weight. |
_newWeight | uint256 | The new value of the weight. |
FeeUpdated
Emitted when protocol fee rate is updated.
event FeeUpdated(
address _sender,
ConfigTypes.FeeType _feeType,
uint256 _oldFeeRate,
uint256 _newFeeRate
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_feeType | ConfigTypes.FeeType | The fee type updated. |
_oldFeeRate | uint256 | The old protocol fee rate. |
_newFeeRate | uint256 | The new protocol fee rate. |
ProtocolFeesClaimed
Emitted when protocol fees claimed.
event ProtocolFeesClaimed(
address _sender, address _to, address _token, uint256 _amount
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the claim. |
_to | address | The address to send protocol fees to. |
_token | address | The address of the token protocol fees in. |
_amount | uint256 | The amount of protocol fees claimed. |
ProtocolFees
Emitted when protocol fees are received.
event ProtocolFees(address indexed _token, uint256 _amt, uint256 _voterAmt);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the token protocol fees in. |
_amt | uint256 | The amount of protocol fees received. |
_voterAmt | uint256 | The amount of protocol fees received by the voter. |
BaseHarvested
Emitted when base + commission rewards are harvested.
event BaseHarvested(address _sender, uint256 _bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_bgtAmt | uint256 | The amount of BGT harvested. |
VaultHarvested
Emitted when a vault harvests its rewards.
event VaultHarvested(
address _sender,
address indexed _asset,
address indexed _vault,
uint256 _bgtAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_asset | address | The asset associated with the vault being harvested. |
_vault | address | The address of the vault being harvested. |
_bgtAmt | uint256 | The amount of BGT harvested. |
BribesCollected
Emitted when bribes are harvested then collected by collector.
event BribesCollected(
address _sender,
address _token,
uint256 _amtWiberaVault,
uint256 _amtIbgtVault
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the bribe collection. |
_token | address | The payout token from bribe collection. |
_amtWiberaVault | uint256 | The amount of collected bribe sent to the wrapped iBERA vault. |
_amtIbgtVault | uint256 | The amount of collected bribe sent to the iBGT vault. |
ValidatorHarvested
Emitted when a validator harvests its rewards.
event ValidatorHarvested(
address _sender,
bytes indexed _validator,
DataTypes.Token[] _rewards,
uint256 _bgtAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_validator | bytes | The public key of the validator. |
_rewards | DataTypes.Token[] | An array of tokens and amounts harvested. |
_bgtAmt | uint256 | The amount of BGT included in the rewards. |
ValidatorsAdded
Emitted when validators are added.
event ValidatorsAdded(address _sender, ValidatorTypes.Validator[] _validators);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the addition. |
_validators | ValidatorTypes.Validator[] | An array of validators that were added. |
ValidatorsRemoved
Emitted when validators are removed from validator set.
event ValidatorsRemoved(address _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the removal. |
_pubkeys | bytes[] | An array of validators' pubkeys that were removed. |
ValidatorReplaced
Emitted when a validator is replaced with a new validator.
event ValidatorReplaced(address _sender, bytes _current, bytes _new);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the replacement. |
_current | bytes | The pubkey of the current validator being replaced. |
_new | bytes | The pubkey of the new validator. |
QueuedBoosts
Emitted when BGT tokens are queued for boosts to validators.
event QueuedBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the boost. |
_pubkeys | bytes[] | The addresses of the validators to which tokens are queued for boosts. |
_amts | uint128[] | The amounts of tokens that were queued. |
CancelledBoosts
Emitted when existing queued boosts to validators are cancelled.
event CancelledBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the cancellation. |
_pubkeys | bytes[] | The pubkeys of the validators to which tokens were queued for boosts. |
_amts | uint128[] | The amounts of tokens to remove from boosts. |
ActivatedBoosts
Emitted when an existing boost to a validator is activated.
event ActivatedBoosts(address _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the activation. |
_pubkeys | bytes[] | The addresses of the validators which were boosted. |
QueueDropBoosts
Emitted when an user queues a drop boost for a validator.
event QueueDropBoosts(
address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user. |
pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
amounts | uint128[] | The amounts of tokens to remove from boosts. |
CancelDropBoosts
Emitted when an user cancels a queued drop boost for a validator.
event CancelDropBoosts(
address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user. |
pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
amounts | uint128[] | The amounts of tokens to remove from boosts. |
DroppedBoosts
Emitted when sender removes an amount of BGT boost from a validator
event DroppedBoosts(address indexed _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the cancellation. |
_pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
Undelegated
Emitted when tokens are undelegated from a validator.
event Undelegated(address _sender, bytes _pubkey, uint256 _amt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the undelegation. |
_pubkey | bytes | The pubkey of the validator from which tokens are undelegated. |
_amt | uint256 | The amount of tokens that were undelegated. |
Redelegated
Emitted when tokens are redelegated from one validator to another.
event Redelegated(address _sender, bytes _from, bytes _to, uint256 _amt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the redelegation. |
_from | bytes | The public key of the validator from which tokens are redelegated. |
_to | bytes | The public key of the validator to which tokens are redelegated. |
_amt | uint256 | The amount of tokens that were redelegated. |
IRSet
Emitted when the IR token is set.
event IRSet(address _sender, address _IR);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_IR | address | The address of the IRdd token. |
UpdatedIRMintRate
event UpdatedIRMintRate(
uint256 oldMintRate, uint256 newMintRate, address sender
);
Parameters
| Name | Type | Description |
|---|---|---|
oldMintRate | uint256 | The old mint rate for IR |
newMintRate | uint256 | The new mint rate for IR |
sender | address | The address that initiated the update |
IBGTSet
Emitted when the iBGT token is set.
event IBGTSet(address _sender, address _ibgt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_ibgt | address | The address of the iBGT token. |
VoterSet
Emitted when the voter contract is set.
event VoterSet(address _sender, address _voter);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_voter | address | The address of the voter contract. |
VaultMigrated
Emitted when vault has migrated.
event VaultMigrated(
address indexed sender,
address indexed asset,
address indexed oldVault,
address newVault
);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address that initiated the update. |
asset | address | The address of the staking token. |
oldVault | address | The address of the old vault. |
newVault | address | The address of the new vault. |
IInfraredV1_3
Inherits: IInfraredV1_2
Interface for V1.3 of the Infrared protocol
Extends V1.2 with validator commission management functionality
Functions
queueValCommission
Queues a commission rate change for a validator on incentive tokens
function queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey |
_commissionRate | uint96 | The commission rate to set |
queueMultipleValCommissions
Queues commission rate changes for multiple validators on incentive tokens
function queueMultipleValCommissions(
bytes[] calldata _pubkeys,
uint96 _commissionRate
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkeys | bytes[] | The array of validator pubkeys |
_commissionRate | uint96 | The commission rate to set for all validators |
activateQueuedValCommission
Activates the queued commission rate of a validator on incentive tokens
function activateQueuedValCommission(bytes calldata _pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey |
Events
ValidatorCommissionQueued
Emitted when a validator's commission rate is queued
event ValidatorCommissionQueued(
address indexed operator, bytes pubkey, uint96 commissionRate
);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | The address that queued the commission change |
pubkey | bytes | The validator's pubkey |
commissionRate | uint96 | The queued commission rate |
ValidatorCommissionActivated
Emitted when a validator's queued commission rate is activated
event ValidatorCommissionActivated(
address indexed operator, bytes pubkey, uint96 commissionRate
);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | The address that activated the commission change |
pubkey | bytes | The validator's pubkey |
commissionRate | uint96 | The new active commission rate |
IInfraredV1_4
Inherits: IInfraredV1_3
Interface for Infrared V1.4 upgrade. Adds BGT incentive claims.
Defines external functions and events for V1.4. Inherits from IInfraredV1_3.
Functions
claimBGTIncentives
Claims BGT incentive rewards via the BGTIncentiveDistributor.
function claimBGTIncentives(IBGTIncentiveDistributor.Claim[] calldata _claims)
external;
Parameters
| Name | Type | Description |
|---|---|---|
_claims | IBGTIncentiveDistributor.Claim[] | Array of claim data. |
Events
BGTIncentivesClaimAttempted
Emitted when claimBGTIncentives is called.
event BGTIncentivesClaimAttempted(
address indexed caller, address indexed distributor, uint256 numClaims
);
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | Address initiating the claim. |
distributor | address | BGTIncentiveDistributor contract called. |
numClaims | uint256 | Number of claims submitted. |
IInfraredV1_5
Inherits: IInfraredV1_4
Interface for Infrared V1.5 upgrade. Adds external berachain user BGT reward claiming, minting iBGT to user.
Defines external functions and events for V1.5. Inherits from IInfraredV1_4.
Functions
claimExternalVaultRewards
Claims all the BGT rewards for the user associated with the berachain vault given staking token.
function claimExternalVaultRewards(address _asset, address user) external;
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
externalVaultRewards
View expected iBGT rewards to claim for the user associated with the berachain vault given staking token.
function externalVaultRewards(address _asset, address user)
external
view
returns (uint256 iBgtAmount);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
Returns
| Name | Type | Description |
|---|---|---|
iBgtAmount | uint256 | amount of iBGT to be minted to user |
Events
ExternalVaultClaimed
Emitted when claimExternalVaultRewards is called.
event ExternalVaultClaimed(
address indexed user,
address indexed stakingAsset,
address indexed berachainRewardVault,
uint256 bgtAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | Address to claim on behalf of. |
stakingAsset | address | staking asset of berachain reward vault to claim for. |
berachainRewardVault | address | vault address |
bgtAmt | uint256 | Amount of BGT claimed. |
IInfraredV1_7
Functions
whitelistedRewardTokens
Checks if a token is a whitelisted reward token
function whitelistedRewardTokens(address _token) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the token to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | bool True if the token is whitelisted, false otherwise |
vaultRegistry
Returns the infrared vault address for a given staking token
function vaultRegistry(address _asset) external view returns (IInfraredVault);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | The address of the staking asset |
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredVault | IInfraredVault The vault associated with the asset |
ibgt
The InfraredBGT liquid staked token
function ibgt() external view returns (InfraredBGT);
Returns
| Name | Type | Description |
|---|---|---|
<none> | InfraredBGT | IInfraredBGT The InfraredBGT token contract address |
rewardsFactory
The Berachain rewards vault factory address
function rewardsFactory()
external
view
returns (IBerachainRewardsVaultFactory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBerachainRewardsVaultFactory | IBerachainRewardsVaultFactory instance of the rewards factory contract address |
chef
The Berachain chef contract for distributing validator rewards
function chef() external view returns (IBeraChef);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBeraChef | IBeraChef instance of the BeraChef contract address |
ibgtVault
The InfraredBGT vault
function ibgtVault() external view returns (IInfraredVault);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredVault | IInfraredVault instance of the iBGT vault contract address |
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 |
fees
Protocol fee rates to charge for various harvest function distributions
function fees(uint256 i) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
i | uint256 | The index of the fee rate |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The fee rate |
wbera
Wrapped bera
function wbera() external view returns (IWBERA);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IWBERA | IWBERA The wbera token contract address |
honey
Honey ERC20 token
function honey() external view returns (ERC20);
Returns
| Name | Type | Description |
|---|---|---|
<none> | ERC20 | ERC20 The honey token contract address |
collector
bribe collector contract
function collector() external view returns (IBribeCollector);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBribeCollector | IBribeCollector The bribe collector contract address |
distributor
Infrared distributor for BGT rewards to validators
function distributor() external view returns (IInfraredDistributor);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredDistributor | IInfraredDistributor instance of the distributor contract address |
voter
IR voter
function voter() external view returns (IVoter);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IVoter | IVoter instance of the voter contract address |
ibera
collects all iBERA realted fees and revenue
function ibera() external view returns (IInfraredBERA);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredBERA | returns IInfraredBERAFeeReceivor instanace of iBeraFeeReceivor |
ir
The IR token
function ir() external view returns (IInfraredGovernanceToken);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredGovernanceToken | IR instance of the IR token contract address |
rewardsDuration
The rewards duration
Used as gloabl variabel to set the rewards duration for all new reward tokens on InfraredVaults
function rewardsDuration() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The reward duration period, in seconds |
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
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;
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
-
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 |
updateWhiteListedRewardTokens
Updates the whitelist status of a reward token
function updateWhiteListedRewardTokens(address _token, bool _whitelisted)
external;
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;
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;
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 or governance, will revert if vault doesn't exist
function pauseStaking(address _asset) external;
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;
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;
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;
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;
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;
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;
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;
Parameters
| Name | Type | Description |
|---|---|---|
_t | ConfigTypes.FeeType | FeeType The fee type |
_fee | uint256 | uint256 The fee rate to update to |
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;
Parameters
| Name | Type | Description |
|---|---|---|
_IR | address | The address of the IR contract |
updateIRMintRate
Updates the mint rate for IR
function updateIRMintRate(uint256 _IRMintRate) external;
Parameters
| Name | Type | Description |
|---|---|---|
_IRMintRate | uint256 | The new mint rate for IR |
claimProtocolFees
Claims accumulated protocol fees in contract
function claimProtocolFees(address _to, address _token) external;
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | address The recipient of the fees |
_token | address | address The token to claim fees in |
harvestBase
Claims all the BGT base and commission rewards minted to this contract for validators.
function harvestBase() external;
harvestOperatorRewards
Credits all accumulated rewards to the operator
function harvestOperatorRewards() external;
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[] memory _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.
_token The payout token for the bribe collector.
_amount The amount of payout received from bribe collector.
function collectBribes(address _token, uint256 _amount) external;
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[] memory _validators)
external;
Parameters
| Name | Type | Description |
|---|---|---|
_validators | ValidatorTypes.Validator[] | Validator[] memory The validators to add. |
removeValidators
Removes validators from the set of InfraredValidators.
function removeValidators(bytes[] memory _pubkeys) external;
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;
Parameters
| Name | Type | Description |
|---|---|---|
_current | bytes | bytes The pubkey of the validator to replace. |
_new | bytes | bytes The new validator pubkey. |
queueBoosts
Queue _amts of tokens to _validators for boosts.
function queueBoosts(bytes[] memory _pubkeys, uint128[] memory _amts)
external;
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[] memory _pubkeys, uint128[] memory _amts)
external;
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[] memory _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 amounts)
external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
amounts | 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 amounts)
external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
amounts | uint128[] | 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. |
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;
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 |
infraredValidators
Gets the set of infrared validator pubkeys.
function infraredValidators()
external
view
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 memory _pubkey)
external
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() external view returns (uint256 bgtBalance);
Returns
| Name | Type | Description |
|---|---|---|
bgtBalance | uint256 | The BGT balance held by this address |
migrateVault
function migrateVault(address _asset, uint8 versionToUpgradeTo)
external
returns (address newVault);
claimExternalVaultRewards
Claims all the BGT rewards for the user associated with the berachain vault given staking token.
function claimExternalVaultRewards(address _asset, address user) external;
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
externalVaultRewards
View expected iBGT rewards to claim for the user associated with the berachain vault given staking token.
function externalVaultRewards(address _asset, address user)
external
view
returns (uint256 iBgtAmount);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | address The address of the staking asset that the vault is for. |
user | address | address The address of the user to get rewards for and mint ibgt to |
Returns
| Name | Type | Description |
|---|---|---|
iBgtAmount | uint256 | amount of iBGT to be minted to user |
queueValCommission
Queues a commission rate change for a validator on incentive tokens
function queueValCommission(bytes calldata _pubkey, uint96 _commissionRate)
external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey |
_commissionRate | uint96 | The commission rate to set |
queueMultipleValCommissions
Queues commission rate changes for multiple validators on incentive tokens
function queueMultipleValCommissions(
bytes[] calldata _pubkeys,
uint96 _commissionRate
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkeys | bytes[] | The array of validator pubkeys |
_commissionRate | uint96 | The commission rate to set for all validators |
activateQueuedValCommission
Activates the queued commission rate of a validator on incentive tokens
function activateQueuedValCommission(bytes calldata _pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
_pubkey | bytes | The validator's pubkey |
Events
NewVault
Emitted when a new vault is registered
event NewVault(address _sender, address indexed _asset, address indexed _vault);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the vault registration |
_asset | address | The address of the asset for which the vault is registered |
_vault | address | The address of the newly created vault |
VaultRegistrationPauseStatus
Emitted when pause status for new vault registration has changed
event VaultRegistrationPauseStatus(bool pause);
Parameters
| Name | Type | Description |
|---|---|---|
pause | bool | True if new vault creation is paused |
OperatorRewardsDistributed
Emitted when InfraredBGT tokens are supplied to distributor.
event OperatorRewardsDistributed(
address indexed _ibera, address indexed _distributor, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_ibera | address | token the rewards are denominated in |
_distributor | address | The address of the distributor receiving the InfraredBGT tokens. |
_amt | uint256 | The amount of WBERA tokens supplied to distributor. |
InfraredBGTSupplied
Emitted when InfraredBGT tokens are supplied to a vault.
event InfraredBGTSupplied(
address indexed _vault, uint256 _ibgtAmt, uint256 _iredAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | The address of the vault receiving the InfraredBGT and IR tokens. |
_ibgtAmt | uint256 | The amount of InfraredBGT tokens supplied to vault. |
_iredAmt | uint256 | The amount of IR tokens supplied to vault as additional reward from protocol. |
RewardSupplied
Emitted when rewards are supplied to a vault.
event RewardSupplied(
address indexed _vault, address indexed _token, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | The address of the vault receiving the reward. |
_token | address | The address of the token being supplied as a reward. |
_amt | uint256 | The amount of the reward token supplied. |
BribeSupplied
Emitted when rewards are supplied to a vault.
event BribeSupplied(
address indexed _recipient, address indexed _token, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The address receiving the bribe. |
_token | address | The address of the token being supplied as a bribe reward. |
_amt | uint256 | The amount of the bribe reward token supplied. |
Recovered
Emitted when tokens are recovered from the contract.
event Recovered(address _sender, address indexed _token, uint256 _amount);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the recovery. |
_token | address | The address of the token being recovered. |
_amount | uint256 | The amount of the token recovered. |
RewardTokenNotSupported
Emitted when a reward token is marked as unsupported.
event RewardTokenNotSupported(address _token);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the reward token. |
InfraredBGTUpdated
Emitted when the InfraredBGT token address is updated.
event InfraredBGTUpdated(address _sender, address _oldIbgt, address _newIbgt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldIbgt | address | The previous address of the InfraredBGT token. |
_newIbgt | address | The new address of the InfraredBGT token. |
InfraredBGTVaultUpdated
Emitted when the InfraredBGT vault address is updated.
event InfraredBGTVaultUpdated(
address _sender, address _oldIbgtVault, address _newIbgtVault
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldIbgtVault | address | The previous address of the InfraredBGT vault. |
_newIbgtVault | address | The new address of the InfraredBGT vault. |
WhiteListedRewardTokensUpdated
Emitted when reward tokens are whitelisted or unwhitelisted.
event WhiteListedRewardTokensUpdated(
address _sender,
address indexed _token,
bool _wasWhitelisted,
bool _isWhitelisted
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_token | address | The address of the token being updated. |
_wasWhitelisted | bool | The previous whitelist status of the token. |
_isWhitelisted | bool | The new whitelist status of the token. |
RewardsDurationUpdated
Emitted when the rewards duration is updated
event RewardsDurationUpdated(
address _sender, uint256 _oldDuration, uint256 _newDuration
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update |
_oldDuration | uint256 | The previous rewards duration |
_newDuration | uint256 | The new rewards duration |
InfraredBERABribeSplitUpdated
Emitted when a weight is updated.
event InfraredBERABribeSplitUpdated(
address _sender, uint256 _oldWeight, uint256 _newWeight
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldWeight | uint256 | The old value of the weight. |
_newWeight | uint256 | The new value of the weight. |
FeeUpdated
Emitted when protocol fee rate is updated.
event FeeUpdated(
address _sender,
ConfigTypes.FeeType _feeType,
uint256 _oldFeeRate,
uint256 _newFeeRate
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_feeType | ConfigTypes.FeeType | The fee type updated. |
_oldFeeRate | uint256 | The old protocol fee rate. |
_newFeeRate | uint256 | The new protocol fee rate. |
ProtocolFeesClaimed
Emitted when protocol fees claimed.
event ProtocolFeesClaimed(
address _sender, address _to, address _token, uint256 _amount
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the claim. |
_to | address | The address to send protocol fees to. |
_token | address | The address of the token protocol fees in. |
_amount | uint256 | The amount of protocol fees claimed. |
ProtocolFees
Emitted when protocol fees are received.
event ProtocolFees(address indexed _token, uint256 _amt, uint256 _voterAmt);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the token protocol fees in. |
_amt | uint256 | The amount of protocol fees received. |
_voterAmt | uint256 | The amount of protocol fees received by the voter. |
BaseHarvested
Emitted when base + commission rewards are harvested.
event BaseHarvested(address _sender, uint256 _bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_bgtAmt | uint256 | The amount of BGT harvested. |
VaultHarvested
Emitted when a vault harvests its rewards.
event VaultHarvested(
address _sender,
address indexed _asset,
address indexed _vault,
uint256 _bgtAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_asset | address | The asset associated with the vault being harvested. |
_vault | address | The address of the vault being harvested. |
_bgtAmt | uint256 | The amount of BGT harvested. |
BribesCollected
Emitted when bribes are harvested then collected by collector.
event BribesCollected(
address _sender,
address _token,
uint256 _amtWiberaVault,
uint256 _amtIbgtVault
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the bribe collection. |
_token | address | The payout token from bribe collection. |
_amtWiberaVault | uint256 | The amount of collected bribe sent to the wrapped iBERA vault. |
_amtIbgtVault | uint256 | The amount of collected bribe sent to the iBGT vault. |
ValidatorHarvested
Emitted when a validator harvests its rewards.
event ValidatorHarvested(
address _sender,
bytes indexed _validator,
DataTypes.Token[] _rewards,
uint256 _bgtAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_validator | bytes | The public key of the validator. |
_rewards | DataTypes.Token[] | An array of tokens and amounts harvested. |
_bgtAmt | uint256 | The amount of BGT included in the rewards. |
ValidatorsAdded
Emitted when validators are added.
event ValidatorsAdded(address _sender, ValidatorTypes.Validator[] _validators);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the addition. |
_validators | ValidatorTypes.Validator[] | An array of validators that were added. |
ValidatorsRemoved
Emitted when validators are removed from validator set.
event ValidatorsRemoved(address _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the removal. |
_pubkeys | bytes[] | An array of validators' pubkeys that were removed. |
ValidatorReplaced
Emitted when a validator is replaced with a new validator.
event ValidatorReplaced(address _sender, bytes _current, bytes _new);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the replacement. |
_current | bytes | The pubkey of the current validator being replaced. |
_new | bytes | The pubkey of the new validator. |
QueuedBoosts
Emitted when BGT tokens are queued for boosts to validators.
event QueuedBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the boost. |
_pubkeys | bytes[] | The addresses of the validators to which tokens are queued for boosts. |
_amts | uint128[] | The amounts of tokens that were queued. |
CancelledBoosts
Emitted when existing queued boosts to validators are cancelled.
event CancelledBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the cancellation. |
_pubkeys | bytes[] | The pubkeys of the validators to which tokens were queued for boosts. |
_amts | uint128[] | The amounts of tokens to remove from boosts. |
ActivatedBoosts
Emitted when an existing boost to a validator is activated.
event ActivatedBoosts(address _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the activation. |
_pubkeys | bytes[] | The addresses of the validators which were boosted. |
QueueDropBoosts
Emitted when an user queues a drop boost for a validator.
event QueueDropBoosts(
address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user. |
pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
amounts | uint128[] | The amounts of tokens to remove from boosts. |
CancelDropBoosts
Emitted when an user cancels a queued drop boost for a validator.
event CancelDropBoosts(
address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user. |
pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
amounts | uint128[] | The amounts of tokens to remove from boosts. |
DroppedBoosts
Emitted when sender removes an amount of BGT boost from a validator
event DroppedBoosts(address indexed _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the cancellation. |
_pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
Undelegated
Emitted when tokens are undelegated from a validator.
event Undelegated(address _sender, bytes _pubkey, uint256 _amt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the undelegation. |
_pubkey | bytes | The pubkey of the validator from which tokens are undelegated. |
_amt | uint256 | The amount of tokens that were undelegated. |
Redelegated
Emitted when tokens are redelegated from one validator to another.
event Redelegated(address _sender, bytes _from, bytes _to, uint256 _amt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the redelegation. |
_from | bytes | The public key of the validator from which tokens are redelegated. |
_to | bytes | The public key of the validator to which tokens are redelegated. |
_amt | uint256 | The amount of tokens that were redelegated. |
IRSet
Emitted when the IR token is set.
event IRSet(address _sender, address _IR);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_IR | address | The address of the IRdd token. |
UpdatedIRMintRate
event UpdatedIRMintRate(
uint256 oldMintRate, uint256 newMintRate, address sender
);
Parameters
| Name | Type | Description |
|---|---|---|
oldMintRate | uint256 | The old mint rate for IR |
newMintRate | uint256 | The new mint rate for IR |
sender | address | The address that initiated the update |
IBGTSet
Emitted when the iBGT token is set.
event IBGTSet(address _sender, address _ibgt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_ibgt | address | The address of the iBGT token. |
VoterSet
Emitted when the voter contract is set.
event VoterSet(address _sender, address _voter);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_voter | address | The address of the voter contract. |
VaultMigrated
Emitted when vault has migrated.
event VaultMigrated(
address indexed sender,
address indexed asset,
address indexed oldVault,
address newVault
);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address that initiated the update. |
asset | address | The address of the staking token. |
oldVault | address | The address of the old vault. |
newVault | address | The address of the new vault. |
ExternalVaultClaimed
Emitted when claimExternalVaultRewards is called.
event ExternalVaultClaimed(
address indexed user,
address indexed stakingAsset,
address indexed berachainRewardVault,
uint256 bgtAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | Address to claim on behalf of. |
stakingAsset | address | staking asset of berachain reward vault to claim for. |
berachainRewardVault | address | vault address |
bgtAmt | uint256 | Amount of BGT claimed. |
ValidatorCommissionQueued
Emitted when a validator's commission rate is queued
event ValidatorCommissionQueued(
address indexed operator, bytes pubkey, uint96 commissionRate
);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | The address that queued the commission change |
pubkey | bytes | The validator's pubkey |
commissionRate | uint96 | The queued commission rate |
ValidatorCommissionActivated
Emitted when a validator's queued commission rate is activated
event ValidatorCommissionActivated(
address indexed operator, bytes pubkey, uint96 commissionRate
);
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | The address that activated the commission change |
pubkey | bytes | The validator's pubkey |
commissionRate | uint96 | The new active commission rate |
IbgtRedeemed
Emitted when the iBGT token is redeemed for bera.
event IbgtRedeemed(address sender, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The address that initiated the update. |
amount | uint256 | Amount to redeem |
AuctionBaseFlagUpdated
Emitted when toggleAuctionBase is called by keeper
event AuctionBaseFlagUpdated(bool _auctionBase);
Parameters
| Name | Type | Description |
|---|---|---|
_auctionBase | bool | new value of bool auctionBase |
IInfraredV1_9
Inherits: IInfraredV1_7
Interface for Infrared V1.9 upgrade.
Functions
wiBGT
function wiBGT() external returns (address);
IBerachainBGT
Inherits: IBGT
IBerachainBGTStaker
Inherits: IBGTStaker
Functions
rewardToken
Temp override of interface to include left out reward token
function rewardToken() external view returns (address);
IBribeCollector
Inherits: IPOLErrors
Functions
payoutToken
Token used for fee payments when claiming bribes
function payoutToken() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of the payout token |
payoutAmount
The amount of payout token that is required to claim POL bribes for all tokens
This works as first come first serve basis. whoever pays this much amount of the payout amount first will get the fees
function payoutAmount() external view returns (uint256);
setPayoutAmount
Update the payout amount to a new value. Must be called by governor
function setPayoutAmount(uint256 _newPayoutAmount) external;
Parameters
| Name | Type | Description |
|---|---|---|
_newPayoutAmount | uint256 | The value that will be the new payout amount |
claimFees
Claims accumulated bribes in exchange for payout token
Caller must approve payoutAmount of payout token to this contract.
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
Events
PayoutAmountSet
Emitted when the payout amount is updated by the governor
event PayoutAmountSet(
uint256 indexed oldPayoutAmount, uint256 indexed newPayoutAmount
);
Parameters
| Name | Type | Description |
|---|---|---|
oldPayoutAmount | uint256 | Previous payout amount |
newPayoutAmount | uint256 | New payout amount set |
FeesClaimed
Emitted when the fees are claimed
event FeesClaimed(
address indexed caller,
address indexed recipient,
address indexed feeToken,
uint256 amount
);
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | Caller of the claimFees function |
recipient | address | The address to which collected POL bribes will be transferred |
feeToken | address | The address of the fee token to collect |
amount | uint256 | The amount of fee token to transfer |
IERC20Mintable
Inherits: IERC20
Functions
MINTER_ROLE
function MINTER_ROLE() external view returns (bytes32);
mint
function mint(address to, uint256 amount) external;
IInfrared
Functions
whitelistedRewardTokens
Checks if a token is a whitelisted reward token
function whitelistedRewardTokens(address _token) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the token to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | bool True if the token is whitelisted, false otherwise |
vaultRegistry
Returns the infrared vault address for a given staking token
function vaultRegistry(address _asset) external view returns (IInfraredVault);
Parameters
| Name | Type | Description |
|---|---|---|
_asset | address | The address of the staking asset |
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredVault | IInfraredVault The vault associated with the asset |
ibgt
The InfraredBGT liquid staked token
function ibgt() external view returns (InfraredBGT);
Returns
| Name | Type | Description |
|---|---|---|
<none> | InfraredBGT | IInfraredBGT The InfraredBGT token contract address |
rewardsFactory
The Berachain rewards vault factory address
function rewardsFactory()
external
view
returns (IBerachainRewardsVaultFactory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBerachainRewardsVaultFactory | IBerachainRewardsVaultFactory instance of the rewards factory contract address |
chef
The Berachain chef contract for distributing validator rewards
function chef() external view returns (IBeraChef);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBeraChef | IBeraChef instance of the BeraChef contract address |
ibgtVault
The InfraredBGT vault
function ibgtVault() external view returns (IInfraredVault);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredVault | IInfraredVault instance of the iBGT vault contract address |
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 |
fees
Protocol fee rates to charge for various harvest function distributions
function fees(uint256 i) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
i | uint256 | The index of the fee rate |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The fee rate |
wbera
Wrapped bera
function wbera() external view returns (IWBERA);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IWBERA | IWBERA The wbera token contract address |
honey
Honey ERC20 token
function honey() external view returns (ERC20);
Returns
| Name | Type | Description |
|---|---|---|
<none> | ERC20 | ERC20 The honey token contract address |
collector
bribe collector contract
function collector() external view returns (IBribeCollector);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBribeCollector | IBribeCollector The bribe collector contract address |
distributor
Infrared distributor for BGT rewards to validators
function distributor() external view returns (IInfraredDistributor);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredDistributor | IInfraredDistributor instance of the distributor contract address |
voter
IR voter
function voter() external view returns (IVoter);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IVoter | IVoter instance of the voter contract address |
ibera
collects all iBERA realted fees and revenue
function ibera() external view returns (IInfraredBERA);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredBERA | returns IInfraredBERAFeeReceivor instanace of iBeraFeeReceivor |
ir
The IR token
function ir() external view returns (IInfraredGovernanceToken);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredGovernanceToken | IR instance of the IR token contract address |
rewardsDuration
The rewards duration
Used as gloabl variabel to set the rewards duration for all new reward tokens on InfraredVaults
function rewardsDuration() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The reward duration period, in seconds |
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
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;
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
-
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 |
updateWhiteListedRewardTokens
Updates the whitelist status of a reward token
function updateWhiteListedRewardTokens(address _token, bool _whitelisted)
external;
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;
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;
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 or governance, will revert if vault doesn't exist
function pauseStaking(address _asset) external;
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;
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;
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;
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;
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;
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;
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;
Parameters
| Name | Type | Description |
|---|---|---|
_t | ConfigTypes.FeeType | FeeType The fee type |
_fee | uint256 | uint256 The fee rate to update to |
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;
Parameters
| Name | Type | Description |
|---|---|---|
_IR | address | The address of the IR contract |
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 |
updateIRMintRate
Updates the mint rate for IR
function updateIRMintRate(uint256 _IRMintRate) external;
Parameters
| Name | Type | Description |
|---|---|---|
_IRMintRate | uint256 | The new mint rate for IR |
claimProtocolFees
Claims accumulated protocol fees in contract
function claimProtocolFees(address _to, address _token) external;
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | address The recipient of the fees |
_token | address | address The token to claim fees in |
harvestBase
Claims all the BGT base and commission rewards minted to this contract for validators.
function harvestBase() external;
harvestOperatorRewards
Credits all accumulated rewards to the operator
function harvestOperatorRewards() external;
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[] memory _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.
_token The payout token for the bribe collector.
_amount The amount of payout received from bribe collector.
function collectBribes(address _token, uint256 _amount) external;
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[] memory _validators)
external;
Parameters
| Name | Type | Description |
|---|---|---|
_validators | ValidatorTypes.Validator[] | Validator[] memory The validators to add. |
removeValidators
Removes validators from the set of InfraredValidators.
function removeValidators(bytes[] memory _pubkeys) external;
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;
Parameters
| Name | Type | Description |
|---|---|---|
_current | bytes | bytes The pubkey of the validator to replace. |
_new | bytes | bytes The new validator pubkey. |
queueBoosts
Queue _amts of tokens to _validators for boosts.
function queueBoosts(bytes[] memory _pubkeys, uint128[] memory _amts)
external;
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[] memory _pubkeys, uint128[] memory _amts)
external;
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[] memory _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 amounts)
external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
amounts | 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 amounts)
external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkeys | bytes[] | bytes[] memory The pubkeys of the validators to remove boost from. |
amounts | uint128[] | 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. |
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;
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 |
infraredValidators
Gets the set of infrared validator pubkeys.
function infraredValidators()
external
view
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 memory _pubkey)
external
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() external view returns (uint256 bgtBalance);
Returns
| Name | Type | Description |
|---|---|---|
bgtBalance | uint256 | The BGT balance held by this address |
Events
NewVault
Emitted when a new vault is registered
event NewVault(address _sender, address indexed _asset, address indexed _vault);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the vault registration |
_asset | address | The address of the asset for which the vault is registered |
_vault | address | The address of the newly created vault |
VaultRegistrationPauseStatus
Emitted when pause status for new vault registration has changed
event VaultRegistrationPauseStatus(bool pause);
Parameters
| Name | Type | Description |
|---|---|---|
pause | bool | True if new vault creation is paused |
OperatorRewardsDistributed
Emitted when InfraredBGT tokens are supplied to distributor.
event OperatorRewardsDistributed(
address indexed _ibera, address indexed _distributor, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_ibera | address | token the rewards are denominated in |
_distributor | address | The address of the distributor receiving the InfraredBGT tokens. |
_amt | uint256 | The amount of WBERA tokens supplied to distributor. |
InfraredBGTSupplied
Emitted when InfraredBGT tokens are supplied to a vault.
event InfraredBGTSupplied(
address indexed _vault, uint256 _ibgtAmt, uint256 _iredAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | The address of the vault receiving the InfraredBGT and IR tokens. |
_ibgtAmt | uint256 | The amount of InfraredBGT tokens supplied to vault. |
_iredAmt | uint256 | The amount of IR tokens supplied to vault as additional reward from protocol. |
RewardSupplied
Emitted when rewards are supplied to a vault.
event RewardSupplied(
address indexed _vault, address indexed _token, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_vault | address | The address of the vault receiving the reward. |
_token | address | The address of the token being supplied as a reward. |
_amt | uint256 | The amount of the reward token supplied. |
BribeSupplied
Emitted when rewards are supplied to a vault.
event BribeSupplied(
address indexed _recipient, address indexed _token, uint256 _amt
);
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The address receiving the bribe. |
_token | address | The address of the token being supplied as a bribe reward. |
_amt | uint256 | The amount of the bribe reward token supplied. |
Recovered
Emitted when tokens are recovered from the contract.
event Recovered(address _sender, address indexed _token, uint256 _amount);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the recovery. |
_token | address | The address of the token being recovered. |
_amount | uint256 | The amount of the token recovered. |
RewardTokenNotSupported
Emitted when a reward token is marked as unsupported.
event RewardTokenNotSupported(address _token);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the reward token. |
InfraredBGTUpdated
Emitted when the InfraredBGT token address is updated.
event InfraredBGTUpdated(address _sender, address _oldIbgt, address _newIbgt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldIbgt | address | The previous address of the InfraredBGT token. |
_newIbgt | address | The new address of the InfraredBGT token. |
InfraredBGTVaultUpdated
Emitted when the InfraredBGT vault address is updated.
event InfraredBGTVaultUpdated(
address _sender, address _oldIbgtVault, address _newIbgtVault
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldIbgtVault | address | The previous address of the InfraredBGT vault. |
_newIbgtVault | address | The new address of the InfraredBGT vault. |
WhiteListedRewardTokensUpdated
Emitted when reward tokens are whitelisted or unwhitelisted.
event WhiteListedRewardTokensUpdated(
address _sender,
address indexed _token,
bool _wasWhitelisted,
bool _isWhitelisted
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_token | address | The address of the token being updated. |
_wasWhitelisted | bool | The previous whitelist status of the token. |
_isWhitelisted | bool | The new whitelist status of the token. |
RewardsDurationUpdated
Emitted when the rewards duration is updated
event RewardsDurationUpdated(
address _sender, uint256 _oldDuration, uint256 _newDuration
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update |
_oldDuration | uint256 | The previous rewards duration |
_newDuration | uint256 | The new rewards duration |
InfraredBERABribeSplitUpdated
Emitted when a weight is updated.
event InfraredBERABribeSplitUpdated(
address _sender, uint256 _oldWeight, uint256 _newWeight
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_oldWeight | uint256 | The old value of the weight. |
_newWeight | uint256 | The new value of the weight. |
FeeUpdated
Emitted when protocol fee rate is updated.
event FeeUpdated(
address _sender,
ConfigTypes.FeeType _feeType,
uint256 _oldFeeRate,
uint256 _newFeeRate
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_feeType | ConfigTypes.FeeType | The fee type updated. |
_oldFeeRate | uint256 | The old protocol fee rate. |
_newFeeRate | uint256 | The new protocol fee rate. |
ProtocolFeesClaimed
Emitted when protocol fees claimed.
event ProtocolFeesClaimed(
address _sender, address _to, address _token, uint256 _amount
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the claim. |
_to | address | The address to send protocol fees to. |
_token | address | The address of the token protocol fees in. |
_amount | uint256 | The amount of protocol fees claimed. |
ProtocolFees
Emitted when protocol fees are received.
event ProtocolFees(address indexed _token, uint256 _amt, uint256 _voterAmt);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address | The address of the token protocol fees in. |
_amt | uint256 | The amount of protocol fees received. |
_voterAmt | uint256 | The amount of protocol fees received by the voter. |
BaseHarvested
Emitted when base + commission rewards are harvested.
event BaseHarvested(address _sender, uint256 _bgtAmt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_bgtAmt | uint256 | The amount of BGT harvested. |
VaultHarvested
Emitted when a vault harvests its rewards.
event VaultHarvested(
address _sender,
address indexed _asset,
address indexed _vault,
uint256 _bgtAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_asset | address | The asset associated with the vault being harvested. |
_vault | address | The address of the vault being harvested. |
_bgtAmt | uint256 | The amount of BGT harvested. |
BribesCollected
Emitted when bribes are harvested then collected by collector.
event BribesCollected(
address _sender,
address _token,
uint256 _amtWiberaVault,
uint256 _amtIbgtVault
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the bribe collection. |
_token | address | The payout token from bribe collection. |
_amtWiberaVault | uint256 | The amount of collected bribe sent to the wrapped iBERA vault. |
_amtIbgtVault | uint256 | The amount of collected bribe sent to the iBGT vault. |
ValidatorHarvested
Emitted when a validator harvests its rewards.
event ValidatorHarvested(
address _sender,
bytes indexed _validator,
DataTypes.Token[] _rewards,
uint256 _bgtAmt
);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the harvest. |
_validator | bytes | The public key of the validator. |
_rewards | DataTypes.Token[] | An array of tokens and amounts harvested. |
_bgtAmt | uint256 | The amount of BGT included in the rewards. |
ValidatorsAdded
Emitted when validators are added.
event ValidatorsAdded(address _sender, ValidatorTypes.Validator[] _validators);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the addition. |
_validators | ValidatorTypes.Validator[] | An array of validators that were added. |
ValidatorsRemoved
Emitted when validators are removed from validator set.
event ValidatorsRemoved(address _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the removal. |
_pubkeys | bytes[] | An array of validators' pubkeys that were removed. |
ValidatorReplaced
Emitted when a validator is replaced with a new validator.
event ValidatorReplaced(address _sender, bytes _current, bytes _new);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the replacement. |
_current | bytes | The pubkey of the current validator being replaced. |
_new | bytes | The pubkey of the new validator. |
QueuedBoosts
Emitted when BGT tokens are queued for boosts to validators.
event QueuedBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the boost. |
_pubkeys | bytes[] | The addresses of the validators to which tokens are queued for boosts. |
_amts | uint128[] | The amounts of tokens that were queued. |
CancelledBoosts
Emitted when existing queued boosts to validators are cancelled.
event CancelledBoosts(address _sender, bytes[] _pubkeys, uint128[] _amts);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the cancellation. |
_pubkeys | bytes[] | The pubkeys of the validators to which tokens were queued for boosts. |
_amts | uint128[] | The amounts of tokens to remove from boosts. |
ActivatedBoosts
Emitted when an existing boost to a validator is activated.
event ActivatedBoosts(address _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the activation. |
_pubkeys | bytes[] | The addresses of the validators which were boosted. |
QueueDropBoosts
Emitted when an user queues a drop boost for a validator.
event QueueDropBoosts(
address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user. |
pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
amounts | uint128[] | The amounts of tokens to remove from boosts. |
CancelDropBoosts
Emitted when an user cancels a queued drop boost for a validator.
event CancelDropBoosts(
address indexed user, bytes[] indexed pubkeys, uint128[] amounts
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user. |
pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
amounts | uint128[] | The amounts of tokens to remove from boosts. |
DroppedBoosts
Emitted when sender removes an amount of BGT boost from a validator
event DroppedBoosts(address indexed _sender, bytes[] _pubkeys);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the cancellation. |
_pubkeys | bytes[] | The addresses of the validators to which tokens were queued for boosts. |
Undelegated
Emitted when tokens are undelegated from a validator.
event Undelegated(address _sender, bytes _pubkey, uint256 _amt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the undelegation. |
_pubkey | bytes | The pubkey of the validator from which tokens are undelegated. |
_amt | uint256 | The amount of tokens that were undelegated. |
Redelegated
Emitted when tokens are redelegated from one validator to another.
event Redelegated(address _sender, bytes _from, bytes _to, uint256 _amt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the redelegation. |
_from | bytes | The public key of the validator from which tokens are redelegated. |
_to | bytes | The public key of the validator to which tokens are redelegated. |
_amt | uint256 | The amount of tokens that were redelegated. |
IRSet
Emitted when the IR token is set.
event IRSet(address _sender, address _IR);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_IR | address | The address of the IRdd token. |
UpdatedIRMintRate
event UpdatedIRMintRate(
uint256 oldMintRate, uint256 newMintRate, address sender
);
Parameters
| Name | Type | Description |
|---|---|---|
oldMintRate | uint256 | The old mint rate for IR |
newMintRate | uint256 | The new mint rate for IR |
sender | address | The address that initiated the update |
IBGTSet
Emitted when the iBGT token is set.
event IBGTSet(address _sender, address _ibgt);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_ibgt | address | The address of the iBGT token. |
VoterSet
Emitted when the voter contract is set.
event VoterSet(address _sender, address _voter);
Parameters
| Name | Type | Description |
|---|---|---|
_sender | address | The address that initiated the update. |
_voter | address | The address of the voter contract. |
IInfraredBERA
Inherits: IERC20, IAccessControl
Functions
infrared
The Infrared.sol smart contract
function infrared() external view returns (address);
depositor
The InfraredBERADepositor.sol smart contract
function depositor() external view returns (address);
withdrawor
The InfraredBERAWithdrawor.sol smart contract
function withdrawor() external view returns (address);
receivor
The InfraredBERAFeeReceivor.sol smart contract
function receivor() external view returns (address);
deposits
The total amount of BERA deposited by the system
function deposits() external view returns (uint256);
stakes
Returns the amount of BERA staked in validator with given pubkey
function stakes(bytes calldata pubkey) external view returns (uint256);
staked
Returns whether initial deposit has been staked to validator with given pubkey
function staked(bytes calldata pubkey) external view returns (bool);
hasExited
Returns whether a validator pubkey has exited
function hasExited(bytes calldata pubkey) external view returns (bool);
signatures
Returns the deposit signature to use for given pubkey
function signatures(bytes calldata pubkey)
external
view
returns (bytes memory);
feeDivisorShareholders
The fee divisor for protocol + operator + voter fees. 1/N, where N is the divisor. example 100 = 1/100 = 1%
function feeDivisorShareholders() external view returns (uint16);
pending
Pending deposits yet to be forwarded to CL
function pending() external view returns (uint256);
confirmed
Confirmed deposits sent to CL, total - future deposits
function confirmed() external view returns (uint256);
keeper
Checks if account has the keeper role
function keeper(address account) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the keeper role |
governor
Checks if account has the governance role
function governor(address account) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the governance role |
validator
Checks if a given pubkey is a validator in the Infrared contract
function validator(bytes calldata pubkey) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the pubkey is a validator |
previewMint
Previews the amount of InfraredBERA shares that would be minted for a given BERA amount
function previewMint(uint256 beraAmount)
external
view
returns (uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
beraAmount | uint256 | The amount of BERA to simulate depositing |
Returns
| Name | Type | Description |
|---|---|---|
shares | uint256 | The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail |
previewBurn
Previews the amount of BERA that would be received for burning InfraredBERA shares
function previewBurn(uint256 shareAmount)
external
view
returns (uint256 beraAmount, uint256 fee);
Parameters
| Name | Type | Description |
|---|---|---|
shareAmount | uint256 | The amount of InfraredBERA shares to simulate burning |
Returns
| Name | Type | Description |
|---|---|---|
beraAmount | uint256 | The amount of BERA that would be received, returns 0 if the operation would fail |
fee | uint256 | The fee that would be charged for the burn operation |
initialize
Initiializer for InfraredBERA
function initialize(
address _gov,
address _keeper,
address _infrared,
address _depositor,
address _withdrawor,
address _receivor
) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | The address of the governance contract |
_keeper | address | The address of the keeper contract |
_infrared | address | The address of the Infrared.sol contract |
_depositor | address | The address of the InfraredBERADepositor.sol contract |
_withdrawor | address | The address of the InfraredBERAWithdrawor.sol contract |
_receivor | address | The address of the InfraredBERAFeeReceivor.sol contract |
compound
Internal function to update top level accounting and compound rewards
function compound() external;
sweep
Compounds accumulated EL yield in fee receivor into deposits
Called internally at bof whenever InfraredBERA minted or burned
Only sweeps if amount transferred from fee receivor would exceed min deposit thresholds
function sweep() external payable;
collect
Collects yield from fee receivor and mints ibera shares to Infrared
Called in RewardsLib::harvestOperatorRewards() in Infrared.sol
Only Infrared can call this function
function collect() external returns (uint256 sharesMinted);
Returns
| Name | Type | Description |
|---|---|---|
sharesMinted | uint256 | The amount of ibera shares |
mint
Mints ibera to the receiver in exchange for bera
takes in msg.value as amount to mint ibera with
function mint(address receiver) external payable returns (uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to mint ibera to |
Returns
| Name | Type | Description |
|---|---|---|
shares | uint256 | The amount of ibera minted |
burn
Burns ibera from the msg.sender and sets a receiver to get the BERA in exchange for iBERA
function burn(address receiver, uint256 shares)
external
payable
returns (uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to send the BERA to |
shares | uint256 | The amount of ibera to burn |
Returns
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The nonce of the withdrawal. Queue based system for withdrawals |
amount | uint256 | The amount of BERA withdrawn for the exchange of iBERA |
register
Updates the accounted for stake of a validator pubkey
function register(bytes calldata pubkey, int256 delta) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey of the validator |
delta | int256 | The change in stake |
setFeeDivisorShareholders
Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV
function setFeeDivisorShareholders(uint16 to) external;
Parameters
| Name | Type | Description |
|---|---|---|
to | uint16 | The new fee shareholders represented as an integer denominator (1/x)% |
setDepositSignature
Sets the deposit signature for a given pubkey. Ensure that the pubkey has signed the correct deposit amount of INITIAL_DEPOSIT
function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey to set the deposit signature for |
signature | bytes | The signature to set for the pubkey |
withdrawalsEnabled
Whether withdrawals are currently enabled
function withdrawalsEnabled() external view returns (bool);
Events
Mint
Emitted when InfraredBERA is minted
event Mint(address indexed receiver, uint256 amount, uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the minted shares |
amount | uint256 | The amount of BERA deposited |
shares | uint256 | The amount of shares minted |
Burn
Emitted when InfraredBERA is burned
event Burn(
address indexed receiver,
uint256 nonce,
uint256 amount,
uint256 shares,
uint256 fee
);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the withdrawn BERA |
nonce | uint256 | The withdrawal nonce |
amount | uint256 | The amount of BERA to withdraw |
shares | uint256 | The amount of shares burned |
fee | uint256 | The fee paid for withdrawal |
Sweep
Emitted when accumulated rewards are swept
event Sweep(uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of BERA swept |
Register
Emitted when validator stake is registered
event Register(bytes pubkey, int256 delta, uint256 stake);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
delta | int256 | The change in stake amount |
stake | uint256 | The new total stake amount |
SetFeeShareholders
Emitted when fee shareholders rate is updated
event SetFeeShareholders(uint16 from, uint16 to);
Parameters
| Name | Type | Description |
|---|---|---|
from | uint16 | Previous fee rate |
to | uint16 | New fee rate |
SetDepositSignature
Emitted when deposit signature is updated
event SetDepositSignature(bytes pubkey, bytes from, bytes to);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
from | bytes | Previous signature |
to | bytes | New signature |
WithdrawalFlagSet
Emitted when withdrawal flag is updated
event WithdrawalFlagSet(bool flag);
Parameters
| Name | Type | Description |
|---|---|---|
flag | bool | New withdrawal flag value |
IInfraredBERAClaimor
Functions
claims
Outstanding BERA claims for a receiver
function claims(address receiver) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address of the claims receiver |
queue
Queues a new BERA claim for a receiver
Only callable by the InfraredBERAWithdrawor contract
function queue(address receiver) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address of the claims receiver |
sweep
Sweeps oustanding BERA claims for a receiver to their address
function sweep(address receiver) external;
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address of the claims receiver |
Events
Queue
event Queue(address indexed receiver, uint256 amount, uint256 claim);
Sweep
event Sweep(address indexed receiver, uint256 amount);
IInfraredBERADepositor
Functions
InfraredBERA
the main InfraredBERA contract address
function InfraredBERA() external view returns (address);
reserves
the queued amount of BERA to be deposited
function reserves() external view returns (uint256);
queue
Queues a deposit by sending BERA to this contract and storing the amount in the pending deposits acculimator
function queue() external payable;
execute
Executes a deposit to the deposit contract for the specified pubkey and amount
Only callable by the keeper
Only callable if the deposits are enabled
function execute(bytes calldata pubkey, uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey of the validator to deposit for |
amount | uint256 | The amount of BERA to deposit |
initialize
Initialize the contract (replaces the constructor)
function initialize(
address _gov,
address _keeper,
address ibera,
address _depositContract
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | Address for admin / gov to upgrade |
_keeper | address | Address for keeper |
ibera | address | The initial IBERA address |
_depositContract | address | The ETH2 (Berachain) Deposit Contract Address |
DEPOSIT_CONTRACT
The Deposit Contract Address for Berachain
function DEPOSIT_CONTRACT() external view returns (address);
ETH1_ADDRESS_WITHDRAWAL_PREFIX
https://eth2book.info/capella/part2/deposits-withdrawals/withdrawal-processing/
function ETH1_ADDRESS_WITHDRAWAL_PREFIX() external view returns (uint8);
Events
Queue
Emitted when BERA is queued for deposit
event Queue(uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of BERA queued |
Execute
Emitted when a deposit is executed to the deposit contract
event Execute(bytes pubkey, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
amount | uint256 | The amount of BERA deposited |
IInfraredBERAFeeReceivor
Functions
InfraredBERA
The address of the InfraredBERA.sol contract
function InfraredBERA() external view returns (address);
infrared
The Infrared.sol contract address
function infrared() external view returns (IInfrared);
shareholderFees
Accumulated protocol fees in contract to be claimed
function shareholderFees() external view returns (uint256);
distribution
Amount of BERA swept to InfraredBERA and fees taken for protool on next call to sweep
function distribution() external view returns (uint256 amount, uint256 fees);
Returns
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of BERA forwarded to InfraredBERA on next sweep |
fees | uint256 | The protocol fees taken on next sweep |
sweep
Sweeps accumulated coinbase priority fees + MEV to InfraredBERA to autocompound principal
function sweep() external returns (uint256 amount, uint256 fees);
Returns
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of BERA forwarded to InfraredBERA |
fees | uint256 | The total fees taken |
collect
Collects accumulated shareholder fees
Reverts if msg.sender is not InfraredBera.sol contract
function collect() external returns (uint256 sharesMinted);
Returns
| Name | Type | Description |
|---|---|---|
sharesMinted | uint256 | The amount of iBERA shares minted and sent to the Infrared.sol |
initialize
Initializer function (replaces constructor)
function initialize(
address _gov,
address _keeper,
address ibera,
address _infrared
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | Address for admin / gov to upgrade |
_keeper | address | Address for keeper |
ibera | address | Address for InfraredBERA |
_infrared | address | Address for Infrared |
Events
Sweep
Emitted when accumulated rewards are swept to InfraredBERA
event Sweep(address indexed receiver, uint256 amount, uint256 fees);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the swept BERA |
amount | uint256 | The amount of BERA swept |
fees | uint256 | The amount of fees taken |
Collect
Emitted when shareholder fees are collected
event Collect(address indexed receiver, uint256 amount, uint256 sharesMinted);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the collected fees |
amount | uint256 | The amount of fees collected |
sharesMinted | uint256 | The amount of iBERA shares minted |
IInfraredBERAWithdrawor
Functions
InfraredBERA
The address of the InfraredBERA contract
function InfraredBERA() external view returns (address);
sweep
Sweeps forced withdrawals to InfraredBERA to re-stake principal
Only callable when withdrawals are disabled and by keeper
function sweep(bytes calldata pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key to sweep funds from |
requests
Outstanding requests for claims on previously burnt ibera
function requests(uint256 nonce)
external
view
returns (
address receiver,
uint96 timestamp,
uint256 fee,
uint256 amountSubmit,
uint256 amountProcess
);
Parameters
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The nonce associated with the claim |
Returns
| Name | Type | Description |
|---|---|---|
receiver | address | The address of the receiver of bera funds to be claimed |
timestamp | uint96 | The block.timestamp at which withdraw request was issued |
fee | uint256 | The fee escrow amount set aside for withdraw precompile request |
amountSubmit | uint256 | The amount of bera left to be submitted for withdraw request |
amountProcess | uint256 | The amount of bera left to be processed for withdraw request |
fees
Amount of BERA internally set aside for withdraw precompile request fees
function fees() external view returns (uint256);
reserves
Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests
function reserves() external view returns (uint256);
rebalancing
Amount of BERA internally rebalancing amongst Infrared validators
function rebalancing() external view returns (uint256);
nonceRequest
The next nonce to issue withdraw request for
function nonceRequest() external view returns (uint256);
nonceSubmit
The next nonce to submit withdraw request for
function nonceSubmit() external view returns (uint256);
nonceProcess
The next nonce in queue to process claims for
function nonceProcess() external view returns (uint256);
queue
Queues a withdraw request from InfraredBERA
Requires msg.value to cover minimum withdrawal fee
function queue(address receiver, uint256 amount)
external
payable
returns (uint256 nonce);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to receive withdrawn funds |
amount | uint256 | The amount of funds to withdraw |
Returns
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The unique identifier for this withdrawal request |
execute
Executes a withdraw request to withdraw precompile
Payable to cover any additional fees required by precompile
Only callable by keeper
function execute(bytes calldata pubkey, uint256 amount) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key to withdraw from |
amount | uint256 | The amount of BERA to withdraw |
process
Processes the funds received from withdraw precompile
Reverts if balance has not increased by full amount of request
Processes requests in FIFO order based on nonce
function process() external;
Events
Queue
Emitted when a withdrawal is queued
event Queue(address indexed receiver, uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address that will receive the withdrawn BERA |
nonce | uint256 | The unique identifier for this withdrawal request |
amount | uint256 | The amount of BERA to be withdrawn |
Execute
Emitted when a withdrawal is executed
event Execute(bytes pubkey, uint256 start, uint256 end, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
start | uint256 | The starting nonce |
end | uint256 | The ending nonce |
amount | uint256 | The amount of BERA withdrawn |
Process
Emitted when a withdrawal is processed
event Process(address indexed receiver, uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the withdrawn BERA |
nonce | uint256 | The nonce of the processed withdrawal |
amount | uint256 | The amount of BERA processed |
Sweep
Emitted when funds are swept from a force-exited validator
event Sweep(address indexed receiver, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the swept BERA |
amount | uint256 | The amount of BERA swept |
IInfraredBERAWithdraworLite
Functions
InfraredBERA
The address of the InfraredBERA contract
function InfraredBERA() external view returns (address);
sweep
Sweeps forced withdrawals to InfraredBERA to re-stake principal
Only callable when withdrawals are disabled and by keeper
function sweep(bytes calldata pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key to sweep funds from |
requests
Outstanding requests for claims on previously burnt ibera
function requests(uint256 nonce)
external
view
returns (
address receiver,
uint96 timestamp,
uint256 fee,
uint256 amountSubmit,
uint256 amountProcess
);
Parameters
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The nonce associated with the claim |
Returns
| Name | Type | Description |
|---|---|---|
receiver | address | The address of the receiver of bera funds to be claimed |
timestamp | uint96 | The block.timestamp at which withdraw request was issued |
fee | uint256 | The fee escrow amount set aside for withdraw precompile request |
amountSubmit | uint256 | The amount of bera left to be submitted for withdraw request |
amountProcess | uint256 | The amount of bera left to be processed for withdraw request |
fees
Amount of BERA internally set aside for withdraw precompile request fees
function fees() external view returns (uint256);
reserves
Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests
function reserves() external view returns (uint256);
rebalancing
Amount of BERA internally rebalancing amongst Infrared validators
function rebalancing() external view returns (uint256);
nonceRequest
The next nonce to issue withdraw request for
function nonceRequest() external view returns (uint256);
nonceSubmit
The next nonce to submit withdraw request for
function nonceSubmit() external view returns (uint256);
nonceProcess
The next nonce in queue to process claims for
function nonceProcess() external view returns (uint256);
queue
Queues a withdraw request from InfraredBERA
Requires msg.value to cover minimum withdrawal fee
function queue(address receiver, uint256 amount)
external
payable
returns (uint256 nonce);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to receive withdrawn funds |
amount | uint256 | The amount of funds to withdraw |
Returns
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The unique identifier for this withdrawal request |
execute
Executes a withdraw request to withdraw precompile
Payable to cover any additional fees required by precompile
Only callable by keeper
function execute(bytes calldata pubkey, uint256 amount) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key to withdraw from |
amount | uint256 | The amount of BERA to withdraw |
process
Processes the funds received from withdraw precompile
Reverts if balance has not increased by full amount of request
Processes requests in FIFO order based on nonce
function process() external;
Events
Queue
Emitted when a withdrawal is queued
event Queue(address indexed receiver, uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address that will receive the withdrawn BERA |
nonce | uint256 | The unique identifier for this withdrawal request |
amount | uint256 | The amount of BERA to be withdrawn |
Execute
Emitted when a withdrawal is executed
event Execute(bytes pubkey, uint256 start, uint256 end, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The validator's public key |
start | uint256 | The starting nonce |
end | uint256 | The ending nonce |
amount | uint256 | The amount of BERA withdrawn |
Process
Emitted when a withdrawal is processed
event Process(address indexed receiver, uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the withdrawn BERA |
nonce | uint256 | The nonce of the processed withdrawal |
amount | uint256 | The amount of BERA processed |
Sweep
Emitted when funds are swept from a force-exited validator
event Sweep(address indexed receiver, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address receiving the swept BERA |
amount | uint256 | The amount of BERA swept |
IInfraredBGT
Inherits: IERC20Mintable, IAccessControl
Functions
burn
function burn(uint256 amount) external;
IInfraredDistributor
Interface for distributing validator commissions and rewards
Handles reward distribution snapshots and claiming logic for validators
Functions
token
Token used for reward distributions
function token() external view returns (ERC20);
Returns
| Name | Type | Description |
|---|---|---|
<none> | ERC20 | The ERC20 token interface of the reward token |
amountsCumulative
Tracks reward amount accumulation per validator
function amountsCumulative() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Current cumulative amount of rewards |
getSnapshot
Get validator's reward snapshots
Returns (0,0) if validator doesn't exist
function getSnapshot(bytes calldata pubkey)
external
view
returns (uint256 amountCumulativeLast, uint256 amountCumulativeFinal);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
Returns
| Name | Type | Description |
|---|---|---|
amountCumulativeLast | uint256 | Last claimed accumulator value |
amountCumulativeFinal | uint256 | Final accumulator value if removed |
getValidator
Get validator's registered claim address
function getValidator(bytes calldata pubkey) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address authorized to claim validator rewards |
add
Register new validator for rewards
Only callable by Infrared contract
Notes:
-
access-control: Requires INFRARED_ROLE
-
error: ValidatorAlreadyExists if validator already registered
function add(bytes calldata pubkey, address validator) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
validator | address | Address authorized to claim rewards |
remove
Removes validator from reward-eligible set
Only callable by Infrared contract
Note: access-control: Requires INFRARED_ROLE
function remove(bytes calldata pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
purge
Purges validator from registry completely
Only possible after all rewards are claimed
Note: error: ClaimableRewardsExist if unclaimed rewards remain
function purge(bytes calldata pubkey) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
notifyRewardAmount
Distributes new commission rewards to validator set
Notes:
-
error: ZeroAmount if amount is 0
-
error: InvalidValidator if no validators exist
function notifyRewardAmount(uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | Amount to distribute equally among validators |
claim
Claims outstanding commission rewards
Notes:
-
error: InvalidValidator if caller not authorized
-
error: ZeroAmount if no rewards to claim
function claim(bytes calldata pubkey, address recipient) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
recipient | address | Address to receive the claimed rewards |
Events
Added
Emitted when validator is added to commission-eligible set
event Added(bytes pubkey, address operator, uint256 amountCumulative);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
operator | address | Address authorized to claim rewards |
amountCumulative | uint256 | Starting point for commission stream |
Removed
Emitted when validator is removed from commission-eligible set
event Removed(bytes pubkey, address operator, uint256 amountCumulative);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
operator | address | Address previously authorized for claims |
amountCumulative | uint256 | Final point for commission stream |
Purged
Emitted when validator is fully purged from registry
event Purged(bytes pubkey, address validator);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Validator's public key |
validator | address | Address being purged |
Notified
Emitted when new commission rewards are added
event Notified(uint256 amount, uint256 num);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | New rewards being distributed |
num | uint256 | Current number of eligible validators |
Claimed
Emitted when validator claims their commission
event Claimed(
bytes pubkey, address validator, address recipient, uint256 amount
);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Claiming validator's public key |
validator | address | Address authorized for claims |
recipient | address | Address receiving the commission |
amount | uint256 | Amount of commission claimed |
Structs
Snapshot
Reward accumulation checkpoints for validators
Used to calculate claimable rewards between snapshots
struct Snapshot {
uint256 amountCumulativeLast;
uint256 amountCumulativeFinal;
}
IInfraredGovernanceToken
Inherits: IERC20Mintable, IAccessControl
Functions
ibgt
The address of the InfraredBGT token
function ibgt() external view returns (address);
infrared
The address of the Infrared contract
function infrared() external view returns (address);
paused
returns paused status of the contract
function paused() external view returns (bool);
IInfraredUpgradeable
Inherits: IAccessControl
Functions
KEEPER_ROLE
Access control for keeper role
function KEEPER_ROLE() external view returns (bytes32);
GOVERNANCE_ROLE
Access control for governance role
function GOVERNANCE_ROLE() external view returns (bytes32);
infrared
Infrared coordinator contract
function infrared() external view returns (address);
IInfraredVault
Inherits: IMultiRewards
Functions
getAllRewardTokens
Returns all reward tokens
function getAllRewardTokens() external view returns (address[] memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address[] | An array of reward token addresses |
getAllRewardsForUser
Returns all rewards for a user
Only up to date since the lastUpdateTime
function getAllRewardsForUser(address _user)
external
view
returns (UserReward[] memory);
Parameters
| Name | Type | Description |
|---|---|---|
_user | address | The address of the user |
Returns
| Name | Type | Description |
|---|---|---|
<none> | UserReward[] | An array of UserReward structs |
infrared
Returns the Infrared protocol coordinator
function infrared() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the Infrared contract |
rewardsVault
Returns the associated Berachain rewards vault
function rewardsVault() external view returns (IBerachainRewardsVault);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IBerachainRewardsVault | The rewards vault contract instance |
updateRewardsDuration
Updates reward duration for a specific reward token
Only callable by Infrared contract
Note: access-control: Requires INFRARED_ROLE
function updateRewardsDuration(address _rewardsToken, uint256 _rewardsDuration)
external;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the reward token |
_rewardsDuration | uint256 | The new duration in seconds |
pauseStaking
Pauses staking functionality on a specific vault
Note: access-control: Requires INFRARED_ROLE
function pauseStaking() external;
unpauseStaking
Un-pauses staking functionality on a specific vault
Note: access-control: Requires INFRARED_ROLE
function unpauseStaking() external;
addReward
Adds a new reward token to the vault
Cannot exceed maximum number of reward tokens
Note: access-control: Requires INFRARED_ROLE
function addReward(address _rewardsToken, uint256 _rewardsDuration) external;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The reward token to add |
_rewardsDuration | uint256 | The reward period duration |
removeReward
Used to remove malicious or unused reward tokens
Note: access-control: Requires INFRARED_ROLE
function removeReward(address _rewardsToken) external;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The reward token to remove |
notifyRewardAmount
Notifies the vault of newly added rewards
Updates internal reward rate calculations
function notifyRewardAmount(address _rewardToken, uint256 _reward) external;
Parameters
| Name | Type | Description |
|---|---|---|
_rewardToken | address | The reward token address |
_reward | uint256 | The amount of new rewards |
recoverERC20
Recovers accidentally sent tokens
Cannot recover staking token or active reward tokens
function recoverERC20(address _to, address _token, uint256 _amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | The address to receive the recovered tokens |
_token | address | The token to recover |
_amount | uint256 | The amount to recover |
Structs
UserReward
A struct to hold a user's reward information
struct UserReward {
address token;
uint256 amount;
}
Properties
| Name | Type | Description |
|---|---|---|
token | address | The address of the reward token |
amount | uint256 | The amount of reward tokens |
IMultiRewards
Functions
totalSupply
Returns the total amount of staked tokens in the contract
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The total supply of staked tokens |
stake
Stakes tokens into the contract
Transfers amount of staking tokens from the user to this contract
function stake(uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of tokens to stake |
withdraw
Withdraws staked tokens from the contract
Transfers amount of staking tokens back to the user
function withdraw(uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of tokens to withdraw |
getReward
Claims all pending rewards for the caller
Transfers all accrued rewards to the caller
function getReward() external;
exit
Withdraws all staked tokens and claims pending rewards
Combines withdraw and getReward operations
function exit() external;
balanceOf
Returns the balance of staked tokens for the given account
function balanceOf(address account) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The account to get the balance for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The balance of staked tokens |
lastTimeRewardApplicable
Calculates the last time reward is applicable for a given rewards token
function lastTimeRewardApplicable(address _rewardsToken)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The timestamp when the reward was last applicable |
rewardPerToken
Calculates the reward per token for a given rewards token
function rewardPerToken(address _rewardsToken)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The reward amount per token |
earned
Calculates the earned rewards for a given account and rewards token
function earned(address account, address _rewardsToken)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address of the account |
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of rewards earned |
getRewardForDuration
Calculates the total reward for the duration of a given rewards token
function getRewardForDuration(address _rewardsToken)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The total reward amount for the duration of a given rewards token |
rewardData
Gets the reward data for a given rewards token
function rewardData(address _rewardsToken)
external
view
returns (
address rewardsDistributor,
uint256 rewardsDuration,
uint256 periodFinish,
uint256 rewardRate,
uint256 lastUpdateTime,
uint256 rewardPerTokenStored,
uint256 rewardResidual
);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
rewardsDistributor | address | The address authorized to distribute rewards |
rewardsDuration | uint256 | The duration of the reward period |
periodFinish | uint256 | The timestamp when rewards finish |
rewardRate | uint256 | The rate of rewards distributed per second |
lastUpdateTime | uint256 | The last time rewards were updated |
rewardPerTokenStored | uint256 | The last calculated reward per token |
rewardResidual | uint256 |
rewardTokens
Returns the reward token address at a specific index
function rewardTokens(uint256 index) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | The index in the reward tokens array |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address of the reward token at the given index |
getRewardForUser
Claims all pending rewards for a specified user
Iterates through all reward tokens and transfers any accrued rewards to the user
function getRewardForUser(address _user) external;
Parameters
| Name | Type | Description |
|---|---|---|
_user | address | The address of the user to claim rewards for |
Events
Staked
Emitted when tokens are staked
event Staked(address indexed user, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user who staked |
amount | uint256 | The amount of tokens staked |
Withdrawn
Emitted when tokens are withdrawn
event Withdrawn(address indexed user, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user who withdrew |
amount | uint256 | The amount of tokens withdrawn |
RewardPaid
Emitted when rewards are claimed
event RewardPaid(
address indexed user, address indexed rewardsToken, uint256 reward
);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user claiming the reward |
rewardsToken | address | The address of the reward token |
reward | uint256 | The amount of rewards claimed |
RewardAdded
Emitted when rewards are added to the contract
event RewardAdded(address indexed rewardsToken, uint256 reward);
Parameters
| Name | Type | Description |
|---|---|---|
rewardsToken | address | The address of the reward token |
reward | uint256 | The amount of rewards added |
RewardRemoved
Emitted when a reward is removed from the contract
event RewardRemoved(address indexed rewardsToken);
RewardsDistributorUpdated
Emitted when a rewards distributor is updaRewardAddedd
event RewardsDistributorUpdated(
address indexed rewardsToken, address indexed newDistributor
);
Parameters
| Name | Type | Description |
|---|---|---|
rewardsToken | address | The address of the reward token |
newDistributor | address | The address of the new distributor |
RewardsDurationUpdated
Emitted when the rewards duration for a token is updated
event RewardsDurationUpdated(address token, uint256 newDuration);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The reward token address whose duration was updated |
newDuration | uint256 | The new duration set for the rewards period |
Recovered
Emitted when tokens are recovered from the contract
event Recovered(address token, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | The address of the token that was recovered |
amount | uint256 | The amount of tokens that were recovered |
RewardStored
Emitted when new reward data is stored
event RewardStored(address rewardsToken, uint256 rewardsDuration);
Parameters
| Name | Type | Description |
|---|---|---|
rewardsToken | address | The address of the reward token |
rewardsDuration | uint256 | The duration set for the reward period |
Structs
Reward
Reward data for a particular reward token
Struct containing all relevant information for reward distribution
struct Reward {
address rewardsDistributor;
uint256 rewardsDuration;
uint256 periodFinish;
uint256 rewardRate;
uint256 lastUpdateTime;
uint256 rewardPerTokenStored;
uint256 rewardResidual;
}
IRED
Inherits: IERC20Mintable, IAccessControl
Functions
ibgt
The address of the InfraredBGT token
function ibgt() external view returns (address);
infrared
The address of the Infrared contract
function infrared() external view returns (address);
IWBERA
Inherits: IERC20
The deposit function allows users to deposit EVM balance (BERA) into the contract. It mints an equivalent amount of WBERA tokens and assigns them to the sender.
Functions
deposit
function deposit() external payable;
withdraw
function withdraw(uint256 amount) external;
Contents
- BatchClaimer
- BatchClaimerV2_1
- BatchClaimerV2_2
- Redeemer
- IInfrared
- IInfraredVault
- RewardDistributor
- WrappedRewardToken
BatchClaimer
Enables batch claiming of rewards for multiple staking assets for a given user.
This contract interacts with the InfraredV1_5 contract and InfraredVaults to claim rewards.
State Variables
infrared
Reference to the InfraredV1_5 contract used to fetch vaults and manage reward claims.
InfraredV1_5 internal constant infrared =
InfraredV1_5(payable(0xb71b3DaEA39012Fb0f2B14D2a9C86da9292fC126));
rewardsFactory
IBerachainRewardsVaultFactory instance of the rewards factory contract address
IBerachainRewardsVaultFactory internal immutable rewardsFactory;
Functions
constructor
constructor();
batchClaim
Allows batch claiming of staking rewards from multiple vaults for a user.
*This function iterates over the stakingAssets array and attempts to:
- Claim rewards from the InfraredVault if it exists.
- Claim external vault rewards if available.*
function batchClaim(address user, address[] calldata stakingAssets) external;
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user for whom rewards are to be claimed. |
stakingAssets | address[] | An array of addresses representing staking asset vaults to process. |
Errors
ZeroAddress
Error indicating the provided address was the zero address.
error ZeroAddress();
InvalidInputs
Error indicating that the provided inputs are invalid (e.g., empty array).
error InvalidInputs();
BatchClaimerV2_1
Enables batch claiming of rewards for multiple staking assets for a given user.
This contract interacts with the InfraredV1_5 contract and InfraredVaults to claim rewards.
State Variables
infrared
Reference to the InfraredV1_5 contract used to fetch vaults and manage reward claims.
InfraredV1_5 internal constant infrared =
InfraredV1_5(payable(0xb71b3DaEA39012Fb0f2B14D2a9C86da9292fC126));
wBYUSD
ERC4626 public constant wBYUSD =
ERC4626(0x334404782aB67b4F6B2A619873E579E971f9AAB7);
rewardsFactory
IBerachainRewardsVaultFactory instance of the rewards factory contract address
IBerachainRewardsVaultFactory internal immutable rewardsFactory;
Functions
constructor
constructor();
batchClaim
Allows batch claiming of staking rewards from multiple vaults for a user.
*This function iterates over the stakingAssets array and attempts to:
- Claim rewards from the InfraredVault if it exists.
- Claim external vault rewards if available.*
function batchClaim(address user, address[] calldata stakingAssets) external;
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user for whom rewards are to be claimed. |
stakingAssets | address[] | An array of addresses representing staking asset vaults to process. |
Errors
ZeroAddress
Error indicating the provided address was the zero address.
error ZeroAddress();
InvalidInputs
Error indicating that the provided inputs are invalid (e.g., empty array).
error InvalidInputs();
BatchClaimerV2_2
Inherits: Initializable, UUPSUpgradeable, OwnableUpgradeable
Enables batch claiming of rewards for multiple staking assets for a given user.
This contract interacts with the InfraredV1_9 contract and InfraredVaults to claim rewards.
This contract is upgradeable using the UUPS proxy pattern.
State Variables
infrared
Reference to the InfraredV1_9 contract used to fetch vaults and manage reward claims.
InfraredV1_9 internal constant infrared =
InfraredV1_9(payable(0xb71b3DaEA39012Fb0f2B14D2a9C86da9292fC126));
wBYUSD
wBYUSD ERC4626 vault constant
ERC4626 public constant wBYUSD =
ERC4626(0x334404782aB67b4F6B2A619873E579E971f9AAB7);
rewardsFactory
IBerachainRewardsVaultFactory instance of the rewards factory contract address
Changed from immutable to storage variable for upgradeability
IBerachainRewardsVaultFactory public rewardsFactory;
wiBGT
wiBGT ERC4626 wrapper for iBGT
ERC4626 public wiBGT;
__gap
This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#storage-gaps
uint256[49] private __gap;
Functions
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor();
initialize
Initializes the contract
This function replaces the constructor for upgradeable contracts
function initialize(address _owner, address _wibgt) public initializer;
Parameters
| Name | Type | Description |
|---|---|---|
_owner | address | The address of the contract owner |
_wibgt | address | The address of wrapped ibgt contract |
batchClaim
Allows batch claiming of staking rewards from multiple vaults for a user.
*This function iterates over the stakingAssets array and attempts to:
- Claim rewards from the InfraredVault if it exists.
- Claim external vault rewards if available.*
function batchClaim(address user, address[] calldata stakingAssets) external;
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The address of the user for whom rewards are to be claimed. |
stakingAssets | address[] | An array of addresses representing staking asset vaults to process. |
updateRewardsFactory
Updates the rewards factory address
Only callable by the owner
function updateRewardsFactory(address _newRewardsFactory) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
_newRewardsFactory | address | The new rewards factory address |
_authorizeUpgrade
Required by UUPSUpgradeable to authorize upgrades
Only the owner can authorize upgrades
function _authorizeUpgrade(address newImplementation)
internal
override
onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
newImplementation | address | Address of the new implementation |
version
Returns the current version of the contract
function version() external pure returns (string memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | The version string |
Errors
ZeroAddress
Error indicating the provided address was the zero address.
error ZeroAddress();
InvalidInputs
Error indicating that the provided inputs are invalid (e.g., empty array).
error InvalidInputs();
Redeemer
Permissionless contract for redeeming iBGT tokens for BERA via the Infrared protocol.
State Variables
bgt
Address of the BGT token.
address public immutable bgt;
ibgt
Address of the iBGT token.
address public immutable ibgt;
infrared
Address of the Infrared protocol contract.
InfraredV1_8 public immutable infrared;
Functions
constructor
Constructor to initialize the contract.
constructor(address _bgt, address _infrared);
Parameters
| Name | Type | Description |
|---|---|---|
_bgt | address | Address of the BGT token. |
_infrared | address | Address of the Infrared protocol. |
redeemIbgtForBera
Redeems iBGT for BERA.
Caller must approve this contract for iBGT. Checks unboosted BGT availability on Infrared. Burns iBGT, calls Infrared to redeem, and transfers BERA to the caller.
function redeemIbgtForBera(uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of iBGT to redeem. |
receive
Fallback to receive BERA from Infrared.
receive() external payable;
Events
IbgtRedeemed
Event emitted when iBGT is redeemed for BERA.
event IbgtRedeemed(address indexed user, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
user | address | The user who redeemed. |
amount | uint256 | The amount of iBGT redeemed. |
Errors
InvalidAmount
Error thrown for zero amount
error InvalidAmount();
InvalidAddress
Error thrown for invalid address
error InvalidAddress();
InsufficientUnboostedBGT
Error thrown when insufficient unboosted BGT is available for redemption.
error InsufficientUnboostedBGT();
IInfrared
Functions
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 |
vaultRegistry
Mapping of staking token addresses to their corresponding InfraredVault
Each staking token can only have one vault
function vaultRegistry(address _stakingToken)
external
view
returns (IInfraredVault vault);
IInfraredVault
Functions
rewardData
Gets the reward data for a given rewards token
function rewardData(address _rewardsToken)
external
view
returns (
address rewardsDistributor,
uint256 rewardsDuration,
uint256 periodFinish,
uint256 rewardRate,
uint256 lastUpdateTime,
uint256 rewardPerTokenStored,
uint256 rewardResidual
);
Parameters
| Name | Type | Description |
|---|---|---|
_rewardsToken | address | The address of the rewards token |
Returns
| Name | Type | Description |
|---|---|---|
rewardsDistributor | address | The address authorized to distribute rewards |
rewardsDuration | uint256 | The duration of the reward period |
periodFinish | uint256 | The timestamp when rewards finish |
rewardRate | uint256 | The rate of rewards distributed per second |
lastUpdateTime | uint256 | The last time rewards were updated |
rewardPerTokenStored | uint256 | The last calculated reward per token |
rewardResidual | uint256 |
totalSupply
Returns the total amount of staked tokens in the contract
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | uint256 The total supply of staked tokens |
RewardDistributor
Inherits: Owned
Distributes reward tokens to the vault to maintain the target APR
This contract integrates with the Infrared controller to distribute rewards to a specified vault. Calculates the reward amount based on the target APR, total staked supply, and reward duration. Uses the vault's rewardRate and periodFinish to compute remaining rewards, accounting for the vault's logic where periodFinish is updated to block.timestamp + rewardsDuration and rewardRate is set to (leftover + newAmount) / rewardsDuration. Protected against sandwich attacks through keeper restrictions and slippage protection on total supply.
Notes:
-
security: The contract grants unlimited approval to the Infrared controller for reward token transfers during initialization. Uses keeper whitelist and slippage protection to prevent manipulation. Only the owner can update configuration parameters or withdraw tokens.
-
access: Only whitelisted keepers can call
distribute. Only the owner can callsetTargetAPR,setDistributionInterval,updateKeeper,setMaxSupplyDeviation, andwithdrawRewards.
State Variables
SECONDS_PER_YEAR
The number of seconds in a year for APR calculations
uint256 private constant SECONDS_PER_YEAR = 36525 * 24 * 60 * 60 / 100;
BASIS_POINTS
The number of basis points in 100% (1% = 100 basis points)
uint256 private constant BASIS_POINTS = 10_000;
infrared
The address of the Infrared controller contract.
IInfrared public immutable infrared;
stakingToken
The address of the staking token associated with the vault.
address public immutable stakingToken;
rewardsToken
The ERC20 token used for rewards distribution.
ERC20 public immutable rewardsToken;
targetAPR
The target APR in basis points (e.g., 100 = 1%)
uint256 public targetAPR;
keepers
Mapping of addresses authorized to call the distribute function
Keepers are trusted entities that can trigger reward distributions
mapping(address => bool) public keepers;
maxSupplyDeviation
Maximum allowed deviation in total supply to prevent sandwich attacks
Expressed in basis points (e.g., 200 = 2% allowed increase)
uint256 public maxSupplyDeviation = 100;
distributionInterval
The interval between distributions in seconds
uint256 public distributionInterval;
lastDistributionTime
The timestamp of the last reward distribution.
uint256 public lastDistributionTime;
Functions
constructor
Initializes the RewardDistributor contract.
constructor(
address _gov,
address _infrared,
address _stakingToken,
address _rewardsToken,
address _keeper,
uint256 _initialTargetAPR,
uint256 _initialDistributionInterval
) Owned(_gov);
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | The address of the contract owner/governance. |
_infrared | address | The address of the Infrared controller contract. |
_stakingToken | address | The address of the staking token associated with the vault. |
_rewardsToken | address | The address of the ERC20 token used for rewards. |
_keeper | address | Initial keeper address |
_initialTargetAPR | uint256 | The initial target APR in basis points (e.g., 100 = 1%) |
_initialDistributionInterval | uint256 | The initial interval between distributions in seconds |
onlyKeeper
Restricts function access to whitelisted keepers only
Reverts if msg.sender is not an active keeper
modifier onlyKeeper();
getMaxTotalSupply
Calculates the maximum acceptable total supply for slippage protection
Returns current total supply plus the allowed deviation percentage
function getMaxTotalSupply() external view returns (uint256 totalSupply);
Returns
| Name | Type | Description |
|---|---|---|
totalSupply | uint256 | The maximum acceptable total supply |
getExpectedAmount
Calculates the expected reward amount to be distributed in the next distribution cycle
Accounts for leftover rewards from incomplete periods and residual amounts in vault Returns 0 if distribution conditions are not met (too soon, zero supply, insufficient balance)
Notes:
-
formula: totalRewardsNeeded = (targetAPR * totalSupply * rewardsDuration) / (SECONDS_PER_YEAR * BASIS_POINTS)
-
formula: amount = totalRewardsNeeded - (leftover + residual)
function getExpectedAmount() external view returns (uint256 amount);
Returns
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of reward tokens expected to be distributed, or 0 if conditions not met |
getCurrentAPR
Returns the current effective APR based on the vault's active reward rate
Calculates APR from the current rewardRate and totalSupply Returns 0 if no active rewards period or zero total supply
Note: formula: apr = (rewardRate * SECONDS_PER_YEAR * BASIS_POINTS) / totalSupply
function getCurrentAPR() external view returns (uint256 apr);
Returns
| Name | Type | Description |
|---|---|---|
apr | uint256 | The current APR in basis points (e.g., 1500 = 15%) |
getAPRForAmount
Calculates the APR that would result from distributing a specific amount of rewards
Useful for determining how much rewards are needed to achieve a target APR
Note: formula: apr = (amount * SECONDS_PER_YEAR * BASIS_POINTS) / (rewardsDuration * totalSupply)
function getAPRForAmount(uint256 amount) external view returns (uint256 apr);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of reward tokens to calculate APR for |
Returns
| Name | Type | Description |
|---|---|---|
apr | uint256 | The resulting APR in basis points if the amount were distributed |
distribute
Distributes reward tokens to the vault to maintain the target APR
Calculates reward amount based on target APR and current supply, protected against sandwich attacks via keeper restriction and slippage check. Accounts for leftover rewards from previous periods and residual amounts in the vault.
Notes:
-
security: Requires msg.sender to be a whitelisted keeper
-
security: Reverts if current totalSupply exceeds _maxTotalSupply (sandwich attack protection)
-
security: Updates state before external calls to prevent reentrancy
function distribute(uint256 _maxTotalSupply) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
_maxTotalSupply | uint256 | Maximum acceptable total supply (slippage protection) |
updateKeeper
Updates the keeper status for a given address
Only callable by owner, reverts if status would not change
Note: security: Consider checking _keeper != address(0) to prevent accidents
function updateKeeper(address _keeper, bool _active) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
_keeper | address | The address to update keeper status for |
_active | bool | Whether the address should be an active keeper |
setTargetAPR
Sets the target APR for reward distributions
Updates the target APR after validating it is non-zero and emits a TargetAPRUpdated event
function setTargetAPR(uint256 _apr) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
_apr | uint256 | The new target APR in basis points (e.g., 100 = 1%) |
setDistributionInterval
Sets the interval between reward distributions
Updates the distribution interval after validating it is non-zero and emits a DistributionIntervalUpdated event
function setDistributionInterval(uint256 _interval) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
_interval | uint256 | The new distribution interval in seconds |
setMaxSupplyDeviation
Sets the maximum allowed supply deviation for slippage protection
Prevents distributions when supply increases beyond this threshold
function setMaxSupplyDeviation(uint256 _deviation) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
_deviation | uint256 | The new maximum deviation in basis points (e.g., 200 = 2%) |
withdrawRewards
Allows the owner to withdraw reward tokens from the contract.
Transfers the specified amount of reward tokens to the owner using safe transfer.
function withdrawRewards(uint256 _amount) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
_amount | uint256 | The amount of reward tokens to withdraw. |
recoverERC20
Recover non-reward tokens sent to this contract by mistake
Cannot be used to withdraw reward tokens - use withdrawRewards instead Transfers entire balance of the specified token to the recipient
Notes:
-
security: Only callable by owner, prevents recovery of reward tokens
-
error: UseWithdrawRewards if attempting to recover reward tokens
-
error: ZeroAmount if token balance is zero
function recoverERC20(address tokenAddress, address to) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
tokenAddress | address | Address of the ERC20 token to recover |
to | address | Address to send recovered tokens to |
Events
RewardsDistributed
Emitted when rewards are successfully distributed to the vault.
event RewardsDistributed(address vault, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
vault | address | The address of the Infrared vault receiving the rewards. |
amount | uint256 | The amount of reward tokens distributed. |
TargetAPRUpdated
Emitted when the target APR is updated
event TargetAPRUpdated(uint256 oldAPR, uint256 newAPR);
Parameters
| Name | Type | Description |
|---|---|---|
oldAPR | uint256 | The previous target APR in basis points |
newAPR | uint256 | The new target APR in basis points |
DistributionIntervalUpdated
Emitted when the distribution interval is updated
event DistributionIntervalUpdated(uint256 oldInterval, uint256 newInterval);
Parameters
| Name | Type | Description |
|---|---|---|
oldInterval | uint256 | The previous distribution interval in seconds |
newInterval | uint256 | The new distribution interval in seconds |
KeeperUpdated
Emitted when a keeper's status is updated
event KeeperUpdated(address indexed keeper, bool active);
Parameters
| Name | Type | Description |
|---|---|---|
keeper | address | The address of the keeper |
active | bool | Whether the keeper is now active or inactive |
MaxSupplyDeviationUpdated
Emitted when the maximum supply deviation is updated
event MaxSupplyDeviationUpdated(uint256 oldDeviation, uint256 newDeviation);
Parameters
| Name | Type | Description |
|---|---|---|
oldDeviation | uint256 | The previous maximum deviation in basis points |
newDeviation | uint256 | The new maximum deviation in basis points |
TokensRecovered
Emitted when tokens are withdrawn by the owner
event TokensRecovered(address indexed token, address to, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of token recovered |
to | address | Address of recipient |
amount | uint256 | Tokens recovered |
Errors
ZeroRewardDuration
Thrown when the reward duration from the vault is zero.
error ZeroRewardDuration();
DistributionTooSoon
Thrown when a distribution is attempted before the reward duration has elapsed.
error DistributionTooSoon();
InsufficientRewardBalance
Thrown when the contract has insufficient reward token balance for distribution.
error InsufficientRewardBalance();
ZeroFixedAmount
Thrown when attempting to set a zero fixed reward amount.
error ZeroFixedAmount();
ZeroAddress
Thrown when attempting to set a zero address.
error ZeroAddress();
ZeroTargetAPR
Thrown when attempting to set a zero target APR
error ZeroTargetAPR();
ZeroDistributionInterval
Thrown when attempting to set a zero distribution interval
error ZeroDistributionInterval();
ZeroTotalSupply
Thrown when the total staked supply in the vault is zero
error ZeroTotalSupply();
NothingToAdd
Thrown when amount to distribute is zero
error NothingToAdd();
NoVault
Thrown when there is no vault for the staking token
error NoVault();
TotalSupplySlippage
Thrown when the current total supply exceeds the maximum allowed (slippage protection)
Prevents distribution during potential sandwich attacks
error TotalSupplySlippage();
NothingToUpdate
Thrown when attempting to update a value that would not change
error NothingToUpdate();
NotKeeper
Thrown when attempting to call onlyKeeper function from non-keeper address
error NotKeeper();
UseWithdrawRewards
Thrown when using recoverERC20 for withdrawing reward tokens
error UseWithdrawRewards();
ZeroAmount
Thrown when calling recoverERC20 with no token balance
error ZeroAmount();
WrappedRewardToken
Inherits: ERC20
A wrapper vault built on ERC4626 to facilitate reward tokens that have low decimals eg 6 like USDC
State Variables
asset
ERC20 public immutable asset;
scaling
The scaling factor to adjust for decimal differences (10^18 / 10^asset.decimals()).
uint256 public immutable scaling;
Functions
constructor
constructor(ERC20 _asset, string memory _name, string memory _symbol)
ERC20(_name, _symbol, 18);
deposit
function deposit(uint256 assets, address receiver)
public
virtual
returns (uint256 shares);
mint
function mint(uint256 shares, address receiver)
public
virtual
returns (uint256 assets);
withdraw
function withdraw(uint256 assets, address receiver, address owner)
public
virtual
returns (uint256 shares);
redeem
function redeem(uint256 shares, address receiver, address owner)
public
virtual
returns (uint256 assets);
totalAssets
function totalAssets() public view virtual returns (uint256);
convertToShares
function convertToShares(uint256 assets)
public
view
virtual
returns (uint256);
convertToAssets
function convertToAssets(uint256 shares)
public
view
virtual
returns (uint256);
previewDeposit
function previewDeposit(uint256 assets) public view virtual returns (uint256);
previewMint
function previewMint(uint256 shares) public view virtual returns (uint256);
previewWithdraw
function previewWithdraw(uint256 assets)
public
view
virtual
returns (uint256);
previewRedeem
function previewRedeem(uint256 shares) public view virtual returns (uint256);
maxDeposit
function maxDeposit(address) public view virtual returns (uint256);
maxMint
function maxMint(address) public view virtual returns (uint256);
maxWithdraw
function maxWithdraw(address owner) public view virtual returns (uint256);
maxRedeem
function maxRedeem(address owner) public view virtual returns (uint256);
beforeWithdraw
function beforeWithdraw(uint256 assets, uint256 shares) internal virtual;
afterDeposit
function afterDeposit(uint256 assets, uint256 shares) internal virtual;
Events
Deposit
event Deposit(
address indexed caller,
address indexed owner,
uint256 assets,
uint256 shares
);
Withdraw
event Withdraw(
address indexed caller,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
Contents
- upgrades
- HarvestBaseCollector
- InfraredBERA
- InfraredBERAClaimor
- InfraredBERAConstants
- InfraredBERADepositor
- InfraredBERAFeeReceivor
- InfraredBERAWithdraworLite
Contents
HarvestBaseCollectorV1_2
Inherits: HarvestBaseCollector
Auction contract for iBGT to WBERA conversion for base fees to compound to iBERA holders
Simplified version of BribeCollector. This contract allows keepers to claim iBGT fees by paying a fixed WBERA amount, which is converted to native BERA and sent to the fee receiver for compounding.
Upgrade to have same interface as Bribe Collector, specifically adding payoutToken and claimFees
Note: oz-upgrades-from: src/staking/HarvestBaseCollector.sol:HarvestBaseCollector
State Variables
payoutToken
Payout token, required to be WBERA token as its unwrapped and used to compound rewards in the iBera system.
address constant payoutToken = 0x6969696969696969696969696969696969696969;
Functions
claimFees
Claims accumulated bribes in exchange for payout token
Caller must approve payoutAmount of payout token to this contract.
function claimFees(
address _recipient,
address[] calldata _feeTokens,
uint256[] calldata _feeAmounts
) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The Address to receive claimed tokens |
_feeTokens | address[] | Array of token addresses to claim |
_feeAmounts | uint256[] | Array of amounts to claim for each fee token |
Events
FeesClaimed
Emitted when the fees are claimed
event FeesClaimed(
address indexed caller,
address indexed recipient,
address indexed feeToken,
uint256 amount
);
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | Caller of the claimFees function |
recipient | address | The address to which collected POL bribes will be transferred |
feeToken | address | The address of the fee token to collect |
amount | uint256 | The amount of fee token to transfer |
InfraredBERADepositorV2
Inherits: Upgradeable
Depositor to deposit BERA to CL for Infrared liquid staking token
State Variables
ETH1_ADDRESS_WITHDRAWAL_PREFIX
https://eth2book.info/capella/part2/deposits-withdrawals/withdrawal-processing/
uint8 public constant ETH1_ADDRESS_WITHDRAWAL_PREFIX = 0x01;
DEPOSIT_CONTRACT
The Deposit Contract Address for Berachain
address public DEPOSIT_CONTRACT;
InfraredBERA
the main InfraredBERA contract address
address public InfraredBERA;
reserves
the queued amount of BERA to be deposited
uint256 public reserves;
minActivationDeposit
Minimum deposit for a validator to become active.
uint256 public minActivationDeposit;
__gap
Reserve storage slots for future upgrades for safety
uint256[39] private __gap;
Functions
initializeV2
Initialize V2
function initializeV2() external onlyGovernor;
queue
Queues a deposit by sending BERA to this contract and storing the amount in reserves account for beacon deposits on batch
function queue() external payable;
executeInitialDeposit
Executes initial deposit for 10k bera to the specified pubkey.
Only callable by the keeper
Only callable if the deposits are enabled
Only callable for initial deposit
function executeInitialDeposit(bytes calldata pubkey) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey of the validator to deposit for |
execute
Executes a deposit to the deposit contract for the specified pubkey and amount.
Only callable by the keeper
Only callable if the deposits are enabled
Only for deposits subsequent to initialization
function execute(
BeaconRootsVerify.BeaconBlockHeader calldata header,
BeaconRootsVerify.Validator calldata validator,
bytes32[] calldata validatorMerkleWitness,
bytes32[] calldata balanceMerkleWitness,
uint256 validatorIndex,
bytes32 balanceLeaf,
uint256 amount,
uint256 nextBlockTimestamp
) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconRootsVerify.BeaconBlockHeader | The Beacon block header data |
validator | BeaconRootsVerify.Validator | The full validator struct to deposit for |
validatorMerkleWitness | bytes32[] | Merkle witness for validator |
balanceMerkleWitness | bytes32[] | Merkle witness for balance container |
validatorIndex | uint256 | index of validator |
balanceLeaf | bytes32 | 32 bytes chunk including packed balance |
amount | uint256 | The amount of BERA to deposit |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
setMinActivationDeposit
function setMinActivationDeposit(uint256 _minActivationDeposit)
external
onlyGovernor;
Events
Queue
Emitted when a new deposit queued
event Queue(uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | New deposit amount in BERA |
Execute
Emitted when a consensus layer deposit queued to a validator
event Execute(bytes pubkey, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | Public key af validator to deposit to |
amount | uint256 | Validator deposit amount |
MinActivationDepositUpdated
Emitted when min activation deposit is updated by governance
event MinActivationDepositUpdated(uint256 newMinActivationDeposit);
Parameters
| Name | Type | Description |
|---|---|---|
newMinActivationDeposit | uint256 | New value for min activation deposit to guarentee set inclusion |
InfraredBERAV2
Inherits: ERC20Upgradeable, Upgradeable, IInfraredBERAV2
Infrared BERA is a liquid staking token for Berachain
This is the main "Front-End" contract for the whole BERA staking system.
State Variables
withdrawalsEnabled
Withdrawals are not enabled by default, not supported by https://github.com/berachain/beacon-kit yet.
bool public withdrawalsEnabled;
_initialized
Whether the contract has been initialized
bool private _initialized;
feeDivisorShareholders
The fee divisor for protocol + operator + voter fees. 1/N, where N is the divisor. example 100 = 1/100 = 1%
uint16 public feeDivisorShareholders;
infrared
The Infrared.sol smart contract.
address public infrared;
depositor
The InfraredBERADepositor.sol smart contract.
address public depositor;
withdrawor
The InfraredBERAWithdrawor.sol smart contract.
address public withdrawor;
receivor
The InfraredBERAFeeReceivor.sol smart contract.
address public receivor;
deposits
The total amount of BERA deposited by the system.
uint256 public deposits;
_stakes
Mapping of validator pubkeyHash to their stake in BERA.
mapping(bytes32 pubkeyHash => uint256 stake) internal _stakes;
_staked
Mapping of validator pubkeyHash to whether they have recieved stake from this contract.
mapping(bytes32 pubkeyHash => bool isStaked) internal _staked;
_exited
Mapping of validator pubkeyHash to whether they have exited from this contract. (voluntarily or force).
mapping(bytes32 pubkeyHash => bool hasExited) internal _exited;
_signatures
Mapping of validator pubkeyHash to their deposit signature. All validators MUST have their signiture amounts set to INITIAL_DEPOSIT to be valid.
mapping(bytes32 pubkeyHash => bytes) internal _signatures;
exitFeesToCollect
internal buffer of accumulated exit fees in iBERA to claim
uint256 internal exitFeesToCollect;
burnFee
burn fee in iBERA covers operational costs for withdrawal precompile (small amounts should be directed to swaps)
uint256 public burnFee;
proofTimestampBuffer
time, in seconds, to allow staleness of proof data relative to current head
uint256 public proofTimestampBuffer;
rateProvider
BEX pool rate provider for backwards compatibility with previewBurn
address public rateProvider;
__gap
Reserve storage slots for future upgrades for safety
uint256[36] private __gap;
Functions
initializeV2
Initiializer for InfraredBERAV2.
function initializeV2() external onlyGovernor;
governor
Checks if account has the governance role.
function governor(address account) public view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the governance role. |
keeper
Checks if account has the keeper role.
function keeper(address account) public view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the keeper role. |
validator
Checks if a given pubkey is a validator in the Infrared contract.
function validator(bytes calldata pubkey) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the pubkey is a validator. |
setWithdrawalsEnabled
Allows withdrawals to be enabled or disabled.
Only callable by the governor.
function setWithdrawalsEnabled(bool flag) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
flag | bool | The flag to set for withdrawals. |
updateBurnFee
Updates burn fee (in iBERA)
Only callable by the governor.
function updateBurnFee(uint256 _fee) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_fee | uint256 | Amount in iBERA to charge for burns |
updateRateProvider
Updates iBERA BEX pool rate provider address
Only callable by the governor.
function updateRateProvider(address _rateProvider) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_rateProvider | address | Address of rate provider |
setFeeDivisorShareholders
Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV
function setFeeDivisorShareholders(uint16 to) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
to | uint16 | The new fee shareholders represented as an integer denominator (1/x)% |
updateProofTimestampBuffer
Updates proof timestamp buffer
function updateProofTimestampBuffer(uint256 _newBuffer) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_newBuffer | uint256 | new timespan in seconds to allow staleness of proof data relative to current head |
setDepositSignature
Sets the deposit signature for a given pubkey. Ensure that the pubkey has signed the correct deposit amount of INITIAL_DEPOSIT.
Only callable by the governor.
function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
external
onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey to set the deposit signature for. |
signature | bytes | The signature to set for the pubkey. |
mint
Mints ibera to the receiver in exchange for bera.
takes in msg.value as amount to mint ibera with.
function mint(address receiver) public payable returns (uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to mint ibera to. |
Returns
| Name | Type | Description |
|---|---|---|
shares | uint256 | The amount of ibera minted. |
burn
Burns ibera from the msg.sender and sets a receiver to get the BERA in exchange for iBERA.
return amount is net of fees
function burn(address receiver, uint256 shares)
external
returns (uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to send the BERA to. |
shares | uint256 | The amount of ibera to burn. |
Returns
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The nonce of the withdrawal. Queue based system for withdrawals. |
amount | uint256 | The amount of BERA withdrawn for the exchange of iBERA. |
_deposit
Internal function to update top level accounting and minimum deposit.
function _deposit(uint256 amount) internal;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of BERA to deposit. |
_withdraw
Internal function to update top level accounting.
function _withdraw(address receiver, uint256 amount)
private
returns (uint256 nonce);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to withdraw BERA to. |
amount | uint256 | The amount of BERA to withdraw. |
previewMint
Previews the amount of InfraredBERA shares that would be minted for a given BERA amount
function previewMint(uint256 beraAmount) public view returns (uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
beraAmount | uint256 | The amount of BERA to simulate depositing |
Returns
| Name | Type | Description |
|---|---|---|
shares | uint256 | The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail |
previewBurn
Previews the amount of BERA that would be received for burning InfraredBERA shares
function previewBurn(uint256 shareAmount)
public
view
returns (uint256 beraAmount, uint256 fee);
Parameters
| Name | Type | Description |
|---|---|---|
shareAmount | uint256 | The amount of InfraredBERA shares to simulate burning |
Returns
| Name | Type | Description |
|---|---|---|
beraAmount | uint256 | The amount of BERA that would be received, returns 0 if the operation would fail |
fee | uint256 | The fee that would be charged for the burn operation in iBERA |
stakes
Returns the amount of BERA staked in validator with given pubkey
function stakes(bytes calldata pubkey) external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of BERA staked in validator |
staked
Returns whether initial deposit has been staked to validator with given pubkey
function staked(bytes calldata pubkey) external view returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | Whethere initial deposit has been staked to validator |
pending
Pending deposits yet to be forwarded to CL
function pending() public view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of BERA yet to be deposited to CL |
confirmed
Confirmed deposits sent to CL, total - future deposits
function confirmed() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of BERA confirmed to be deposited to CL |
compound
Internal function to update top level accounting and compound rewards
function compound() public;
sweep
Compounds accumulated EL yield in fee receivor into deposits
Called internally at bof whenever InfraredBERA minted or burned
Only sweeps if amount transferred from fee receivor would exceed min deposit thresholds
function sweep() external payable;
collect
Collects yield from fee receivor and mints ibera shares to Infrared
Called in RewardsLib::harvestOperatorRewards() in Infrared.sol
Only Infrared can call this function
function collect() external returns (uint256 sharesMinted);
Returns
| Name | Type | Description |
|---|---|---|
sharesMinted | uint256 | The amount of ibera shares |
claimExitFees
Claims ibera exit fees for funding withdrawal precompile fees
Only Governance can call this function
function claimExitFees(address to) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
to | address | address to send exit fees to (eg keeper or governance multisig) |
register
Updates the accounted for stake of a validator pubkey.
This does NOT mean its the balance on the CL, edge case is if another user has staked to the pubkey.
function register(bytes calldata pubkey, int256 delta) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey of the validator. |
delta | int256 | The change in stake. |
registerViaProofs
Updates the internal accounting for stake of a validator pubkey.
used after edge case events, such as bypass beacon deposits
function registerViaProofs(
BeaconRootsVerify.BeaconBlockHeader calldata header,
BeaconRootsVerify.Validator calldata _validator,
bytes32[] calldata validatorMerkleWitness,
bytes32[] calldata balanceMerkleWitness,
uint256 validatorIndex,
bytes32 balanceLeaf,
uint256 nextBlockTimestamp
) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconRootsVerify.BeaconBlockHeader | The Beacon block header data |
_validator | BeaconRootsVerify.Validator | Validator struct data |
validatorMerkleWitness | bytes32[] | merkle proof of the validator against state root in header |
balanceMerkleWitness | bytes32[] | Merkle witness for balance container |
validatorIndex | uint256 | index of validator |
balanceLeaf | bytes32 | 32 bytes chunk including packed balance |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
hasExited
Returns whether a validator pubkey has exited.
function hasExited(bytes calldata pubkey) external view returns (bool);
signatures
Returns the deposit signature to use for given pubkey
function signatures(bytes calldata pubkey)
external
view
returns (bytes memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | The deposit signature for pubkey |
asset
function asset() external pure returns (address);
totalAssets
function totalAssets() public view returns (uint256);
maxDeposit
function maxDeposit(address) external pure returns (uint256);
maxMint
function maxMint(address) external pure returns (uint256);
maxWithdraw
function maxWithdraw(address owner) external view returns (uint256);
maxRedeem
function maxRedeem(address owner) external view returns (uint256);
convertToShares
function convertToShares(uint256 assets)
public
view
virtual
returns (uint256);
convertToAssets
function convertToAssets(uint256 shares)
public
view
virtual
returns (uint256);
InfraredBERAWithdrawor
Inherits: Upgradeable, IInfraredBERAWithdrawor
Manages withdrawal requests for BERA tokens from the consensus layer in the Infrared liquid staking protocol.
Assumes BERA is returned via the EIP-7002 withdrawal precompile and credited to the contract. Inherits from Upgradeable for governance and upgradability.
Tickets start at requestId = 1, and requestLength is incremented before assignment.
State Variables
WITHDRAW_PRECOMPILE
The address of the Withdraw Precompile settable in the next upgrade.
address public WITHDRAW_PRECOMPILE;
InfraredBERA
The address of the InfraredBERA.sol contract.
address public InfraredBERA;
requestLength
The current number of withdrawal requests queued (next requestId to be assigned).
uint256 public requestLength;
requests
Mapping of request IDs to withdrawal request tickets.
Key is the requestId (starting at 1), and value is the WithdrawalRequest struct.
mapping(uint256 => WithdrawalRequest) public requests;
requestsFinalisedUntil
The highest requestId that has been finalized by process.
uint256 public requestsFinalisedUntil;
totalClaimable
Total amount of BERA (in wei) marked as claimable (in PROCESSED state, non-depositor tickets).
uint256 public totalClaimable;
minActivationBalance
Minimum balance for a validator to stay active.
uint256 public minActivationBalance;
pendingWithdrawalsLength
Length of pending withdrawals queue
uint256 public pendingWithdrawalsLength;
nonceProcess
holding slot for withdraworLite storage var
uint256 public nonceProcess;
pendingWithdrawals
Mapping to track individual pending withdrawal amounts
mapping(uint256 => PendingWithdrawal) public pendingWithdrawals;
__gap
Reserve storage slots for future upgrades for safety
uint256[39] private __gap;
Functions
initializeV2
Initializes the contract for the next version, setting the withdrawal precompile address.
Only callable by the governance role (onlyGovernor). Reverts if _withdraw_precompile is zero.
function initializeV2(address _withdraw_precompile) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_withdraw_precompile | address | The address of the EIP-7002 withdrawal precompile. |
reserves
Returns the amount of BERA available for new withdrawals (excluding claimable funds).
function reserves() public view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The contract’s balance minus totalClaimable (in wei). |
getFee
Retrieves the current fee required by the withdrawal precompile.
Performs a static call to the precompile. Reverts if the call fails or the response is invalid (not 32 bytes).
function getFee() public view returns (uint256 fee);
Returns
| Name | Type | Description |
|---|---|---|
fee | uint256 | The fee (in wei) required for a withdrawal request. |
getQueuedAmount
Returns the total amount of BERA queued for withdrawal across all unprocessed tickets.
Calculates the difference between the cumulative amount at requestLength and requestsFinalisedUntil.
Returns 0 if requestLength == requestsFinalisedUntil (no unprocessed tickets) or requestLength == 0 (no tickets queued).
Assumes tickets from requestsFinalisedUntil + 1 to requestLength are in QUEUED state, as enforced by process.
function getQueuedAmount() public view returns (uint256 queuedAmount);
Returns
| Name | Type | Description |
|---|---|---|
queuedAmount | uint256 | The total amount of BERA (in wei) in QUEUED tickets from requestsFinalisedUntil + 1 to requestLength. |
getRequestsToProcess
Calculates the highest request ID that can be finalized by process given the current reserves.
Iterates through unprocessed tickets (requestsFinalisedUntil + 1 to requestLength) to find the maximum number of requests whose cumulative amount does not exceed reserves().
Returns requestsFinalisedUntil if no additional tickets can be processed due to insufficient reserves.
function getRequestsToProcess()
external
view
returns (uint256 newRequestsFinalisedUntil);
Returns
| Name | Type | Description |
|---|---|---|
newRequestsFinalisedUntil | uint256 | The highest requestId (inclusive) that can be processed without exceeding available reserves, or 0 if no tickets can be processed. |
getTotalPendingWithdrawals
Sums all current pending withdrawals as helper for keeper to calculate how much needs to be executed next
Iterates through pending withdrawals, counting only those that have not expired (fulfilled)
function getTotalPendingWithdrawals(bytes32 pubkeyHash)
public
view
returns (uint256 total);
Parameters
| Name | Type | Description |
|---|---|---|
pubkeyHash | bytes32 | keccak256 of public key for validator to get pending withdrawals for |
Returns
| Name | Type | Description |
|---|---|---|
total | uint256 | Sum amount in bera, pending on CL to return to contract |
queue
Queues a withdrawal request for BERA from the consensus layer.
*Only callable by the InfraredBERA contract or a keeper. Reverts if:
- Caller is unauthorized (
msg.senderis neitherInfraredBERAnor a keeper). - Receiver is invalid (keeper cannot queue for non-depositor, non-keeper cannot queue for depositor).
- Amount is zero for non-depositor or exceeds
InfraredBERA.confirmed()balance.*
function queue(address receiver, uint256 amount)
external
whenNotPaused
returns (uint256 requestId);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to receive the withdrawn BERA (user or depositor for rebalancing). |
amount | uint256 | The amount of BERA to withdraw (in wei). |
Returns
| Name | Type | Description |
|---|---|---|
requestId | uint256 | The unique ID assigned to the withdrawal request (starts at 1). |
execute
Executes a withdrawal request via the EIP-7002 precompile.
*Rules for withdrawals:
- Pass 0 amount for full exit
- If not full exit withdrawal amount must leave validator in active state, which means stake must remain above 250k*
*Only callable by a keeper (onlyKeeper). Reverts if:
- Exceeds validator stake, is not divisible by 1 gwei, or exceeds
uint64max. - Precompile call fails or returns invalid fee data.
- Provided
msg.valueis less than the precompile fee.*
Refunds excess msg.value to the keeper after the precompile call.
*References:
- https://eips.ethereum.org/EIPS/eip-7002
- https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4788.md*
function execute(
BeaconRootsVerify.BeaconBlockHeader calldata header,
BeaconRootsVerify.Validator calldata validator,
bytes32[] calldata validatorMerkleWitness,
bytes32[] calldata balanceMerkleWitness,
uint256 validatorIndex,
bytes32 balanceLeaf,
uint256 amount,
uint256 nextBlockTimestamp
) external payable onlyKeeper whenNotPaused;
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconRootsVerify.BeaconBlockHeader | The Beacon block header data |
validator | BeaconRootsVerify.Validator | The full validator struct to deposit for |
validatorMerkleWitness | bytes32[] | Merkle witness for validator |
balanceMerkleWitness | bytes32[] | Merkle witness for balance container |
validatorIndex | uint256 | index of validator in beacon state tree |
balanceLeaf | bytes32 | 32 bytes chunk including packed balance |
amount | uint256 | The amount of BERA to withdraw (in wei). |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
process
Finalizes a range of withdrawal requests, marking them as claimable or rebalancing to the depositor.
*Reverts if:
newRequestsFinalisedUntilexceedsrequestLength.newRequestsFinalisedUntilis less than or equal torequestsFinalisedUntil.- Available reserves are insufficient for the total amount to finalize.*
Accumulates amounts for depositor rebalancing into a single call to InfraredBERADepositor.queue.
Updates totalClaimable for non-depositor tickets.
function process(uint256 newRequestsFinalisedUntil)
external
onlyKeeper
whenNotPaused;
Parameters
| Name | Type | Description |
|---|---|---|
newRequestsFinalisedUntil | uint256 | The highest requestId to finalize (inclusive). |
claim
Claims a finalized withdrawal request for a user.
*Reverts if:
requestIdexceedsrequestsFinalisedUntil(not finalized).- sender is not receiver or keeper
- Ticket is not in
PROCESSEDstate or belongs to the depositor.*
Transitions the ticket to CLAIMED and transfers the amount to the receiver.
function claim(uint256 requestId) external whenNotPaused;
Parameters
| Name | Type | Description |
|---|---|---|
requestId | uint256 | The ID of the withdrawal request to claim. |
claimBatch
Claims multiple finalized withdrawal requests for same receiver in a single transaction.
*Reverts if:
- Any
requestIdexceedsrequestsFinalisedUntil(not finalized). - Any ticket receiver is not the same as the others
- Any ticket is not in
PROCESSEDstate or belongs to the depositor. - sender is not receiver or keeper*
Transitions each ticket to CLAIMED and transfers the total amount to the caller.
Emits a Claimed event for each claimed ticket.
function claimBatch(uint256[] calldata requestIds, address receiver)
external
whenNotPaused;
Parameters
| Name | Type | Description |
|---|---|---|
requestIds | uint256[] | An array of request IDs to claim. |
receiver | address | recipient address of all requestIds |
sweepForcedExit
Handles Forced withdrawals from the CL.
*RESTRICTED USAGE: This function should ONLY be called when:
- A validator has been forced to exit from the CL.*
The funds will enter the IBERA system as a deposit via the InfraredBERADepositor.
function sweepForcedExit(
BeaconRootsVerify.BeaconBlockHeader calldata header,
BeaconRootsVerify.Validator calldata validator,
uint256 validatorIndex,
bytes32[] calldata validatorMerkleWitness,
uint256 nextBlockTimestamp
) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconRootsVerify.BeaconBlockHeader | The Beacon block header data |
validator | BeaconRootsVerify.Validator | The full validator struct to deposit for |
validatorIndex | uint256 | index of validator |
validatorMerkleWitness | bytes32[] | Merkle witness for validator |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
sweepUnaccountedForFunds
Handles excess stake that was refunded from a validator due to non-IBERA (bypass) deposits exceeding MAX_EFFECTIVE_BALANCE
*RESTRICTED USAGE: This function should ONLY be called when:
- A non-IBERA entity deposits to our validator, pushing total stake above MAX_EFFECTIVE_BALANCE
- The excess stake is refunded by the CL to this contract*
The funds will enter the IBERA system as yield via the FeeReceivor
*This should NEVER be used for:
- Validators exited due to falling out of the validator set*
Note: access: Only callable by governance
function sweepUnaccountedForFunds(uint256 amount) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of excess stake to sweep |
receive
receive() external payable;
setMinActivationBalance
function setMinActivationBalance(uint256 _minActivationBalance)
external
onlyGovernor;
totalPendingWithdrawals
Internal function to get total pending withdrawals over all validators and remove outdated ones
function totalPendingWithdrawals() internal returns (uint256 total);
HarvestBaseCollector
Inherits: InfraredUpgradeable
Auction contract for iBGT to WBERA conversion for base fees to compound to iBERA holders
Simplified version of BribeCollector. This contract allows keepers to claim iBGT fees by paying a fixed WBERA amount, which is converted to native BERA and sent to the fee receiver for compounding.
Note: oz-upgrades:
State Variables
feeReceivor
the addres of the fee recivor contract that compounds BERA to iBERA.
address public feeReceivor;
ibgt
the addres of iBGT, the expected fee token
ERC20 public ibgt;
wbera
WBERA token that is used instead of native BERA token.
WBERA public wbera;
payoutAmount
Payout amount is a constant value that is paid by the caller of the claimFees function.
uint256 public payoutAmount;
__gap
uint256[20] private __gap;
Functions
initialize
Initializes the contract with required parameters and roles.
Reverts if any address is zero or payout amount is zero. Grants roles and initializes upgradeable components.
function initialize(
address _infrared,
address _gov,
address _keeper,
address _ibgt,
address _wbera,
address _feeReceivor,
uint256 _payoutAmount
) external initializer;
Parameters
| Name | Type | Description |
|---|---|---|
_infrared | address | Address of the Infrared contract. |
_gov | address | Address of the governance. |
_keeper | address | Address of the keeper. |
_ibgt | address | Address of the iBGT token. |
_wbera | address | Address of the WBERA token. |
_feeReceivor | address | Address of the fee receiver. |
_payoutAmount | uint256 | Initial payout amount. |
setPayoutAmount
Set the payout amount for the bribe collector.
Only callable by the governor. Reverts if amount is zero. Emits PayoutAmountSet.
function setPayoutAmount(uint256 _newPayoutAmount) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_newPayoutAmount | uint256 | updated payout amount |
claimFee
Claims fees by transferring WBERA payout from caller, converting to native BERA, sending to fee receiver, and transferring iBGT to recipient.
Only callable by keeper. Reverts on insufficient balances or zero recipient. Emits FeeClaimed.
function claimFee(address _recipient, uint256 _feeAmount) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
_recipient | address | The address to receive the iBGT fees. |
_feeAmount | uint256 | The amount of iBGT to transfer. |
sweep
Sweeps any WBERA or native BERA balances to the fee receiver.
Only callable by keeper. Useful for recovering stuck funds.
function sweep() external onlyKeeper;
receive
Fallback function to receive BERA
receive() external payable;
Events
PayoutAmountSet
Emitted when the payout amount is updated by the governor
event PayoutAmountSet(
uint256 indexed oldPayoutAmount, uint256 indexed newPayoutAmount
);
Parameters
| Name | Type | Description |
|---|---|---|
oldPayoutAmount | uint256 | Previous payout amount |
newPayoutAmount | uint256 | New payout amount set |
FeeClaimed
Emitted when the fees are claimed
event FeeClaimed(
address indexed caller, address indexed recipient, uint256 amount
);
Parameters
| Name | Type | Description |
|---|---|---|
caller | address | Caller of the claimFees function |
recipient | address | The address to which collected POL bribes will be transferred |
amount | uint256 | The amount of fee token to transfer |
InfraredBERA
Inherits: ERC20Upgradeable, Upgradeable, IInfraredBERA
Infrared BERA is a liquid staking token for Berachain
This is the main "Front-End" contract for the whole BERA staking system.
State Variables
withdrawalsEnabled
Withdrawals are not enabled by default, not supported by https://github.com/berachain/beacon-kit yet.
bool public withdrawalsEnabled;
_initialized
Whether the contract has been initialized
bool private _initialized;
feeDivisorShareholders
The fee divisor for protocol + operator + voter fees. 1/N, where N is the divisor. example 100 = 1/100 = 1%
uint16 public feeDivisorShareholders;
infrared
The Infrared.sol smart contract.
address public infrared;
depositor
The InfraredBERADepositor.sol smart contract.
address public depositor;
withdrawor
The InfraredBERAWithdrawor.sol smart contract.
address public withdrawor;
receivor
The InfraredBERAFeeReceivor.sol smart contract.
address public receivor;
deposits
The total amount of BERA deposited by the system.
uint256 public deposits;
_stakes
Mapping of validator pubkeyHash to their stake in BERA.
mapping(bytes32 pubkeyHash => uint256 stake) internal _stakes;
_staked
Mapping of validator pubkeyHash to whether they have recieved stake from this contract.
mapping(bytes32 pubkeyHash => bool isStaked) internal _staked;
_exited
Mapping of validator pubkeyHash to whether they have exited from this contract. (voluntarily or force).
mapping(bytes32 pubkeyHash => bool hasExited) internal _exited;
_signatures
Mapping of validator pubkeyHash to their deposit signature. All validators MUST have their signiture amounts set to INITIAL_DEPOSIT to be valid.
mapping(bytes32 pubkeyHash => bytes) internal _signatures;
__gap
Reserve storage slots for future upgrades for safety
uint256[40] private __gap;
Functions
initialize
Initiializer for InfraredBERA.
function initialize(
address _gov,
address _keeper,
address _infrared,
address _depositor,
address _withdrawor,
address _receivor
) external payable initializer;
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | The address of the governance contract. |
_keeper | address | The address of the keeper contract. |
_infrared | address | The address of the Infrared.sol contract. |
_depositor | address | The address of the InfraredBERADepositor.sol contract. |
_withdrawor | address | The address of the InfraredBERAWithdrawor.sol contract. |
_receivor | address | The address of the InfraredBERAFeeReceivor.sol contract. |
governor
Checks if account has the governance role.
function governor(address account) public view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the governance role. |
keeper
Checks if account has the keeper role.
function keeper(address account) public view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
account | address | The address to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the account has the keeper role. |
validator
Checks if a given pubkey is a validator in the Infrared contract.
function validator(bytes calldata pubkey) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey to check. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the pubkey is a validator. |
setWithdrawalsEnabled
Allows withdrawals to be enabled or disabled.
Only callable by the governor.
function setWithdrawalsEnabled(bool flag) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
flag | bool | The flag to set for withdrawals. |
setFeeDivisorShareholders
Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV
function setFeeDivisorShareholders(uint16 to) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
to | uint16 | The new fee shareholders represented as an integer denominator (1/x)% |
setDepositSignature
Sets the deposit signature for a given pubkey. Ensure that the pubkey has signed the correct deposit amount of INITIAL_DEPOSIT.
Only callable by the governor.
function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
external
onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey to set the deposit signature for. |
signature | bytes | The signature to set for the pubkey. |
mint
Mints ibera to the receiver in exchange for bera.
takes in msg.value as amount to mint ibera with.
function mint(address receiver) public payable returns (uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to mint ibera to. |
Returns
| Name | Type | Description |
|---|---|---|
shares | uint256 | The amount of ibera minted. |
burn
Burns ibera from the msg.sender and sets a receiver to get the BERA in exchange for iBERA.
function burn(address receiver, uint256 shares)
external
payable
returns (uint256 nonce, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to send the BERA to. |
shares | uint256 | The amount of ibera to burn. |
Returns
| Name | Type | Description |
|---|---|---|
nonce | uint256 | The nonce of the withdrawal. Queue based system for withdrawals. |
amount | uint256 | The amount of BERA withdrawn for the exchange of iBERA. |
_deposit
Internal function to update top level accounting and minimum deposit.
function _deposit(uint256 amount) internal;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of BERA to deposit. |
_withdraw
Internal function to update top level accounting.
function _withdraw(address receiver, uint256 amount, uint256 fee)
private
returns (uint256 nonce);
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address to withdraw BERA to. |
amount | uint256 | The amount of BERA to withdraw. |
fee | uint256 | The fee to pay for the withdrawal. |
previewMint
Previews the amount of InfraredBERA shares that would be minted for a given BERA amount
function previewMint(uint256 beraAmount) public view returns (uint256 shares);
Parameters
| Name | Type | Description |
|---|---|---|
beraAmount | uint256 | The amount of BERA to simulate depositing |
Returns
| Name | Type | Description |
|---|---|---|
shares | uint256 | The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail |
previewBurn
Previews the amount of BERA that would be received for burning InfraredBERA shares
function previewBurn(uint256 shareAmount)
public
view
returns (uint256 beraAmount, uint256 fee);
Parameters
| Name | Type | Description |
|---|---|---|
shareAmount | uint256 | The amount of InfraredBERA shares to simulate burning |
Returns
| Name | Type | Description |
|---|---|---|
beraAmount | uint256 | The amount of BERA that would be received, returns 0 if the operation would fail |
fee | uint256 | The fee that would be charged for the burn operation |
stakes
Returns the amount of BERA staked in validator with given pubkey
function stakes(bytes calldata pubkey) external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of BERA staked in validator |
staked
Returns whether initial deposit has been staked to validator with given pubkey
function staked(bytes calldata pubkey) external view returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | Whethere initial deposit has been staked to validator |
pending
Pending deposits yet to be forwarded to CL
function pending() public view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of BERA yet to be deposited to CL |
confirmed
Confirmed deposits sent to CL, total - future deposits
function confirmed() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The amount of BERA confirmed to be deposited to CL |
compound
Internal function to update top level accounting and compound rewards
function compound() public;
sweep
Compounds accumulated EL yield in fee receivor into deposits
Called internally at bof whenever InfraredBERA minted or burned
Only sweeps if amount transferred from fee receivor would exceed min deposit thresholds
function sweep() external payable;
collect
Collects yield from fee receivor and mints ibera shares to Infrared
Called in RewardsLib::harvestOperatorRewards() in Infrared.sol
Only Infrared can call this function
function collect() external returns (uint256 sharesMinted);
Returns
| Name | Type | Description |
|---|---|---|
sharesMinted | uint256 | The amount of ibera shares |
register
Updates the accounted for stake of a validator pubkey.
This does NOT mean its the balance on the CL, edge case is if another user has staked to the pubkey.
function register(bytes calldata pubkey, int256 delta) external;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey of the validator. |
delta | int256 | The change in stake. |
hasExited
Returns whether a validator pubkey has exited.
function hasExited(bytes calldata pubkey) external view returns (bool);
signatures
Returns the deposit signature to use for given pubkey
function signatures(bytes calldata pubkey)
external
view
returns (bytes memory);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | The deposit signature for pubkey |
InfraredBERAClaimor
Inherits: Upgradeable, IInfraredBERAClaimor
Claimor to claim BERA withdrawn from CL for Infrared liquid staking token
Separate contract so withdrawor process has trusted contract to forward funds to so no issue with naked bera transfer and receive function
State Variables
claims
Outstanding BERA claims for a receiver
mapping(address => uint256) public claims;
ibera
IInfraredBERA public ibera;
__gap
Reserve storage slots for future upgrades for safety
uint256[40] private __gap;
Functions
initialize
Initializer function (replaces constructor)
function initialize(address _gov, address _keeper, address _ibera)
external
initializer;
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | Address of the initial admin / gov |
_keeper | address | Address of the initial keeper |
_ibera | address | Address of InfraredBera proxy contract |
queue
Queues a new BERA claim for a receiver
Only callable by the InfraredBERAWithdrawor contract
function queue(address receiver) external payable;
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address of the claims receiver |
sweep
Sweeps oustanding BERA claims for a receiver to their address
function sweep(address receiver) external;
Parameters
| Name | Type | Description |
|---|---|---|
receiver | address | The address of the claims receiver |
InfraredBERAConstants
State Variables
INITIAL_DEPOSIT
uint256 public constant INITIAL_DEPOSIT = 10000 ether;
MINIMUM_WITHDRAW_FEE
uint256 public constant MINIMUM_WITHDRAW_FEE = 0.01 ether;
FORCED_MIN_DELAY
uint256 public constant FORCED_MIN_DELAY = 7 days;
MAX_EFFECTIVE_BALANCE
uint256 public constant MAX_EFFECTIVE_BALANCE = 10_000_000 ether;
InfraredBERADepositor
Inherits: Upgradeable
Depositor to deposit BERA to CL for Infrared liquid staking token
State Variables
ETH1_ADDRESS_WITHDRAWAL_PREFIX
https://eth2book.info/capella/part2/deposits-withdrawals/withdrawal-processing/
uint8 public constant ETH1_ADDRESS_WITHDRAWAL_PREFIX = 0x01;
DEPOSIT_CONTRACT
The Deposit Contract Address for Berachain
address public DEPOSIT_CONTRACT;
InfraredBERA
the main InfraredBERA contract address
address public InfraredBERA;
reserves
the queued amount of BERA to be deposited
uint256 public reserves;
__gap
Reserve storage slots for future upgrades for safety
uint256[40] private __gap;
Functions
initialize
Initialize the contract (replaces the constructor)
function initialize(
address _gov,
address _keeper,
address ibera,
address _depositContract
) public initializer;
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | Address for admin / gov to upgrade |
_keeper | address | Address for keeper |
ibera | address | The initial IBERA address |
_depositContract | address | The ETH2 (Berachain) Deposit Contract Address |
queue
Queues a deposit by sending BERA to this contract and storing the amount in the pending deposits acculimator
function queue() external payable;
execute
Executes a deposit to the deposit contract for the specified pubkey and amount.
Only callable by the keeper
Only callable if the deposits are enabled
function execute(bytes calldata pubkey, uint256 amount) external onlyKeeper;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey of the validator to deposit for |
amount | uint256 | The amount of BERA to deposit |
Events
Queue
event Queue(uint256 amount);
Execute
event Execute(bytes pubkey, uint256 amount);
InfraredBERAFeeReceivor
Inherits: Upgradeable, IInfraredBERAFeeReceivor
Receivor for fees from InfraredBERA from tips and share of the proof-of-liquidity incentive system.
Validators need to set this address as their coinbase(fee_recepient on most clients).
State Variables
InfraredBERA
The address of the InfraredBERA.sol contract.
address public InfraredBERA;
infrared
The Infrared.sol contract address.
IInfrared public infrared;
shareholderFees
Accumulated protocol fees in contract to be claimed.
uint256 public shareholderFees;
__gap
Reserve storage slots for future upgrades for safety
uint256[40] private __gap;
Functions
initialize
Initializer function (replaces constructor)
function initialize(
address _gov,
address _keeper,
address ibera,
address _infrared
) external initializer;
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | Address for admin / gov to upgrade |
_keeper | address | Address for keeper |
ibera | address | Address for InfraredBERA |
_infrared | address | Address for Infrared |
distribution
Amount of BERA swept to InfraredBERA and fees taken for protool on next call to sweep
function distribution() public view returns (uint256 amount, uint256 fees);
Returns
| Name | Type | Description |
|---|---|---|
amount | uint256 | THe amount of BERA forwarded to InfraredBERA on next sweep. |
fees | uint256 | The protocol fees taken on next sweep. |
sweep
Sweeps accumulated coinbase priority fees + MEV to InfraredBERA to autocompound principal
function sweep() external returns (uint256 amount, uint256 fees);
Returns
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of BERA forwarded to InfraredBERA. |
fees | uint256 | The total fees taken. |
collect
Collects accumulated shareholder fees
Reverts if msg.sender is not InfraredBera.sol contract
function collect() external returns (uint256 sharesMinted);
Returns
| Name | Type | Description |
|---|---|---|
sharesMinted | uint256 | The amount of iBERA shares minted and sent to the Infrared.sol |
receive
Fallback function to receive BERA
receive() external payable;
InfraredBERAWithdraworLite
Inherits: Upgradeable, IInfraredBERAWithdraworLite
This contract is only responsible for handling involuntary exits from the CL. It is a light version of the InfraredBERAWithdrawor contract.
This contract should be upgraded once withdrawals are enabled by https://github.com/berachain/beacon-kit.
expects compliance of https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7002.md
State Variables
WITHDRAW_REQUEST_TYPE
The withdrawal request type, execution layer withdrawal.
uint8 public constant WITHDRAW_REQUEST_TYPE = 0x01;
WITHDRAW_PRECOMPILE
The address of the Withdraw Precompile settable in the next upgrade.
address public WITHDRAW_PRECOMPILE;
InfraredBERA
The address of the InfraredBERA.sol contract.
address public InfraredBERA;
claimor
The address of the InfraredBERAClaimor.sol contract.
This contract will be set in the next upgrade.
address public claimor;
requests
Outstanding requests for claims on previously burnt ibera The key = nonce associated with the claim
mapping(uint256 => Request) public requests;
fees
Amount of BERA internally set aside for withdraw precompile request fees
uint256 public fees;
rebalancing
Amount of BERA internally rebalancing amongst Infrared validators
uint256 public rebalancing;
nonceRequest
The next nonce to issue withdraw request for
uint256 public nonceRequest;
nonceSubmit
The next nonce to submit withdraw request for
uint256 public nonceSubmit;
nonceProcess
The next nonce in queue to process claims for
uint256 public nonceProcess;
__gap
Reserve storage slots for future upgrades for safety
uint256[40] private __gap;
Functions
initialize
Initialize the contract (replaces the constructor)
function initialize(address _gov, address _keeper, address ibera)
public
initializer;
Parameters
| Name | Type | Description |
|---|---|---|
_gov | address | Address for admin / gov to upgrade |
_keeper | address | Address for keeper |
ibera | address | The initial InfraredBERA address |
_enoughtime
Checks whether enough time has passed beyond min delay
function _enoughtime(uint96 then, uint96 current)
private
pure
returns (bool has);
Parameters
| Name | Type | Description |
|---|---|---|
then | uint96 | The block timestamp in past |
current | uint96 | The current block timestamp now |
Returns
| Name | Type | Description |
|---|---|---|
has | bool | Whether time between then and now exceeds forced min delay |
reserves
Amount of BERA internally set aside to process withdraw compile requests from funds received on successful requests
function reserves() public view returns (uint256);
queue
Queues a withdraw from InfraredBERA for chain withdraw precompile escrowing minimum fees for request to withdraw precompile
not used until next upgrade.
function queue(address, uint256) external payable returns (uint256);
execute
Executes a withdraw request to withdraw precompile
not used until next upgrade.
function execute(bytes calldata, uint256) external payable;
process
Processes the funds received from withdraw precompile to next-to-process request receiver
Reverts if balance has not increased by full amount of request for next-to-process request nonce
not used until next upgrade.
function process() external pure;
sweep
Handles Forced withdrawals from the CL.
*RESTRICTED USAGE: This function should ONLY be called when:
- A validator has been forced to exit from the CL.*
The funds will enter the IBERA system as a deposit via the InfraredBERADepositor.
function sweep(bytes calldata pubkey) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
pubkey | bytes | The pubkey of the validator that has been forced to exit. |
sweepUnaccountedForFunds
Handles excess stake that was refunded from a validator due to non-IBERA deposits exceeding MAX_EFFECTIVE_BALANCE
*RESTRICTED USAGE: This function should ONLY be called when:
- A non-IBERA entity deposits to our validator, pushing total stake above MAX_EFFECTIVE_BALANCE
- The excess stake is refunded by the CL to this contract*
The funds will enter the IBERA system as yield via the FeeReceivor
*This should NEVER be used for:
- Validators exited due to falling out of the validator set*
Note: access: Only callable by governance
function sweepUnaccountedForFunds(uint256 amount) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | The amount of excess stake to sweep |
receive
receive() external payable;
Structs
Request
The request struct for withdrawal requests.
struct Request {
address receiver;
uint96 timestamp;
uint256 fee;
uint256 amountSubmit;
uint256 amountProcess;
}
Properties
| Name | Type | Description |
|---|---|---|
receiver | address | The address of the receiver of the withdrawn BERA funds. |
timestamp | uint96 | The block.timestamp at which the withdraw request was issued. |
fee | uint256 | The fee escrow for the withdraw precompile request. |
amountSubmit | uint256 | The amount of withdrawn BERA funds left to submit request to withdraw precompile. |
amountProcess | uint256 | The amount of withdrawn BERA funds left to process from funds received via withdraw request. |
Contents
BeaconRootsVerify
Verifies Beacon chain data using Merkle hashing to reconstruct the beacon block root, which can be queried on-chain via beacon roots contract (EIP-4788)
State Variables
BALANCES_INDEX
Beacon state balances list container field index in state
uint256 public constant BALANCES_INDEX = 10;
VALIDATORS_INDEX
Beacon state validators list container field index in state
uint256 public constant VALIDATORS_INDEX = 9;
VALIDATOR_PROOF_DEPTH
Beacon state validator proof depth in list container
uint256 public constant VALIDATOR_PROOF_DEPTH = 41;
BALANCE_PROOF_DEPTH
Beacon state balance proof depth in list container
uint256 public constant BALANCE_PROOF_DEPTH = 39;
BEACON_ROOTS
Address of beacon roots contract on ethereum (https://eips.ethereum.org/EIPS/eip-4788)
address public constant BEACON_ROOTS =
0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02;
Functions
getParentBeaconBlockRoot
Fetches the parent block root from the Beacon Roots contract at a specific timestamp
function getParentBeaconBlockRoot(uint256 timestamp)
public
view
returns (bytes32 root);
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | The timestamp for which to fetch the parent beacon block root |
Returns
| Name | Type | Description |
|---|---|---|
root | bytes32 | The parent block root at the given timestamp |
calculateBeaconHeaderMerkleRoot
Calculates the Merkle root of a given Beacon block header
function calculateBeaconHeaderMerkleRoot(BeaconBlockHeader calldata header)
public
pure
returns (bytes32 root);
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconBlockHeader | The Beacon block header data |
Returns
| Name | Type | Description |
|---|---|---|
root | bytes32 | The Merkle root of the block header |
verifyBeaconHeaderMerkleRoot
Verifies the Merkle root of a given Beacon block header and root
function verifyBeaconHeaderMerkleRoot(
BeaconBlockHeader calldata header,
bytes32 root
) public pure returns (bool validRoot);
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconBlockHeader | The Beacon block header data |
root | bytes32 | The root to verify against |
Returns
| Name | Type | Description |
|---|---|---|
validRoot | bool | True if root matches Merkleized Header |
verifyBeaconHeaderMerkleRoot
Verifies the Merkle root of a given Beacon block header against beacon roots contract
will only work for slots within the last 24 hours
function verifyBeaconHeaderMerkleRoot(
BeaconBlockHeader calldata header,
uint256 nextBlockTimestamp
) public view returns (bool validRoot);
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconBlockHeader | The Beacon block header data |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
Returns
| Name | Type | Description |
|---|---|---|
validRoot | bool | True if beacon roots call matches Merkleized Header |
verifyStateRoot
Verify a merkle proof of the beacon state root against a beacon block header root
function verifyStateRoot(
bytes32 beaconBlockHeaderRoot,
bytes32 beaconStateRoot,
bytes32[] calldata proof
) public pure returns (bool validStateRoot);
Parameters
| Name | Type | Description |
|---|---|---|
beaconBlockHeaderRoot | bytes32 | merkle root of the beacon block header |
beaconStateRoot | bytes32 | merkle root of the beacon state |
proof | bytes32[] | merkle proof of its inclusion under beaconBlockHeaderRoot |
Returns
| Name | Type | Description |
|---|---|---|
validStateRoot | bool | True if successfully verified |
calculateValidatorMerkleRoot
Calculates the Merkle root of a given Validator
function calculateValidatorMerkleRoot(Validator calldata validator)
public
pure
returns (bytes32 root);
Parameters
| Name | Type | Description |
|---|---|---|
validator | Validator | The Validator data |
Returns
| Name | Type | Description |
|---|---|---|
root | bytes32 | The Merkle root of the block header |
verifyValidator
Verify a merkle proof of the validator against a beacon state root
function verifyValidator(
bytes32 beaconStateRoot,
Validator calldata validator,
bytes32[] calldata proof,
uint256 valIndex
) public pure returns (bool validValidator);
Parameters
| Name | Type | Description |
|---|---|---|
beaconStateRoot | bytes32 | merkle root of the beacon state |
validator | Validator | Validator struct data |
proof | bytes32[] | merkle proof of the validator |
valIndex | uint256 | index of validator |
Returns
| Name | Type | Description |
|---|---|---|
validValidator | bool | True for successful verification |
verifyValidator
Verify a merkle proof of the validator against beacon roots contract
function verifyValidator(
BeaconBlockHeader calldata header,
Validator calldata validator,
bytes32[] calldata proof,
uint256 valIndex,
uint256 nextBlockTimestamp
) public view returns (bool validValidator);
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconBlockHeader | The Beacon block header data |
validator | Validator | Validator struct data |
proof | bytes32[] | merkle proof of the validator against state root in header |
valIndex | uint256 | index of validator |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
Returns
| Name | Type | Description |
|---|---|---|
validValidator | bool | True for successful verification |
verifyValidatorBalance
Verify a merkle proof of the validator balance against a beacon state root
function verifyValidatorBalance(
BeaconBlockHeader calldata header,
bytes32[] calldata proof,
uint256 valIndex,
uint256 balance,
bytes32 balanceLeaf,
uint256 nextBlockTimestamp
) public view returns (bool validValidatorBalance);
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconBlockHeader | The Beacon block header data |
proof | bytes32[] | merkle proof of the validator balance |
valIndex | uint256 | index of validator |
balance | uint256 | declared balance of validator to prove |
balanceLeaf | bytes32 | 32 bytes chunk including packed balance |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
Returns
| Name | Type | Description |
|---|---|---|
validValidatorBalance | bool | True for successful verification |
verifyValidatorPublicKey
Verify public key of a validator by merkle proof of the validator against a beacon state root
function verifyValidatorPublicKey(
BeaconBlockHeader calldata header,
Validator calldata validator,
bytes32[] calldata proof,
uint256 valIndex,
bytes calldata pubkey,
uint256 nextBlockTimestamp
) public view returns (bool validValidator);
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconBlockHeader | The Beacon block header data |
validator | Validator | Validator struct data |
proof | bytes32[] | merkle proof of the validator |
valIndex | uint256 | index of validator |
pubkey | bytes | public key to verify |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
Returns
| Name | Type | Description |
|---|---|---|
validValidator | bool | True for successful verification |
verifyValidatorEffectiveBalance
Verify effective balance of a validator by merkle proof of the validator against a beacon state root
function verifyValidatorEffectiveBalance(
BeaconBlockHeader calldata header,
Validator calldata validator,
bytes32[] calldata proof,
uint256 valIndex,
uint64 effectiveBalance,
uint256 nextBlockTimestamp
) public view returns (bool validValidator);
Parameters
| Name | Type | Description |
|---|---|---|
header | BeaconBlockHeader | The Beacon block header data |
validator | Validator | Validator struct data |
proof | bytes32[] | merkle proof of the validator |
valIndex | uint256 | index of validator |
effectiveBalance | uint64 | balance to verify |
nextBlockTimestamp | uint256 | timestamp of following block to header to verify parent root in beaconroots call |
Returns
| Name | Type | Description |
|---|---|---|
validValidator | bool | True for successful verification |
verifyValidatorWithdrawalAddress
Verify withdrawal address of a validator by merkle proof of the validator against a beacon state root
function verifyValidatorWithdrawalAddress(
bytes32 beaconStateRoot,
Validator calldata validator,
bytes32[] calldata proof,
uint256 valIndex,
address withdrawalAddress
) public pure returns (bool validValidator);
Parameters
| Name | Type | Description |
|---|---|---|
beaconStateRoot | bytes32 | merkle root of the beacon state |
validator | Validator | Validator struct data |
proof | bytes32[] | merkle proof of the validator |
valIndex | uint256 | index of validator |
withdrawalAddress | address | staker address to verify |
Returns
| Name | Type | Description |
|---|---|---|
validValidator | bool | True for successful verification |
extractBalance
function extractBalance(bytes32 chunk, uint256 offset)
internal
pure
returns (uint64);
Errors
RootNotFound
error RootNotFound();
FieldMismatch
error FieldMismatch();
Structs
BeaconBlockHeader
https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#beaconblockheader
struct BeaconBlockHeader {
uint64 slot;
uint64 proposerIndex;
bytes32 parentRoot;
bytes32 stateRoot;
bytes32 bodyRoot;
}
Validator
https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/beacon-chain.md#validator
struct Validator {
bytes pubkey;
bytes32 withdrawalCredentials;
uint64 effectiveBalance;
bool slashed;
uint64 activationEligibilityEpoch;
uint64 activationEpoch;
uint64 exitEpoch;
uint64 withdrawableEpoch;
}
DataTypes
State Variables
NATIVE_ASSET
The address of the native asset as of EIP-7528.
address public constant NATIVE_ASSET =
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
Structs
Token
struct Token {
address tokenAddress;
uint256 amount;
}
EndianHelper
Provides helper functions for converting values to little-endian format
Functions
toLittleEndian
Converts a 256-bit unsigned integer to little-endian format
function toLittleEndian(uint256 value) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
value | uint256 | The unsigned integer to convert |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | The little-endian representation of the input value as bytes32 |
toLittleEndian
Converts a boolean value to its little-endian bytes32 representation
function toLittleEndian(bool value) internal pure returns (bytes32);
Parameters
| Name | Type | Description |
|---|---|---|
value | bool | The boolean to convert |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes32 | The little-endian representation of the boolean as bytes32 |
reverseBytes64
Reverses a uint64 from little-endian to big-endian (needed in Solidity)
function reverseBytes64(uint64 input) internal pure returns (uint64);
Errors
Errors
ZeroAddress
error ZeroAddress();
ZeroAmount
error ZeroAmount();
UnderFlow
error UnderFlow();
InvalidArrayLength
error InvalidArrayLength();
AlreadySet
error AlreadySet();
NotPauser
error NotPauser();
InsufficientBalance
error InsufficientBalance();
InvalidFeeToken
error InvalidFeeToken();
FeeTokenNotWhitelisted
error FeeTokenNotWhitelisted();
InsufficientFeeTokenBalance
error InsufficientFeeTokenBalance();
ValidatorAlreadyExists
error ValidatorAlreadyExists();
FailedToAddValidator
error FailedToAddValidator();
ValidatorDoesNotExist
error ValidatorDoesNotExist();
MaxNumberOfRewards
error MaxNumberOfRewards();
Unauthorized
error Unauthorized(address sender);
IBGTNotRewardToken
error IBGTNotRewardToken();
IBGTNotStakingToken
error IBGTNotStakingToken();
StakedInRewardsVault
error StakedInRewardsVault();
NoRewardsVault
error NoRewardsVault();
RewardRateDecreased
error RewardRateDecreased();
RegistrationPaused
error RegistrationPaused();
RewardTokenNotWhitelisted
error RewardTokenNotWhitelisted();
InvalidValidator
error InvalidValidator();
InvalidOperator
error InvalidOperator();
InvalidDepositAmount
error InvalidDepositAmount();
ValidatorAlreadyRemoved
error ValidatorAlreadyRemoved();
VaultNotSupported
error VaultNotSupported();
InvalidNonce
error InvalidNonce();
VaultNotStaked
error VaultNotStaked();
ClaimDistrRewardsFailed
error ClaimDistrRewardsFailed();
ClaimableRewardsExist
error ClaimableRewardsExist();
DuplicateAssetAddress
error DuplicateAssetAddress();
VaultDeploymentFailed
error VaultDeploymentFailed();
RewardTokenNotSupported
error RewardTokenNotSupported();
BGTBalanceMismatch
error BGTBalanceMismatch();
NotInfrared
error NotInfrared();
NotInitialized
error NotInitialized();
InvalidFee
error InvalidFee();
InvalidCommissionRate
error InvalidCommissionRate();
InvalidDelegatee
error InvalidDelegatee();
InvalidWeight
error InvalidWeight();
MaxProtocolFeeAmount
error MaxProtocolFeeAmount();
BoostExceedsSupply
error BoostExceedsSupply();
ETHTransferFailed
error ETHTransferFailed();
TokensReservedForProtocolFees
error TokensReservedForProtocolFees();
NoRewardsToClaim
error NoRewardsToClaim();
VaultAlreadyUpToDate
error VaultAlreadyUpToDate();
InvalidAmount
error InvalidAmount();
InvalidShares
error InvalidShares();
WithdrawalsNotEnabled
error WithdrawalsNotEnabled();
InvalidSignature
error InvalidSignature();
InvalidReceiver
error InvalidReceiver();
CallFailed
error CallFailed();
InvalidReserves
error InvalidReserves();
UnauthorizedOperator
error UnauthorizedOperator();
ValidatorForceExited
error ValidatorForceExited();
CanNotCompoundAccumuldatedBERA
error CanNotCompoundAccumuldatedBERA();
ExceedsMaxEffectiveBalance
error ExceedsMaxEffectiveBalance();
HandleForceExitsBeforeDeposits
error HandleForceExitsBeforeDeposits();
HandleForceExitsBeforeRegister
error HandleForceExitsBeforeRegister();
OperatorAlreadySet
error OperatorAlreadySet();
InvalidPrecompileResponse
error InvalidPrecompileResponse();
ExcessiveFee
error ExcessiveFee();
AlreadyFinalised
error AlreadyFinalised();
ExceedsRequestLength
error ExceedsRequestLength();
NotFinalised
error NotFinalised();
InvalidState
error InvalidState();
InvalidWithdrawalAddress
error InvalidWithdrawalAddress();
DepositMustBeGreaterThanMinActivationBalance
error DepositMustBeGreaterThanMinActivationBalance();
WithdrawMustLeaveMoreThanMinActivationBalance
error WithdrawMustLeaveMoreThanMinActivationBalance();
MinExitFeeNotMet
error MinExitFeeNotMet();
AlreadyExited
error AlreadyExited();
AlreadyInitiated
error AlreadyInitiated();
BalanceMissmatch
error BalanceMissmatch();
EffectiveBalanceMissmatch
error EffectiveBalanceMissmatch();
NotExited
error NotExited();
ProcessReserves
error ProcessReserves();
StaleProof
error StaleProof();
WaitForPending
error WaitForPending();
ZeroBalance
error ZeroBalance();
InfraredVaultDeployer
Functions
deploy
Deploys a new InfraredVault or InfraredBGTVault contract.
If _stakingToken == InfraredBGT, then deploys InfraredBGTVault.
function deploy(address _stakingToken, uint256 _rewardsDuration)
public
returns (address _new);
Parameters
| Name | Type | Description |
|---|---|---|
_stakingToken | address | address The address of the staking token. |
_rewardsDuration | uint256 | The duration of the rewards for the vault. |
Returns
| Name | Type | Description |
|---|---|---|
_new | address | address The address of the new InfraredVault contract. |
MerkleTree
Provides functions for calculating Merkle roots
Functions
calculateMerkleRoot
Calculates the Merkle root of an array of SSZ-encoded data using sha256 for hashing
function calculateMerkleRoot(bytes32[] memory data)
internal
pure
returns (bytes32 root);
Parameters
| Name | Type | Description |
|---|---|---|
data | bytes32[] | The array of SSZ-encoded data (as bytes32 values) |
Returns
| Name | Type | Description |
|---|---|---|
root | bytes32 | The Merkle root of the data |
verifyMerkleLeaf
Verifies the inclusion of a leaf node in a Merkle tree using a given proof.
Follows a bottom-up approach by iteratively hashing the leaf with proof elements based on the index and comparing the computed root with the provided Merkle root.
function verifyMerkleLeaf(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf,
uint256 index
) public pure returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
proof | bytes32[] | Array of bytes32 values representing the Merkle proof. |
root | bytes32 | The Merkle root to verify the leaf node against. |
leaf | bytes32 | The leaf node whose inclusion in the Merkle tree is being verified. |
index | uint256 | The index of the leaf node in the tree, used to determine proof element order. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the computed Merkle root matches the provided root, indicating valid inclusion; otherwise, false. |
calculateMerkleRootFromProof
Calculates the Merkle root from a leaf, proof, and index.
function calculateMerkleRootFromProof(
bytes32[] memory proof,
bytes32 leaf,
uint256 index
) public pure returns (bytes32 root);
Parameters
| Name | Type | Description |
|---|---|---|
proof | bytes32[] | Array of bytes32 values representing the Merkle proof. |
leaf | bytes32 | The leaf node whose inclusion in the Merkle tree is being verified. |
index | uint256 | The index of the leaf node in the tree, used to determine proof element order. |
Returns
| Name | Type | Description |
|---|---|---|
root | bytes32 | The computed Merkle root. |
Upgradeable
Inherits: UUPSUpgradeable, PausableUpgradeable, AccessControlUpgradeable
Provides base upgradeability functionality using UUPS and access control.
State Variables
KEEPER_ROLE
bytes32 public constant KEEPER_ROLE = keccak256("KEEPER_ROLE");
GOVERNANCE_ROLE
bytes32 public constant GOVERNANCE_ROLE = keccak256("GOVERNANCE_ROLE");
PAUSER_ROLE
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
__gap
uint256[20] private __gap;
Functions
onlyKeeper
Modifier to restrict access to KEEPER_ROLE.
modifier onlyKeeper();
onlyGovernor
Modifier to restrict access to GOVERNANCE_ROLE.
modifier onlyGovernor();
onlyPauser
Modifier to restrict access to PAUSER_ROLE.
modifier onlyPauser();
whenInitialized
modifier whenInitialized();
constructor
Note: oz-upgrades-unsafe-allow: constructor
constructor();
__Upgradeable_init
Initialize the upgradeable contract.
function __Upgradeable_init() internal onlyInitializing;
pause
function pause() public;
unpause
function unpause() public onlyGovernor;
_authorizeUpgrade
Restrict upgrades to only the governor.
function _authorizeUpgrade(address newImplementation)
internal
override
onlyGovernor;
currentImplementation
Returns the current implementation address.
function currentImplementation() external view returns (address);
implementation
Alias for currentImplementation for clarity.
function implementation() external view returns (address);
Contents
CustomPausable
Inherits: ERC20, Pausable
ERC-20 token with pausable token transfers, minting and burning. Useful for scenarios such as preventing trades until the end of an evaluation period, or having an emergency switch for freezing all token transfers in the event of a large bug. IMPORTANT: This contract does not include public pause and unpause functions. In addition to inheriting this contract, you must define both functions, invoking the Pausable-_pause and {Pausable-_unpause} internal functions, with appropriate access control, e.g. using {AccessControl} or {Ownable}. Not doing so will make the contract pause mechanism of the contract unreachable, and thus unusable.
Functions
_update
*See ERC20-_update. This contract modifies the default behavior of ERC20Pausable.
- When paused, transfers are not paused.
- The
whenNotPausedmodifier has been removed to allow transfers even when the contract is paused. - Only minting and burning operations are paused when the contract is paused.*
function _update(address from, address to, uint256 value)
internal
virtual
override;
ERC20PresetMinterPauser
Inherits: Context, AccessControlEnumerable, CustomPausable
*{ERC20} token, including:
- ability for holders to burn (destroy) their tokens
- a minter role that allows for token minting (creation)
- a pauser role that allows to stop all token transfers This contract uses {AccessControl} to lock permissioned functions using the different roles - head to its documentation for details. The account that deploys the contract will be granted the minter and pauser roles, as well as the default admin role, which will let it grant both minter and pauser roles to other accounts. Deprecated in favor of https://wizard.openzeppelin.com/[Contracts Wizard].*
State Variables
MINTER_ROLE
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
PAUSER_ROLE
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
BURNER_ROLE
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
Functions
constructor
Grants DEFAULT_ADMIN_ROLE, MINTER_ROLE and PAUSER_ROLE to the
account that deploys the contract.
See ERC20-constructor.
constructor(
string memory name,
string memory symbol,
address _admin,
address _minter,
address _pauser,
address _burner
) ERC20(name, symbol);
mint
*Creates amount new tokens for to.
See ERC20-_mint.
Requirements:
- the caller must have the
MINTER_ROLE.*
function mint(address to, uint256 amount) public virtual whenNotPaused;
burn
*Burn amount new tokens from from.
See ERC20-_burn.
Requirements:
- the caller must have the
BURNER_ROLE.*
function burn(uint256 amount) public virtual whenNotPaused;
pause
*Pauses all token transfers. See {ERC20Pausable} and {Pausable-_pause}. Requirements:
- the caller must have the
PAUSER_ROLE.*
function pause() public virtual;
unpause
*Unpauses all token transfers. See {ERC20Pausable} and {Pausable-_unpause}. Requirements:
- the caller must have the
PAUSER_ROLE.*
function unpause() public virtual;
_update
function _update(address from, address to, uint256 value)
internal
virtual
override(CustomPausable);
Contents
Contents
IReward
Interface for rewards distribution contracts in the Infrared Voter
Base interface implemented by all reward-type contracts
Functions
DURATION
Duration of each reward epoch in seconds
function DURATION() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Fixed duration of 7 days |
voter
Address of the Voter contract that manages rewards
function voter() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Voter contract address |
ve
Address of the VotingEscrow contract that manages veNFTs
function ve() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | VotingEscrow contract address |
authorized
Address permitted to call privileged state-changing functions
function authorized() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Authorized caller address |
totalSupply
Total amount of staking tokens locked in contract
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Current total supply of staked tokens |
balanceOf
Retrieves current staked balance for a veNFT
function balanceOf(uint256 tokenId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | ID of the veNFT to query |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Current staked token balance |
tokenRewardsPerEpoch
Gets reward amount allocated for a specific epoch
function tokenRewardsPerEpoch(address token, uint256 epochStart)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of reward token |
epochStart | uint256 | Starting timestamp of epoch |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Amount of token allocated as rewards for the epoch |
lastEarn
Retrieves timestamp of last reward claim for a veNFT
function lastEarn(address token, uint256 tokenId)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of reward token |
tokenId | uint256 | ID of veNFT that claimed |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Timestamp of last claim for this token/veNFT pair |
isReward
Checks if a token is configured as a reward token
function isReward(address token) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of token to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if token is active for rewards |
numCheckpoints
Number of balance checkpoints for a veNFT
function numCheckpoints(uint256 tokenId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | ID of veNFT to query |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Number of checkpoints recorded |
supplyNumCheckpoints
Total number of supply checkpoints recorded
function supplyNumCheckpoints() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Count of global supply checkpoints |
checkpoints
Gets balance checkpoint data for a veNFT at specific index
function checkpoints(uint256 tokenId, uint256 index)
external
view
returns (uint256 timestamp, uint256 balanceOf);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | ID of veNFT to query |
index | uint256 | Checkpoint index to read |
Returns
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | Time checkpoint was created |
balanceOf | uint256 | Balance recorded at checkpoint |
supplyCheckpoints
Gets total supply checkpoint data at specific index
function supplyCheckpoints(uint256 index)
external
view
returns (uint256 timestamp, uint256 supply);
Parameters
| Name | Type | Description |
|---|---|---|
index | uint256 | Checkpoint index to read |
Returns
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | Time checkpoint was created |
supply | uint256 | Total supply recorded at checkpoint |
getPriorBalanceIndex
Gets historical balance index for a veNFT at timestamp
Uses binary search to find checkpoint index
function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | ID of veNFT to query |
timestamp | uint256 | Time to query balance at |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Index of nearest checkpoint before timestamp |
getPriorSupplyIndex
Gets historical supply index at timestamp
Uses binary search to find checkpoint index
function getPriorSupplyIndex(uint256 timestamp)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | Time to query supply at |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Index of nearest checkpoint before timestamp |
rewardsListLength
Number of tokens configured for rewards
function rewardsListLength() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Length of rewards token list |
earned
Calculates unclaimed rewards for a veNFT
function earned(address token, uint256 tokenId)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of reward token to calculate |
tokenId | uint256 | ID of veNFT to calculate for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Amount of unclaimed rewards |
_deposit
Records a token deposit and updates checkpoints
Can only be called by authorized address
function _deposit(uint256 amount, uint256 tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | Amount of tokens being deposited |
tokenId | uint256 | ID of veNFT receiving deposit |
_withdraw
Records a token withdrawal and updates checkpoints
Can only be called by authorized address
function _withdraw(uint256 amount, uint256 tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | Amount of tokens being withdrawn |
tokenId | uint256 | ID of veNFT withdrawing from |
getReward
Claims accumulated rewards for a veNFT
function getReward(uint256 tokenId, address[] memory tokens) external;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | ID of veNFT claiming rewards |
tokens | address[] | Array of reward token addresses to claim |
notifyRewardAmount
Adds new reward tokens for distribution
Transfers tokens from caller and updates reward accounting
function notifyRewardAmount(address token, uint256 amount) external;
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of token to add as reward |
amount | uint256 | Amount of token to add to rewards |
renotifyRewardAmount
in case rewards where distributed during a epoch with no deposits, redistribute the rewards
function renotifyRewardAmount(uint256 timestamp, address token) external;
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | Timestamp of the start of the epoch to renotify |
token | address | Address of token to renotify |
Events
Deposit
Emitted when tokens are deposited for rewards
event Deposit(address indexed from, uint256 indexed tokenId, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
from | address | Address depositing tokens |
tokenId | uint256 | ID of the veNFT receiving deposit |
amount | uint256 | Amount of tokens deposited |
Withdraw
Emitted when tokens are withdrawn from rewards
event Withdraw(address indexed from, uint256 indexed tokenId, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
from | address | Address withdrawing tokens |
tokenId | uint256 | ID of the veNFT withdrawing from |
amount | uint256 | Amount of tokens withdrawn |
NotifyReward
Emitted when new rewards are added
event NotifyReward(
address indexed from,
address indexed reward,
uint256 indexed epoch,
uint256 amount
);
Parameters
| Name | Type | Description |
|---|---|---|
from | address | Address supplying the reward tokens |
reward | address | Token being added as reward |
epoch | uint256 | Epoch timestamp for reward distribution |
amount | uint256 | Amount of reward tokens added |
ClaimRewards
Emitted when rewards are claimed
event ClaimRewards(
address indexed from, address indexed reward, uint256 amount
);
Parameters
| Name | Type | Description |
|---|---|---|
from | address | Address claiming the rewards |
reward | address | Token being claimed |
amount | uint256 | Amount of tokens claimed |
Errors
InvalidReward
Thrown when attempting to interact with an invalid reward token
error InvalidReward();
NotAuthorized
Thrown when caller is not authorized to perform operation
error NotAuthorized();
NotWhitelisted
Thrown when token is not in whitelist
error NotWhitelisted();
ZeroAmount
Thrown when attempting operation with zero amount
error ZeroAmount();
NonZeroSupply
Thrown when supply is not zero
error NonZeroSupply();
ActiveEpoch
Thrown when epoch is active
error ActiveEpoch();
Structs
Checkpoint
Balance checkpoint for tracking historical balances
struct Checkpoint {
uint256 timestamp;
uint256 balanceOf;
}
Properties
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | Time of checkpoint |
balanceOf | uint256 | Balance at checkpoint |
SupplyCheckpoint
Supply checkpoint for tracking total supply
struct SupplyCheckpoint {
uint256 timestamp;
uint256 supply;
}
Properties
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | Time of checkpoint |
supply | uint256 | Total supply at checkpoint |
IVeArtProxy
Functions
tokenURI
Generate a SVG based on veNFT metadata
function tokenURI(uint256 _tokenId)
external
view
returns (string memory output);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | Unique veNFT identifier |
Returns
| Name | Type | Description |
|---|---|---|
output | string | SVG metadata as HTML tag |
lineArtPathsOnly
Generate only the foreground
function lineArtPathsOnly(uint256 _tokenId)
external
view
returns (bytes memory output);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | Unique veNFT identifier |
Returns
| Name | Type | Description |
|---|---|---|
output | bytes | Encoded output of generateShape() |
generateConfig
Generate the master art config metadata for a veNFT
function generateConfig(uint256 _tokenId)
external
view
returns (Config memory cfg);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | Unique veNFT identifier |
Returns
| Name | Type | Description |
|---|---|---|
cfg | Config | Config struct |
twoStripes
Generate the points for two stripe lines based on the config generated for a veNFT
function twoStripes(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
| Name | Type | Description |
|---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of line drawn |
Returns
| Name | Type | Description |
|---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn stripes |
circles
Generate the points for circles based on the config generated for a veNFT
function circles(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
| Name | Type | Description |
|---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of circles drawn |
Returns
| Name | Type | Description |
|---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn circles |
interlockingCircles
Generate the points for interlocking circles based on the config generated for a veNFT
function interlockingCircles(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
| Name | Type | Description |
|---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of interlocking circles drawn |
Returns
| Name | Type | Description |
|---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn interlocking circles |
corners
Generate the points for corners based on the config generated for a veNFT
function corners(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
| Name | Type | Description |
|---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of corners drawn |
Returns
| Name | Type | Description |
|---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn corners |
curves
Generate the points for a curve based on the config generated for a veNFT
function curves(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
| Name | Type | Description |
|---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of curve drawn |
Returns
| Name | Type | Description |
|---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn curve |
spiral
Generate the points for a spiral based on the config generated for a veNFT
function spiral(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
| Name | Type | Description |
|---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of spiral drawn |
Returns
| Name | Type | Description |
|---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn spiral |
explosion
Generate the points for an explosion based on the config generated for a veNFT
function explosion(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
| Name | Type | Description |
|---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of explosion drawn |
Returns
| Name | Type | Description |
|---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn explosion |
wormhole
Generate the points for a wormhole based on the config generated for a veNFT
function wormhole(Config memory cfg, int256 l)
external
pure
returns (Point[100] memory Line);
Parameters
| Name | Type | Description |
|---|---|---|
cfg | Config | Master art config metadata of a veNFT |
l | int256 | Number of wormhole drawn |
Returns
| Name | Type | Description |
|---|---|---|
Line | Point[100] | (x, y) coordinates of the drawn wormhole |
Structs
Config
Art configuration
struct Config {
int256 _tokenId;
int256 _balanceOf;
int256 _lockedEnd;
int256 _lockedAmount;
int256 shape;
uint256 palette;
int256 maxLines;
int256 dash;
int256 seed1;
int256 seed2;
int256 seed3;
}
lineConfig
Individual line art path variables.
struct lineConfig {
bytes8 color;
uint256 stroke;
uint256 offset;
uint256 offsetHalf;
uint256 offsetDashSum;
uint256 pathLength;
}
Point
Represents an (x,y) coordinate in a line.
struct Point {
int256 x;
int256 y;
}
IVoter
Interface for Infrared's voting system that manages votes for POL CuttingBoard allocation and bribe vault creation
Handles voting power allocation, managed veNFT deposits, and bribe distribution
Functions
ve
Returns the VotingEscrow contract address
function ve() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of the VE token that governs these contracts |
totalWeight
Returns total voting weight across all votes
function totalWeight() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total weight sum of all active votes |
maxVotingNum
Returns maximum number of staking tokens one voter can vote for
function maxVotingNum() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Maximum number of allowed votes per voter |
feeVault
Returns global fee distribution vault address
function feeVault() external view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of the fee vault |
bribeVaults
Returns bribe vault address for a given staking token
function bribeVaults(address stakingToken) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
stakingToken | address | Address of staking token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of associated bribe vault |
weights
Returns total weight allocated to a staking token
function weights(address stakingToken) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
stakingToken | address | Address of staking token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total voting weight for the token |
votes
Returns vote weight allocated by token ID for specific staking token
function votes(uint256 tokenId, address stakingToken)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | NFT token ID |
stakingToken | address | Address of staking token |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Vote weight allocated |
usedWeights
Returns total vote weight used by specific token ID
function usedWeights(uint256 tokenId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | NFT token ID |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total used voting weight |
lastVoted
Returns timestamp of last vote for a token ID
function lastVoted(uint256 tokenId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | NFT token ID |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Timestamp of last vote |
isWhitelistedToken
Checks if a token is whitelisted for rewards
function isWhitelistedToken(address token) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of token to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if token is whitelisted |
isWhitelistedNFT
Checks if NFT is whitelisted for special voting
function isWhitelistedNFT(uint256 tokenId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | NFT token ID to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if NFT is whitelisted |
isAlive
Checks if bribe vault is active
function isAlive(address bribeVault) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
bribeVault | address | Address of bribe vault to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if vault is active |
length
Returns number of staking tokens with active bribe vaults
function length() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Count of staking tokens with bribe vaults |
epochStart
Calculates start of epoch containing timestamp
function epochStart(uint256 _timestamp) external pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Start of epoch time |
epochNext
Calculates start of next epoch after timestamp
function epochNext(uint256 _timestamp) external pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Start of next epoch time |
epochVoteStart
Calculates start of voting window for epoch containing timestamp
function epochVoteStart(uint256 _timestamp) external pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Vote window start time |
epochVoteEnd
Calculates end of voting window for epoch containing timestamp
function epochVoteEnd(uint256 _timestamp) external pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Vote window end time |
poke
Updates voting balances in rewards contracts for a token ID
Should be called after any action that affects vote weight
function poke(uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to update |
vote
Distributes voting weight to multiple staking tokens
Weight is allocated proportionally based on provided weights
function vote(
uint256 _tokenId,
address[] calldata _stakingTokenVote,
uint256[] calldata _weights
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID voting with |
_stakingTokenVote | address[] | Array of staking token addresses receiving votes |
_weights | uint256[] | Array of weights to allocate to each token |
reset
Resets voting state for a token ID
Required before making changes to veNFT state
function reset(uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to reset |
depositManaged
Deposits veNFT into a managed NFT
NFT will be re-locked to max time on withdrawal
function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to deposit |
_mTokenId | uint256 | Managed NFT token ID to deposit into |
withdrawManaged
Withdraws veNFT from a managed NFT
Withdrawing locks NFT to max lock time
function withdrawManaged(uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to withdraw |
claimBribes
Claims bribes from multiple sources for a veNFT
function claimBribes(
address[] memory _bribes,
address[][] memory _tokens,
uint256 _tokenId
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_bribes | address[] | Array of bribe vault addresses to claim from |
_tokens | address[][] | Array of reward tokens to claim for each vault |
_tokenId | uint256 | veNFT token ID to claim for |
claimFees
Claims fee rewards for a veNFT
function claimFees(address[] memory _tokens, uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokens | address[] | Array of fee tokens to claim |
_tokenId | uint256 | veNFT token ID to claim for |
setMaxVotingNum
Updates maximum allowed votes per voter
function setMaxVotingNum(uint256 _maxVotingNum) external;
Parameters
| Name | Type | Description |
|---|---|---|
_maxVotingNum | uint256 | New maximum number of allowed votes |
whitelistNFT
Updates whitelist status for veNFT for privileged voting
function whitelistNFT(uint256 _tokenId, bool _bool) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to update |
_bool | bool | New whitelist status |
createBribeVault
Creates new bribe vault for staking token
function createBribeVault(
address _stakingToken,
address[] calldata _rewardTokens
) external returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
_stakingToken | address | Address of staking token |
_rewardTokens | address[] | Array of reward token addresses |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of created bribe vault |
killBribeVault
Disables a bribe vault
function killBribeVault(address _stakingToken) external;
Parameters
| Name | Type | Description |
|---|---|---|
_stakingToken | address | Address of staking token for vault to disable |
reviveBribeVault
Re-enables a disabled bribe vault
function reviveBribeVault(address _stakingToken) external;
Parameters
| Name | Type | Description |
|---|---|---|
_stakingToken | address | Address of staking token for vault to re-enable |
Events
BribeVaultCreated
Emitted when a new bribe vault is created
event BribeVaultCreated(
address stakingToken, address bribeVault, address creator
);
Parameters
| Name | Type | Description |
|---|---|---|
stakingToken | address | The staking token address for which the vault was created |
bribeVault | address | The address of the newly created bribe vault |
creator | address | The address that created the bribe vault |
BribeVaultKilled
Emitted when a bribe vault is killed (disabled)
event BribeVaultKilled(address indexed bribeVault);
Parameters
| Name | Type | Description |
|---|---|---|
bribeVault | address | The address of the killed bribe vault |
BribeVaultRevived
Emitted when a killed bribe vault is revived (re-enabled)
event BribeVaultRevived(address indexed bribeVault);
Parameters
| Name | Type | Description |
|---|---|---|
bribeVault | address | The address of the revived bribe vault |
Voted
Emitted when votes are cast for a staking token
event Voted(
address indexed voter,
address indexed stakingToken,
uint256 indexed tokenId,
uint256 weight,
uint256 totalWeight,
uint256 timestamp
);
Parameters
| Name | Type | Description |
|---|---|---|
voter | address | Address of the account casting the vote |
stakingToken | address | The staking token being voted for |
tokenId | uint256 | ID of the veNFT used to vote |
weight | uint256 | Vote weight allocated |
totalWeight | uint256 | New total vote weight for the staking token |
timestamp | uint256 | Block timestamp when vote was cast |
Abstained
Emitted when votes are withdrawn/reset
event Abstained(
address indexed voter,
address indexed stakingToken,
uint256 indexed tokenId,
uint256 weight,
uint256 totalWeight,
uint256 timestamp
);
Parameters
| Name | Type | Description |
|---|---|---|
voter | address | Address of the account withdrawing votes |
stakingToken | address | The staking token votes are withdrawn from |
tokenId | uint256 | ID of the veNFT used to vote |
weight | uint256 | Vote weight withdrawn |
totalWeight | uint256 | New total vote weight for the staking token |
timestamp | uint256 | Block timestamp when votes were withdrawn |
WhitelistNFT
Emitted when an NFT's whitelist status changes
event WhitelistNFT(
address indexed whitelister, uint256 indexed tokenId, bool indexed _bool
);
Parameters
| Name | Type | Description |
|---|---|---|
whitelister | address | Address making the whitelist change |
tokenId | uint256 | ID of the NFT being whitelisted/unwhitelisted |
_bool | bool | New whitelist status |
SkipKilledBribeVault
Emitted when a killed bribe vault is skipped
event SkipKilledBribeVault(
address indexed stakingToken, uint256 indexed tokenId
);
Parameters
| Name | Type | Description |
|---|---|---|
stakingToken | address | Address of staking token for vault to skip |
tokenId | uint256 | ID of the veNFT used to vote |
MaxVotingNumSet
Emitted when maximum voting number is set
event MaxVotingNumSet(uint256 indexed maxVotingNum);
Parameters
| Name | Type | Description |
|---|---|---|
maxVotingNum | uint256 | New maximum number of allowed votes |
Errors
AlreadyVotedOrDeposited
error AlreadyVotedOrDeposited();
BribeVaultAlreadyKilled
error BribeVaultAlreadyKilled();
BribeVaultAlreadyRevived
error BribeVaultAlreadyRevived();
BribeVaultExists
error BribeVaultExists();
BribeVaultDoesNotExist
error BribeVaultDoesNotExist(address _stakingToken);
BribeVaultNotAlive
error BribeVaultNotAlive(address _stakingToken);
InactiveManagedNFT
error InactiveManagedNFT();
MaximumVotingNumberTooLow
error MaximumVotingNumberTooLow();
NonZeroVotes
error NonZeroVotes();
NotAStakingToken
error NotAStakingToken();
NotApprovedOrOwner
error NotApprovedOrOwner();
NotWhitelistedNFT
error NotWhitelistedNFT();
NotWhitelistedToken
error NotWhitelistedToken();
SameValue
error SameValue();
SpecialVotingWindow
error SpecialVotingWindow();
TooManyStakingTokens
error TooManyStakingTokens();
UnequalLengths
error UnequalLengths();
ZeroBalance
error ZeroBalance();
ZeroAddress
error ZeroAddress();
VaultNotRegistered
error VaultNotRegistered();
NotGovernor
error NotGovernor();
DistributeWindow
error DistributeWindow();
IVotes
Modified IVotes interface for tokenId based voting
Functions
getPastVotes
Returns the amount of votes that tokenId had at a specific moment in the past.
If the account passed in is not the owner, returns 0.
function getPastVotes(address account, uint256 tokenId, uint256 timepoint)
external
view
returns (uint256);
getPastTotalSupply
Returns the total supply of votes available at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value the end of the corresponding block.
NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
Votes that have not been delegated are still part of total supply, even though they would not participate in a
vote.
function getPastTotalSupply(uint256 timepoint)
external
view
returns (uint256);
delegates
Returns the delegate that tokenId has chosen. Can never be equal to the delegator's tokenId.
Returns 0 if not delegated.
function delegates(uint256 tokenId) external view returns (uint256);
delegate
Delegates votes from the sender to delegatee.
function delegate(uint256 delegator, uint256 delegatee) external;
delegateBySig
Delegates votes from delegator to delegatee. Signer must own delegator.
function delegateBySig(
uint256 delegator,
uint256 delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) external;
Events
DelegateChanged
Emitted when an account changes their delegate.
event DelegateChanged(
address indexed delegator,
uint256 indexed fromDelegate,
uint256 indexed toDelegate
);
DelegateVotesChanged
Emitted when a token transfer or delegate change results in changes to a delegate's number of votes.
event DelegateVotesChanged(
address indexed delegate, uint256 previousBalance, uint256 newBalance
);
IVotingEscrow
Inherits: IVotes, IERC4906, IERC6372, IERC721Metadata
Functions
token
Address of token (IR) used to create a veNFT
function token() external view returns (address);
distributor
Address of RewardsDistributor.sol
function distributor() external view returns (address);
voter
Address of Voter.sol
function voter() external view returns (address);
artProxy
Address of art proxy used for on-chain art generation
function artProxy() external view returns (address);
allowedManager
address which can create managed NFTs
function allowedManager() external view returns (address);
tokenId
Current count of token
function tokenId() external view returns (uint256);
infrared
Address of Infrared contract
function infrared() external view returns (IInfraredUpgradeable);
Returns
| Name | Type | Description |
|---|---|---|
<none> | IInfraredUpgradeable | IInfrared instance of contract address |
escrowType
Mapping of token id to escrow type Takes advantage of the fact default value is EscrowType.NORMAL
function escrowType(uint256 tokenId) external view returns (EscrowType);
idToManaged
Mapping of token id to managed id
function idToManaged(uint256 tokenId)
external
view
returns (uint256 managedTokenId);
weights
Mapping of user token id to managed token id to weight of token id
function weights(uint256 tokenId, uint256 managedTokenId)
external
view
returns (uint256 weight);
deactivated
Mapping of managed id to deactivated state
function deactivated(uint256 tokenId) external view returns (bool inactive);
createManagedLockFor
Create managed NFT (a permanent lock) for use within ecosystem.
Throws if address already owns a managed NFT.
function createManagedLockFor(address _to)
external
returns (uint256 _mTokenId);
Returns
| Name | Type | Description |
|---|---|---|
_mTokenId | uint256 | managed token id. |
depositManaged
Delegates balance to managed nft Note that NFTs deposited into a managed NFT will be re-locked to the maximum lock time on withdrawal. Permanent locks that are deposited will automatically unlock.
Managed nft will remain max-locked as long as there is at least one deposit or withdrawal per week. Throws if deposit nft is managed. Throws if recipient nft is not managed. Throws if deposit nft is already locked. Throws if not called by voter.
function depositManaged(uint256 _tokenId, uint256 _mTokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | tokenId of NFT being deposited |
_mTokenId | uint256 | tokenId of managed NFT that will receive the deposit |
withdrawManaged
Retrieves locked rewards and withdraws balance from managed nft. Note that the NFT withdrawn is re-locked to the maximum lock time.
Throws if NFT not locked. Throws if not called by voter.
function withdrawManaged(uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | tokenId of NFT being deposited. |
setAllowedManager
Permit one address to call createManagedLockFor() that is not Voter.governor()
function setAllowedManager(address _allowedManager) external;
setManagedState
Set Managed NFT state. Inactive NFTs cannot be deposited into.
function setManagedState(uint256 _mTokenId, bool _state) external;
Parameters
| Name | Type | Description |
|---|---|---|
_mTokenId | uint256 | managed nft state to set |
_state | bool | true => inactive, false => active |
name
function name() external view returns (string memory);
symbol
function symbol() external view returns (string memory);
version
function version() external view returns (string memory);
decimals
function decimals() external view returns (uint8);
setArtProxy
function setArtProxy(address _proxy) external;
tokenURI
A distinct Uniform Resource Identifier (URI) for a given asset.
Throws if _tokenId is not a valid NFT. URIs are defined in RFC
3986. The URI may point to a JSON file that conforms to the "ERC721
Metadata JSON Schema".
function tokenURI(uint256 tokenId) external view returns (string memory);
ownerToNFTokenIdList
Mapping from owner address to mapping of index to tokenId
function ownerToNFTokenIdList(address _owner, uint256 _index)
external
view
returns (uint256 _tokenId);
ownerOf
Find the owner of an NFT
NFTs assigned to zero address are considered invalid, and queries about them do throw.
function ownerOf(uint256 tokenId) external view returns (address owner);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
owner | address | The address of the owner of the NFT |
balanceOf
Count all NFTs assigned to an owner
NFTs assigned to the zero address are considered invalid, and this function throws for queries about the zero address.
function balanceOf(address owner) external view returns (uint256 balance);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address |
Returns
| Name | Type | Description |
|---|---|---|
balance | uint256 | The number of NFTs owned by _owner, possibly zero |
getApproved
Get the approved address for a single NFT
Throws if _tokenId is not a valid NFT.
function getApproved(uint256 _tokenId)
external
view
returns (address operator);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | The NFT to find the approved address for |
Returns
| Name | Type | Description |
|---|---|---|
operator | address | The approved address for this NFT, or the zero address if there is none |
isApprovedForAll
Query if an address is an authorized operator for another address
function isApprovedForAll(address owner, address operator)
external
view
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
owner | address | |
operator | address |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if _operator is an approved operator for _owner, false otherwise |
isApprovedOrOwner
Check whether spender is owner or an approved user for a given veNFT
function isApprovedOrOwner(address _spender, uint256 _tokenId)
external
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_spender | address | . |
_tokenId | uint256 | . |
approve
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless msg.sender is the current NFT owner, or an authorized
operator of the current owner.
function approve(address to, uint256 tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
to | address | |
tokenId | uint256 |
setApprovalForAll
Enable or disable approval for a third party ("operator") to manage
all of msg.sender's assets
Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.
function setApprovalForAll(address operator, bool approved) external;
Parameters
| Name | Type | Description |
|---|---|---|
operator | address | |
approved | bool |
transferFrom
Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE
THEY MAY BE PERMANENTLY LOST
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT.
function transferFrom(address from, address to, uint256 tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(address from, address to, uint256 tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 |
safeTransferFrom
Transfers the ownership of an NFT from one address to another address
Throws unless msg.sender is the current owner, an authorized
operator, or the approved address for this NFT. Throws if _from is
not the current owner. Throws if _to is the zero address. Throws if
_tokenId is not a valid NFT. When transfer is complete, this function
checks if _to is a smart contract (code size > 0). If so, it calls
onERC721Received on _to and throws if the return value is not
bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
Parameters
| Name | Type | Description |
|---|---|---|
from | address | |
to | address | |
tokenId | uint256 | |
data | bytes | Additional data with no specified format, sent in call to _to |
supportsInterface
Query if a contract implements an interface
Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_interfaceID | bytes4 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | true if the contract implements interfaceID and interfaceID is not 0xffffffff, false otherwise |
epoch
Total count of epochs witnessed since contract creation
function epoch() external view returns (uint256);
supply
Total amount of token() deposited
function supply() external view returns (uint256);
permanentLockBalance
Aggregate permanent locked balances
function permanentLockBalance() external view returns (uint256);
userPointEpoch
function userPointEpoch(uint256 _tokenId)
external
view
returns (uint256 _epoch);
slopeChanges
time -> signed slope change
function slopeChanges(uint256 _timestamp) external view returns (int128);
canSplit
account -> can split
function canSplit(address _account) external view returns (bool);
pointHistory
Global point history at a given index
function pointHistory(uint256 _loc)
external
view
returns (GlobalPoint memory);
locked
Get the LockedBalance (amount, end) of a _tokenId
function locked(uint256 _tokenId)
external
view
returns (LockedBalance memory);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | LockedBalance | LockedBalance of _tokenId |
userPointHistory
User -> UserPoint[userEpoch]
function userPointHistory(uint256 _tokenId, uint256 _loc)
external
view
returns (UserPoint memory);
checkpoint
Record global data to checkpoint
function checkpoint() external;
depositFor
Deposit _value tokens for _tokenId and add to the lock
Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user
function depositFor(uint256 _tokenId, uint256 _value) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | lock NFT |
_value | uint256 | Amount to add to user's lock |
createLock
Deposit _value tokens for msg.sender and lock for _lockDuration
function createLock(uint256 _value, uint256 _lockDuration)
external
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | TokenId of created veNFT |
createLockFor
Deposit _value tokens for _to and lock for _lockDuration
function createLockFor(uint256 _value, uint256 _lockDuration, address _to)
external
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
_to | address | Address to deposit |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | TokenId of created veNFT |
increaseAmount
Deposit _value additional tokens for _tokenId without modifying the unlock time
function increaseAmount(uint256 _tokenId, uint256 _value) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | |
_value | uint256 | Amount of tokens to deposit and add to the lock |
increaseUnlockTime
Extend the unlock time for _tokenId
Cannot extend lock time of permanent locks
function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | |
_lockDuration | uint256 | New number of seconds until tokens unlock |
withdraw
Withdraw all tokens for _tokenId
Only possible if the lock is both expired and not permanent This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.
function withdraw(uint256 _tokenId) external;
merge
Merges _from into _to.
Cannot merge _from locks that are permanent or have already voted this epoch.
Cannot merge _to locks that have already expired.
This will burn the veNFT. Any rebases or rewards that are unclaimed
will no longer be claimable. Claim all rebases and rewards prior to calling this.
function merge(uint256 _from, uint256 _to) external;
Parameters
| Name | Type | Description |
|---|---|---|
_from | uint256 | VeNFT to merge from. |
_to | uint256 | VeNFT to merge into. |
split
Splits veNFT into two new veNFTS - one with oldLocked.amount - _amount, and the second with _amount
This burns the tokenId of the target veNFT
Callable by approved or owner
If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs
Returns the two new split veNFTs to owner
If from is permanent, will automatically dedelegate.
This will burn the veNFT. Any rebases or rewards that are unclaimed
will no longer be claimable. Claim all rebases and rewards prior to calling this.
function split(uint256 _from, uint256 _amount)
external
returns (uint256 _tokenId1, uint256 _tokenId2);
Parameters
| Name | Type | Description |
|---|---|---|
_from | uint256 | VeNFT to split. |
_amount | uint256 | Amount to split from veNFT. |
Returns
| Name | Type | Description |
|---|---|---|
_tokenId1 | uint256 | Return tokenId of veNFT with oldLocked.amount - _amount. |
_tokenId2 | uint256 | Return tokenId of veNFT with _amount. |
toggleSplit
Toggle split for a specific address.
Toggle split for address(0) to enable or disable for all.
function toggleSplit(address _account, bool _bool) external;
Parameters
| Name | Type | Description |
|---|---|---|
_account | address | Address to toggle split permissions |
_bool | bool | True to allow, false to disallow |
lockPermanent
Permanently lock a veNFT. Voting power will be equal to
LockedBalance.amount with no decay. Required to delegate.
Only callable by unlocked normal veNFTs.
function lockPermanent(uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | tokenId to lock. |
unlockPermanent
Unlock a permanently locked veNFT. Voting power will decay. Will automatically dedelegate if delegated.
Only callable by permanently locked veNFTs. Cannot unlock if already voted this epoch.
function unlockPermanent(uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | tokenId to unlock. |
balanceOfNFT
Get the voting power for _tokenId at the current timestamp
Returns 0 if called in the same block as a transfer.
function balanceOfNFT(uint256 _tokenId) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Voting power |
balanceOfNFTAt
Get the voting power for _tokenId at a given timestamp
function balanceOfNFTAt(uint256 _tokenId, uint256 _t)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
_t | uint256 | Timestamp to query voting power |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Voting power |
totalSupply
Calculate total voting power at current timestamp
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total voting power at current timestamp |
totalSupplyAt
Calculate total voting power at a given timestamp
function totalSupplyAt(uint256 _t) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_t | uint256 | Timestamp to query total voting power |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total voting power at given timestamp |
voted
See if a queried _tokenId has actively voted
function voted(uint256 _tokenId) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if voted, else false |
setVoterAndDistributor
Set the global state voter and distributor
This is only called once, at setup
function setVoterAndDistributor(address _voter, address _distributor)
external;
voting
Set voted for _tokenId to true or false
Only callable by voter
function voting(uint256 _tokenId, bool _voted) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
_voted | bool | . |
numCheckpoints
The number of checkpoints for each tokenId
function numCheckpoints(uint256 tokenId) external view returns (uint48);
nonces
A record of states for signing / validating signatures
function nonces(address account) external view returns (uint256);
delegates
Returns the delegate that tokenId has chosen. Can never be equal to the delegator's tokenId.
Returns 0 if not delegated.
function delegates(uint256 delegator) external view returns (uint256);
checkpoints
A record of delegated token checkpoints for each account, by index
function checkpoints(uint256 tokenId, uint48 index)
external
view
returns (Checkpoint memory);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | . |
index | uint48 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Checkpoint | Checkpoint |
getPastVotes
Returns the amount of votes that tokenId had at a specific moment in the past.
If the account passed in is not the owner, returns 0.
function getPastVotes(address account, uint256 tokenId, uint256 timestamp)
external
view
returns (uint256);
getPastTotalSupply
Returns the total supply of votes available at a specific moment in the past. If the clock() is
configured to use block numbers, this will return the value the end of the corresponding block.
NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes.
Votes that have not been delegated are still part of total supply, even though they would not participate in a
vote.
function getPastTotalSupply(uint256 timestamp)
external
view
returns (uint256);
delegate
Delegates votes from the sender to delegatee.
function delegate(uint256 delegator, uint256 delegatee) external;
delegateBySig
Delegates votes from delegator to delegatee. Signer must own delegator.
function delegateBySig(
uint256 delegator,
uint256 delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) external;
clock
Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting).
function clock() external view returns (uint48);
CLOCK_MODE
Description of the clock
function CLOCK_MODE() external view returns (string memory);
Events
Deposit
event Deposit(
address indexed provider,
uint256 indexed tokenId,
DepositType indexed depositType,
uint256 value,
uint256 locktime,
uint256 ts
);
Withdraw
event Withdraw(
address indexed provider, uint256 indexed tokenId, uint256 value, uint256 ts
);
LockPermanent
event LockPermanent(
address indexed _owner,
uint256 indexed _tokenId,
uint256 amount,
uint256 _ts
);
UnlockPermanent
event UnlockPermanent(
address indexed _owner,
uint256 indexed _tokenId,
uint256 amount,
uint256 _ts
);
Supply
event Supply(uint256 prevSupply, uint256 supply);
Merge
event Merge(
address indexed _sender,
uint256 indexed _from,
uint256 indexed _to,
uint256 _amountFrom,
uint256 _amountTo,
uint256 _amountFinal,
uint256 _locktime,
uint256 _ts
);
Split
event Split(
uint256 indexed _from,
uint256 indexed _tokenId1,
uint256 indexed _tokenId2,
address _sender,
uint256 _splitAmount1,
uint256 _splitAmount2,
uint256 _locktime,
uint256 _ts
);
CreateManaged
event CreateManaged(
address indexed _to, uint256 indexed _mTokenId, address indexed _from
);
DepositManaged
event DepositManaged(
address indexed _owner,
uint256 indexed _tokenId,
uint256 indexed _mTokenId,
uint256 _weight,
uint256 _ts
);
WithdrawManaged
event WithdrawManaged(
address indexed _owner,
uint256 indexed _tokenId,
uint256 indexed _mTokenId,
uint256 _weight,
uint256 _ts
);
SetAllowedManager
event SetAllowedManager(address indexed _allowedManager);
ToggleSplit
event ToggleSplit(address indexed account, bool indexed canSplit);
VoterAndDistributorSet
event VoterAndDistributorSet(
address indexed voter, address indexed distributor
);
Errors
AlreadyVoted
error AlreadyVoted();
AmountTooBig
error AmountTooBig();
ERC721ReceiverRejectedTokens
error ERC721ReceiverRejectedTokens();
ERC721TransferToNonERC721ReceiverImplementer
error ERC721TransferToNonERC721ReceiverImplementer();
InvalidNonce
error InvalidNonce();
InvalidSignature
error InvalidSignature();
InvalidSignatureS
error InvalidSignatureS();
InvalidManagedNFTId
error InvalidManagedNFTId();
LockDurationNotInFuture
error LockDurationNotInFuture();
LockDurationTooLong
error LockDurationTooLong();
LockExpired
error LockExpired();
LockNotExpired
error LockNotExpired();
NoLockFound
error NoLockFound();
NonExistentToken
error NonExistentToken();
NotApprovedOrOwner
error NotApprovedOrOwner();
NotDistributor
error NotDistributor();
NotEmergencyCouncilOrGovernor
error NotEmergencyCouncilOrGovernor();
NotGovernor
error NotGovernor();
NotGovernorOrManager
error NotGovernorOrManager();
NotManagedNFT
error NotManagedNFT();
NotManagedOrNormalNFT
error NotManagedOrNormalNFT();
NotLockedNFT
error NotLockedNFT();
NotNormalNFT
error NotNormalNFT();
NotPermanentLock
error NotPermanentLock();
NotOwner
error NotOwner();
NotTeam
error NotTeam();
NotVoter
error NotVoter();
OwnershipChange
error OwnershipChange();
PermanentLock
error PermanentLock();
SameAddress
error SameAddress();
SameNFT
error SameNFT();
SameState
error SameState();
SplitNoOwner
error SplitNoOwner();
SplitNotAllowed
error SplitNotAllowed();
SignatureExpired
error SignatureExpired();
TooManyTokenIDs
error TooManyTokenIDs();
ZeroAddress
error ZeroAddress();
ZeroAmount
error ZeroAmount();
ZeroBalance
error ZeroBalance();
Structs
LockedBalance
Represents a locked token balance in the voting escrow system
struct LockedBalance {
int128 amount;
uint256 end;
bool isPermanent;
}
Properties
| Name | Type | Description |
|---|---|---|
amount | int128 | The amount of tokens locked by the user |
end | uint256 | The expiration timestamp for the lock |
isPermanent | bool | Flag indicating if the lock is permanent |
UserPoint
Represents a snapshot of a user's voting power at a given point
struct UserPoint {
int128 bias;
int128 slope;
uint256 ts;
uint256 blk;
uint256 permanent;
}
Properties
| Name | Type | Description |
|---|---|---|
bias | int128 | Voting power, decaying over time |
slope | int128 | Rate of decay of voting power |
ts | uint256 | Timestamp of this snapshot |
blk | uint256 | Block number of this snapshot |
permanent | uint256 | Amount locked permanently without decay |
GlobalPoint
Tracks cumulative voting power and its decay across all users
struct GlobalPoint {
int128 bias;
int128 slope;
uint256 ts;
uint256 blk;
uint256 permanentLockBalance;
}
Properties
| Name | Type | Description |
|---|---|---|
bias | int128 | Total voting power, decaying over time |
slope | int128 | Global decay rate of voting power |
ts | uint256 | Timestamp of this global checkpoint |
blk | uint256 | Block number of this global checkpoint |
permanentLockBalance | uint256 | Cumulative balance of permanently locked tokens |
Checkpoint
Snapshot of delegated voting weights at a particular timestamp
struct Checkpoint {
uint256 fromTimestamp;
address owner;
uint256 delegatedBalance;
uint256 delegatee;
}
Properties
| Name | Type | Description |
|---|---|---|
fromTimestamp | uint256 | Timestamp when the delegation was made |
owner | address | Address of the NFT owner |
delegatedBalance | uint256 | Balance that has been delegated |
delegatee | uint256 | Address receiving the delegated voting power |
Enums
DepositType
Types of deposits supported in the voting escrow contract
enum DepositType {
DEPOSIT_FOR_TYPE,
CREATE_LOCK_TYPE,
INCREASE_LOCK_AMOUNT,
INCREASE_UNLOCK_TIME
}
EscrowType
Specifies the type of voting escrow NFT (veNFT)
enum EscrowType {
NORMAL,
LOCKED,
MANAGED
}
Contents
BalanceLogicLibrary
State Variables
WEEK
uint256 internal constant WEEK = 1 weeks;
Functions
getPastUserPointIndex
Binary search to get the user point index for a token id at or prior to a given timestamp
If a user point does not exist prior to the timestamp, this will return 0.
function getPastUserPointIndex(
mapping(uint256 => uint256) storage _userPointEpoch,
mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage
_userPointHistory,
uint256 _tokenId,
uint256 _timestamp
) internal view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_userPointEpoch | mapping(uint256 => uint256) | State of all user point epochs |
_userPointHistory | mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) | State of all user point history |
_tokenId | uint256 | . |
_timestamp | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | User point index |
getPastGlobalPointIndex
Binary search to get the global point index at or prior to a given timestamp
If a checkpoint does not exist prior to the timestamp, this will return 0.
function getPastGlobalPointIndex(
uint256 _epoch,
mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,
uint256 _timestamp
) internal view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_epoch | uint256 | Current global point epoch |
_pointHistory | mapping(uint256 => IVotingEscrow.GlobalPoint) | State of all global point history |
_timestamp | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Global point index |
balanceOfNFTAt
Get the current voting power for _tokenId
Adheres to the ERC20 balanceOf interface for Aragon compatibility
Although only true of curve, but not solidly and its forks.
Fetches last user point prior to a certain timestamp, then walks forward to timestamp.
function balanceOfNFTAt(
mapping(uint256 => uint256) storage _userPointEpoch,
mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) storage
_userPointHistory,
uint256 _tokenId,
uint256 _t
) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_userPointEpoch | mapping(uint256 => uint256) | State of all user point epochs |
_userPointHistory | mapping(uint256 => IVotingEscrow.UserPoint[1000000000]) | State of all user point history |
_tokenId | uint256 | NFT for lock |
_t | uint256 | Epoch time to return voting power at |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | User voting power |
supplyAt
Calculate total voting power at some point in the past
function supplyAt(
mapping(uint256 => int128) storage _slopeChanges,
mapping(uint256 => IVotingEscrow.GlobalPoint) storage _pointHistory,
uint256 _epoch,
uint256 _t
) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_slopeChanges | mapping(uint256 => int128) | State of all slopeChanges |
_pointHistory | mapping(uint256 => IVotingEscrow.GlobalPoint) | State of all global point history |
_epoch | uint256 | The epoch to start search from |
_t | uint256 | Time to calculate the total voting power at |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total voting power at that time |
DelegationLogicLibrary
Functions
checkpointDelegator
Used by _mint, _transferFrom, _burn and delegate
to update delegator voting checkpoints.
Automatically dedelegates, then updates checkpoint.
This function depends on _locked and must be called prior to token state changes.
If you wish to dedelegate only, use _delegate(tokenId, 0) instead.
function checkpointDelegator(
mapping(uint256 => IVotingEscrow.LockedBalance) storage _locked,
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
mapping(uint256 => uint256) storage _delegates,
uint256 _delegator,
uint256 _delegatee,
address _owner
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_locked | mapping(uint256 => IVotingEscrow.LockedBalance) | State of all locked balances |
_numCheckpoints | mapping(uint256 => uint48) | State of all user checkpoint counts |
_checkpoints | mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) | State of all user checkpoints |
_delegates | mapping(uint256 => uint256) | State of all user delegatees |
_delegator | uint256 | The delegator to update checkpoints for |
_delegatee | uint256 | The new delegatee for the delegator. Cannot be equal to _delegator (use 0 instead). |
_owner | address | The new (or current) owner for the delegator |
checkpointDelegatee
Update delegatee's delegatedBalance by balance.
Only updates if delegating to a new delegatee.
If used with balance == _locked[_tokenId].amount, then this is the same as
delegating or dedelegating from _tokenId
If used with balance < _locked[_tokenId].amount, then this is used to adjust
delegatedBalance when a user's balance is modified (e.g. increaseAmount, merge etc).
If delegatee is 0 (i.e. user is not delegating), then do nothing.
function checkpointDelegatee(
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
uint256 _delegatee,
uint256 balance_,
bool _increase
) public;
Parameters
| Name | Type | Description |
|---|---|---|
_numCheckpoints | mapping(uint256 => uint48) | State of all user checkpoint counts |
_checkpoints | mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) | State of all user checkpoints |
_delegatee | uint256 | The delegatee's tokenId |
balance_ | uint256 | The delta in balance change |
_increase | bool | True if balance is increasing, false if decreasing |
_isCheckpointInNewBlock
function _isCheckpointInNewBlock(
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
uint256 _tokenId
) internal view returns (bool);
getPastVotesIndex
Binary search to get the voting checkpoint for a token id at or prior to a given timestamp.
If a checkpoint does not exist prior to the timestamp, this will return 0.
function getPastVotesIndex(
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
uint256 _tokenId,
uint256 _timestamp
) internal view returns (uint48);
Parameters
| Name | Type | Description |
|---|---|---|
_numCheckpoints | mapping(uint256 => uint48) | State of all user checkpoint counts |
_checkpoints | mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) | State of all user checkpoints |
_tokenId | uint256 | . |
_timestamp | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint48 | The index of the checkpoint. |
getPastVotes
Retrieves historical voting balance for a token id at a given timestamp.
If a checkpoint does not exist prior to the timestamp, this will return 0. The user must also own the token at the time in order to receive a voting balance.
function getPastVotes(
mapping(uint256 => uint48) storage _numCheckpoints,
mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) storage
_checkpoints,
address _account,
uint256 _tokenId,
uint256 _timestamp
) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_numCheckpoints | mapping(uint256 => uint48) | State of all user checkpoint counts |
_checkpoints | mapping(uint256 => mapping(uint48 => IVotingEscrow.Checkpoint)) | State of all user checkpoints |
_account | address | . |
_tokenId | uint256 | . |
_timestamp | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total voting balance including delegations at a given timestamp. |
VelodromeTimeLibrary
State Variables
WEEK
uint256 internal constant WEEK = 7 days;
Functions
epochStart
Calculate the start of the current epoch based on the timestamp provided
Epochs are aligned to weekly intervals, with each epoch starting at midnight UTC.
function epochStart(uint256 timestamp) internal pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | The current timestamp to align |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The start timestamp of the epoch week |
epochNext
Calculate the start of the next epoch or end of the current epoch
Returns the timestamp at the start of the next weekly epoch following the given timestamp.
function epochNext(uint256 timestamp) internal pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | The current timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The start timestamp of the next epoch |
epochVoteStart
Determine the start of the voting window for the current epoch
Voting windows start one hour into the weekly epoch.
function epochVoteStart(uint256 timestamp) internal pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | The timestamp to calculate from |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The start timestamp of the voting window within the epoch |
epochVoteEnd
Calculate the end of the voting window within the current epoch
Voting windows close one hour before the next epoch begins.
function epochVoteEnd(uint256 timestamp) internal pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | The timestamp to calculate from |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The end timestamp of the voting window within the epoch |
Contents
BribeVotingReward
Inherits: VotingReward
Implementation of voting rewards for bribes based on user votes
Final implementation of voting rewards specifically for bribe distribution
Functions
constructor
Initializes bribe voting rewards
constructor(address _voter, address[] memory _rewards)
VotingReward(_voter, _rewards);
Parameters
| Name | Type | Description |
|---|---|---|
_voter | address | Address of voter contract |
_rewards | address[] | Initial array of reward token addresses |
notifyRewardAmount
Validates and whitelists reward tokens before processing
function notifyRewardAmount(address token, uint256 amount)
external
override
nonReentrant;
removeNoLongerWhitelistedTokens
Removes tokens from the rewards list that are no longer whitelisted
function removeNoLongerWhitelistedTokens(address[] calldata tokens) external;
Parameters
| Name | Type | Description |
|---|---|---|
tokens | address[] | The list of tokens to remove |
Events
NoLongerWhitelistedTokenRemoved
event NoLongerWhitelistedTokenRemoved(address indexed token);
Reward
Inherits: IReward, ReentrancyGuard
Author: velodrome.finance, @figs999, @pegahcarter
Base implementation for reward distribution contracts
Abstract contract providing core reward distribution functionality
State Variables
DURATION
Duration of each reward epoch in seconds
uint256 public constant DURATION = 7 days;
voter
Address of the Voter contract that manages rewards
address public immutable voter;
ve
Address of the VotingEscrow contract that manages veNFTs
address public immutable ve;
authorized
Address permitted to call privileged state-changing functions
address public immutable authorized;
totalSupply
Total amount of staking tokens locked in contract
uint256 public totalSupply;
supplyNumCheckpoints
Total number of supply checkpoints recorded
uint256 public supplyNumCheckpoints;
rewards
List of all reward tokens supported by this contract
Used for token enumeration and management
address[] public rewards;
balanceOf
Retrieves current staked balance for a veNFT
mapping(uint256 => uint256) public balanceOf;
tokenRewardsPerEpoch
Gets reward amount allocated for a specific epoch
mapping(address => mapping(uint256 => uint256)) public tokenRewardsPerEpoch;
lastEarn
Retrieves timestamp of last reward claim for a veNFT
mapping(address => mapping(uint256 => uint256)) public lastEarn;
isReward
Checks if a token is configured as a reward token
mapping(address => bool) public isReward;
checkpoints
A record of balance checkpoints for each account, by index
mapping(uint256 => mapping(uint256 => Checkpoint)) public checkpoints;
numCheckpoints
Number of balance checkpoints for a veNFT
mapping(uint256 => uint256) public numCheckpoints;
supplyCheckpoints
A record of balance checkpoints for each token, by index
mapping(uint256 => SupplyCheckpoint) public supplyCheckpoints;
Functions
constructor
Initializes reward contract with voter address
constructor(address _voter);
Parameters
| Name | Type | Description |
|---|---|---|
_voter | address | Address of voter contract managing rewards |
getPriorBalanceIndex
Gets historical balance index for a veNFT at timestamp
Uses binary search to find checkpoint index
function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp)
public
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | ID of veNFT to query |
timestamp | uint256 | Time to query balance at |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Index of nearest checkpoint before timestamp |
getPriorSupplyIndex
Gets historical supply index at timestamp
Uses binary search to find checkpoint index
function getPriorSupplyIndex(uint256 timestamp) public view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | Time to query supply at |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Index of nearest checkpoint before timestamp |
_writeCheckpoint
Writes user checkpoint with updated balance
Updates or creates checkpoint based on epoch timing
function _writeCheckpoint(uint256 tokenId, uint256 balance) internal;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | ID of veNFT to checkpoint |
balance | uint256 | New balance to record |
_writeSupplyCheckpoint
Writes global supply checkpoint
Updates or creates checkpoint based on epoch timing
function _writeSupplyCheckpoint() internal;
rewardsListLength
Number of tokens configured for rewards
function rewardsListLength() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Length of rewards token list |
earned
Calculates unclaimed rewards for a veNFT
function earned(address token, uint256 tokenId) public view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of reward token to calculate |
tokenId | uint256 | ID of veNFT to calculate for |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Amount of unclaimed rewards |
_deposit
Records a token deposit and updates checkpoints
Can only be called by authorized address
function _deposit(uint256 amount, uint256 tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | Amount of tokens being deposited |
tokenId | uint256 | ID of veNFT receiving deposit |
_withdraw
Records a token withdrawal and updates checkpoints
Can only be called by authorized address
function _withdraw(uint256 amount, uint256 tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
amount | uint256 | Amount of tokens being withdrawn |
tokenId | uint256 | ID of veNFT withdrawing from |
getReward
Claims accumulated rewards for a veNFT
function getReward(uint256 tokenId, address[] memory tokens)
external
virtual
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | ID of veNFT claiming rewards |
tokens | address[] | Array of reward token addresses to claim |
_getReward
Internal helper for processing reward claims
Calculates and transfers earned rewards to recipient
function _getReward(address recipient, uint256 tokenId, address[] memory tokens)
internal;
Parameters
| Name | Type | Description |
|---|---|---|
recipient | address | Address to receive claimed rewards |
tokenId | uint256 | ID of veNFT claiming rewards |
tokens | address[] | Array of reward tokens to claim |
notifyRewardAmount
Adds new reward tokens for distribution
Transfers tokens from caller and updates reward accounting
function notifyRewardAmount(address token, uint256 amount)
external
virtual
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
token | address | Address of token to add as reward |
amount | uint256 | Amount of token to add to rewards |
renotifyRewardAmount
in case rewards where distributed during a epoch with no deposits, redistribute the rewards
function renotifyRewardAmount(uint256 timestamp, address token) external;
Parameters
| Name | Type | Description |
|---|---|---|
timestamp | uint256 | Timestamp of the start of the epoch to renotify |
token | address | Address of token to renotify |
_notifyRewardAmount
Internal helper for adding rewards
Transfers tokens and updates reward accounting
function _notifyRewardAmount(address sender, address token, uint256 amount)
internal;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | Address providing reward tokens |
token | address | Address of reward token |
amount | uint256 | Amount of tokens to add as rewards |
VotingReward
Inherits: Reward
Base contract for rewards distributed based on voting power
Extends Reward with voting-specific reward logic
Functions
constructor
Configures voting rewards with initial reward tokens
constructor(address _voter, address[] memory _rewards) Reward(_voter);
Parameters
| Name | Type | Description |
|---|---|---|
_voter | address | Address of voter contract |
_rewards | address[] | Initial array of reward token addresses |
getReward
Validates caller is token owner or voter before processing claim
function getReward(uint256 tokenId, address[] memory tokens)
external
override
nonReentrant;
notifyRewardAmount
function notifyRewardAmount(address token, uint256 amount)
external
virtual
override
nonReentrant;
Voter
Inherits: IVoter, InfraredUpgradeable, ReentrancyGuardUpgradeable
Author: Modified from Velodrome (https://github.com/velodrome-finance/contracts/blob/main/contracts/Voter.sol)
Ensure new epoch before voting and manage staking tokens and bribe vaults.
This contract manages votes for POL CuttingBoard allocation and respective bribeVault creation. It also provides support for depositing and withdrawing from managed veNFTs. Inspired by Velodrome V2 Voter.
State Variables
ve
Returns the VotingEscrow contract address
address public ve;
totalWeight
Returns total voting weight across all votes
uint256 public totalWeight;
maxVotingNum
Returns maximum number of staking tokens one voter can vote for
uint256 public maxVotingNum;
MIN_MAXVOTINGNUM
Minimum allowed value for maximum voting number
Used as validation threshold in setMaxVotingNum
uint256 internal constant MIN_MAXVOTINGNUM = 1;
feeVault
Returns global fee distribution vault address
address public feeVault;
stakingTokens
Internal array of all staking tokens with active bribe vaults Used for token enumeration and state tracking
address[] public stakingTokens;
bribeVaults
Returns bribe vault address for a given staking token
mapping(address => address) public bribeVaults;
weights
Returns total weight allocated to a staking token
mapping(address => uint256) public weights;
votes
Returns vote weight allocated by token ID for specific staking token
mapping(uint256 => mapping(address => uint256)) public votes;
stakingTokenVote
NFT => List of stakingTokens voted for by NFT
mapping(uint256 => address[]) public stakingTokenVote;
usedWeights
Returns total vote weight used by specific token ID
mapping(uint256 => uint256) public usedWeights;
lastVoted
Returns timestamp of last vote for a token ID
mapping(uint256 => uint256) public lastVoted;
isWhitelistedNFT
Checks if NFT is whitelisted for special voting
mapping(uint256 => bool) public isWhitelistedNFT;
isAlive
Checks if bribe vault is active
mapping(address => bool) public isAlive;
__gap
Reserve storage slots for future upgrades for safety
uint256[40] private __gap;
Functions
onlyNewEpoch
Ensures operations only occur in new epochs and outside distribution window
Validates both epoch transition and proper timing within epoch
modifier onlyNewEpoch(uint256 _tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | The token ID to check last vote timestamp for |
epochStart
Calculates start of epoch containing timestamp
function epochStart(uint256 _timestamp) external pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Start of epoch time |
epochNext
Calculates start of next epoch after timestamp
function epochNext(uint256 _timestamp) external pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Start of next epoch time |
epochVoteStart
Calculates start of voting window for epoch containing timestamp
function epochVoteStart(uint256 _timestamp) external pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Vote window start time |
epochVoteEnd
Calculates end of voting window for epoch containing timestamp
function epochVoteEnd(uint256 _timestamp) external pure returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 | Input timestamp |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Vote window end time |
initialize
Initializes the Voter contract with the voting escrow and fee vault
Sets up initial state including fee vault with configured reward tokens
function initialize(
address _infrared,
address _ve,
address _gov,
address _keeper
) external initializer;
Parameters
| Name | Type | Description |
|---|---|---|
_infrared | address | Address of the Infrared contract |
_ve | address | Address of the voting escrow contract |
_gov | address | Address of the governance multisig |
_keeper | address | Address of the keeper |
setMaxVotingNum
Updates maximum allowed votes per voter
function setMaxVotingNum(uint256 _maxVotingNum) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_maxVotingNum | uint256 | New maximum number of allowed votes |
reset
Resets voting state for a token ID
Required before making changes to veNFT state
function reset(uint256 _tokenId) external onlyNewEpoch(_tokenId) nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to reset |
_reset
Resets vote state for a token ID
Cleans up all vote accounting and emits appropriate events
function _reset(uint256 _tokenId) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | Token ID to reset voting state for |
poke
Updates voting balances in rewards contracts for a token ID
Should be called after any action that affects vote weight
function poke(uint256 _tokenId) external nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to update |
_poke
Updates voting power for a token ID
Recalculates and updates all vote weightings
function _poke(uint256 _tokenId, uint256 _weight) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | Token ID to update voting power for |
_weight | uint256 | New voting power weight to apply |
_vote
Core voting logic to allocate weights to staking tokens
Handles vote accounting, reward deposits and event emissions
*Implementation sequence:
- Reset all existing votes and accounting via _reset
- Calculate total vote weight for normalizing allocations
- For each staking token:
- Validate bribe vault exists and is active
- Calculate and apply normalized vote weight
- Update token-specific accounting
- Deposit into bribe vault
- Update global vote accounting if votes were cast
- If _isPoke is true, skip processing for tokens with killed bribe vaults*
function _vote(
uint256 _tokenId,
uint256 _weight,
address[] memory _stakingTokenVote,
uint256[] memory _weights,
bool _isPoke
) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | Token ID that is voting |
_weight | uint256 | Total voting power weight available |
_stakingTokenVote | address[] | Array of staking tokens to vote for |
_weights | uint256[] | Array of weights to allocate to each token |
_isPoke | bool | if fees should be deposited in addition to marking tokenId as voted |
vote
Distributes voting weight to multiple staking tokens
Weight is allocated proportionally based on provided weights
function vote(
uint256 _tokenId,
address[] calldata _stakingTokenVote,
uint256[] calldata _weights
) external onlyNewEpoch(_tokenId) nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID voting with |
_stakingTokenVote | address[] | Array of staking token addresses receiving votes |
_weights | uint256[] | Array of weights to allocate to each token |
depositManaged
Deposits veNFT into a managed NFT
NFT will be re-locked to max time on withdrawal
function depositManaged(uint256 _tokenId, uint256 _mTokenId)
external
nonReentrant
onlyNewEpoch(_tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to deposit |
_mTokenId | uint256 | Managed NFT token ID to deposit into |
withdrawManaged
Withdraws veNFT from a managed NFT
Withdrawing locks NFT to max lock time
function withdrawManaged(uint256 _tokenId)
external
nonReentrant
onlyNewEpoch(_tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to withdraw |
isWhitelistedToken
Checks if a token is whitelisted for rewards
function isWhitelistedToken(address _token) external view returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_token | address |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if token is whitelisted |
whitelistNFT
Updates whitelist status for veNFT for privileged voting
function whitelistNFT(uint256 _tokenId, bool _bool) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | veNFT token ID to update |
_bool | bool | New whitelist status |
createBribeVault
Creates new bribe vault for staking token
function createBribeVault(address _stakingToken, address[] calldata _rewards)
external
onlyKeeper
nonReentrant
whenInitialized
returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
_stakingToken | address | Address of staking token |
_rewards | address[] |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | Address of created bribe vault |
killBribeVault
Disables a bribe vault
function killBribeVault(address _stakingToken) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_stakingToken | address | Address of staking token for vault to disable |
reviveBribeVault
Re-enables a disabled bribe vault
function reviveBribeVault(address _stakingToken) external onlyGovernor;
Parameters
| Name | Type | Description |
|---|---|---|
_stakingToken | address | Address of staking token for vault to re-enable |
length
Returns number of staking tokens with active bribe vaults
function length() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Count of staking tokens with bribe vaults |
claimBribes
Claims bribes from multiple sources for a veNFT
function claimBribes(
address[] memory _bribes,
address[][] memory _tokens,
uint256 _tokenId
) external;
Parameters
| Name | Type | Description |
|---|---|---|
_bribes | address[] | Array of bribe vault addresses to claim from |
_tokens | address[][] | Array of reward tokens to claim for each vault |
_tokenId | uint256 | veNFT token ID to claim for |
claimFees
Claims fee rewards for a veNFT
function claimFees(address[] memory _tokens, uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokens | address[] | Array of fee tokens to claim |
_tokenId | uint256 | veNFT token ID to claim for |
getStakingTokenWeights
Returns all staking tokens and their current voting weights
Helper function that aggregates staking token data
function getStakingTokenWeights()
public
view
returns (
address[] memory _stakingTokens,
uint256[] memory _weights,
uint256 _totalWeight
);
Returns
| Name | Type | Description |
|---|---|---|
_stakingTokens | address[] | Array of staking token addresses |
_weights | uint256[] | Array of voting weights corresponding to each token |
_totalWeight | uint256 | Sum of all voting weights |
VotingEscrow
Inherits: IVotingEscrow, ReentrancyGuard
Authors: Modified from Solidly (https://github.com/solidlyexchange/solidly/blob/master/contracts/ve.sol), Modified from Curve (https://github.com/curvefi/curve-dao-contracts/blob/master/contracts/VotingEscrow.vy), Modified from velodrome.finance (https://github.com/velodrome-finance/contracts/blob/main/contracts/VotingEscrow.sol)
veNFT implementation that escrows ERC-20 tokens in the form of an ERC-721 NFT
Votes have a weight depending on time, so that users are committed to the future of (whatever they are voting for)
Vote weight decays linearly over time. Lock time cannot be more than MAXTIME (4 years).
State Variables
keeper
address public immutable keeper;
token
Address of token (IR) used to create a veNFT
address public immutable token;
distributor
Address of RewardsDistributor.sol
address public distributor;
voter
Address of Voter.sol
address public voter;
artProxy
Address of art proxy used for on-chain art generation
address public artProxy;
allowedManager
address which can create managed NFTs
address public allowedManager;
_pointHistory
mapping(uint256 => GlobalPoint) internal _pointHistory;
supportedInterfaces
Mapping of interface id to bool about whether or not it's supported
mapping(bytes4 => bool) internal supportedInterfaces;
ERC165_INTERFACE_ID
ERC165 interface ID of ERC165
bytes4 internal constant ERC165_INTERFACE_ID = 0x01ffc9a7;
ERC721_INTERFACE_ID
ERC165 interface ID of ERC721
bytes4 internal constant ERC721_INTERFACE_ID = 0x80ac58cd;
ERC721_METADATA_INTERFACE_ID
ERC165 interface ID of ERC721Metadata
bytes4 internal constant ERC721_METADATA_INTERFACE_ID = 0x5b5e139f;
ERC4906_INTERFACE_ID
ERC165 interface ID of ERC4906
bytes4 internal constant ERC4906_INTERFACE_ID = 0x49064906;
ERC6372_INTERFACE_ID
ERC165 interface ID of ERC6372
bytes4 internal constant ERC6372_INTERFACE_ID = 0xda287a1d;
tokenId
Current count of token
uint256 public tokenId;
infrared
Address of Infrared contract
IInfraredUpgradeable public immutable infrared;
escrowType
Mapping of token id to escrow type Takes advantage of the fact default value is EscrowType.NORMAL
mapping(uint256 => EscrowType) public escrowType;
idToManaged
Mapping of token id to managed id
mapping(uint256 => uint256) public idToManaged;
weights
Mapping of user token id to managed token id to weight of token id
mapping(uint256 => mapping(uint256 => uint256)) public weights;
deactivated
Mapping of managed id to deactivated state
mapping(uint256 => bool) public deactivated;
name
string public constant name = "veNFT";
symbol
string public constant symbol = "veNFT";
version
string public constant version = "2.0.0";
decimals
uint8 public constant decimals = 18;
idToOwner
Mapping from NFT ID to the address that owns it.
mapping(uint256 => address) internal idToOwner;
ownerToNFTokenCount
Mapping from owner address to count of his tokens.
mapping(address => uint256) internal ownerToNFTokenCount;
idToApprovals
Mapping from NFT ID to approved address.
mapping(uint256 => address) internal idToApprovals;
ownerToOperators
Mapping from owner address to mapping of operator addresses.
mapping(address => mapping(address => bool)) internal ownerToOperators;
ownershipChange
mapping(uint256 => uint256) internal ownershipChange;
ownerToNFTokenIdList
Mapping from owner address to mapping of index to tokenId
mapping(address => mapping(uint256 => uint256)) public ownerToNFTokenIdList;
tokenToOwnerIndex
Mapping from NFT ID to index of owner
mapping(uint256 => uint256) internal tokenToOwnerIndex;
WEEK
uint256 internal constant WEEK = 1 weeks;
MAXTIME
uint256 internal constant MAXTIME = 4 * 365 * 86400;
iMAXTIME
int128 internal constant iMAXTIME = 4 * 365 * 86400;
MULTIPLIER
uint256 internal constant MULTIPLIER = 1 ether;
epoch
Total count of epochs witnessed since contract creation
uint256 public epoch;
supply
Total amount of token() deposited
uint256 public supply;
_locked
mapping(uint256 => LockedBalance) internal _locked;
_userPointHistory
mapping(uint256 => UserPoint[1000000000]) internal _userPointHistory;
userPointEpoch
mapping(uint256 => uint256) public userPointEpoch;
slopeChanges
time -> signed slope change
mapping(uint256 => int128) public slopeChanges;
canSplit
account -> can split
mapping(address => bool) public canSplit;
permanentLockBalance
Aggregate permanent locked balances
uint256 public permanentLockBalance;
voted
See if a queried _tokenId has actively voted
mapping(uint256 => bool) public voted;
DOMAIN_TYPEHASH
The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
DELEGATION_TYPEHASH
The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256(
"Delegation(uint256 delegator,uint256 delegatee,uint256 nonce,uint256 expiry)"
);
_delegates
A record of each accounts delegate
mapping(uint256 => uint256) private _delegates;
_checkpoints
A record of delegated token checkpoints for each tokenId, by index
mapping(uint256 => mapping(uint48 => Checkpoint)) private _checkpoints;
numCheckpoints
The number of checkpoints for each tokenId
mapping(uint256 => uint48) public numCheckpoints;
nonces
A record of states for signing / validating signatures
mapping(address => uint256) public nonces;
Functions
constructor
Initializes VotingEscrow contract
constructor(address _keeper, address _token, address _voter, address _infrared);
Parameters
| Name | Type | Description |
|---|---|---|
_keeper | address | Address of keeper contract |
_token | address | Address of token (IR) used to create a veNFT |
_voter | address | Address of Voter contract |
_infrared | address | Address of Infrared contract |
createManagedLockFor
Create managed NFT (a permanent lock) for use within ecosystem.
Throws if address already owns a managed NFT.
function createManagedLockFor(address _to)
external
nonReentrant
returns (uint256 _mTokenId);
Returns
| Name | Type | Description |
|---|---|---|
_mTokenId | uint256 | managed token id. |
depositManaged
Delegates balance to managed nft Note that NFTs deposited into a managed NFT will be re-locked to the maximum lock time on withdrawal. Permanent locks that are deposited will automatically unlock.
Managed nft will remain max-locked as long as there is at least one deposit or withdrawal per week. Throws if deposit nft is managed. Throws if recipient nft is not managed. Throws if deposit nft is already locked. Throws if not called by voter.
function depositManaged(uint256 _tokenId, uint256 _mTokenId)
external
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | tokenId of NFT being deposited |
_mTokenId | uint256 | tokenId of managed NFT that will receive the deposit |
withdrawManaged
Retrieves locked rewards and withdraws balance from managed nft. Note that the NFT withdrawn is re-locked to the maximum lock time.
Throws if NFT not locked. Throws if not called by voter.
function withdrawManaged(uint256 _tokenId) external nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | tokenId of NFT being deposited. |
setAllowedManager
Permit one address to call createManagedLockFor() that is not Voter.governor()
function setAllowedManager(address _allowedManager) external;
setManagedState
Set Managed NFT state. Inactive NFTs cannot be deposited into.
function setManagedState(uint256 _mTokenId, bool _state) external;
Parameters
| Name | Type | Description |
|---|---|---|
_mTokenId | uint256 | managed nft state to set |
_state | bool | true => inactive, false => active |
setArtProxy
function setArtProxy(address _proxy) external;
tokenURI
function tokenURI(uint256 _tokenId) external view returns (string memory);
_ownerOf
function _ownerOf(uint256 _tokenId) internal view returns (address);
ownerOf
function ownerOf(uint256 _tokenId) external view returns (address);
balanceOf
function balanceOf(address _owner) external view returns (uint256);
getApproved
function getApproved(uint256 _tokenId) external view returns (address);
isApprovedForAll
function isApprovedForAll(address _owner, address _operator)
external
view
returns (bool);
isApprovedOrOwner
Check whether spender is owner or an approved user for a given veNFT
function isApprovedOrOwner(address _spender, uint256 _tokenId)
external
view
returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_spender | address | . |
_tokenId | uint256 | . |
_isApprovedOrOwner
function _isApprovedOrOwner(address _spender, uint256 _tokenId)
internal
view
returns (bool);
approve
function approve(address _approved, uint256 _tokenId) external;
setApprovalForAll
function setApprovalForAll(address _operator, bool _approved) external;
_transferFrom
function _transferFrom(
address _from,
address _to,
uint256 _tokenId,
address _sender
) internal;
transferFrom
function transferFrom(address _from, address _to, uint256 _tokenId) external;
safeTransferFrom
function safeTransferFrom(address _from, address _to, uint256 _tokenId)
external;
_isContract
function _isContract(address account) internal view returns (bool);
safeTransferFrom
function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes memory _data
) public;
supportsInterface
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
_addTokenToOwnerList
Add a NFT to an index mapping to a given address
function _addTokenToOwnerList(address _to, uint256 _tokenId) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | address of the receiver |
_tokenId | uint256 | uint ID Of the token to be added |
_addTokenTo
Add a NFT to a given address
Throws if _tokenId is owned by someone.
function _addTokenTo(address _to, uint256 _tokenId) internal;
_mint
Function to mint tokens
Throws if _to is zero address.
Throws if _tokenId is owned by someone.
function _mint(address _to, uint256 _tokenId) internal returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
_to | address | The address that will receive the minted tokens. |
_tokenId | uint256 | The token id to mint. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | A boolean that indicates if the operation was successful. |
_removeTokenFromOwnerList
Remove a NFT from an index mapping to a given address
function _removeTokenFromOwnerList(address _from, uint256 _tokenId) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_from | address | address of the sender |
_tokenId | uint256 | uint ID Of the token to be removed |
_removeTokenFrom
Remove a NFT from a given address
Throws if _from is not the current owner.
function _removeTokenFrom(address _from, uint256 _tokenId) internal;
_burn
Must be called prior to updating LockedBalance
function _burn(uint256 _tokenId) internal;
locked
Get the LockedBalance (amount, end) of a _tokenId
function locked(uint256 _tokenId)
external
view
returns (LockedBalance memory);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | LockedBalance | LockedBalance of _tokenId |
userPointHistory
User -> UserPoint[userEpoch]
function userPointHistory(uint256 _tokenId, uint256 _loc)
external
view
returns (UserPoint memory);
pointHistory
Global point history at a given index
function pointHistory(uint256 _loc)
external
view
returns (GlobalPoint memory);
_checkpoint
Record global and per-user data to checkpoints. Used by VotingEscrow system.
function _checkpoint(
uint256 _tokenId,
LockedBalance memory _oldLocked,
LockedBalance memory _newLocked
) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | NFT token ID. No user checkpoint if 0 |
_oldLocked | LockedBalance | Pevious locked amount / end lock time for the user |
_newLocked | LockedBalance | New locked amount / end lock time for the user |
_depositFor
Deposit and lock tokens for a user
function _depositFor(
uint256 _tokenId,
uint256 _value,
uint256 _unlockTime,
LockedBalance memory _oldLocked,
DepositType _depositType
) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | NFT that holds lock |
_value | uint256 | Amount to deposit |
_unlockTime | uint256 | New time when to unlock the tokens, or 0 if unchanged |
_oldLocked | LockedBalance | Previous locked amount / timestamp |
_depositType | DepositType | The type of deposit |
checkpoint
Record global data to checkpoint
function checkpoint() external nonReentrant;
depositFor
Deposit _value tokens for _tokenId and add to the lock
Anyone (even a smart contract) can deposit for someone else, but cannot extend their locktime and deposit for a brand new user
function depositFor(uint256 _tokenId, uint256 _value) external nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | lock NFT |
_value | uint256 | Amount to add to user's lock |
_createLock
Deposit _value tokens for _to and lock for _lockDuration
function _createLock(uint256 _value, uint256 _lockDuration, address _to)
internal
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
_to | address | Address to deposit |
createLock
Deposit _value tokens for msg.sender and lock for _lockDuration
function createLock(uint256 _value, uint256 _lockDuration)
external
nonReentrant
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | TokenId of created veNFT |
createLockFor
Deposit _value tokens for _to and lock for _lockDuration
function createLockFor(uint256 _value, uint256 _lockDuration, address _to)
external
nonReentrant
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_value | uint256 | Amount to deposit |
_lockDuration | uint256 | Number of seconds to lock tokens for (rounded down to nearest week) |
_to | address | Address to deposit |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | TokenId of created veNFT |
_increaseAmountFor
function _increaseAmountFor(
uint256 _tokenId,
uint256 _value,
DepositType _depositType
) internal;
increaseAmount
Deposit _value additional tokens for _tokenId without modifying the unlock time
function increaseAmount(uint256 _tokenId, uint256 _value)
external
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | |
_value | uint256 | Amount of tokens to deposit and add to the lock |
increaseUnlockTime
Extend the unlock time for _tokenId
Cannot extend lock time of permanent locks
function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration)
external
nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | |
_lockDuration | uint256 | New number of seconds until tokens unlock |
withdraw
Withdraw all tokens for _tokenId
Only possible if the lock is both expired and not permanent This will burn the veNFT. Any rebases or rewards that are unclaimed will no longer be claimable. Claim all rebases and rewards prior to calling this.
function withdraw(uint256 _tokenId) external nonReentrant;
merge
Merges _from into _to.
Cannot merge _from locks that are permanent or have already voted this epoch.
Cannot merge _to locks that have already expired.
This will burn the veNFT. Any rebases or rewards that are unclaimed
will no longer be claimable. Claim all rebases and rewards prior to calling this.
function merge(uint256 _from, uint256 _to) external nonReentrant;
Parameters
| Name | Type | Description |
|---|---|---|
_from | uint256 | VeNFT to merge from. |
_to | uint256 | VeNFT to merge into. |
split
Splits veNFT into two new veNFTS - one with oldLocked.amount - _amount, and the second with _amount
This burns the tokenId of the target veNFT
Callable by approved or owner
If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs
Returns the two new split veNFTs to owner
If from is permanent, will automatically dedelegate.
This will burn the veNFT. Any rebases or rewards that are unclaimed
will no longer be claimable. Claim all rebases and rewards prior to calling this.
function split(uint256 _from, uint256 _amount)
external
nonReentrant
returns (uint256 _tokenId1, uint256 _tokenId2);
Parameters
| Name | Type | Description |
|---|---|---|
_from | uint256 | VeNFT to split. |
_amount | uint256 | Amount to split from veNFT. |
Returns
| Name | Type | Description |
|---|---|---|
_tokenId1 | uint256 | Return tokenId of veNFT with oldLocked.amount - _amount. |
_tokenId2 | uint256 | Return tokenId of veNFT with _amount. |
_createSplitNFT
function _createSplitNFT(address _to, LockedBalance memory _newLocked)
private
returns (uint256 _tokenId);
toggleSplit
Toggle split for a specific address.
Toggle split for address(0) to enable or disable for all.
function toggleSplit(address _account, bool _bool) external;
Parameters
| Name | Type | Description |
|---|---|---|
_account | address | Address to toggle split permissions |
_bool | bool | True to allow, false to disallow |
lockPermanent
Permanently lock a veNFT. Voting power will be equal to
LockedBalance.amount with no decay. Required to delegate.
Only callable by unlocked normal veNFTs.
function lockPermanent(uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | tokenId to lock. |
unlockPermanent
Unlock a permanently locked veNFT. Voting power will decay. Will automatically dedelegate if delegated.
Only callable by permanently locked veNFTs. Cannot unlock if already voted this epoch.
function unlockPermanent(uint256 _tokenId) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | tokenId to unlock. |
_balanceOfNFTAt
function _balanceOfNFTAt(uint256 _tokenId, uint256 _t)
internal
view
returns (uint256);
_supplyAt
function _supplyAt(uint256 _timestamp) internal view returns (uint256);
balanceOfNFT
Get the voting power for _tokenId at the current timestamp
Returns 0 if called in the same block as a transfer.
function balanceOfNFT(uint256 _tokenId) public view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Voting power |
balanceOfNFTAt
Get the voting power for _tokenId at a given timestamp
function balanceOfNFTAt(uint256 _tokenId, uint256 _t)
external
view
returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
_t | uint256 | Timestamp to query voting power |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Voting power |
totalSupply
Calculate total voting power at current timestamp
function totalSupply() external view returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total voting power at current timestamp |
totalSupplyAt
Calculate total voting power at a given timestamp
function totalSupplyAt(uint256 _timestamp) external view returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
_timestamp | uint256 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | Total voting power at given timestamp |
setVoterAndDistributor
Set the global state voter and distributor
This is only called once, at setup
function setVoterAndDistributor(address _voter, address _distributor)
external;
voting
Set voted for _tokenId to true or false
Only callable by voter
function voting(uint256 _tokenId, bool _voted) external;
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | . |
_voted | bool | . |
delegates
function delegates(uint256 delegator) external view returns (uint256);
checkpoints
A record of delegated token checkpoints for each account, by index
function checkpoints(uint256 _tokenId, uint48 _index)
external
view
returns (Checkpoint memory);
Parameters
| Name | Type | Description |
|---|---|---|
_tokenId | uint256 | |
_index | uint48 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | Checkpoint | Checkpoint |
getPastVotes
function getPastVotes(address _account, uint256 _tokenId, uint256 _timestamp)
external
view
returns (uint256);
getPastTotalSupply
function getPastTotalSupply(uint256 _timestamp)
external
view
returns (uint256);
_checkpointDelegator
function _checkpointDelegator(
uint256 _delegator,
uint256 _delegatee,
address _owner
) internal;
_checkpointDelegatee
function _checkpointDelegatee(
uint256 _delegatee,
uint256 balance_,
bool _increase
) internal;
_delegate
Record user delegation checkpoints. Used by voting system.
Skips delegation if already delegated to delegatee.
function _delegate(uint256 _delegator, uint256 _delegatee) internal;
delegate
function delegate(uint256 delegator, uint256 delegatee) external;
delegateBySig
function delegateBySig(
uint256 delegator,
uint256 delegatee,
uint256 nonce,
uint256 expiry,
uint8 v,
bytes32 r,
bytes32 s
) external;
clock
function clock() external view returns (uint48);
CLOCK_MODE
function CLOCK_MODE() external pure returns (string memory);
