Skip to main content
The ixWrapperMarketOffer instruction executes a market order on the Exponent orderbook.

Usage

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

const { ix, setupIxs } = await orderbook.ixWrapperMarketOffer({
  trader: wallet.publicKey,
  maxPriceApy: 5.5,
  amount: 1_000_000_000n,
  offerType: OfferType.BuyYt,
  minAmountOut: 990_000_000n,
  virtualOffer: false,
  mintSy: syMintAddress,
});

Required Parameters

ParameterTypeDescription
traderPublicKeyThe trader’s wallet public key
maxPriceApynumberMaximum price in APY terms
amountbigintThe amount to trade
offerTypeOfferTypeThe type of offer (OfferType.BuyYt / OfferType.SellYt)
minAmountOutbigintMinimum amount to receive (slippage protection)
virtualOfferbooleanWhether this is a virtual offer
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 an object with:
  • ix - The TransactionInstruction that executes the market order
  • setupIxs - An array of setup instructions to run before ix:
    • setupIxs[0] - Creates the PT associated token account for the trader (if it doesn’t exist)
    • setupIxs[1] - Creates the YT associated token account for the trader (if it doesn’t exist)
    • setupIxs[2] - Creates the SY associated token account for the trader (if it doesn’t exist)