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

Usage

import { Vault, LOCAL_ENV, amount } from "@exponent-labs/exponent-sdk";
import { Connection, PublicKey, 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);

// Collect all available interest
const ix = vault.ixCollectInterest({
  owner: wallet.publicKey,
  amount: amount("All"),
});

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

Required Parameters

ParameterTypeDescription
ownerPublicKeyThe owner’s wallet public key
amountAmountamount("All") or amount("Some", [value])

Optional Parameters

ParameterTypeDescription
syDstPublicKeyDestination SY token account. Defaults to owner’s ATA

Returns

Returns a TransactionInstruction that transfers accrued SY interest to the owner.
You must stage yield before collecting. Staging computes the earned interest from the exchange rate delta.