Module queue

Source
Expand description

Chain-agnostic withdrawal queue types and pure logic functions.

This module provides data structures for pending withdrawals and pure functions for queue logic. Storage implementation is left to chain-specific executors (NEAR, Soroban, etc.).

Re-exports§

pub use crate::state::vault::MAX_PENDING;

Structs§

PendingWithdrawal
A pending withdrawal request in the queue.
PendingWithdrawals
QueueStatus
Aggregate status of the entire withdrawal queue.
WithdrawQueue
Withdrawal queue storage with FIFO ordering.
WithdrawalRequestStatus
Status information for a single withdrawal request in the queue.
WithdrawalResult
Result of attempting to satisfy a withdrawal from available assets.

Enums§

QueueError
Errors that can occur during queue operations.

Constants§

DEFAULT_COOLDOWN_NS
Default cooldown period in nanoseconds (24 hours). Withdrawals cannot be processed until this time has elapsed.
MAX_QUEUE_LENGTH
Maximum queue length before rejecting new requests.
MIN_WITHDRAWAL_ASSETS
Minimum withdrawal amount in base asset units to prevent dust. Withdrawals below this threshold should be rejected.

Functions§

can_enqueue
can_partially_satisfy
Check if a withdrawal can be partially satisfied.
can_satisfy_withdrawal
Check if a withdrawal can be satisfied given available assets.
compute_full_withdrawal
Compute the withdrawal result for a fully satisfied withdrawal.
compute_idle_settlement
compute_partial_withdrawal
Compute the withdrawal result for a partial withdrawal.
compute_queue_status
Compute aggregate queue status from an iterator of withdrawals.
compute_settlement
Compute escrow settlement when completing a withdrawal.
compute_settlement_by_price
Compute settlement using share price (WAD-scaled).
count_satisfiable
Calculate how many withdrawals can be fully satisfied from a queue.
find_request_status
Find a withdrawal request’s status by owner.
is_past_cooldown
is_valid_withdrawal_amount