Skip to main content
The unified deposit API simplifies deposits by automatically detecting the optimal authorization method. Use prepareDepositAuthorization() to determine the method, then prepareDeposit() to execute.

Import

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 directly
  2. Detect smart wallet — If the address has deployed bytecode (Safe, EIP-4337, EIP-7702), route to APPROVAL so callers can batch approve + deposit atomically
  3. Check permit support — If the token supports EIP-2612, return permit signature data
  4. Check existing allowance — If sufficient, return ALREADY_APPROVED
  5. Default to approval — Return approval transaction data

Token Permit Support

The following table shows which supported tokens use the gas-efficient EIP-2612 permit path versus the standard ERC-20 approval path. The SDK detects this automatically — use forceMethod: "approval" to override when needed (e.g., smart contract wallets).

prepareDeposit()

Prepares transaction data for a deposit, automatically using the correct method based on provided parameters.

Function Signature

Parameters

Return Type

Returns a discriminated union based on which deposit method is used:
The two result variants have different txData shapes. Standard deposits use a flat structure (txData.abi), while permit deposits use a nested structure (txData.data.abi). Use result.method to determine which shape you’re working with.

Complete Flow Example

Force Specific Method

Override automatic detection when needed:

Slippage Configuration

Error Handling