Skip to main content

createRemoveOfferInstruction

Builds a raw instruction to cancel and remove a previously posted limit order from the orderbook, returning the escrowed tokens back to the trader.

Usage

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

const ix = createRemoveOfferInstruction(
  {
    trader: wallet.publicKey,
    orderbook: orderbookAddress,
    vault: vaultAddress,
    tokenEscrowYt: orderbookYtEscrow,
    tokenEscrowSy: orderbookSyEscrow,
    tokenEscrowPt: orderbookPtEscrow,
    tokenSyTrader: userSyTokenAccount,
    tokenYtTrader: userYtTokenAccount,
    tokenPtTrader: userPtTokenAccount,
    systemProgram: SYSTEM_PROGRAM_ID,
    tokenProgram: TOKEN_2022_PROGRAM_ID,
    syProgram: syProgramId,
    exponentCore: EXPONENT_CORE_PROGRAM_ID,
    addressLookupTable: vaultLookupTable,
    cpiAccountOrderbook: cpiAccountsOrderbook,
    eventAuthority: eventAuthorityPda,
    program: EXPONENT_ORDERBOOK_PROGRAM_ID,
  },
  {
    offerIdx: 42,
  }
);

Accounts

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

Args

NameTypeDescription
offerIdxnumberIndex of the offer to remove (u32)

Returns

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