Skip to main content

createBuyPtInstruction

Buys PT tokens from base assets in a single atomic operation. This is an alias for the buyPt instruction which handles the base-to-SY conversion internally via CPI remaining accounts. The caller supplies base tokens and receives PT directly, without needing to manually mint SY first.

Usage

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

const ix = createBuyPtInstruction({
  buyer: buyerKeypair.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..."),
  ticks: new PublicKey("ticks..."),
  tokenFeeTreasurySy: new PublicKey("tokenFeeTreasurySy..."),
  tokenFeeTreasuryPt: new PublicKey("tokenFeeTreasuryPt..."),
  eventAuthority: new PublicKey("eventAuthority..."),
  program: new PublicKey("program..."),
  minPtAmount: 950_000n,
  baseAmount: 1_000_000n,
  priceSpotLimit: 0.95,
  mintSyRemAccountsUntil: 3,
});

Accounts

NameTypeSignerWritableDescription
buyerPublicKeyYesYesWallet 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
minPtAmountu64The minimum amount of PT tokens to receive
baseAmountu64The amount of base asset to spend
priceSpotLimitf64 (optional)The price limit for the trade
mintSyRemAccountsUntilu8The number of CPI remaining accounts used for SY minting

Returns

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