Calculate Pool Metrics

Calculate key performance indicators for liquidity pools.

Quick Start

// Get pool and calculate basic metrics
const pool = await sdk.Pool.getPool(poolId)

// Current price
const price = TickMath.sqrtPriceX64ToPrice(
  pool.current_sqrt_price,
  9,  // decimalsA
  6   // decimalsB
)

// TVL in tokens
const tvlA = Number(pool.coinAmountA) / 10**9
const tvlB = Number(pool.coinAmountB) / 10**6

console.log({
  price: price.toFixed(4),
  tvlSUI: tvlA,
  tvlUSDC: tvlB
})

Price Calculations

Current Price

Price Range

TVL Calculation

Pool TVL

Position Value

APR Calculations

Fee APR

Total APR with Rewards

Volume Metrics

Estimate from Fees

Price Impact

Calculate for Swap

Liquidity Distribution

Active Liquidity

Complete Example

Important Notes

  • TVL calculation requires external price feeds

  • APR is estimated based on historical data

  • Volume calculation depends on fee collection data

  • Price impact varies with liquidity distribution

  • Metrics should be cached for performance

  • Consider using indexer for historical data

Last updated