IWithdrawController
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
| Name | Type | Description |
|---|---|---|
_requestToken | address | Asset to withdraw into. |
_shares | uint256 | Number 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
| Name | Type | Description |
|---|---|---|
_requestTokens | address[] | List of withdrawal asset addresses. |
_shares | uint256[] | 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
| Name | Type | Description |
|---|---|---|
_id | uint256 | Receipt 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
| Name | Type | Description |
|---|---|---|
_ids | uint256[] | 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
| Name | Type | Description |
|---|---|---|
_id | uint256 | Receipt ID of withdrawal. |
completeWithdrawals
Batch complete withdrawals.
Burns shares, transfers asset to user, applies fees.
function completeWithdrawals(uint256[] memory _ids) external;
Parameters
| Name | Type | Description |
|---|---|---|
_ids | uint256[] | An array of receipt IDs of withdrawals. |
getWithdrawalReceiptsLength
Returns total number of withdrawal receipts created.
function getWithdrawalReceiptsLength() external view returns (uint256 length_);
Returns
| Name | Type | Description |
|---|---|---|
length_ | uint256 | Total number of withdrawal receipts. |
getWithdrawalReceipts
Paginates withdrawal receipts.
function getWithdrawalReceipts(uint256 _offset, uint256 _limit)
external
view
returns (WithdrawalReceipt[] memory receipts_);
Parameters
| Name | Type | Description |
|---|---|---|
_offset | uint256 | Start index in array. |
_limit | uint256 | Number of receipts to fetch. |
Returns
| Name | Type | Description |
|---|---|---|
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
| Name | Type | Description |
|---|---|---|
requester | address | The address of the user requesting withdrawal. |
requestAsset | address | The asset requested for withdrawal. |
requestShares | uint256 | The number of shares submitted for withdrawal. |
id | uint256 | The 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
| Name | Type | Description |
|---|---|---|
requester | address | The address of the user who cancelled. |
requestShares | uint256 | The number of shares refunded. |
id | uint256 | The 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
| Name | Type | Description |
|---|---|---|
requester | address | The user receiving withdrawn assets. |
withdrawnAsset | address | The ERC20 asset withdrawn. |
withdrawnAmount | uint256 | The amount of asset received by the user. |
feeCharged | uint256 | The fee amount deducted from the withdrawal. |
id | uint256 | The 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
| Name | Type | Description |
|---|---|---|
shareTokenPrice | uint256 | The price of the share token at processing. |
requestAssetPrice | uint256 | The price of the requested asset at processing. |
id | uint256 | The 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
| Name | Type | Description |
|---|---|---|
id | uint256 | The ID of the processed withdrawal receipt. |
WithdrawalReviewing
Emitted when a withdrawal receipt is marked as under review.
event WithdrawalReviewing(uint256 id);
Parameters
| Name | Type | Description |
|---|---|---|
id | uint256 | The ID of the withdrawal receipt. |
WithdrawalRejected
Emitted when a withdrawal request is rejected.
event WithdrawalRejected(uint256 id);
Parameters
| Name | Type | Description |
|---|---|---|
id | uint256 | The ID of the rejected withdrawal receipt. |
WithdrawalForfeited
Emitted when a withdrawal request is forfeited.
event WithdrawalForfeited(uint256 id);
Parameters
| Name | Type | Description |
|---|---|---|
id | uint256 | The ID of the forfeited withdrawal receipt. |
WithdrawalAssetAdded
Emitted when a new withdrawal asset is added.
event WithdrawalAssetAdded(address indexed asset);
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The address of the newly added ERC20 asset. |
WithdrawalAssetRemoved
Emitted when a withdrawal asset is removed.
event WithdrawalAssetRemoved(address indexed asset);
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The address of the removed ERC20 asset. |
SetAssetsRouter
Emitted when the AssetsRouter address is updated.
event SetAssetsRouter(address oldRouter, address newRouter);
Parameters
| Name | Type | Description |
|---|---|---|
oldRouter | address | The previous router address. |
newRouter | address | The new router address. |
AssetRepaid
Emitted when an operator repays assets into the controller.
event AssetRepaid(address indexed asset, uint256 amount);
Parameters
| Name | Type | Description |
|---|---|---|
asset | address | The ERC20 asset repaid. |
amount | uint256 | The 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
}