Withdraw from a supply pool
The aaveWithdrawAsset
data slice provides a re-usable Alpine.js data slice for enabling the current user to withdraw their asset from the Aave pool via the withdraw()
contract method.
Data Slice Structure
status
- Type: String
- Description: Represents the status of the contract write request. Can be
'idle'
,'signaturePending'
,'transactionPending'
,'transactionSuccessful'
, or'error'
. Defaults to'idle'
.
amount
- Type: Number
- Description: Amount of the asset to withdraw from the pool. Defaults to
0
. Set or update it in the markup withx-bind
,x-init
, orx-data
.
token
- Type: Object or Undefined
- Description: Reserve asset information the user wishes to withdraw. Defaults to
undefined
. Set or update it in the markup withx-bind
,x-init
, orx-data
.
txsHashes
- Type: Any
- Description: Hash(es) of the transactions. Defaults to
undefined
and is defined within thewithdrawAsset
function.
Methods
The aaveWithdrawAsset
data slice provides the following method:
withdrawAsset(): Promise<void>
This method allows the current user to withdraw their underlying asset from an Aave V3 pool via the withdraw()
contract method.
Parameters:
args.amount
- (Optional) Amount of reserve asset to withdraw.args.reserve
- (Optional) Token the user wishes to withdraw from the supply pool.
Example
The snippet below showcases a simple implementation of a widget that allows the user to withdraw their DAI for the supply pool.