Skip to main content

createDepositLiquidityInstruction

Builds a raw instruction to create a new LP position and deposit liquidity at specified tick boundaries. This initializes a fresh position account and deposits PT and SY tokens into the pool within the defined tick range.

Usage

import { createDepositLiquidityInstruction } from "@exponent-labs/exponent-sdk/client/clmm";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";

const lpPositionKeypair = Keypair.generate();

const ix = createDepositLiquidityInstruction({
  depositor: depositorKeypair.publicKey,
  market: marketAddress,
  ticks: ticksAccount,
  lpPosition: lpPositionKeypair.publicKey,
  tokenPtSrc: depositorPtTokenAccount,
  tokenSySrc: depositorSyTokenAccount,
  tokenPtEscrow: marketPtEscrow,
  tokenSyEscrow: marketSyEscrow,
  addressLookupTable: lookupTableAddress,
  tokenProgram: tokenProgramId,
  syProgram: syProgramId,
  systemProgram: SystemProgram.programId,
  eventAuthority: eventAuthorityPda,
  program: clmmProgramId,
  lowerTickKey: 100,
  upperTickKey: 200,
  maxSyIn: 1_000_000_000n,
  maxPtIn: 500_000_000n,
});

Accounts

NameTypeSignerWritableDescription
depositorPublicKeyYesYesWallet providing liquidity
marketPublicKeyNoYesThe CLMM market account
ticksPublicKeyNoYesThe market tick array account
lpPositionPublicKeyYesYesLP position account (signer for new positions)
tokenPtSrcPublicKeyNoYesDepositor’s PT token account
tokenSySrcPublicKeyNoYesDepositor’s SY token account
tokenPtEscrowPublicKeyNoYesMarket PT escrow account
tokenSyEscrowPublicKeyNoYesMarket SY escrow account
addressLookupTablePublicKeyNoNoMarket address lookup table
tokenProgramPublicKeyNoNoSPL Token program
syProgramPublicKeyNoNoSY program
systemProgramPublicKeyNoNoSystem program
eventAuthorityPublicKeyNoNoEvent authority PDA
programPublicKeyNoNoCLMM program ID

Args

NameTypeDescription
lowerTickKeyu32Lower tick boundary for the position
upperTickKeyu32Upper tick boundary for the position
maxSyInu64Maximum amount of SY tokens to deposit
maxPtInu64Maximum amount of PT tokens to deposit

Returns

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