Before withdrawing, you must approve the WithdrawQueue contract to spend your
vault shares. Consider using
prepareWithdrawalAuthorization
for a higher-level API that handles approval checking automatically.
Import
Usage
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
vaultName | string | Yes | Vault name from AmplifyVault.name (e.g. from getVaultsByConfig()) |
wantAssetAddress | Address | Yes | Token address you want to receive |
withdrawAmount | string | No | Amount to approve (defaults to max uint256) |
chainId | number | Yes | Chain ID |
shareDecimals | number | No | Pre-fetched vault share decimals (avoids redundant RPC call) |
Return Type
- Type Definition
- Example Response
Examples
- Viem
- Wagmi
Max vs Specific Approval
Max Approval (Default)
WhenwithdrawAmount is not provided, the SDK approves the maximum amount. This is a one-time approval that covers all future withdrawals:
Specific Amount Approval
For tighter security, approve only the amount you intend to withdraw:Checking Existing Approval
Before approving, check if approval is already granted:Consider using
prepareWithdrawalAuthorization
instead, which combines the approval check and approval preparation into a
single call.
Error Handling
| Error | Description | Resolution |
|---|---|---|
Vault not found | No vault matches vaultName | Verify vault name via getVaultsByConfig() |
Vault chain mismatch | Vault not on requested chain | Verify chainId matches vault deployment |
BoringVault contract address not configured | Missing vault config | Check vault configuration |
WithdrawQueue contract address not configured | Missing queue config | Check vault configuration |
Related
- getVaultsByConfig - Discover vault names
- prepareWithdrawalAuthorization - Unified authorization (recommended)
- prepareWithdrawOrderTxData - Submit the withdrawal order
- Withdrawals Guide - Complete withdrawal flow