Skip to main content

createSellPtInstruction

Builds a raw instruction to sell PT tokens for base assets. This instruction handles SY redemption to the base asset internally via remaining accounts, making it a convenience wrapper that combines the sell-PT and redeem-SY steps into a single instruction.

Usage

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

const ix = createSellPtInstruction({
  seller: sellerKeypair.publicKey,
  market: marketAddress,
  tokenSyTrader: sellerSyTokenAccount,
  tokenPtTrader: sellerPtTokenAccount,
  tokenSyEscrow: marketSyEscrow,
  tokenPtEscrow: marketPtEscrow,
  addressLookupTable: lookupTableAddress,
  tokenProgram: tokenProgramId,
  syProgram: syProgramId,
  tokenFeeTreasurySy: feeTreasurySyAccount,
  tokenFeeTreasuryPt: feeTreasuryPtAccount,
  ticks: ticksAccount,
  eventAuthority: eventAuthorityPda,
  program: clmmProgramId,
  amountPt: 1_000_000_000n,
  minBaseAmount: 900_000_000n,
  priceSpotLimit: 0.95,
  redeemSyRemAccountsUntil: 5,
});

Accounts

NameTypeSignerWritableDescription
sellerPublicKeyYesYesWallet executing the trade
marketPublicKeyNoYesThe CLMM market account
ticksPublicKeyNoYesThe market tick array account
tokenSyTraderPublicKeyNoYesTrader’s SY token account
tokenPtTraderPublicKeyNoYesTrader’s PT token account
tokenSyEscrowPublicKeyNoYesMarket SY escrow account
tokenPtEscrowPublicKeyNoYesMarket PT escrow account
addressLookupTablePublicKeyNoNoMarket address lookup table
tokenProgramPublicKeyNoNoSPL Token program
syProgramPublicKeyNoNoSY program
tokenFeeTreasurySyPublicKeyNoYesSY fee treasury account
tokenFeeTreasuryPtPublicKeyNoYesPT fee treasury account
eventAuthorityPublicKeyNoNoEvent authority PDA
programPublicKeyNoNoCLMM program ID

Args

NameTypeDescription
amountPtu64Amount of PT tokens to sell
minBaseAmountu64Minimum amount of base asset to receive
priceSpotLimitf64 (optional)Price limit for anti-sandwich protection
redeemSyRemAccountsUntilu8Number of remaining accounts used for the SY redemption CPI

Returns

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