Skip to main content

Mercury proxy

The browser calls same-origin server routes. POST /api/mercury accepts { query, variables } and proxies GraphQL using server-only MERCURY_URL and MERCURY_KEY. GET /api/mercury/events proxies event history; the client decodes base64 ScVal topics and payloads with Stellar SDK. isMercuryEnabled() is a browser-context hint, not a credential/health check. Missing Mercury configuration can return an API error. History consumers have protocol-specific Mercury/RPC paths; check the relevant mercury-* and *-history-rpc.ts modules rather than treating Mercury as the authoritative source of current balances.

Current balances and freshness

/api/pools returns shared pool statistics. /api/account/[addr] returns a derived account snapshot. Both can serve cached results. lib/account-snapshot.ts and lib/margin-health.ts centralize displayed margin metrics; the snapshot includes debt/collateral reconciliation and UI dust handling. RPC event history is retention-limited; cached or indexed history can be delayed or incomplete. Confirm transaction success by hash and current state, not by the immediate appearance of a history row.

Hubble is separate

/stats and the Hubble /api/analytics/* routes are gated by server-only STATS_ENABLED="true"; otherwise they return 404. Hubble uses a mainnet Stellar BigQuery dataset, not this testnet’s authoritative account ledger. Credentials are supplied via GOOGLE_CREDS_JSON or Application Default Credentials with GOOGLE_CLOUD_PROJECT. Dataset queries run in the US location. The existing /analytics/... UI is a different surface: some pages use live reads, while others include fixture-backed simulations or fallback data. See Frontend.

Source reference

  • mercury-stellar-backend/lib/mercury-client.ts
  • mercury-stellar-backend/app/api/mercury/route.ts
  • mercury-stellar-backend/app/api/mercury/events/route.ts
  • mercury-stellar-backend/lib/hubble/gate.ts
  • mercury-stellar-backend/lib/hubble/client.ts