Get Pair Reserves

Fetch complete liquidity distribution across all bins in a pair, including reserves and accumulated fees. This method provides a comprehensive view of the entire liquidity landscape.

Prerequisites

Before fetching reserves:

  • Have a valid LBPair object from getPair()

  • Understand the difference between reserves and fees

  • Be prepared to handle potentially large datasets

Basic Usage

// Get pair first
const pair = await sdk.Pair.getPair(pairAddress);

// Fetch all bin reserves
const reserves = await sdk.Pair.getPairReserves(pair);

console.log(`Total bins with liquidity: ${reserves.length}`);

// Display first few bins
reserves.slice(0, 5).forEach(bin => {
  console.log(`Bin ${bin.id}:`, {
    reserveX: bin.reserve_x.toString(),
    reserveY: bin.reserve_y.toString(),
    feeX: bin.fee_x.toString(),
    feeY: bin.fee_y.toString()
  });
});

Method Signature

Returns

Array of BinReserves objects sorted by bin ID:

Understanding the Data

Reserves vs Fees

  • Reserves: Liquidity available for trading

  • Fees: Accumulated trading fees not yet collected

  • Total: reserves + fees = total bin value

Practical Examples

Calculate Total Value Locked (TVL)

Find Liquidity Distribution

Analyze Fee Generation

Create Liquidity Heatmap Data

Performance Considerations

  • Fetches all bins with liquidity (no range limit)

  • Uses pagination internally for large datasets

  • May return hundreds of bins for active pairs

  • Consider caching results for repeated analysis

Differences from getPairBins

Feature
getPairReserves
getPairBins

Range

All bins with liquidity

Specified range only

Fees

Includes accumulated fees

Reserves only

Performance

Slower for large pairs

Faster for small ranges

Use Case

Complete analysis

Targeted inspection

Last updated