Get All Pairs
Get All Pairs
Discover all available DLMM trading pairs deployed on the network. This method fetches the complete list of pair contracts with their current configuration and state.
Prerequisites
Before fetching pairs:
Initialize the SDK with network connection
Ensure RPC endpoint is accessible
Understand LBPair data structure
Basic Usage
// Fetch all pairs from the network
const allPairs = await sdk.Pair.getPairs();
console.log(`Total pairs found: ${allPairs.length}`);
// Access pair data
allPairs.forEach(pair => {
console.log({
pairId: pair.id,
tokenX: pair.tokenXType,
tokenY: pair.tokenYType,
activeId: pair.parameters.active_id,
binStep: pair.binStep
});
});
Method Details
async getPairs(): Promise<LBPair[]>
Returns an array of all LBPair objects containing:
Pair configuration (tokens, bin step)
Current state (reserves, active bin)
Manager addresses (bins, positions)
Fee parameters
Understanding the Response
Each pair in the array contains:
{
id: "0x123...", // Unique pair address
tokenXType: "0x2::sui::SUI", // Full type of token X
tokenYType: "0x...::USDC", // Full type of token Y
binStep: "20", // Price granularity (basis points)
reserveX: "1000000000", // Total X token reserves
reserveY: "2000000000", // Total Y token reserves
parameters: {
active_id: 8388608, // Current trading bin
// ... other parameters
}
}
Practical Examples
Find Specific Token Pairs
const pairs = await sdk.Pair.getPairs();
// Find all pairs containing SUI
const suiPairs = pairs.filter(pair =>
pair.tokenXType === "0x2::sui::SUI" ||
pair.tokenYType === "0x2::sui::SUI"
);
Check Pair Activity
const pairs = await sdk.Pair.getPairs();
// Find pairs with liquidity
const activePairs = pairs.filter(pair =>
BigInt(pair.reserveX) > 0n || BigInt(pair.reserveY) > 0n
);
console.log(`Active pairs: ${activePairs.length}/${pairs.length}`);
Group by Bin Step
const pairs = await sdk.Pair.getPairs();
const pairsByBinStep = pairs.reduce((groups, pair) => {
const step = pair.binStep;
if (!groups[step]) groups[step] = [];
groups[step].push(pair);
return groups;
}, {});
console.log("Pairs grouped by bin step:", Object.keys(pairsByBinStep));
Performance Considerations
First call may take longer due to network fetching
Returns all pairs in a single response (no pagination)
Consider caching results for repeated access
Large deployments may have significant response size
Common Use Cases
Market Discovery: Find available trading opportunities
Liquidity Analysis: Identify pairs with sufficient depth
Pair Selection: Choose optimal pairs for trading strategies
Network Overview: Monitor total market deployment
Related Topics
Get Single Pair - Fetch specific pair details
Create LB Pair - Deploy new pairs
Get Pair Reserves - Detailed liquidity distribution
Execute Swap - Trade on discovered pairs
Last updated