# 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

```typescript
// 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

```typescript
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:

```typescript
{
  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

```typescript
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

```typescript
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

```typescript
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

1. **Market Discovery**: Find available trading opportunities
2. **Liquidity Analysis**: Identify pairs with sufficient depth
3. **Pair Selection**: Choose optimal pairs for trading strategies
4. **Network Overview**: Monitor total market deployment

### Related Topics

* [Get Single Pair](/integration/dlmm/typescript-sdk/trading-pairs/get-single-pair.md) - Fetch specific pair details
* [Create LB Pair](/integration/dlmm/typescript-sdk/trading-pairs/create-lb-pair.md) - Deploy new pairs
* [Get Pair Reserves](/integration/dlmm/typescript-sdk/trading-pairs/get-pair-reserves.md) - Detailed liquidity distribution
* [Execute Swap](/integration/dlmm/typescript-sdk/swap-operations/execute-swap.md) - Trade on discovered pairs


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ferra.ag/integration/dlmm/typescript-sdk/trading-pairs/get-all-pairs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
