Skip to main content

createSellPtInstruction

Sells PT tokens for base assets in a single atomic operation. This is an alias for the sellPt instruction which handles the SY-to-base redemption internally via CPI remaining accounts. The caller supplies PT tokens and receives base tokens directly, without needing to manually redeem SY.

Usage

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

const ix = createSellPtInstruction({
  seller: sellerKeypair.publicKey,
  market: new PublicKey("market..."),
  tokenSyTrader: new PublicKey("tokenSyTrader..."),
  tokenPtTrader: new PublicKey("tokenPtTrader..."),
  tokenSyEscrow: new PublicKey("tokenSyEscrow..."),
  tokenPtEscrow: new PublicKey("tokenPtEscrow..."),
  addressLookupTable: new PublicKey("lookupTable..."),
  tokenProgram: new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),
  syProgram: new PublicKey("syProgram..."),
  tokenFeeTreasurySy: new PublicKey("tokenFeeTreasurySy..."),
  tokenFeeTreasuryPt: new PublicKey("tokenFeeTreasuryPt..."),
  ticks: new PublicKey("ticks..."),
  eventAuthority: new PublicKey("eventAuthority..."),
  program: new PublicKey("program..."),
  amountPt: 1_000_000n,
  minBaseAmount: 950_000n,
  priceSpotLimit: 1.05,
  redeemSyRemAccountsUntil: 3,
});

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
amountPtu64The amount of PT tokens to sell
minBaseAmountu64The minimum amount of base asset to receive
priceSpotLimitf64 (optional)The price limit for the trade
redeemSyRemAccountsUntilu8The number of CPI remaining accounts used for SY redemption

Returns

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