IWithdrawController

Git Source

Author: luoyhang003

Interface for the WithdrawController contract, which manages withdrawal requests, processing, completion, and administration of supported withdrawal assets.

Defines core data structures, events, and status enums used by the WithdrawController implementation.

Functions

requestWithdrawal

Request withdrawal of a specific asset by burning shares.

User must be whitelisted. Generates a withdrawal receipt.

function requestWithdrawal(address _requestToken, uint256 _shares) external;

Parameters

NameTypeDescription
_requestTokenaddressAsset to withdraw into.
_sharesuint256Number of shares to redeem.

requestWithdrawals

Batch request withdrawals across multiple assets.

Lengths must match. Generates multiple withdrawal receipts.

function requestWithdrawals(address[] memory _requestTokens, uint256[] memory _shares) external;

Parameters

NameTypeDescription
_requestTokensaddress[]List of withdrawal asset addresses.
_sharesuint256[]Corresponding share amounts per asset.

cancelWithdrawal

Cancel a single pending withdrawal request.

Only the original requester can cancel. Shares are refunded.

function cancelWithdrawal(uint256 _id) external;

Parameters

NameTypeDescription
_iduint256Receipt ID of the withdrawal request.

cancelWithdrawals

Batch cancel withdrawal requests.

Only the original requester can cancel. Shares are refunded.

function cancelWithdrawals(uint256[] memory _ids) external;

Parameters

NameTypeDescription
_idsuint256[]An array of receipt IDs of the withdrawal requests.

completeWithdrawal

Complete a withdrawal once processed.

Burns shares, transfers asset to user, applies fees.

function completeWithdrawal(uint256 _id) external;

Parameters

NameTypeDescription
_iduint256Receipt ID of withdrawal.

completeWithdrawals

Batch complete withdrawals.

Burns shares, transfers asset to user, applies fees.

function completeWithdrawals(uint256[] memory _ids) external;

Parameters

NameTypeDescription
_idsuint256[]An array of receipt IDs of withdrawals.

getWithdrawalReceiptsLength

Returns total number of withdrawal receipts created.

function getWithdrawalReceiptsLength() external view returns (uint256 length_);

Returns

NameTypeDescription
length_uint256Total number of withdrawal receipts.

getWithdrawalReceipts

Paginates withdrawal receipts.

function getWithdrawalReceipts(uint256 _offset, uint256 _limit)
    external
    view
    returns (WithdrawalReceipt[] memory receipts_);

Parameters

NameTypeDescription
_offsetuint256Start index in array.
_limituint256Number of receipts to fetch.

Returns

NameTypeDescription
receipts_WithdrawalReceipt[]List of withdrawal receipts within range.

Events

WithdrawalRequested

Emitted when a user submits a withdrawal request.

event WithdrawalRequested(address indexed requester, address indexed requestAsset, uint256 requestShares, uint256 id);

Parameters

NameTypeDescription
requesteraddressThe address of the user requesting withdrawal.
requestAssetaddressThe asset requested for withdrawal.
requestSharesuint256The number of shares submitted for withdrawal.
iduint256The unique ID assigned to the withdrawal receipt.

WithdrawalCancelled

Emitted when a withdrawal request is cancelled by the user.

event WithdrawalCancelled(address indexed requester, uint256 requestShares, uint256 id);

Parameters

NameTypeDescription
requesteraddressThe address of the user who cancelled.
requestSharesuint256The number of shares refunded.
iduint256The ID of the cancelled withdrawal receipt.

WithdrawalCompleted

Emitted when a withdrawal is completed and assets are transferred.

event WithdrawalCompleted(
    address indexed requester, address indexed withdrawnAsset, uint256 withdrawnAmount, uint256 feeCharged, uint256 id
);

Parameters

NameTypeDescription
requesteraddressThe user receiving withdrawn assets.
withdrawnAssetaddressThe ERC20 asset withdrawn.
withdrawnAmountuint256The amount of asset received by the user.
feeChargeduint256The fee amount deducted from the withdrawal.
iduint256The ID of the completed withdrawal receipt.

WithdrawalProcessing

Emitted when a withdrawal request is marked as processing.

event WithdrawalProcessing(uint256 shareTokenPrice, uint256 requestAssetPrice, uint256 id);

Parameters

NameTypeDescription
shareTokenPriceuint256The price of the share token at processing.
requestAssetPriceuint256The price of the requested asset at processing.
iduint256The ID of the withdrawal receipt being processed.

AllMarkedAsProcessing

Emitted when all targeted withdrawal requests are marked as processing.

event AllMarkedAsProcessing();

WithdrawalProcessed

Emitted when a withdrawal receipt is marked as processed.

event WithdrawalProcessed(uint256 id);

Parameters

NameTypeDescription
iduint256The ID of the processed withdrawal receipt.

WithdrawalReviewing

Emitted when a withdrawal receipt is marked as under review.

event WithdrawalReviewing(uint256 id);

Parameters

NameTypeDescription
iduint256The ID of the withdrawal receipt.

WithdrawalRejected

Emitted when a withdrawal request is rejected.

event WithdrawalRejected(uint256 id);

Parameters

NameTypeDescription
iduint256The ID of the rejected withdrawal receipt.

WithdrawalForfeited

Emitted when a withdrawal request is forfeited.

event WithdrawalForfeited(uint256 id);

Parameters

NameTypeDescription
iduint256The ID of the forfeited withdrawal receipt.

WithdrawalAssetAdded

Emitted when a new withdrawal asset is added.

event WithdrawalAssetAdded(address indexed asset);

Parameters

NameTypeDescription
assetaddressThe address of the newly added ERC20 asset.

WithdrawalAssetRemoved

Emitted when a withdrawal asset is removed.

event WithdrawalAssetRemoved(address indexed asset);

Parameters

NameTypeDescription
assetaddressThe address of the removed ERC20 asset.

SetAssetsRouter

Emitted when the AssetsRouter address is updated.

event SetAssetsRouter(address oldRouter, address newRouter);

Parameters

NameTypeDescription
oldRouteraddressThe previous router address.
newRouteraddressThe new router address.

AssetRepaid

Emitted when an operator repays assets into the controller.

event AssetRepaid(address indexed asset, uint256 amount);

Parameters

NameTypeDescription
assetaddressThe ERC20 asset repaid.
amountuint256The amount of asset repaid.

Structs

WithdrawalReceipt

Record of a single withdrawal request.

Used to track user withdrawals, pricing context, fees, and status.

struct WithdrawalReceipt {
    address requester;
    address requestAsset;
    uint256 requestShares;
    uint256 shareTokenPrice;
    uint256 requestAssetPrice;
    uint256 feeRate;
    WITHDRAWAL_STATUS status;
}

Enums

WITHDRAWAL_STATUS

Lifecycle statuses of a withdrawal request.

Used in {WithdrawalReceipt.status} to track progress and outcomes.

enum WITHDRAWAL_STATUS {
    REQUESTED,
    CANCELLED,
    PROCESSING,
    REVIEWING,
    PROCESSED,
    COMPLETED,
    REJECTED,
    FORFEITED
}