Skip to content

feat(treasury): show fiat in R$ on the pt-BR locale - #2

Closed
sktbrd wants to merge 2 commits into
feat/treasury-column-layoutfrom
feat/treasury-brl-locale
Closed

feat(treasury): show fiat in R$ on the pt-BR locale#2
sktbrd wants to merge 2 commits into
feat/treasury-column-layoutfrom
feat/treasury-brl-locale

Conversation

@sktbrd

@sktbrd sktbrd commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • On /pt-br/treasury, every fiat figure converts USD→BRL at one server-cached rate and renders as R$ (pt-BR conventions). EN is untouched.
  • Token quantities never convert ("13.439,7503 USDC" stays a quantity); the conversion applies uniformly to USD values — 1 USDC renders as ~R$ 5, never R$ 1 (covered by a unit test).
  • Rate outage → the page falls back to US$ with a visible amber note on each affected card ("Cotação do dólar indisponível — valores em US$"), never silent stale reais.

Changes

  • src/services/exchange-rate.ts — open.er-api.com/v6/latest/USD (keyless), unstable_cache 1h; failures throw inside the cached fn so misses aren't pinned for an hour; getBrlRateForRequest() returns the rate only on pt-br, React-cached per request
  • src/lib/i18n/fiat.ts + tests — pure localizeFiat/formatFiatUsd
  • FiatFallbackNote.tsx — the visible USD-fallback indicator
  • Wired into TreasuryBalance(Client), TokenHoldings(Client), TreasuryAllocation, SponsorshipYield, page.tsx
  • messages/{en,pt-br}/treasury.jsonfiat.usdFallback in both locales

Test plan

  • pnpm test — 141 passed (8 new, incl. the 1-USDC≠R$1 case)
  • tsc / eslint / prettier clean
  • Captures: PT desktop+mobile showing R$, EN unchanged, PT fallback state with the amber notes

Stacked on r4topunk#273's branch (feat/treasury-column-layout).

Generated with Claude Code

sktbrd and others added 2 commits August 18, 2026 12:50
…opunk#273)

* wip(treasury): Token Holdings to the right column, NFT grid full width

Sponsorship left ~280px of dead space; Token Holdings (three rows) fills
it, and its old half-width row goes to the NFT grid — the one section
where width is the feature. Preview grows 7 -> 15 + the +N tile: two
complete 8-column rows at sm+, four complete 4-column rows on mobile,
no holes at either breakpoint.

WIP: compiles clean (tsc/eslint/prettier), structure confirmed rendering
(Token Holdings in the right column, NFT section full width), but a
clean LOADED capture was not obtained - dev-server recompiles kept
catching the page mid-stream. Do not merge without the capture.

* fix(treasury): two-line token rows so values fit the narrow column

The three-column table clipped its Value column once Token Holdings
moved into the right-hand column. Stacked value-over-amount rows fit
any width; the now-unused table header keys are dropped from both
locales.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Every USD figure on the treasury page — total value KPI, allocation
bar, token holdings values, sponsorship TVL/yield — converts to BRL
on pt-br at one server-cached USD→BRL rate (open.er-api.com, 1h
unstable_cache; errors are not cached so a miss retries next request).
Token quantities never convert: a USDC position's USD value multiplies
by the rate like everything else — 1 USDC is not R$ 1.

If the rate fetch fails the page keeps US$ figures and each affected
card says so out loud (FiatFallbackNote) instead of silently showing
stale reais. EN is untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sktbrd

sktbrd commented Aug 18, 2026

Copy link
Copy Markdown
Owner Author

Superseded: r4topunk#273 was squash-merged upstream, so this branch was rebased onto r4topunk/main and re-opened as an upstream PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant