Skip to main content
The ixWrapperBuyYt method on the MarketThree class converts base assets into YT (Yield Tokens) by wrapping the base into SY, stripping SY into PT and YT, and swapping the PT back for SY in a single atomic operation.

Usage

import { MarketThree, LOCAL_ENV } 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 market = await MarketThree.load(LOCAL_ENV, connection, marketAddress);

const { ixs, setupIxs } = await market.ixWrapperBuyYt({
  owner: wallet.publicKey,
  ytOut: 1_000_000_000n,
  maxBaseIn: 1_200_000_000n,
});

const tx = new Transaction().add(...setupIxs, ...ixs);
const signature = await sendAndConfirmTransaction(connection, tx, [wallet]);
This is an async method because it needs to construct the SY minting accounts and YT deposit accounts from the market’s configuration.

Required Parameters

ParameterTypeDescription
ownerPublicKeyThe owner’s wallet public key
ytOutbigintAmount of YT tokens to receive
maxBaseInbigintMaximum amount of base asset to spend

Optional Parameters

ParameterTypeDescription
tokenSyTraderPublicKeyIntermediate SY token account. Defaults to owner’s ATA
tokenPtTraderPublicKeyIntermediate PT token account. Defaults to owner’s ATA
tokenYtTraderPublicKeyDestination YT token account. Defaults to owner’s ATA
tokenBaseTraderPublicKeySource base token account. Defaults to owner’s ATA

Returns

Returns a Promise<PreparedInstruction> with the following structure:
{
  ixs: TransactionInstruction[],      // Main instructions to execute
  setupIxs: TransactionInstruction[]  // Setup instructions for creating ATAs
}
The setupIxs array contains instructions to create the necessary associated token accounts (ATAs) for SY, PT, and YT tokens. The ixs array contains the flavor pre-instructions followed by the buy YT instruction.