Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

IInfraredBERAWithdrawor

Git Source

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

NameTypeDescription
pubkeyHashbytes32keccak256 of public key for validator to get pending withdrawals for

Returns

NameTypeDescription
totaluint256Sum 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

NameTypeDescription
feeuint256The 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

NameTypeDescription
queuedAmountuint256The 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

NameTypeDescription
newRequestsFinalisedUntiluint256The 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

NameTypeDescription
receiveraddressThe address to receive withdrawn funds
amountuint256The amount of funds to withdraw

Returns

NameTypeDescription
nonceuint256The 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:

  • newRequestsFinalisedUntil exceeds requestLength.
  • newRequestsFinalisedUntil is less than or equal to requestsFinalisedUntil.
  • 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

NameTypeDescription
newRequestsFinalisedUntiluint256The highest requestId to finalize (inclusive).

claim

Claims a finalized withdrawal request for a user.

*Reverts if:

  • requestId exceeds requestsFinalisedUntil (not finalized).
  • Ticket is not in PROCESSED state or belongs to the depositor.*

Transitions the ticket to CLAIMED and transfers the amount to the receiver.

function claim(uint256 requestId) external;

Parameters

NameTypeDescription
requestIduint256The ID of the withdrawal request to claim.

claimBatch

Claims multiple finalized withdrawal requests in a single transaction.

*Reverts if:

  • Any requestId exceeds requestsFinalisedUntil (not finalized).
  • Any ticket is not in PROCESSED state 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

NameTypeDescription
requestIdsuint256[]An array of request IDs to claim.
receiveraddressrecipient address of all requestId's

Events

Queue

Emitted when a withdrawal is queued

event Queue(address indexed receiver, uint256 nonce, uint256 amount);

Parameters

NameTypeDescription
receiveraddressThe address that will receive the withdrawn BERA
nonceuint256The unique identifier for this withdrawal request
amountuint256The amount of BERA to be withdrawn

Execute

Emitted when a withdrawal is executed

event Execute(bytes pubkey, uint256 amount);

Parameters

NameTypeDescription
pubkeybytesThe validator's public key
amountuint256The amount of BERA withdrawn

Process

Emitted when a queue is processed

event Process(address indexed receiver, uint256 nonce, uint256 amount);

Parameters

NameTypeDescription
receiveraddressThe address receiving the withdrawn BERA
nonceuint256The nonce of the processed withdrawal
amountuint256The amount of BERA processed

ProcessRange

Emitted when a withdrawal request range is processed

event ProcessRange(uint256 startRequestId, uint256 finishRequestId);

Parameters

NameTypeDescription
startRequestIduint256First request processed
finishRequestIduint256Last request processed

Claimed

Emitted when a claim is processed

event Claimed(address indexed receiver, uint256 nonce, uint256 amount);

Parameters

NameTypeDescription
receiveraddressThe address receiving the withdrawn BERA
nonceuint256The nonce of the processed withdrawal
amountuint256The amount of BERA processed

Sweep

Emitted when funds are swept from a force-exited validator

event Sweep(address indexed receiver, uint256 amount);

Parameters

NameTypeDescription
receiveraddressThe address receiving the swept BERA
amountuint256The amount of BERA swept

MinActivationBalanceUpdated

Emitted when min activation balance is updated by governance

event MinActivationBalanceUpdated(uint256 newMinActivationBalance);

Parameters

NameTypeDescription
newMinActivationBalanceuint256New 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

NameTypeDescription
stateRequestStaterecords whether queued, processed or claimed
timestampuint88The block.timestamp at which the withdraw request was issued.
receiveraddressThe address of the receiver of the withdrawn BERA funds.
amountuint128The amount of BERA to be claimed by receiver.
accumulatedAmountuint128Running 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
}