Withdraw
In MAAT, assets are not stored directly in the token vault. Instead, they are distributed across different networks and various strategies. This distribution enhances yield generation but also means that calling the withdraw
or redeem
functions might fail if there are no available funds in the vault.
How to Withdraw
You need to call the requestWithdraw
function to withdraw funds. This function locks the specified shares on the contract and initiates the withdrawal process. The YieldSearcher
will then fetch the assets from the necessary strategies while maintaining the optimal state of the entire system. After this process, the user receives the required amount of assets.
Initiating a withdrawal request involves submitting a separate transaction distinct from other operations. Ensure that this transaction is properly signed and confirmed on the blockchain.
If the withdrawal involves assets from another network, the fulfillment of the withdrawal request may take up to 20 minutes. This delay accounts for cross-chain communication and asset bridging processes.
shares
: The amount of shares to withdraw.dstEid
: The unique ID of the destination chain's LayerZero endpointowner
: The address of the owner of the shares to be burned.receiver
: The address that will receive the withdrawn assets.
The function returns an intentionId
— a unique identifier for your withdrawal action. This intentionId
allows you to cancel the withdrawal later if needed.
How to Cancel Withdraw Request
A withdrawal request may be cancelled by calling the cancelWithdrawal
function. Once the request is canceled, the shares will be returned to the owner's address.
The cancelWithdrawal
function can only be invoked one hour after the withdrawal request has been created.
The cancellation mechanism is intended only for emergencies where the withdrawal request cannot be fulfilled on the current network. In such cases, bridging the shares to another network may be necessary to complete the withdrawal.
This function requires the intentionId
returned when you initiated the withdrawal request. You can only proceed after the withdrawal cancellation delay has passed, which can be obtained by calling the withdrawCancellationDelay()
function. It is important that the initiator of the withdrawal request calls this function.
intentionId
: The unique identifier of the withdrawal request you wish to cancel.
Example Usage with Ethers.js
Example Usage with Solidity
Last updated