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:
newRequestsFinalisedUntil
exceedsrequestLength
.newRequestsFinalisedUntil
is 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:
requestId
exceedsrequestsFinalisedUntil
(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
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
requestId
exceedsrequestsFinalisedUntil
(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
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
}