Skip to main content
Determine whether vault share approval is needed for a withdrawal operation and prepare the appropriate authorization. This is the recommended entry point for the withdrawal flow. It automatically:
  • Checks existing vault share allowance
  • Detects smart contract wallets (Safe, EIP-4337, EIP-7702)
  • Returns the appropriate authorization result

Import

Usage


Parameters


Return Type

Returns a discriminated union WithdrawAuthorizationResult:

WithdrawAuthMethod.APPROVAL

Returned when approval is needed (insufficient allowance, smart wallet detected in auto mode, or forceMethod: "approval").

WithdrawAuthMethod.ALREADY_APPROVED

Returned when existing allowance is sufficient.

Type Guards

Use type guards for type-safe handling:
Or use a switch statement:

Smart Wallet Behavior

In auto mode, smart contract wallets (Safe, EIP-4337, EIP-7702) are routed to APPROVAL with approve tx data so they can batch approve + withdraw atomically.
The SDK detects smart wallets by checking for deployed bytecode at the address using getCode. This covers:
  • Safe (Gnosis Safe) multi-sig wallets
  • EIP-4337 smart accounts (e.g., Biconomy, ZeroDev, Alchemy)
  • EIP-7702 delegated EOAs
  • Privy embedded wallets (when using smart wallets)

Force Method Overrides

Use forceMethod for deterministic behavior:

Examples


Comparison with Deposit Authorization

prepareWithdrawalAuthorization() mirrors the deposit flow’s prepareDepositAuthorization(): Withdrawals don’t support EIP-2612 permits since the approval is on vault shares (BoringVault ERC20), not the deposit token.

Error Handling