{"id":"XE-0932","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":13,"title":"SDK fromMicro renders negative amounts as garbage strings","area":"sdk-docs-web","claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-06T18:42:26.849227+00:00","updated_at":"2026-11-14T22:53:33.031826+00:00","source_created_at":null,"told_at":"2026-11-14T22:53:33.793920+00:00","status_changed_at":"2026-11-08T20:32:08.872204+00:00","url":"https://bounty.xe.network/XE-0932","body":"## Summary\r\nfromMicro is the SDK display helper that turns a micro-unit bigint into a six-decimal XE or XUSD string for wallets, quotes, and refunds. At sdk/src/types.ts:144-147 it splits the bigint with JS remainder into whole and frac, then concatenates them as `${whole}.${frac}`, and JS remainder keeps the sign of the dividend so minus 100n modulo 1000000n is minus 100n. The minus therefore lands inside the decimal string: fromMicro(-100n) is 0.00-100 and fromMicro(-100500000n) is minus 100.-500000, while a positive 1500000n still formats as 1.500000. Any SDK caller that prints a signed settlement, refund, or negative quote hits this formatter. GitHub #43 is swap unwind; this is display-only corruption in the SDK formatter.\r\n\r\n## Affected components\r\nsdk/src/types.ts:144-147 fromMicro (JS remainder sign on frac, then whole.frac concatenate) at sdk 0dbc92ecff709bee79768e4e37788c682a0f4525.\r\n\r\n## Impact\r\nAny negative XE or XUSD amount the SDK prints is unreadable (0.00-100 and minus 100.-500000). Positive amounts still format as 1.500000. Display integrity only; on-chain amounts are unaffected, but a user reading a negative settlement or refund cannot recover the true value from the string.\r\n\r\n## PoC\r\n\r\n```javascript\r\n#!/usr/bin/env node\r\n/** A3 — fromMicro corrupts negative amounts. */\r\nimport { fromMicro, toMicro } from './sdk.mjs'\r\n\r\nconst PIN = '0dbc92ecff709bee79768e4e37788c682a0f4525'\r\nconsole.log(`PROVENANCE: sdk=${PIN} file=poc/round3/a3_frommicro.mjs`)\r\n\r\nconst ctrl = fromMicro(1_500_000n)\r\nconsole.log(`CONTROL fromMicro(1500000n)=${ctrl}`)\r\nconst roundTrip = fromMicro(toMicro('1.500000'))\r\nconsole.log(`CONTROL toMicro/fromMicro('1.500000')=${roundTrip}`)\r\n\r\nconst cases = [-100n, -100_500_000n, -1n, -1_000_000n]\r\nfor (const n of cases) {\r\n  const s = fromMicro(n)\r\n  const looksDecimal = /^-?\\d+\\.\\d{6}$/.test(s) && !s.includes('-', 1)\r\n  console.log(`ATTACK fromMicro(${n})=${JSON.stringify(s)} well_formed=${looksDecimal}`)\r\n}\r\n\r\nconst a = fromMicro(-100n)\r\nconst b = fromMicro(-100_500_000n)\r\nconst aBad = a.includes('-', 1) || a.startsWith('0.-') || /[.]-/.test(a) || !/^-?\\d+\\.\\d+$/.test(a)\r\nconst bBad = b.includes('-', 1) || /[.]-/.test(b) || b.split('.').length !== 2 || (b.startsWith('-') && b.indexOf('-', 1) >= 0)\r\nconst corrupted = aBad || bBad || a === '0.00-100' || a.includes('00-') || b.includes('.-')\r\n\r\nif (ctrl === '1.500000' && corrupted) {\r\n  console.log(`PASS: fromMicro(-100n)=${JSON.stringify(a)} fromMicro(-100500000n)=${JSON.stringify(b)} CONTROL=${ctrl}`)\r\n  console.log('VERDICT=CONFIRMED')\r\n  process.exit(0)\r\n}\r\nconsole.log(`KILL: ctrl=${ctrl} a=${a} b=${b} corrupted=${corrupted}`)\r\nconsole.log('VERDICT=KILLED')\r\nprocess.exit(0)\r\n```\r\n\r\n```\r\nATTACK fromMicro(-100)=\"0.00-100\" well_formed=false\r\nATTACK fromMicro(-100500000)=\"-100.-500000\" well_formed=false\r\nPASS: fromMicro(-100n)=\"0.00-100\" fromMicro(-100500000n)=\"-100.-500000\"\r\n```\r\n\r\n## Suggested fix\r\nTake the sign once from the whole amount, format abs(whole) and abs(frac) as six-decimal digits, and prefix a single minus when the input is negative.\r\n---","patch_refs":[],"thread":[{"id":3792,"source":"desk","source_ref":"reply:2534","author":"XE desk","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-0932 and says what differs; it is read like any other.","created_at":"2026-11-14T22:53:33.031826+00:00"}]}