> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-sdk-v2/dynamic-pool-and-token-data.md).

# Dynamic Pool & Token Data

Fetch the live pool and token config from Flash's CDN instead of the snapshot bundled with the SDK, and pick up new pools, token listings, custody changes, and oracle updates without an SDK upgrade or a redeploy.

### Why the bundled snapshot goes stale

`PoolConfig.fromIdsByName('Crypto.1', 'mainnet-beta')` reads pool and token data compiled into the npm package — a snapshot frozen at the version you installed. When Flash adds a pool, lists a token, changes a custody, or updates an oracle, that snapshot is out of date until the next SDK release ships and you upgrade.

The live config is published to a CDN as a single JSON manifest — the same data the Flash UI and Flash's own bots run on. Read it at runtime and your integration stays current the moment protocol config changes.

### Fetch the manifest

```
https://dxjms0h859jb3.cloudfront.net/pool-config/flash-trade-v2/prod.json
```

The shape, trimmed to the fields you'll reach for first:

```json
{
  "configMeta": {
    "version": "<commit SHA the config was published from>",
    "env": "prod",
    "publishedAt": "2026-07-08T11:55:39Z",
    "promotedAt": "2026-07-08T11:56:24Z"
  },
  "pools": [
    {
      "poolName": "Crypto.1",
      "cluster": "mainnet-beta",
      "poolAddress": "HfF7GCcEc76…",
      "tokens": [],
      "custodies": [],
      "markets": [],
      "addressLookupTableAddresses": []
    }
  ],
  "otherTokens": []
}
```

Three top-level keys:

| Key             | What it holds                                                                                                                                                                |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `configMeta`    | Publish metadata. `version` is the commit the config was published from — log it so a stale-config bug is one grep away.                                                     |
| `pools[]`       | Full config for every pool: addresses, custodies, markets, tokens, and lookup tables — every field `PoolConfig` needs.                                                       |
| `otherTokens[]` | The protocol-wide token directory (symbols, mints, decimals, price ids, icons) for tokens not currently in a pool — useful for search and display without a pool round-trip. |

One file carries **both clusters'** pools. Every `pools[]` entry has a `cluster` field (`mainnet-beta` or `devnet`), so you filter by cluster after fetching — not by URL.

{% hint style="info" %}
**Don't hardcode pool names.** The manifest is the source of truth and grows as pools launch — treat any static pool list in older docs or examples as illustrative. `listDynamicPools.ts` (below) prints exactly what is live right now.
{% endhint %}

### Use it in your app

Copy [`fetchPoolConfigManifest.ts`](https://github.com/flash-trade/flash-sdk-v2/blob/main/examples/config/fetchPoolConfigManifest.ts) into your project. It is self-contained — its only dependency is the SDK's public `PoolConfig.buildPoolconfigFromJson` — and it returns real `PoolConfig` instances you hand to `FlashPerpetualsClient` exactly like the bundled one:

```ts
import { fetchPoolConfigManifest } from './fetchPoolConfigManifest'

const manifest = await fetchPoolConfigManifest('mainnet-beta', { poolNames: ['Crypto.1'] })
const poolConfig = manifest!.pools[0] // a real PoolConfig — use it anywhere

// poolConfig drives markets, custodies, tokens, lookup tables, oracles — all live.
```

Omit `poolNames` to build every pool for the cluster.

### Hot-reload in bots and backends

Long-running processes — bots, keepers, backends — shouldn't restart just because a token was listed. Poll the manifest and swap config when it changes. Pass the previous fetch's `lastModified` back in: when nothing changed, the CDN answers `304 Not Modified` with no body, so steady-state polling every 30–60 seconds is nearly free. Deduplicate on `configMeta.version` — a republish with no real change keeps the same commit, so skip the swap when the version hasn't moved:

```ts
import { fetchPoolConfigManifest } from './fetchPoolConfigManifest'

let lastModified: string | null = null
let version: string | undefined

setInterval(async () => {
  const manifest = await fetchPoolConfigManifest('mainnet-beta', { lastModified })
  if (!manifest) return // 304 — config unchanged, nothing downloaded
  lastModified = manifest.lastModified
  if (manifest.configMeta?.version === version) return // republished, nothing changed
  version = manifest.configMeta?.version
  // swap the new manifest.pools / manifest.otherTokens into your app state
}, 30_000)
```

Keep your current config when a fetch fails or a payload looks malformed — an empty `pools` array is almost always a transient fetch problem, not a mass delisting. The helper also isolates bad entries per pool (one malformed `pools[]` entry is skipped instead of failing the whole load). `watchPoolConfig.ts` is the full production pattern: conditional refetch, version dedupe, last-known-good on errors, and a change log on every reload.

### Run the examples

All three examples run with no wallet and no RPC endpoint, from a clone of [`flash-sdk-v2`](https://github.com/flash-trade/flash-sdk-v2/tree/main/examples/config):

```bash
# Print the live pools and token directory
CLUSTER=mainnet-beta yarn example examples/config/listDynamicPools.ts

# Poll and hot-reload on config change (Ctrl-C to stop)
CLUSTER=mainnet-beta POLL_MS=30000 yarn example examples/config/watchPoolConfig.ts
```

| File                         | What it does                                                                             |
| ---------------------------- | ---------------------------------------------------------------------------------------- |
| `fetchPoolConfigManifest.ts` | The helper. Copy it into your project as-is; conditional (`304`) refetch built in.       |
| `listDynamicPools.ts`        | Prints the live pools and token directory for a cluster.                                 |
| `watchPoolConfig.ts`         | Polls and hot-reloads on config change — the pattern for long-running bots and backends. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-sdk-v2/dynamic-pool-and-token-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
