Skip to content

fix(math): stabilize decimal scaling for order amounts#16

Merged
SebastianBoehler merged 1 commit into
mainfrom
codex/fix-decimal-scaling
May 25, 2026
Merged

fix(math): stabilize decimal scaling for order amounts#16
SebastianBoehler merged 1 commit into
mainfrom
codex/fix-decimal-scaling

Conversation

@SebastianBoehler
Copy link
Copy Markdown
Owner

Summary

  • add a small decimal math module for scaled-integer conversion
  • route to_wei through the shared helper instead of stringifying a pre-truncated double
  • tolerate tiny binary floating artifacts just below an integer scaled amount
  • convert test_utils away from assert so Release builds actually execute the checks

Context

Fixes #15. A rounded trading value such as the representable double just below 3.03 could become 3029999 instead of 3030000 when converted to six-decimal order units.

Validation

  • cmake -S . -B /tmp/polymarket-cpp-client-math-verify -DPOLYMARKET_CLIENT_BUILD_EXAMPLES=ON -DPOLYMARKET_CLIENT_BUILD_TESTS=ON -DPOLYMARKET_CLIENT_BUILD_BENCHMARKS=ON
  • cmake --build /tmp/polymarket-cpp-client-math-verify -- -j4
  • ctest --test-dir /tmp/polymarket-cpp-client-math-verify --output-on-failure
  • git diff --check

@SebastianBoehler SebastianBoehler merged commit 1945e73 into main May 25, 2026
8 checks passed
@SebastianBoehler SebastianBoehler deleted the codex/fix-decimal-scaling branch May 25, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

to_wei decimal precision issue

1 participant