Skip to main content
The ixWrapperRemoveOffer instruction removes an existing order from the Exponent orderbook.

Usage

import { PublicKey } from "@solana/web3.js";

const ix = await orderbook.ixWrapperRemoveOffer({
  trader: wallet.publicKey,
  offerIdx: 0,
  mintSy: syMintAddress,
});

Required Parameters

ParameterTypeDescription
traderPublicKeyThe trader’s wallet public key
offerIdxnumberThe index of the offer to remove
mintSyPublicKeyThe SY token mint address

Optional Parameters

ParameterTypeDescription
ptSrcPublicKeyPT token source account
ytSrcPublicKeyYT token source account
sySrcPublicKeySY token source account
tokenBaseTraderPublicKeyBase token account for the trader

Returns

Returns a TransactionInstruction that removes the specified order from the orderbook.
Removing an order automatically stages any accrued YT interest before returning tokens to your escrow. Collect staged interest separately via ixWrapperCollectInterest.

Finding the Offer Index

Use getUserOpenOrders to get the list of open orders and their indices:
const openOrders = orderbook.getUserOpenOrders(wallet.publicKey);

for (const order of openOrders) {
  console.log("Offer index:", order.offerIndex);
  console.log("Amount:", order.amount);
  console.log("Price APY:", order.priceApy);
}

// Remove the first open order
const ix = await orderbook.ixWrapperRemoveOffer({
  trader: wallet.publicKey,
  offerIdx: openOrders[0].offerIndex,
  mintSy: syMintAddress,
});