Skip to content

Commit 754a183

Browse files
authored
Add international vault listings
## Why Non-USD vaults need a dedicated listing and detail-page handling so their TVL is shown consistently in USD while still exposing the denomination and native currency context. The existing pages treated some non-USD vault NAV values as already-dollar-denominated or skipped conversion when the backend supplied an empty denomination rate object. ## Lessons learnt Git worktrees do not copy ignored local files such as `.env.local` and `data/`, so private vault chart data can fail locally even when the main checkout works. The new worktree documentation records the required env and data symlink setup. EURCV metadata may not have its own USD rate, so the frontend needs to infer the native currency and use stablecoin metadata fallback rates. Empty `denomination_token_rate` objects should not block that enrichment. ## Summary - Add an International vault listing page for non-USD vaults and include it in vault listing navigation and the sitemap. - Convert current and peak TVL through denomination exchange rates in listings and vault detail metrics, including native-currency context and tooltips for non-USD/depegged vaults. - Enrich vault detail loads with stablecoin metadata fallback rates, including fetched timestamps and empty-rate-object handling. - Hide the utilisation chart on vault detail pages because vault protocols do not report useful utilisation data. - Add worktree documentation and cross-links for local env/data setup.
1 parent 4083263 commit 754a183

16 files changed

Lines changed: 904 additions & 22 deletions

File tree

.claude/docs/worktree.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Worktrees
2+
3+
Git worktrees share tracked files with the main checkout, but ignored local files are separate per worktree. Before running a dev server, browser preview, or private-data test from a worktree, copy or link the local environment and data cache from the main checkout.
4+
5+
## Required local files
6+
7+
The main checkout normally has local-only files that are intentionally ignored by git:
8+
9+
- `.env.local` - private environment variables loaded by Vite/SvelteKit.
10+
- `data/` - local cache for large private datasets, including `data/cleaned-vault-prices-1h.parquet`.
11+
12+
Without these files, vault metadata may still load if `TS_PRIVATE_TOP_VAULTS_URL` is set manually, but chart endpoints that need the historical parquet can fail with 500 responses.
13+
14+
## Environment variables
15+
16+
Copy or symlink `.env.local` from the main checkout so the worktree gets the same private server configuration:
17+
18+
```shell
19+
ln -s /home/mikko/code/frontend/.env.local .env.local
20+
```
21+
22+
The important vault data variables are:
23+
24+
```env
25+
TS_PRIVATE_R2_ACCOUNT_ID=
26+
TS_PRIVATE_R2_ACCESS_KEY_ID=
27+
TS_PRIVATE_R2_SECRET_ACCESS_KEY=
28+
TS_PRIVATE_R2_BUCKET_NAME=
29+
TS_PRIVATE_TOP_VAULTS_URL=
30+
TS_PRIVATE_VAULT_PRICES_PARQUET_URL=
31+
```
32+
33+
R2 credentials are the canonical source for both vault metadata and the historical parquet. `TS_PRIVATE_TOP_VAULTS_URL` and `TS_PRIVATE_VAULT_PRICES_PARQUET_URL` are fallback direct URLs when R2 is not configured.
34+
35+
Restart the dev server after changing `.env.local`; Vite reads these values at process start.
36+
37+
## Data symlink
38+
39+
The historical vault parquet is large and is read from a path relative to the current worktree:
40+
41+
```text
42+
data/cleaned-vault-prices-1h.parquet
43+
```
44+
45+
Use a symlink instead of duplicating the cache:
46+
47+
```shell
48+
ln -s /home/mikko/code/frontend/data data
49+
```
50+
51+
This allows worktree-local endpoints such as `/trading-view/vaults/{id}/metrics` to find the same cached parquet as the main checkout.
52+
53+
## Checks
54+
55+
Confirm ignored local resources are present:
56+
57+
```shell
58+
ls -l .env.local data/cleaned-vault-prices-1h.parquet
59+
git check-ignore -v .env.local data/cleaned-vault-prices-1h.parquet
60+
```
61+
62+
Confirm the running dev server inherited private environment variables:
63+
64+
```shell
65+
ps -eo pid,cmd | rg 'vite|pnpm run dev'
66+
tr '\0' '\n' < /proc/<vite-pid>/environ | rg 'TS_PRIVATE_R2_|TS_PRIVATE_TOP_VAULTS_URL|TS_PRIVATE_VAULT_PRICES_PARQUET_URL'
67+
```
68+
69+
Confirm vault chart data works:
70+
71+
```shell
72+
curl -s 'http://127.0.0.1:5173/trading-view/vaults/<vault-id>/metrics'
73+
```

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ working on that area:
1414
| Doc | Description |
1515
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
1616
| `.claude/docs/agent-tricks-and-troubleshooting.md` | **MANDATORY read before ANY Claude CLI or Codex CLI invocation** (reviews, sanity checks, or one-off runs) |
17+
| `.claude/docs/worktree.md` | Required local env and data symlinks when running dev servers or private-data checks from git worktrees |
1718

1819
## Agent review workflows
1920

@@ -68,6 +69,7 @@ pnpm run test:integration # Run integration tests (requires build)
6869

6970
- `TS_PUBLIC_` prefix for client-accessible values
7071
- `TS_PRIVATE_` prefix for server-only values
72+
- In git worktrees, copy or symlink ignored local files such as `.env.local` and `data/` from the main checkout before running dev servers; see `.claude/docs/worktree.md`.
7173

7274
**Formatting:**
7375

@@ -128,6 +130,8 @@ Use it for:
128130

129131
Always develop and verify against the Vite dev server started with `pnpm run dev` (typical local target `http://127.0.0.1:5173/`). Do **not** use `pnpm run preview` (Vite preview) for development or verification: its preview server runs its own prerender/manifest step that can resolve routes differently from both dev and the production adapter-node server (e.g. newly added routes may 404 under preview while working everywhere else). `pnpm run preview` is only for sanity-checking a production build. Integration tests (`pnpm run test:integration`) intentionally run against a build via the test harness; that is separate from manual development.
130132

133+
When using a git worktree, follow `.claude/docs/worktree.md` before starting the dev server so private env vars and cached vault datasets are available in that worktree.
134+
131135
```text
132136
http://127.0.0.1:5173/
133137
```

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ Environment variables required by the app are maintained in a checked-in `.env`
5353
Put local-only secrets and overrides in `.env.local`, which is gitignored and loaded automatically
5454
by Vite/SvelteKit. Variables in `.env.local` override `.env`.
5555

56+
When running from a git worktree, ignored local files are not copied from the main checkout. Symlink
57+
or copy `.env.local` and the `data/` cache before starting the dev server; see
58+
[worktree setup](./.claude/docs/worktree.md).
59+
5660
Use the existing prefixes when adding variables:
5761

5862
- `TS_PUBLIC_` for values that may be exposed client-side

docs/chart-pages.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ The dropdown and in-page selector can intentionally have different counts. For e
107107

108108
Use Playwright integration tests for chart page navigation and route rendering. The integration test harness uses a test-mode build and Vite preview; for manual development and visual checks, use `pnpm run dev` instead.
109109

110+
If the dev server runs from a git worktree, follow [worktree setup](../.claude/docs/worktree.md)
111+
first so private env vars and the historical vault parquet cache are available to chart endpoints.
112+
110113
Useful checks:
111114

112115
- Run unit tests for chart payload builders, e.g. `pnpm exec vitest run src/lib/echarts/core3-risk.test.ts`.

docs/tests.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ pnpm run test:integration
7070
For normal development, keep checked-in defaults in `.env` and place local-only secrets in
7171
`.env.local`. Vite/SvelteKit loads `.env.local` automatically and it overrides `.env`.
7272

73+
In git worktrees, `.env.local` is not copied from the main checkout. Symlink or copy it before
74+
running private-data tests or local dev servers; see [worktree setup](../.claude/docs/worktree.md).
75+
7376
The regular integration suite intentionally stays deterministic and uses `.env.test` plus mock
7477
APIs. This means secret-backed features should not be added to the default `pnpm run test:integration`
7578
flow unless they can be mocked reliably.
@@ -100,6 +103,9 @@ You can safely run the dev server and test builds concurrently without cache cor
100103

101104
For manual browser checks from another machine, use the Vite dev server rather than Vite preview:
102105

106+
If the dev server runs from a git worktree, first make sure `.env.local` and the `data/` cache are
107+
available in that worktree; see [worktree setup](../.claude/docs/worktree.md).
108+
103109
```shell
104110
pnpm run dev --host 0.0.0.0
105111
```

docs/vault-data-source.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,7 @@ For local development, ensure R2 credentials are set in `.env.local`. All data s
148148
- Top vaults JSON is fetched on first page load and cached in memory for 1 hour
149149
- Vault prices parquet (~150 MB) is downloaded on first metrics request and cached locally with a 1-hour refresh interval
150150
- Treasury benchmark data is fetched from FRED on demand (no credentials needed) and cached for 24 hours
151+
152+
When developing from a git worktree, `.env.local` and `data/` are ignored local files and are not
153+
created automatically. Symlink or copy them from the main checkout before starting the dev server;
154+
see [worktree setup](../.claude/docs/worktree.md).

0 commit comments

Comments
 (0)