InfraredBERA

Git Source

Inherits: ERC20Upgradeable, Upgradeable, IInfraredBERA

Infrared liquid staking token for BERA

Assumes BERA balances do not change at the CL

State Variables

withdrawalsEnabled

Flag to show whether withdrawals are currently enabled

bool public withdrawalsEnabled;

_initialized

Whether initial mint to address(this) has happened

bool private _initialized;

feeDivisorShareholders

Fee taken by the shareholders on yield from EL coinbase priority fees + MEV, represented as an integer denominator (1/x)%

uint16 public feeDivisorShareholders;

infrared

Address of the Infrared operator contract

address public infrared;

depositor

Address of the depositor that interacts with chain deposit precompile

address public depositor;

withdrawor

Address of the withdrawor that interacts with chain withdraw precompile

address public withdrawor;

receivor

Address of the fee receivor contract that receives tx priority fees + MEV on EL

address public receivor;

deposits

Deposits of BERA backing InfraredBERA intended for use in CL by validators

uint256 public deposits;

_stakes

mapping(bytes32 pubkeyHash => uint256 stake) internal _stakes;

_staked

mapping(bytes32 pubkeyHash => bool isStaked) internal _staked;

_exited

mapping(bytes32 pubkeyHash => bool hasExited) internal _exited;

_signatures

mapping(bytes32 pubkeyHash => bytes) internal _signatures;

Functions

initialize

Initializes InfraredBERA to allow for future mints and burns

Must be called before InfraredBERA can offer deposits and withdraws

function initialize(
    address _gov,
    address _keeper,
    address _infrared,
    address _depositor,
    address _withdrawor,
    address _receivor
) external payable initializer;

setWithdrawalsEnabled

function setWithdrawalsEnabled(bool flag) external onlyGovernor;

_deposit

function _deposit(uint256 value)
    private
    returns (uint256 nonce, uint256 amount, uint256 fee);

_withdraw

function _withdraw(address receiver, uint256 amount, uint256 fee)
    private
    returns (uint256 nonce);

pending

Pending deposits yet to be forwarded to CL

function pending() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA yet to be deposited to CL

confirmed

Confirmed deposits sent to CL

function confirmed() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The amount of BERA confirmed to be deposited to CL

keeper

Returns whether given account is an InfraredBERA keeper

function keeper(address account) public view returns (bool);

Returns

NameTypeDescription
<none>boolWhether account is a keeper

governor

Returns whether given account is an InfraredBERA governor

function governor(address account) public view returns (bool);

Returns

NameTypeDescription
<none>boolWhether account is a governor

validator

Returns whether given pubkey is in Infrared validator set

function validator(bytes calldata pubkey) external view returns (bool);

Returns

NameTypeDescription
<none>boolWhether pubkey in Infrared validator set

compound

Compounds accumulated EL yield in fee receivor into deposits

Called internally at bof whenever InfraredBERA minted or burned

function compound() public;

sweep

Sweeps received funds in msg.value as yield into deposits

Fee receivor must call this function in its sweep function for autocompounding

function sweep() external payable;

mint

Mints ibera shares to receiver for bera paid in by sender

function mint(address receiver)
    public
    payable
    returns (uint256 nonce, uint256 shares);

Parameters

NameTypeDescription
receiveraddressAddress of the receiver of ibera

Returns

NameTypeDescription
nonceuint256The nonce issued to identify the credited bera funds for deposit
sharesuint256The amount of shares of ibera minted

burn

Burns ibera shares from sender for bera to ultimately be transferred to receiver on subsequent call to claim

Sender must pay withdraw precompile fee upfront

function burn(address receiver, uint256 shares)
    external
    payable
    returns (uint256 nonce, uint256 amount);

Parameters

NameTypeDescription
receiveraddressAddress of the receiver of future bera
sharesuint256The amount of shares of ibera burned

Returns

NameTypeDescription
nonceuint256The nonce issued to identify the owed bera funds for claim
amountuint256The amount of bera funds that will be available for claim

register

Registers update to BERA staked in validator with given pubkey at CL

Reverts if not called by depositor or withdrawor

function register(bytes calldata pubkey, int256 delta) external;

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator to update BERA stake for at CL
deltaint256The change in the amount of BERA staked/unstaked (+/-) at CL

setFeeDivisorShareholders

Sets the fee shareholders taken on yield from EL coinbase priority fees + MEV

function setFeeDivisorShareholders(uint16 to) external onlyGovernor;

Parameters

NameTypeDescription
touint16The new fee shareholders represented as an integer denominator (1/x)%

setDepositSignature

Sets the deposit signature to be used when depositing to pubkey

function setDepositSignature(bytes calldata pubkey, bytes calldata signature)
    external
    onlyGovernor;

Parameters

NameTypeDescription
pubkeybytesThe pubkey of the validator receiving the deposit
signaturebytesThe deposit signature to use for pubkey

collect

Collects yield from fee receivor and mints ibera shares to Infrared

Only Infrared can call this function

function collect() external returns (uint256 sharesMinted);

Returns

NameTypeDescription
sharesMinteduint256The amount of ibera shares minted

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, uint256 fee);

Parameters

NameTypeDescription
beraAmountuint256The amount of BERA to simulate depositing

Returns

NameTypeDescription
sharesuint256The amount of InfraredBERA shares that would be minted, returns 0 if the operation would fail
feeuint256The fee that would be charged for the mint operation

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

NameTypeDescription
shareAmountuint256

Returns

NameTypeDescription
beraAmountuint256The amount of BERA that would be received, returns 0 if the operation would fail
feeuint256The 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

NameTypeDescription
<none>uint256The 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

NameTypeDescription
<none>boolWhethere initial deposit has been staked to validator

hasExited

Checks if a validator has been force exited from the Consensus Layer

exited validators can no longer be deposited in.

function hasExited(bytes calldata pubkey) external view returns (bool);

Parameters

NameTypeDescription
pubkeybytesThe public key of the validator to check

Returns

NameTypeDescription
<none>boolbool True if the validator has been force exited, false otherwise

signatures

Returns the deposit signature to use for given pubkey

function signatures(bytes calldata pubkey)
    external
    view
    returns (bytes memory);

Returns

NameTypeDescription
<none>bytesThe deposit signature for pubkey