Skip to content

fix(claims-ui): formatRtc understates every reward 100x (divides micro-RTC by 10^8 not 10^6)#8007

Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Scottcjn:mainfrom
Vyacheslav-Tomashevskiy:fix/claims-rtc-100x-display-scaling
Open

fix(claims-ui): formatRtc understates every reward 100x (divides micro-RTC by 10^8 not 10^6)#8007
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Scottcjn:mainfrom
Vyacheslav-Tomashevskiy:fix/claims-rtc-100x-display-scaling

Conversation

@Vyacheslav-Tomashevskiy

Copy link
Copy Markdown
Contributor

The bug

Every reward amount on the claim page is rendered through one helper, formatRtc in web/claims/claims.js:

function formatRtc(urtc) {
  return (safeNumber(urtc) / 100_000_000).toFixed(6);
}

The input is reward_urtcmicro-RTC, where 1 RTC = 10^6 units. That's the backend's convention: node/claims_submission.py converts to human-readable RTC by dividing by 1_000_000 in every place it reports a value (lines 452, 582, 663):

"reward_rtc": row["reward_urtc"] / 1_000_000,
...
"total_claimed_rtc": total_claimed / 1_000_000,

The frontend divides by 100_000_000 (10^8) instead — a 100x error. It reads the raw _urtc integer fields straight from the API (epoch.reward_urtc, claim.reward_urtc, stats.total_claimed_urtc, result.reward_urtc) and scales them client-side with the wrong divisor.

Concrete input → wrong output: a reward of 1_500_000 micro-RTC = 1.5 RTC. The backend returns reward_rtc = 1.5; the page showed 1_500_000 / 100_000_000 = 0.015"0.015000 RTC".

formatRtc feeds the whole claims UI, so all of these were understated 100x: the epoch dropdown (L390), the claim summary reward (L410), the history reward column (L462), the Total Claimed stat (L491), the post-submit success message (L672), and the CSV export (L769). In a payout flow that's exactly the kind of misleading number that erodes trust.

The fix

Divide by micro-RTC (10^6) to match the backend and the function's own docstring — one line:

function formatRtc(urtc) {
  // reward_urtc is micro-RTC (10^6 units per RTC), matching the backend
  // convention in node/claims_submission.py (reward_urtc / 1_000_000).
  return (safeNumber(urtc) / 1_000_000).toFixed(6);
}

Test

Added tests/test_claims_frontend_rtc_scaling.py (source-assertion style, matching the repo's existing claims.js tests): extracts the divisor from formatRtc, asserts it is 1_000_000, asserts it matches the backend's reward_urtc divisor, and checks the worked 1.5-RTC example. 3 pass with the fix; the first two fail against the old 100_000_000. The existing 26 claims-frontend tests still pass.

Verified against upstream/main @ c6501de.

RTC: RTCd1554f0f35576faf01d386a6be1c947f560dd0b7

…splayed reward 100x too small

reward_urtc is micro-RTC (10^6 units/RTC); the backend converts via
reward_urtc / 1_000_000 everywhere (node/claims_submission.py). The
claims page helper divided by 100_000_000, so every amount it renders
(epoch dropdown, claim summary, history, Total Claimed stat, success
message, CSV export) was understated 100x — a 1.5 RTC reward showed as
0.015 RTC. Align the divisor with the backend and add a regression test.
@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) tests Test suite changes size/M PR: 51-200 lines labels Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/M PR: 51-200 lines tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant