> For the complete documentation index, see [llms.txt](https://docs.trover.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trover.tech/engineering/runbook-dex-overhaul.md).

# DEX Overhaul Deployment Runbook — 2026-08-27

Ships the basedbot-parity overhaul of dex.trover.tech: header network switcher (Robinhood primary), theme de-greening (`#00e676` → teal accents, TradingView candle colors), native chain-indexed token candle chart with WebSocket realtime, Robinhood chain indexer (pools / swap tape / holders / candles), NFT holders %-of-supply, persisted trait counts with rarity %, item price formatting, and token social links.

## 1. Environment additions

Edit `/home/teztap/trover/.env` and add (or confirm):

```env
# Robinhood chain-first market indexer (pools, swaps, holders, candles).
ROBINHOOD_INDEXER_ENABLED=true
# First block the historical backfill starts from. 0 walks from genesis;
# set to a recent block to skip ancient history on first deploy.
ROBINHOOD_INDEXER_START_BLOCK=0

# Realtime NFT events (already supported, previously off by default).
OPENSEA_STREAM_ENABLED=true
```

Already-existing knobs the new indexer reuses (defaults are fine): `ROBINHOOD_PUBLIC_RPC_URLS`, `STABLEDEX_INDEXER_INTERVAL_SECONDS` (5s tick), `STABLEDEX_INDEXER_BATCH_BLOCKS`, `STABLEDEX_INDEXER_LIVE_BLOCKS`, `STABLEDEX_HOLDER_INDEXER_TOKENS_PER_TICK`.

## 2. Deploy

**Frontend (Vercel):** deploys automatically from GitHub `main` — no server step. The push that shipped this change already triggered a Vercel build; confirm it went green in the Vercel dashboard. Deploy the backend below before (or soon after) it finishes: the new frontend degrades gracefully against the old API (charts fall back to the DexScreener embed, holders show an empty state), but the realtime chart, holders %, and trait % need the new API and worker live.

**Backend (server):** run in order:

```bash
cd /home/teztap/trover
git pull --ff-only origin main

# Build the backend images (all three share one compiled stage — one compile).
docker compose -f docker-compose.yml -f docker-compose.production.yml build migrate api worker

# Apply the new migration (dex_token_candles, nft_ownerships, nft_trait_counts).
docker compose -f docker-compose.yml -f docker-compose.production.yml up migrate

# Roll the backend services.
docker compose -f docker-compose.yml -f docker-compose.production.yml up -d --force-recreate api worker
```

### Faster rebuilds

* `api`, `worker`, and `migrate` share one `backend-build` stage — always list them in a single `build` command so the backend compiles once, not three times.
* Never build the `web` image on the server; the frontend ships via Vercel.
* The dependency-install layers only re-run when a package.json or the lockfile changes; ordinary code changes skip straight to the compile step.

## 3. Smoke test

* **Header**: dex.trover.tech shows the network dropdown left of the wallet switcher; Robinhood is default with its logo; switching to Stable/BNB/X Layer/Ink re-filters the markets list immediately.
* **No agent** on the DEX chrome (mobile bottom nav has 4 items, no floating agent bubble).
* **Token page (Robinhood token)**: native candle chart renders from `GET /v1/dex/tokens/robinhood/<token>/candles?interval=1m` once the indexer has run a few ticks; the header pill shows `realtime` when the WebSocket (`/v1/dex/tokens/robinhood/<token>/stream`) is connected; Price/MCap toggle works; interval pills 1m/5m/15m/1h/4h; social icons render beside the symbol; the Holders tab lists wallets with % of supply. Until the index warms up, the page falls back to the DexScreener embed — that is expected on day one.
* **NFT collection page**: chart candles are teal/red (`#26a69a`/`#ef5350`), no doubled "live sales"/"market ceiling" text, the floor overlay is hidden until the `floor` pill is toggled, items show `x.xxx ETH` + `$…` or `UNLISTED`, the traits tab shows collapsed categories that expand to values with `count · %`, and the holders tab shows % of supply (Robinhood/Ink collections; other chains keep the provider fallback).
* **trover.tech**: visually unchanged (only the NFT chart candle hue softened).
* **Worker logs**: `docker compose logs -f worker | grep -E "Robinhood market index|candle aggregation"` should show `Robinhood market index advanced` every \~5s.

## 4. Notes

* **Candles**: `DexTokenCandle` stores USD OHLCV per pool per interval (1m/5m/15m/1h/4h), aggregated incrementally from the persisted swap tape. Robinhood native quotes use the live ETH/USD rate; Stable quotes are $1.
* **First-day behavior**: holder %, candles, and NFT ownership all backfill incrementally from public RPC. Partial coverage is expected until cursors catch up; nothing is fabricated in the meantime.
* **TradingView Advanced Charts**: basedbot renders with TradingView's gated Advanced Charts library (`charting_library`). Our chart uses `lightweight-charts` styled identically, and the `/candles` API is already shaped like a TV datafeed. To swap in Advanced Charts later, apply for the free license at <https://www.tradingview.com/advanced-charts/> — once granted, self-host the bundle under `apps/web/public/static/charting_library/` and feed it from the same endpoints.
* **Rollback**: the migration is additive (three new tables); reverting the app images is safe without a schema rollback.


---

# 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.trover.tech/engineering/runbook-dex-overhaul.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.
