Skip to main content
The ixWrapperProvideLiquidity method on the MarketThree class provides liquidity to the CLMM pool using base assets. It wraps the base into SY, strips SY into PT and YT, adds liquidity with the PT, and returns YT and LP tokens to the depositor in a single atomic operation.

Usage

import { MarketThree, LOCAL_ENV } from "@exponent-labs/exponent-sdk";
import { Connection, PublicKey, Transaction, sendAndConfirmTransaction, Keypair } 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, signers } = await market.ixWrapperProvideLiquidity({
  depositor: wallet.publicKey,
  amountBase: 10_000_000_000n,
  minLpOut: 9_000_000_000n,
  lowerTickApy: 0.05,  // 5% APY
  upperTickApy: 0.15,  // 15% APY
});

const tx = new Transaction().add(...setupIxs, ...ixs);
const signature = await sendAndConfirmTransaction(connection, tx, [wallet, ...signers]);
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
depositorPublicKeyThe depositor’s wallet public key
amountBasebigintAmount of base asset to provide
minLpOutbigintMinimum amount of LP tokens to receive
lowerTickApynumberLower bound APY for the liquidity range
upperTickApynumberUpper bound APY for the liquidity range

Optional Parameters

ParameterTypeDescription
tokenSyDepositorPublicKeyIntermediate SY token account. Defaults to depositor’s ATA
tokenYtDepositorPublicKeyDestination YT token account. Defaults to depositor’s ATA
tokenPtDepositorPublicKeyIntermediate PT token account. Defaults to depositor’s ATA
tokenBaseDepositorPublicKeySource base token account. Defaults to depositor’s ATA
lpPositionKeypair | PublicKeyLP position account. Defaults to a generated Keypair

Returns

Returns a Promise<PreparedInstruction> with the following structure:
{
  ixs: TransactionInstruction[],      // Main instructions to execute
  setupIxs: TransactionInstruction[], // Setup instructions for creating ATAs
  signers?: Keypair[]                 // Optional signers (lpPosition if generated)
}
The setupIxs array contains instructions to create the necessary associated token accounts (ATAs) for SY, YT, and PT tokens. The ixs array contains the flavor pre-instructions, the provide liquidity instruction, and the flavor post-instructions. If lpPosition was not provided, signers will contain the generated LP position keypair.