Skip to main content

Documentation Index

Fetch the complete documentation index at: https://v2-docs.exponent.finance/llms.txt

Use this file to discover all available pages before exploring further.

The liquidityUnitPriceInAsset() method calculates the price per unit of liquidity in underlying asset terms, considering only the principal value (excluding fees) for a specific tick range.

Usage

import { MarketThree, LOCAL_ENV } from "@exponent-labs/exponent-sdk";
import { Connection } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");
const market = await MarketThree.load(LOCAL_ENV, connection, marketAddress);

// Calculate liquidity unit price for a tick range
const lowerTickKey = 50000;  // 5% APY (scaled by 10^6)
const upperTickKey = 100000; // 10% APY (scaled by 10^6)

const pricePerUnit = market.liquidityUnitPriceInAsset({
  lowerTickKey,
  upperTickKey,
});

console.log("Price per unit of liquidity:", pricePerUnit);

// Optional: use custom ticks or SY exchange rate
const customPrice = market.liquidityUnitPriceInAsset({
  lowerTickKey,
  upperTickKey,
  ticksOverride: customTicksAccount,
  syExchangeRateOverride: 1.05,
});

Parameters

ParameterTypeRequiredDescription
lowerTickKeynumberYesInclusive tick key for the left boundary (scaled by 10^6)
upperTickKeynumberYesExclusive tick key for the right boundary (scaled by 10^6)
ticksOverrideTicksNoOptional ticks account data (defaults to the instance state)
syExchangeRateOverridenumberNoOptional SY exchange rate (defaults to current flavor rate)

Returns

Returns a number representing the price per unit of liquidity in underlying asset terms (principal only). Returns 0 if:
  • No ticks exist in the specified range
  • Total share supply is 0
  • lowerTickKey >= upperTickKey (throws error)

Calculation Details

The method:
  1. Filters tick intervals within the specified range
  2. Aggregates principalPt, principalSy, and principalShareSupply across intervals
  3. Calculates PT asset value using time decay:
    ptAssetValuePerToken = exp(-timeFactor * currentSpotPrice)
    
  4. Computes total principal value:
    principalValue = (principalPt * ptAssetValue) + (principalSy * syExchangeRate)
    
  5. Returns price per unit:
    pricePerUnit = principalValue / totalShareSupply
    
This calculation excludes accrued fees and represents only the principal component of the liquidity position.