> ## Documentation Index
> Fetch the complete documentation index at: https://build.flashnet.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Querying Pools

> List, filter, and retrieve pool state and market data

The Flashnet SDK allows you to discover active liquidity pools and retrieve detailed market data for them. You can list all available pools with powerful filtering and sorting options, or query for the specific details of a single pool.

The `listPools` method returns all pool types: V2 constant product, V2 bonding curve, and V3 concentrated liquidity. Each pool type has a different `curveType` value.

## Listing Pools

The `listPools` method is the primary way to discover pools. You can use it without any parameters to get a list of all pools, or provide a query object to filter and sort the results.

```typescript theme={null}
async function discoverPools() {
  try {
    const response = await client.listPools({
      minTvl: 10000, // Minimum TVL of $10,000 (if Asset B is a stablecoin)
      sort: "VOLUME24H_DESC", // Show most active pools first
      limit: 20,
    });

    console.log(`Found ${response.totalCount} pools meeting the criteria.`);
    response.pools.forEach(pool => {
      console.log(`- Pool ${pool.lpPublicKey}: TVL = ${pool.tvlAssetB}, Volume (24h) = ${pool.volume24hAssetB}`);
    });

  } catch (error) {
    console.error('Failed to list pools:', error);
  }
}
```

### Filtering and Sorting

The `listPools` method accepts a `ListPoolsQuery` object with the following options:

| Parameter        | Type            | Description                                                                     |
| ---------------- | --------------- | ------------------------------------------------------------------------------- |
| `assetAAddress`  | `string`        | Filter by the address of Asset A.                                               |
| `assetBAddress`  | `string`        | Filter by the address of Asset B.                                               |
| `hostNames`      | `string[]`      | Filter by one or more host namespaces.                                          |
| `minVolume24h`   | `number`        | Only include pools with 24-hour volume above this value.                        |
| `minTvl`         | `number`        | Only include pools with TVL above this value.                                   |
| `curveTypes`     | `string[]`      | Filter by curve type: `CONSTANT_PRODUCT`, `SINGLE_SIDED`, or `V3_CONCENTRATED`. |
| `sort`           | `PoolSortOrder` | Sort results by `TVL`, `VOLUME24H`, or `CREATED_AT`.                            |
| `limit`          | `number`        | The maximum number of pools to return.                                          |
| `offset`         | `number`        | The number of pools to skip for pagination.                                     |
| `afterUpdatedAt` | `string`        | RFC3339 timestamp to get pools updated after a date.                            |

### Example: Finding Specific Pairs

```typescript theme={null}
async function findBtcUsdbPools() {
  const pools = await client.listPools({
    assetAAddress: "bitcoin-pubkey",
    assetBAddress: "usdb-pubkey",
    sort: "TVL_DESC",
  });
  console.log('Found BTC/USDB pools by TVL:', pools);
}
```

## Getting Pool Details

To get all available information for a single pool, use the `getPool` method with the pool's ID (its `lpPublicKey`).

```typescript theme={null}
async function getPoolDetails(poolId: string) {
  try {
    const pool = await client.getPool(poolId);

    console.log('Pool Details:', pool);
    console.log(`- TVL: ${pool.tvlAssetB}`);
    console.log(`- 24h Volume: ${pool.volume24hAssetB}`);
    console.log(`- 24h Price Change: ${pool.priceChangePercent24h}%`);
    console.log(`- Current Price: ${pool.currentPriceAInB}`);

  } catch (error) {
    console.error('Failed to get pool details:', error);
  }
}
```

## Understanding Market Data

The pool objects returned by the SDK contain valuable market data. Some fields are common to all pool types, while others are specific to either constant product or single-sided bonding curve pools.

| Field                       | Applies To   | Description                                                                                             |
| --------------------------- | ------------ | ------------------------------------------------------------------------------------------------------- |
| `lpPublicKey`               | Both         | The unique identifier (public key) for the liquidity pool. This is used as the `poolId`.                |
| `hostName`                  | Both         | The namespace of the host that created the pool, if any.                                                |
| `hostFeeBps`                | Both         | The host fee rate in basis points (e.g., 100 BPS = 1%).                                                 |
| `lpFeeBps`                  | Both         | The liquidity provider fee rate in basis points (e.g., 30 BPS = 0.3%).                                  |
| `assetAAddress`             | Both         | The public key (address) of the first asset in the pair.                                                |
| `assetBAddress`             | Both         | The public key (address) of the second asset in the pair.                                               |
| `assetAReserve`             | Both         | The current amount of Asset A held in the pool's reserves.                                              |
| `assetBReserve`             | Both         | The current amount of Asset B held in the pool's reserves.                                              |
| `tvlAssetB`                 | Both         | Total Value Locked, denominated in Asset B. This is a key measure of a pool's liquidity.                |
| `volume24hAssetB`           | Both         | The total value of assets swapped in the pool over the last 24 hours, denominated in Asset B.           |
| `priceChangePercent24h`     | Both         | The percentage change in the price of Asset A relative to Asset B over the last 24 hours.               |
| `currentPriceAInB`          | Both         | The current spot price of Asset A in terms of Asset B, calculated from the pool's reserves.             |
| `curveType`                 | All          | The type of pool: `CONSTANT_PRODUCT`, `SINGLE_SIDED`, or `V3_CONCENTRATED`.                             |
| `createdAt`                 | Both         | The timestamp when the pool was created.                                                                |
| `updatedAt`                 | Both         | The timestamp of the last event (e.g., swap, liquidity change) that updated the pool's state.           |
| `virtualReserveA`           | Single-Sided | The virtual reserve of Asset A used for price calculations along the bonding curve.                     |
| `virtualReserveB`           | Single-Sided | The virtual reserve of Asset B used for price calculations along the bonding curve.                     |
| `initialReserveA`           | Single-Sided | The initial amount of Asset A deposited by the creator to start the bonding curve.                      |
| `graduationThresholdAmount` | Single-Sided | The absolute amount of Asset A that must be sold for the pool to "graduate" to a constant product pool. |
| `bondingProgressPercent`    | Single-Sided | The percentage of the `graduationThresholdAmount` that has been met so far.                             |
| `thresholdPct`              | Single-Sided | The graduation threshold expressed as a percentage of the `initialReserveA`.                            |
| `currentTick`               | V3 Only      | The current tick representing the pool's price.                                                         |
| `tickSpacing`               | V3 Only      | The minimum tick increment for positions (10, 60, or 200).                                              |
| `sqrtPriceX96`              | V3 Only      | The square root of price scaled by 2^96 for precise calculations.                                       |
| `totalLiquidity`            | V3 Only      | Total liquidity across all positions in the V3 pool.                                                    |
| `positionCount`             | V3 Only      | Number of active liquidity positions in the V3 pool.                                                    |

## Filtering by Pool Type

```typescript theme={null}
// List only V3 concentrated liquidity pools
const v3Pools = await client.listPools({
  curveTypes: ["V3_CONCENTRATED"],
  sort: "TVL_DESC",
});

// List only V2 constant product pools
const v2Pools = await client.listPools({
  curveTypes: ["CONSTANT_PRODUCT"],
});

// List all pool types
const allPools = await client.listPools();
for (const pool of allPools.pools) {
  console.log(`${pool.lpPublicKey}: ${pool.curveType}`);
}
```

## V3 Pool Details

V3 pools have additional endpoints for detailed liquidity data:

```typescript theme={null}
// Get liquidity distribution for depth charts
const liquidity = await client.getPoolLiquidity("v3-pool-id");
console.log('Current price:', liquidity.currentPrice);
console.log('Active liquidity:', liquidity.activeLiquidity);
console.log('Liquidity ranges:', liquidity.ranges.length);

// Get tick data for swap simulation
const ticks = await client.getPoolTicks("v3-pool-id");
console.log('Current tick:', ticks.currentTick);
console.log('LP fee:', ticks.lpFeeBps, 'bps');
```

See [Concentrated Liquidity](/products/flashnet-amm/concentrated-liquidity) for the full V3 API including position management.
