Skip to main content
The ixCollectInterest method on the YtPosition class creates a transaction instruction that collects staged interest (paid in SY) from the yield position.

Usage

import { Vault, YtPosition, LOCAL_ENV } from "@exponent-labs/exponent-sdk";
import { Connection, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const vault = await Vault.load(LOCAL_ENV, connection, vaultAddress);
const ytPosition = await YtPosition.loadByOwner(LOCAL_ENV, connection, wallet.publicKey, vault);

// Collect all staged interest
const ix = ytPosition.ixCollectInterest({
  signer: wallet.publicKey,
});

const tx = new Transaction().add(ix);
const signature = await sendAndConfirmTransaction(connection, tx, [wallet]);
To collect a specific amount:
const ix = ytPosition.ixCollectInterest({
  signer: wallet.publicKey,
  amount: 500_000n,
});

Required Parameters

ParameterTypeDescription
signerPublicKeyThe position owner (signer)

Optional Parameters

ParameterTypeDescription
syDstPublicKeyDestination SY token account. Defaults to signer’s ATA
amountbigintSpecific amount to collect. Defaults to all available

Returns

Returns a TransactionInstruction that transfers staged SY interest to the owner.
You must stage yield before collecting. Staging and collecting can be combined in the same transaction.