Skip to content

Use each token's real decimals for displayAmount #181

Closed

Description

@Miracle656

Background

toDisplayAmount (src/api.ts:88-95) divides every amount by a hardcoded STROOPS = 10_000_000n (src/api.ts:81). Wraith already fetches and caches per-token decimals (src/rpc.ts:280-290, src/tokenCache.ts:10), and that cache's own comment says serving the wrong decimals is worse than the wrong symbol.

So every 6-decimal token — USDC included, the asset the offramp actually moves — is displayed 10× too small, across REST (src/db.ts:447), CSV/Parquet export (src/routes/exports.ts:94, 147) and the WebSocket stream (src/ws.ts:41).

Acceptance criteria

  • toDisplayAmount(amount, decimals), defaulting to today's behaviour when decimals are unknown
  • Read-path callers pass the cached decimals for the row's contractId
  • A 6-decimal token's displayAmount equals amount / 1e6 — fails before, passes after
  • 7-decimal output is byte-identical to today; existing snapshots unchanged
  • A token with no cached metadata still renders and does not error

Drips Wave · Complexity: Intermediate · 150 points


How this repo is laid out

Wraith is a Soroban incoming-transfer indexer: it fills the gap Horizon leaves for SAC/SEP-41 token events by recipient address. Roughly 14k lines under src/, REST + GraphQL + WebSocket, Postgres via Prisma, deployed on Render.

  • Unit tests are jest (src/**/__tests__, tests/*.test.ts), with a coverage gate.
  • Integration tests are vitest (tests/integration/, vitest.integration.config.ts, Docker).
  • Don't mix the two runners in one file.

Known state of main before you start

tsc --noEmit and the unit suite are green. The Integration tests CI job is red, and so is Load test — both predate this batch. Open PRs #177 and #178 address them. If the integration job is red when you open a PR, that is not your fault; say so in the PR and carry on.

Four modules are shipped, closed as done, and imported by nothing: src/indexer/checkpoint.ts, src/ingest/reorg.ts, src/middleware/opa.ts, and src/api/candles.ts + src/workers/ohlc-refresh.ts. So the live indexer today has no reorg handling and no atomic checkpointing, despite both features being closed. Two issues below start unpicking that — don't assume a closed issue means a wired feature.

Ground rules

  • Every PR needs a test that fails before the change and passes after, unless the issue says otherwise.
  • Don't widen a Prometheus label to something unbounded — addresses and contract ids must never become label values.
  • Nothing may log or return a raw database error, a connection string, or a provider URL.
  • Don't reformat a file you're changing. A diff that is 90% whitespace hides the 10% that matters.


Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk

Activity

  1. krsnak commented on Sep 24, 2026

    @krsnak
    Contributor

    @krsnak has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi, I’d like to work on this. I’ll add the Zod validation, configurable export row cap, and clear truncation signaling while preserving the existing export behavior. I’ll also add focused regression tests around the new limits and validation.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @krsnak to this issue.

  2. Glorious21 commented on Sep 26, 2026

    @Glorious21
    Contributor

    @Glorious21 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi Maintainer, I am an excellent Web Developer. I love collaborating and contributing to valuable and viable project like this.
    I would appreciate and execute the task excellently, if you can assign this issue to me.
    I will deliver up to your expectation. Thanks

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Glorious21 to this issue.

  3. drips-wave commented on Sep 26, 2026

    @drips-wave

    Congratulations, @krsnak! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

    🧑‍💻 @krsnak: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  4. drips-wave commented on Sep 30, 2026

    @drips-wave

    This issue has been marked as completed by a Drips Wave moderator for @krsnak as part of the Stellar Wave Program's 9th Wave 🥳

    Moderator's reason: [Auto-assessed] The contributor successfully implemented token-specific decimal formatting across REST, GraphQL, WebSocket, CSV/Parquet exports, and account views as requested in issue #181, adding new unit tests that verify the changes. The PR is open with no maintainer objections, and the failing CI check is an expected action_required state for fork PRs requiring maintainer authorization.

    😎 @krsnak: You earned 150 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

    ℹ️ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions