Get Pair Bins
Retrieve detailed bin data for a specific trading pair within a given range. This method allows you to inspect liquidity distribution and reserves at each price level.
Prerequisites
Before fetching bin data:
Have a valid LBPair object from
getPair()orgetPairs()Understand bin ID ranges and price relationships
Know which bins to inspect (around active bin)
Basic Usage
// First, get the pair
const pair = await sdk.Pair.getPair(pairAddress);
// Fetch bins around the active bin
const activeId = pair.parameters.active_id;
const bins = await sdk.Pair.getPairBins(
pair,
[activeId - 10, activeId + 10] // 20 bins range
);
// Display bin reserves
bins.forEach((bin, index) => {
const binId = activeId - 10 + index;
console.log(`Bin ${binId}:`, {
reserveX: bin.reserve_x.toString(),
reserveY: bin.reserve_y.toString()
});
});Method Signature
Parameters
pair: The LBPair object to querybinRange: Tuple of [fromBinId, toBinId] (inclusive start, exclusive end)
Returns
Array of PairBin objects:
Understanding Bin Ranges
Practical Examples
Analyze Liquidity Depth
Find Liquidity Walls
Display Price Levels
Performance Notes
Queries use
devInspectTransactionBlock(no gas cost)Larger ranges take more time to fetch
Maximum practical range depends on RPC limits
Consider chunking very large ranges
Common Use Cases
Order Book Visualization: Display liquidity at each price level
Slippage Calculation: Estimate impact before swaps
Liquidity Analysis: Find optimal entry/exit points
Market Depth: Assess pair's ability to handle large trades
Related Topics
Get Pair Reserves - Complete liquidity distribution
Price Impact - Calculate trade impact
Add Liquidity Overview - Add to specific bins
Last updated