Skip to main content

createCollectInterestInstruction

Builds a raw instruction to collect accrued interest (paid in SY) from a yield position.

Usage

import { createCollectInterestInstruction, amount } from "@exponent-labs/exponent-sdk/client/core";
import { PublicKey } from "@solana/web3.js";

// Collect all accrued interest
const ix = createCollectInterestInstruction(
  {
    owner: wallet.publicKey,
    yieldPosition: userYieldPositionPda,
    vault: vaultAddress,
    tokenSyDst: userSyTokenAccount,
    escrowSy: vaultEscrowSy,
    authority: vaultAuthority,
    tokenProgram: TOKEN_PROGRAM_ID,
    syProgram: syProgramId,
    treasurySyTokenAccount: treasurySyAccount,
    addressLookupTable: vaultLookupTable,
    eventAuthority: eventAuthorityPda,
    program: EXPONENT_CORE_PROGRAM_ID,
  },
  {
    amount: amount("All"),
  }
);

// Collect a specific amount
const ixPartial = createCollectInterestInstruction(
  { /* ...same accounts... */ },
  {
    amount: amount("Some", [500_000n]),
  }
);

Accounts

NameTypeSignerWritableDescription
ownerPublicKeyYesYesThe yield position owner
yieldPositionPublicKeyNoYesUser’s yield position PDA
vaultPublicKeyNoYesVault account
tokenSyDstPublicKeyNoYesDestination SY token account
escrowSyPublicKeyNoYesVault SY escrow account
authorityPublicKeyNoYesVault authority PDA
tokenProgramPublicKeyNoNoSPL Token program
syProgramPublicKeyNoNoSY program
treasurySyTokenAccountPublicKeyNoYesTreasury SY token account (fees)
addressLookupTablePublicKeyNoNoVault address lookup table
eventAuthorityPublicKeyNoNoEvent authority PDA
programPublicKeyNoNoExponent Core program

Args

NameTypeDescription
amountAmountAmount to collect: amount("All") or amount("Some", [value])

Amount Helper

import { amount } from "@exponent-labs/exponent-sdk/client/core";

amount("All")                // collect everything available
amount("Some", [500_000n])   // collect a specific amount

Returns

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