Skip to main content

WithdrawalQueue

What is WithdrawalQueue?

WithdrawalQueue manages the FIFO queue for async withdrawal requests. When a user calls requestRedeem() on OllaVault, a withdrawal request is enqueued here. During rebalance, OllaCore finalizes requests in order, making them claimable.

The queue handles slashing protection: if the exchange rate drops between request and finalization, the payout is adjusted down using min(currentRate, lockedRate) so that slashing losses are fairly distributed.

WithdrawalQueue is upgradeable via UUPS proxy. Only OllaVault can enqueue, finalize, and claim.

Methods

All write methods are restricted to OllaVault.

requestWithdrawal()

Enqueue a new withdrawal request.

function requestWithdrawal(address recipient, uint256 shares, uint256 assetsExpected, uint256 rate) external returns (uint256 requestId)

finalizeWithdrawals()

Finalize requests in order using available buffer liquidity.

function finalizeWithdrawals(uint256 available, uint256 currentRate) external returns (uint256 used, uint256 finalizedCount, uint256 totalAdjusted)

claimWithdrawal()

Mark a finalized request as claimed.

function claimWithdrawal(uint256 id) external returns (uint256 assetsExpected)

setGasThreshold()

Set the gas floor for batch finalization.

function setGasThreshold(uint256 threshold) external

View methods

getRequest()

Get details of a specific withdrawal request (recipient, shares, assets, rate, status).

function getRequest(uint256 id) external view returns (WithdrawalRequest memory request)

nextUnfinalized()

ID of the next request awaiting finalization.

function nextUnfinalized() external view returns (uint256 requestId)

totalPendingAssets()

Total assets pending in the queue.

function totalPendingAssets() external view returns (uint256 totalPending)

gasThreshold()

Gas floor for the finalization loop.

function gasThreshold() external view returns (uint32)

Events

event WithdrawalRequested(uint256 indexed id, address indexed recipient, uint256 shares, uint256 assetsExpected, uint256 rate)

New withdrawal request enqueued.

event WithdrawalFinalized(uint256 indexed id, uint256 assets)

Withdrawal request finalized and claimable.

event WithdrawalClaimed(uint256 indexed id, address indexed recipient, uint256 assetsExpected)

Finalized withdrawal claimed by user.

event WithdrawalAdjusted(uint256 indexed id, uint256 originalAmount, uint256 adjustedAmount)

Payout adjusted down due to slashing.

event GasThresholdUpdated(uint256 oldThreshold, uint256 newThreshold)

Gas threshold changed.