Skip to main content

createDepositLiquidityInstruction

Builds a raw instruction to deposit tokens into a Strategy Vault and receive LP tokens in return. The depositor specifies the token mint, the amount to deposit, and a minimum LP output to protect against slippage. Called by depositors who want to add liquidity to the vault.

Usage

import { createDepositLiquidityInstruction } from "@exponent-labs/exponent-sdk/client/vaults";
import { PublicKey } from "@solana/web3.js";

const ix = createDepositLiquidityInstruction(
  {
    depositor: wallet.publicKey,
    vault: vaultAddress,
    exponentPrices: exponentPricesPda,
    tokenSrc: depositorTokenAccount,
    entryTokenVault: vaultEntryTokenAccount,
    tokenLpDst: depositorLpTokenAccount,
    mintLp: lpMintAddress,
    tokenProgram: TOKEN_PROGRAM_ID,
    eventAuthority: eventAuthorityPda,
    program: EXPONENT_VAULTS_PROGRAM_ID,
  },
  {
    mint: tokenMintAddress,
    tokenAmountIn: BigInt(1_000_000),
    minLpOut: BigInt(990_000),
  }
);

Accounts

NameSignerWritableDescription
depositorYesYesThe user depositing tokens into the vault
vaultNoYesThe Strategy Vault account
exponentPricesNoNoGlobal ExponentPrices account for AUM calculations
tokenSrcNoYesDepositor’s source token account
entryTokenVaultNoYesVault’s token account for the deposited mint
tokenLpDstNoYesDepositor’s destination LP token account
mintLpNoYesThe vault’s LP token mint
tokenProgramNoNoSPL Token program
eventAuthorityNoNoEvent authority PDA
programNoNoExponent Vaults program

Args

NameTypeDescription
mintPublicKeyToken mint to deposit
tokenAmountInbigintAmount of tokens to deposit (u64, in base units)
minLpOutbigintMinimum LP tokens to receive (u64, slippage protection)

Returns

TransactionInstruction — a transaction instruction ready to be added to a transaction.