prepareDepositAuthorization() to determine the method, then prepareDeposit() to execute.
Import
prepareDepositAuthorization()
Determines the optimal authorization method for a deposit operation.Function Signature
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
yieldType | YieldType | Yes | Yield strategy type (e.g., YieldType.CORE) |
depositAsset | Address | Yes | Token contract address to deposit |
depositAmount | string | Yes | Amount as decimal string (e.g., “100.25”) |
to | Address | Yes | Recipient address for vault shares |
chainId | number | Yes | Blockchain network ID |
deadline | bigint | No | Permit deadline (defaults to 1 hour) |
forceMethod | "permit" | "approval" | No | Override automatic detection |
Return Type (Discriminated Union)
- Type Definition
- Permit Result
- Approval Result
- Already Approved Result
Decision Logic
The function follows this priority order:- Check
forceMethod- If specified, use that method - Check permit support - If token is in permit allowlist, return permit data
- Check existing allowance - If sufficient, return
ALREADY_APPROVED - Default to approval - Return approval transaction data
prepareDeposit()
Prepares transaction data for a deposit, automatically using the correct method based on provided parameters.Function Signature
Parameters
Return Type
Complete Flow Example
Force Specific Method
Override automatic detection when needed:Slippage Configuration
Error Handling
| Error Code | Description | Resolution |
|---|---|---|
SDK_NOT_INITIALIZED | SDK used before init | Call initAmplifySDK() first |
VAULT_NOT_FOUND | No vault matches params | Verify yieldType, token, chainId |
PERMIT_NOT_SUPPORTED | Token doesn’t support EIP-2612 | Use approval flow instead |
INSUFFICIENT_ALLOWANCE | Approval amount too low | Increase approval or use permit |
Related
- Deposits Guide - Complete integration examples
- DepositAuthMethod - Type definitions
- prepareDepositTxData - Lower-level deposit function