Skip to main content
The Unified Deposit API simplifies deposits by automatically detecting the optimal authorization method. Use prepareDepositAuthorization() to determine the method, then prepareDepositTxData() or prepareDepositWithPermitTxData() to execute.

DepositAuthMethod

prepareDepositAuthorization()

Determines the optimal authorization method for a deposit operation.

Function Signature

Parameters

Return Type (Discriminated Union)

Decision Logic

The function follows this priority order:
  1. Check forceMethod - If specified, use that method
  2. Check permit support - If token is in permit allowlist, return permit data
  3. Check existing allowance - If sufficient, return ALREADY_APPROVED
  4. Default to approval - Return approval transaction data

prepareDepositTxData()

Prepares transaction data for a standard deposit (after approval).

Function Signature

Parameters

Return Type

prepareDepositWithPermitTxData()

Prepares transaction data for a permit-based deposit (single transaction).

Function Signature

Parameters

Return Type

Complete Flow Examples

React with Privy

React with wagmi

React with viem

Force Specific Method

Override automatic detection when needed:

Slippage Configuration

The default slippage is 50 basis points (0.5%). Override when needed:

Error Handling

Both helpers throw APIError with actionable metadata:
For withdrawal operations, see Withdraw.