Skip to main content

createWrapperCollectInterestInstruction

Builds a raw instruction that collects accrued interest from the orderbook with automatic SY redemption to the base asset. This combines the interest collection and SY redemption steps atomically.

Usage

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

const ix = createWrapperCollectInterestInstruction(
  {
    trader: wallet.publicKey,
    orderbook: orderbookAddress,
    vault: vaultAddress,
    cpiAccountOrderbook: cpiAccountsOrderbook,
    tokenEscrowSy: orderbookEscrowSy,
    tokenSyTrader: userSyTokenAccount,
    systemProgram: SystemProgram.programId,
    syProgram: syProgramId,
    tokenProgram: TOKEN_PROGRAM_ID,
    exponentCore: EXPONENT_CORE_PROGRAM_ID,
    addressLookupTable: vaultLookupTable,
    eventAuthority: eventAuthorityPda,
    program: EXPONENT_ORDERBOOK_PROGRAM_ID,
  },
  {
    redeemSyAccountsUntil: 0,
  }
);

Accounts

NameTypeSignerWritableDescription
traderPublicKeyYesNoThe trader collecting interest
orderbookPublicKeyNoYesOrderbook account
vaultPublicKeyNoYesVault account
cpiAccountOrderbookPublicKeyNoNoCPI accounts orderbook
tokenEscrowSyPublicKeyNoYesOrderbook SY escrow account
tokenSyTraderPublicKeyNoYesTrader’s SY token account
systemProgramPublicKeyNoNoSystem program
syProgramPublicKeyNoNoSY program
tokenProgramPublicKeyNoNoSPL Token program
exponentCorePublicKeyNoNoExponent Core program
addressLookupTablePublicKeyNoNoVault address lookup table
eventAuthorityPublicKeyNoNoEvent authority PDA
programPublicKeyNoNoExponent Orderbook program

Args

NameTypeDescription
redeemSyAccountsUntilnumberIndex into remaining accounts for SY redemption CPI accounts

Returns

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