[BUG] Precision Loss from Floating Point Math

Open
#71 1 comment 0 reactions 0 assignees View on GitHub

@Rav1Chauhan is already working on this.

Since Feb 24, 2026.

  • #90 by @Rav1Chauhan — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
20/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
blockchain, javascript

Research direction

Start with src/helpers.js and inspect calculateBcUsdEquivalent, especially the conversion from large amounts to USD. Reproduce the reported precision loss with a very large amount, such as the 10^18 wei equivalent, and compare the result with the expected precision. Done means currency calculations retain precision until display; an open linked pull request already addresses this issue.

Written by the indexing model from the issue text.

Description

[y] I have checked for duplicate issues

Description:
Conversion functions for USD equivalents use native JS parseFloat and multipliers like 1e6. This causes rounding errors for large currency amounts.

How to Reproduce:
Call calculateBcUsdEquivalent with a very large amountFloat (e.g., 10^18 wei equivalent).

Actual Behaviour:
Resulting values lose precision after the 15th significant digit, which is unacceptable for financial software.

Expected Behaviour:
All currency calculations must stay within BigInt or a dedicated library like bignumber.js until the final display stage.

Location: StablePay/djed-sdk/src/helpers.js

[y] I want to work on this issue

Dominant language
JavaScript
Stars
16
Forks
29
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StabilityNexus/StablePay

All issues in StabilityNexus/StablePay

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.