> For the complete documentation index, see [llms.txt](https://bubblegum-reality.gitbook.io/bubblegum-reality-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bubblegum-reality.gitbook.io/bubblegum-reality-docs/architecture/asset-discovery.md).

# Asset Discovery

The registry of tradable stock tokens is discovered, never hardcoded.

## Pipeline

```
GET /rhj/assets
   │
   ├─ filter: chainId === 4663            → drop other deployments
   ├─ normalize: upstream shape → camelCase → stable DTO shape
   ├─ checksum: getAddress(address)       → reject malformed
   ├─ partition: ASSET_STATUS_ACTIVE      → active list + inactive count
   └─ retain: multiplier, pending multiplier + effective time,
              capabilities, logo, canonical address, decimals
```

The result is an [`AssetsPayload`](/bubblegum-reality-docs/reference/data-types.md#assetspayload):

```ts
{
  assets: StockTokenAsset[],
  fetchedAt: string,      // ISO timestamp of the successful fetch
  totalOnChain: number,   // deployments on 4663 before the active filter
  inactiveCount: number   // preserved so the UI can warn, not hide
}
```

## Upstream shape drift

The feed is versionless and has changed under us. The normalizer therefore accepts both the historical and current shapes:

| Concern        | Current upstream shape                                                                     |
| -------------- | ------------------------------------------------------------------------------------------ |
| Symbol / name  | `tokenSymbol` / `tokenName`                                                                |
| Trading status | nested per-session objects (`market`, `extended`, `overnight`) under `tradingCapabilities` |
| Prices         | `quotes[]` envelope from `/rhj/prices/{symbol}`, halt flag as `isTradingHalt`              |

A silent parse failure here returns zero assets rather than wrong assets, so `assets.test.ts` pins both shapes.

## Why inactive assets are kept

Filtering inactive assets out entirely would make a delisted or suspended token look like it never existed. Instead the count is preserved and surfaced as a warning. Selecting an inactive asset in the terminal disables execution with the specific reason.

## Fields that matter downstream

| Field                                     | Consumed by                                                                        |
| ----------------------------------------- | ---------------------------------------------------------------------------------- |
| `address`, `decimals`                     | Approval + swap calldata, balance reads                                            |
| `currentMultiplier`                       | [Pricing](/bubblegum-reality-docs/architecture/pricing.md) — token reference value |
| `pendingMultiplier`, `pendingEffectiveAt` | Corporate-action warning banner                                                    |
| `status`                                  | Execution gate                                                                     |
| `tradable`, `extendedHours`               | Markets filters, session logic                                                     |
| `assetClass`                              | ETF vs equity filter, where metadata allows                                        |
| `logoUrl`                                 | Markets and terminal UI                                                            |

## Markets page behaviour

`/markets` renders the full registry as a searchable, sortable table with filters for tradable, halted, extended-hours, route-available, and asset class.

Quotes are **queued and cached on demand**. The page never fires one 0x request per row — hundreds of parallel quote calls would rate-limit the key and produce a wall of failures. Route availability is resolved lazily for the rows the user actually engages with.

## Failure behaviour

If `/rhj/assets` fails, `getAssets()` returns `{ ok: false, error }` with a sanitized message. The markets table and terminal selector render an error state with a retry action. No cached-forever list is presented as live, and no synthetic asset list is substituted.


---

# 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://bubblegum-reality.gitbook.io/bubblegum-reality-docs/architecture/asset-discovery.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.
