Skip to main content

The following pattern shows the state reads that are useful before routing a user into a tranche or accepting tranching LP tokens in another protocol.
import {
  TranchingMarket,
  tranchingFromNumber,
} from "@exponent-labs/exponent-sdk";
import {
  TrancheSide,
  TranchingMarketState,
} from "@exponent-labs/exponent-sdk/client/tranching";
import { PublicKey } from "@solana/web3.js";

const market = await TranchingMarket.load(connection, new PublicKey("..."), env);
await market.reload();

const side = TrancheSide.Senior;
const lpMint = market.lpMint(side);
const userLpAta = market.lpAta(side, user);

const isPaused = (market.state.statusFlags & 1) !== 0;
const isRecovery =
  market.state.marketState === TranchingMarketState.FixedTermRecovery;

const lpPrice =
  side === TrancheSide.Senior
    ? market.getSrLpPriceNetAsset()
    : market.getJrLpPriceNetAsset();

const remainingNavCapacity =
  side === TrancheSide.Senior
    ? market.getSyncedSrRemainingCapacityNetAssetValue()
    : market.getSyncedJrRemainingCapacityNetAssetValue();

console.log({
  lpMint: lpMint.toBase58(),
  userLpAta: userLpAta.toBase58(),
  isPaused,
  isRecovery,
  lpPriceRaw: lpPrice, // raw fixed-point NAV per raw LP unit
  lpPriceFixedPoint: tranchingFromNumber(lpPrice),
  remainingNavCapacityRaw: remainingNavCapacity, // raw fixed-point NAV units
  remainingNavCapacityFixedPoint: tranchingFromNumber(remainingNavCapacity),
  utilization: tranchingFromNumber(market.state.financials.utilization),
  fixedTermEndTsSec: market.state.financials.fixedTermEndTs,
});
tranchingFromNumber only converts Exponent Tranching Number fixed-point values. It does not divide token amounts by mint decimals. Balance, NAV, and transaction amount displays usually also need the SY, base, and LP mint decimals.

Transaction Builders

A transaction can then be built with the instruction that matches the user’s input and desired output:
User starts withUser wantsSDK method
Base assetLP tokensixWrapperDeposit
SYLP tokensixDeposit
LP tokensSYixWithdraw
LP tokensBase assetixWrapperWithdraw
Output protection is normally represented by these guard fields:
MethodOutput guard
ixWrapperDepositminLpOut
ixDepositminLpOut
ixWithdrawminAmountOut
ixWrapperWithdrawminBaseOut

Integration Sequence

Most integrations follow this sequence:
  1. TranchingMarket.load(...) creates the market context.
  2. market.reload() refreshes state before pricing or transaction construction.
  3. market.lpMint(trancheSide) identifies the selected LP mint.
  4. getSrLpPriceNetAsset() or getJrLpPriceNetAsset() provides the effective-NAV price input.
  5. state.marketState, state.statusFlags, utilization, and recovery timestamps describe the current lifecycle and risk state.
  6. Capacity Helpers provide remaining Senior or Junior room.
  7. APY and Protection helpers can show expected Senior/Junior return and Senior drawdown protection.
  8. SDK instruction builders construct the deposit or withdrawal transaction, with minLpOut, minAmountOut, or minBaseOut as output guards.
  9. Lending integrations usually treat FixedTermRecovery as a Senior redemption lock and apply conservative collateral factors to Junior LP because Junior absorbs first losses.

Read Functions

SDK getters for market state, LP prices, capacity, APY, and token accounts.

TypeScript Instructions

SDK builders for deposits, withdrawals, and wrappers.