Skip to main content

createWrapperPostOfferInstruction

Builds a raw instruction that posts a limit order offer to the orderbook with automatic SY minting or YT withdrawal. This combines the SY minting/YT withdrawal and offer posting steps atomically.

Usage

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

const ix = createWrapperPostOfferInstruction(
  {
    trader: wallet.publicKey,
    orderbook: orderbookAddress,
    vault: vaultAddress,
    cpiAccountOrderbook: cpiAccountsOrderbook,
    yieldPosition: yieldPositionPda,
    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,
  },
  {
    priceApy: 5.5,
    amountBase: BigInt(1_000_000),
    offerType: { sellYt: {} },
    virtualOffer: false,
    expirySeconds: 3600,
    options: { fillOrKill: [false] },
    mintSyOrWithdrawYtAccountsUntil: 0,
  }
);

Accounts

NameTypeSignerWritableDescription
traderPublicKeyYesNoThe trader posting the offer
orderbookPublicKeyNoYesOrderbook account
vaultPublicKeyNoYesVault account
cpiAccountOrderbookPublicKeyNoNoCPI accounts orderbook
yieldPositionPublicKeyNoYesUser’s yield position PDA
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
priceApynumberPrice as implied APY (f64)
amountBasebigintAmount of base asset to use (in base units)
offerTypeOfferTypeType of offer (SellYt or BuyYt)
virtualOfferbooleanWhether this is a virtual offer
expirySecondsnumberExpiry time in seconds (u32)
optionsOfferOptionsOffer options (e.g., FillOrKill)
mintSyOrWithdrawYtAccountsUntilnumberIndex into remaining accounts for SY minting or YT withdrawal CPI accounts

Returns

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