Get Single Pair
Fetch comprehensive data for a specific DLMM trading pair including reserves, fees, and configuration.
Prerequisites
Before fetching pair data:
Have a valid pair address
Initialize the SDK with network connection
Understand basic pair structure and bins
Basic Usage
const pairAddress = "0x123...abc";
const pair = await sdk.Pair.getPair(pairAddress);
if (!pair) {
console.log("Pair not found");
return;
}
console.log("Active Bin ID:", pair.parameters.active_id);
console.log("Bin Step:", pair.binStep);
Returned Data Structure
interface LBPair {
id: string; // Pair object address
tokenXType: string; // Token X full type
tokenYType: string; // Token Y full type
binStep: string; // Basis points
reserveX: string; // Total X reserves
reserveY: string; // Total Y reserves
parameters: {
active_id: number; // Current trading bin
base_factor: string; // Base fee factor
protocol_share: string; // Protocol fee %
volatility_accumulator: string;
// ... more fee parameters
};
binManager: string; // Bins storage address
positionManager: {
id: string; // Positions storage
total_supplies: string; // Supply tracking
};
}
Common Usage Patterns
Check Pair Status
const pair = await sdk.Pair.getPair(pairAddress);
// Calculate current price from active bin
const currentPrice = getPriceFromBinId(
pair.parameters.active_id,
Number(pair.binStep)
);
// Check liquidity depth
const hasLiquidity = BigInt(pair.reserveX) > 0n ||
BigInt(pair.reserveY) > 0n;
Monitor Pair Metrics
// Get fee configuration
const baseFee = Number(pair.parameters.base_factor);
const protocolShare = Number(pair.parameters.protocol_share);
// Calculate TVL (simplified)
const tvl = calculateTVL(
pair.reserveX,
pair.reserveY,
currentPrice
);
Error Handling
try {
const pair = await sdk.Pair.getPair(invalidAddress);
if (!pair) {
// Address valid but pair doesn't exist
handlePairNotFound();
}
} catch (error) {
// Invalid address format
console.error("Invalid pair address");
}
Use Cases
Before Trading: Check reserves and active bin
Analytics: Monitor TVL and fee parameters
Position Management: Get position manager address
Price Discovery: Find current trading price
Related Topics
Get All Pairs - Discover available pairs
Get Pair Bins - Detailed bin information
Get Pair Reserves - Liquidity distribution
Execute Swap - Trade on the pair
Last updated