FilOzone / FilOzone/filecoin-pay-explorer

fix(explorer): apply consistent rule for rounding/truncating token amounts

Open
#328 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3
Forks
7
Avg merge
5d 14h
Merged PRs (30d)
47

Description

Token amounts across the explorer are formatted with `formatToken`, which rounds to nearest via `Number() + toFixed`. That can mislead in both directions:

- Held/available amounts (e.g. `Available` in the Funds table) can round up, showing a user more than they actually have.
- Owed amounts (e.g. `Debt` in the Funds table, `Locked`) can round down, understating what they actually owe.

Rule to apply: amounts the user holds → truncate; amounts the user owes → round up. (Already applied to the Settle Rail dialog's settlement amount preview via `formatTokenTruncated` in #309.)

Proposed approach:
1. Add `formatTokenCeiling` next to `formatTokenTruncated` in `formatter.ts` (same BigInt-exact approach, rounds up instead of down).
2. Audit `formatToken` call sites and switch each to truncate/ceiling based on what it represents. Known cases:
- Available (Funds table) → truncate
- Locked / Debt (Funds table) → ceiling
- Historical/informational totals (Paid out, Earned, Historical Settled, rates) → leave as-is, not a pending balance or charge

Ref - https://github.com/FilOzone/filecoin-pay-explorer/pull/309#discussion_r3823677248

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in formatter.ts by reading formatTokenTruncated and the existing formatToken call sites. Audit the Funds table and other displayed totals, applying truncation to held amounts and ceiling to owed amounts while leaving historical and informational totals unchanged. Done means formatTokenCeiling uses the same BigInt-exact approach and each named balance follows the stated rounding rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.