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 |
|---|---|---|---|
yieldType | YieldType | Yes | Yield strategy (CORE, TREASURY, FRONTIER) |
wantAssetAddress | Address | Yes | Token address you want to receive |
withdrawAmount | string | No | Amount to approve (defaults to max uint256) |
chainId | ChainId | 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 chain mismatch | Vault not on requested chain | Verify chainId matches vault deployment |
BoringVault contract address not configured | Missing vault config | Check vault exists for yieldType/chain |
WithdrawQueue contract address not configured | Missing queue config | Check vault configuration |
Related
- prepareWithdrawalAuthorization - Unified authorization (recommended)
- prepareWithdrawOrderTxData - Submit the withdrawal order
- Withdrawals Guide - Complete withdrawal flow