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