Skip to main content
prepareDepositTxData builds calldata for vault deposits. Use it when the user has already granted allowance to the Boring Vault contract (or when a permit flow will supply approval).

Helper Signature

import { prepareDepositTxData } from "@paxoslabs/amplify-sdk";

const tx = await prepareDepositTxData({
  yieldType, // e.g. YieldType.CORE
  recipientAddress, // receives vault shares
  depositToken, // ERC-20 the user spends
  depositAmount, // decimal string
  chainId,
  slippage, // optional bps, defaults to DEFAULT_DEPOSIT_SLIPPAGE (100)
});
  • Returns { abi, address, functionName: 'deposit', args, chainId }.
  • args[0] is the recipient, args[1] is the deposit amount in base units.
  • Throws APIError if the vault, token, or chain is unsupported.

React with Privy

import { encodeFunctionData } from "viem";
import { mainnet } from "viem/chains";
import { prepareDepositTxData, YieldType } from "@paxoslabs/amplify-sdk";
import { usePrivy, useWallets } from "@privy-io/react-auth";

const { sendTransaction } = usePrivy();
const { wallets } = useWallets();
const wallet = wallets[0];
if (!wallet) {
  throw new Error("Connect a wallet before preparing transactions.");
}

const owner = wallet.address as `0x${string}`;

const deposit = await prepareDepositTxData({
  yieldType: YieldType.CORE,
  recipientAddress: owner,
  depositToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
  depositAmount: "1000",
  chainId: mainnet.id,
});

await sendTransaction({
  chainId: deposit.chainId,
  to: deposit.address,
  data: encodeFunctionData({
    abi: deposit.abi,
    functionName: deposit.functionName,
    args: deposit.args,
  }),
});

React with wagmi

import { prepareDepositTxData, YieldType } from "@paxoslabs/amplify-sdk";
import { useAccount, useWriteContract } from "wagmi";

const { address, chainId } = useAccount();
const { writeContractAsync } = useWriteContract();
if (!address || !chainId) {
  throw new Error("Connect a wallet before preparing transactions.");
}

const { chainId: _ignored, ...tx } = await prepareDepositTxData({
  yieldType: YieldType.CORE,
  recipientAddress: address,
  depositToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
  depositAmount: "1000",
  chainId,
});

await writeContractAsync({ ...tx, account: address });

React with viem

import { createWalletClient, custom } from "viem";
import { mainnet } from "viem/chains";
import { prepareDepositTxData, YieldType } from "@paxoslabs/amplify-sdk";

// ethereum is window.ethereum from an injected wallet.
const [account] = (await ethereum.request({
  method: "eth_requestAccounts",
})) as `0x${string}`[];

const client = createWalletClient({
  account,
  chain: mainnet,
  transport: custom(ethereum),
});

const { chainId: _ignored, ...tx } = await prepareDepositTxData({
  yieldType: YieldType.CORE,
  recipientAddress: account,
  depositToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
  depositAmount: "1000",
  chainId: mainnet.id,
});

await client.writeContract({ ...tx, account });
If the allowance is insufficient, switch to the Approve & Deposit flow. For permit-enabled tokens, jump to Deposit with Permit.***