Documentation Index
Fetch the complete documentation index at: https://developers.paxoslabs.com/llms.txt
Use this file to discover all available pages before exploring further.
Prepares the transaction data for executing a deposit after the user has approved token spending. Use this for the approval flow or when allowance is already sufficient.
Import
import { prepareDepositTxData } from "@paxoslabs/amplify-sdk";
Usage
const txData = await prepareDepositTxData({
yieldType: YieldType.CORE,
depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
depositAmount: "1000",
to: "0x...",
chainId: 1,
});
Parameters
| Parameter | Type | Required | Description |
|---|
yieldType | YieldType | Yes | Yield strategy type (CORE, TREASURY, or FRONTIER) |
depositAsset | Address | Yes | Token contract address to deposit |
depositAmount | string | Yes | Amount to deposit as decimal string (e.g., "100.50") |
to | Address | Yes | Recipient address for vault shares |
chainId | number | Yes | Blockchain network ID |
slippage | number | No | Slippage tolerance in basis points (default: 50 = 0.5%) |
partnerCode | string | No | Partner code for fee attribution |
interface PrepareDepositParams {
/** Yield strategy type (e.g., YieldType.CORE) */
yieldType: YieldType;
/** Token contract address to deposit */
depositAsset: Address;
/** Amount to deposit as decimal string (e.g., "100.25") */
depositAmount: string;
/** Recipient address for vault shares */
to: Address;
/** Blockchain network ID */
chainId: number;
/** Slippage in basis points (default: 50 = 0.5%) */
slippage?: number;
/** Partner code for fee attribution */
partnerCode?: string;
}
Return Type
Type Definition
Example Response
interface DepositTxData {
/** Contract ABI for the deposit function */
abi: Abi;
/** Depositor contract address */
address: Address;
/** Function name to call */
functionName: string;
/** Encoded function arguments */
args: unknown[];
/** Chain ID for the transaction */
chainId: number;
}
{
abi: [...], // Depositor ABI
address: "0x1234...5678",
functionName: "deposit",
args: [
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // asset
1000000000n, // amount in wei
"0xUser...Address", // recipient
995000000n, // minShares (with slippage)
],
chainId: 1,
}
Examples
import { encodeFunctionData } from "viem";
import { usePrivy } from "@privy-io/react-auth";
import { prepareDepositTxData, YieldType } from "@paxoslabs/amplify-sdk";
const { sendTransaction } = usePrivy();
// After approval is confirmed...
const txData = await prepareDepositTxData({
yieldType: YieldType.CORE,
depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
depositAmount: "1000",
to: userAddress,
chainId: 1,
});
await sendTransaction({
chainId: txData.chainId,
to: txData.address,
data: encodeFunctionData({
abi: txData.abi,
functionName: txData.functionName,
args: txData.args,
}),
});
import { useWriteContract } from "wagmi";
import { prepareDepositTxData, YieldType } from "@paxoslabs/amplify-sdk";
const { writeContractAsync } = useWriteContract();
// After approval is confirmed...
const txData = await prepareDepositTxData({
yieldType: YieldType.CORE,
depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
depositAmount: "1000",
to: address,
chainId: chainId,
});
await writeContractAsync({
...txData,
account: address,
});
import { createWalletClient, custom } from "viem";
import { mainnet } from "viem/chains";
import { prepareDepositTxData, YieldType } from "@paxoslabs/amplify-sdk";
const client = createWalletClient({
account,
chain: mainnet,
transport: custom(window.ethereum),
});
const txData = await prepareDepositTxData({
yieldType: YieldType.CORE,
depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
depositAmount: "1000",
to: account,
chainId: mainnet.id,
});
await client.writeContract({
...txData,
account,
});
Slippage Configuration
The default slippage is 50 basis points (0.5%). Adjust for volatile conditions:
// 1% slippage for higher tolerance
const txData = await prepareDepositTxData({
...params,
slippage: 100,
});
// 0.1% slippage for tighter tolerance
const txData = await prepareDepositTxData({
...params,
slippage: 10,
});
Error Handling
| Error Code | Description | Resolution |
|---|
SDK_NOT_INITIALIZED | SDK not initialized | Call initAmplifySDK() first |
VAULT_NOT_FOUND | No vault matches parameters | Verify yieldType, token, chainId |
INSUFFICIENT_ALLOWANCE | Token not approved | Call approval first or use permit flow |
INVALID_AMOUNT | Amount is zero or negative | Provide valid positive amount |