Skip to main content
Prepares transaction data for a deposit using an EIP-2612 permit signature. This enables single-transaction deposits without a separate approval step.
For most use cases, use the unified deposit workflow which handles authorization automatically.

Import

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

Usage

const txData = await prepareDepositWithPermitTxData({
  yieldType: YieldType.CORE,
  depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  depositAmount: "1000",
  to: "0x...",
  chainId: 1,
  signature: "0x...", // From wallet signing
  deadline: 1234567890n,
});

Parameters

ParameterTypeRequiredDescription
yieldTypeYieldTypeYesYield strategy type (CORE, TREASURY, or FRONTIER)
depositAssetAddressYesToken contract address to deposit
depositAmountstringYesAmount to deposit as decimal string (e.g., "100.50")
toAddressYesRecipient address for vault shares
chainIdnumberYesBlockchain network ID
signatureHexYesPermit signature from wallet signing
deadlinebigintYesPermit deadline (must match signed deadline)
slippagenumberNoSlippage tolerance in basis points (default: 50)
partnerCodestringNoPartner code for fee attribution
interface PrepareDepositWithPermitParams {
  /** Yield strategy type (e.g., YieldType.CORE) */
  yieldType: YieldType;
  /** Token contract address to deposit */
  depositAsset: Address;
  /** Amount to deposit as decimal string */
  depositAmount: string;
  /** Recipient address for vault shares */
  to: Address;
  /** Blockchain network ID */
  chainId: number;
  /** Permit signature (hex string from wallet signing) */
  signature: Hex;
  /** Permit deadline (must match signature deadline) */
  deadline: bigint;
  /** Slippage in basis points (default: 50 = 0.5%) */
  slippage?: number;
  /** Partner code for fee attribution */
  partnerCode?: string;
}

Return Type

interface PermitDepositTxData {
  /** Depositor contract address */
  address: Address;
  /** Chain ID for the transaction */
  chainId: number;
  /** Transaction data */
  data: {
    /** Contract ABI */
    abi: Abi;
    /** Function name to call */
    functionName: string;
    /** Encoded function arguments */
    args: unknown[];
  };
}

Examples

import { encodeFunctionData } from "viem";
import { usePrivy, useWallets } from "@privy-io/react-auth";
import {
  prepareDepositAuthorization,
  prepareDepositWithPermitTxData,
  isPermitAuth,
  YieldType,
} from "@paxoslabs/amplify-sdk";

const { sendTransaction } = usePrivy();
const { wallets } = useWallets();
const wallet = wallets[0];
const owner = wallet.address as `0x${string}`;

const params = {
  yieldType: YieldType.CORE,
  depositAsset: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" as const,
  depositAmount: "1000",
  to: owner,
  chainId: 1,
};

// Step 1: Get permit data
const auth = await prepareDepositAuthorization(params);

if (isPermitAuth(auth)) {
  // Step 2: Sign the permit
  const provider = await wallet.getEthereumProvider();
  const signature = await provider.request({
    method: "eth_signTypedData_v4",
    params: [owner, JSON.stringify(auth.permitData)],
  }) as `0x${string}`;

  // Step 3: Execute deposit with permit
  const txData = await prepareDepositWithPermitTxData({
    ...params,
    signature,
    deadline: BigInt(auth.permitData.message.deadline),
  });

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

Permit Support

Not all tokens support EIP-2612 permits. Use prepareDepositAuthorization() to check:
TokenSupports Permit
USDCYes
USDGYes
pyUSDYes
USDTNo
Smart contract wallets (like Privy Smart Wallets or Safe) cannot sign permits. Use the approval flow with transaction batching instead.

Error Handling

Error CodeDescriptionResolution
SDK_NOT_INITIALIZEDSDK not initializedCall initAmplifySDK() first
PERMIT_NOT_SUPPORTEDToken doesn’t support EIP-2612Use approval flow instead
INVALID_SIGNATURESignature verification failedRe-sign with correct data
DEADLINE_EXPIREDPermit deadline has passedGenerate new permit with fresh deadline