Skip to main content

createWrapperRemoveOfferInstruction

Builds a raw instruction that removes a posted offer from the orderbook with automatic SY redemption. This combines the offer removal and SY redemption steps atomically.

Usage

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

const ix = createWrapperRemoveOfferInstruction(
  {
    trader: wallet.publicKey,
    orderbook: orderbookAddress,
    vault: vaultAddress,
    cpiAccountOrderbook: cpiAccountsOrderbook,
    tokenEscrowYt: orderbookEscrowYt,
    tokenEscrowSy: orderbookEscrowSy,
    tokenEscrowPt: orderbookEscrowPt,
    tokenSyTrader: userSyTokenAccount,
    tokenYtTrader: userYtTokenAccount,
    tokenPtTrader: userPtTokenAccount,
    systemProgram: SystemProgram.programId,
    syProgram: syProgramId,
    tokenProgram: TOKEN_PROGRAM_ID,
    exponentCore: EXPONENT_CORE_PROGRAM_ID,
    addressLookupTable: vaultLookupTable,
    eventAuthority: eventAuthorityPda,
    program: EXPONENT_ORDERBOOK_PROGRAM_ID,
  },
  {
    offerIdx: 42,
    redeemSyAccountsUntil: 0,
  }
);

Accounts

NameTypeSignerWritableDescription
traderPublicKeyYesNoThe trader removing the offer
orderbookPublicKeyNoYesOrderbook account
vaultPublicKeyNoYesVault account
cpiAccountOrderbookPublicKeyNoNoCPI accounts orderbook
tokenEscrowYtPublicKeyNoYesOrderbook YT escrow account
tokenEscrowSyPublicKeyNoYesOrderbook SY escrow account
tokenEscrowPtPublicKeyNoYesOrderbook PT escrow account
tokenSyTraderPublicKeyNoYesTrader’s SY token account
tokenYtTraderPublicKeyNoYesTrader’s YT token account
tokenPtTraderPublicKeyNoYesTrader’s PT token account
systemProgramPublicKeyNoNoSystem program
syProgramPublicKeyNoNoSY program
tokenProgramPublicKeyNoNoSPL Token program
exponentCorePublicKeyNoNoExponent Core program
addressLookupTablePublicKeyNoNoVault address lookup table
eventAuthorityPublicKeyNoNoEvent authority PDA
programPublicKeyNoNoExponent Orderbook program

Args

NameTypeDescription
offerIdxnumberIndex of the offer to remove (u32)
redeemSyAccountsUntilnumberIndex into remaining accounts for SY redemption CPI accounts

Returns

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