Files
apex-mcp-server/packages/shared/test
FilipBl4gojevic 71b3cc599c fix: convert AP3X amounts to lovelace exactly, never through float multiplication
Math.floor(amountApex * 1_000_000) silently drops a lovelace whenever the
IEEE-754 product lands just under the intended integer (empirically
confirmed on this Node build: 1.005, 2.05, and 8.11 AP3X all lose exactly
1 lovelace this way). Adds apexToLovelace(amountApex): bigint in
packages/shared/src/tx.ts - a string-exact conversion via
Number.prototype.toString() (not toFixed(), which reveals the same binary
noise this function exists to avoid) that rejects non-finite, negative,
and >6-decimal-place amounts instead of silently truncating.

Replaces every AP3X-to-lovelace float multiply on a money path:
buildSendApex and buildSendTokens' apexAmount path in build.ts, and the
three stake conversions (critique/endorse/proposal-lock) in gov-build.ts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-31 17:52:30 +02:00
..