{"id":"XE-1736","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":451,"title":"Payout CSV truncates fractional XE awards (floor division drops the sub-XE part)","area":"other","claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-09T01:53:31.593529+00:00","updated_at":"2026-11-14T22:57:04.296924+00:00","source_created_at":null,"told_at":"2026-11-10T14:00:35.227635+00:00","status_changed_at":"2026-11-10T14:00:33.557657+00:00","url":"https://bounty.xe.network/XE-1736","body":"## Summary\r\n\r\nThe treasurer's payout CSV renders each award with floor division — `award_xe // 1_000_000` — silently dropping the fractional part of any award stored in micro-XE. An award of 1,500,000 micro-XE (1.5 XE) renders as `1`; an award of 999,999 micro-XE (0.999999 XE) renders as `0`. The JSON payout list from the same rows is untruncated, so the two exports disagree, and the CSV is the one documented \"for the mainnet-launch payout\". The precondition is real: the team award route accepts arbitrary micro-XE amounts — only the agent proposal path enforces whole XE.\r\n\r\n## Impact\r\n\r\n- **The payout file understates what is owed.** A treasurer paying from the CSV underpays every fractional award: 1.5 XE pays as 1 XE (0.5 XE short), 0.999999 XE pays as 0 XE (the whole award silently zeroed). The 999,999 case is the sharp one — a real, approved, payable award appears in the payout file as worth nothing.\r\n- **The JSON export disagrees with the CSV.** Both come from the same `payout_rows` (\"the one source for the treasurer's JSON and CSV\", XE-0711/XE-0801), but the CSV truncates and the JSON does not. A treasurer cross-checking the two sees different numbers with no indication of which is right; a treasurer paying from the CSV alone never sees the discrepancy.\r\n- **Bounded, hence Low.** The CSV is treasurer-only (`export:payouts`, treasurer role), so the wrong numbers reach one trusted role, not the public. Fractional awards only exist if a team member sets one directly (the proposal path forces whole XE), and the JSON source of truth is correct, so the error is catchable by cross-checking. No funds move wrongly inside the desk itself — the loss happens only if the CSV is used as the payment list without checking the JSON.\r\n\r\n## Severity reasoning\r\n\r\n- **Low, not Medium:** the wrong values reach only the treasurer role; the correct values exist in the parallel JSON export; and fractional awards require a deliberate direct set (the normal proposal flow cannot produce one). The harm is a real underpayment risk on a real payout file, but it needs a human to pay from the CSV without cross-checking.\r\n- **Low, not informational:** the truncation is silent — no rounding note, no decimal column, no warning — and the file's own docstring presents it as the payout list. A payout file that zeroes a payable award is a defect, not a formatting preference.\r\n\r\n## Root cause\r\n\r\nTwo facts combine:\r\n\r\n1. **The CSV floor-divides the award.** `desk/api/team.py:481` (`payouts_csv`):\r\n\r\n   ```python\r\n   cells = dict(r, award_xe=r[\"award_xe\"] // 1_000_000, reporter_id=r[\"reporter_id\"] or \"\")\r\n   ```\r\n\r\n   `award_xe` is stored in micro-XE (1 XE = 1,000,000 micro-XE), so `//` drops the fractional part. The route's docstring (`desk/api/team.py:470-472`) says the file is \"for the mainnet-launch payout\" — this is the payment list, not a display summary.\r\n\r\n2. **The JSON export from the same rows does not truncate.** `desk/api/team.py:314-332` (`payouts`) returns `\"award_xe\": r[\"award_xe\"]` — the raw micro-XE value. Same source (`payout_rows`, `desk/services/reporters.py:605`), which returns `\"award_xe\": t.award_xe or 0` — the stored micro-XE amount. The two exports disagree by construction.\r\n\r\n**Precondition confirmed — fractional awards are storable:**\r\n\r\n- `set_award` (`desk/services/tickets.py:949-965`) checks only that the amount is `≥ 0`, `≤ AWARD_MAX` (`1_000_000 * 1_000_000` micro-XE, i.e. one million XE — `desk/services/tickets.py:923`), and within the tier ceiling (`_check_ceiling`, `:926-940`, ceiling in micro-XE). Nothing requires a whole number of XE. A team member can set 1,500,000 or 999,999 micro-XE directly and approve it.\r\n- Only the *proposal* path is whole-XE: `desk/services/proposals.py:48-53` rejects a non-integer `award_xe` (\"award_xe is a whole number of XE, 0 or more\"), and `decide` converts with `int(value) * 1_000_000` (`:187-191`). So the normal agent-proposal flow cannot produce a fractional award — but the direct team route, which is the route that sets the final payable amount, can.\r\n\r\n## Reproduction\r\n\r\n### A. The rendering line, executed (verbatim arithmetic)\r\n\r\nThe exact expression from `desk/api/team.py:481`, run in Python:\r\n\r\n```\r\n1500000 // 1_000_000 = 1\r\n999999 // 1_000_000 = 0\r\n500000 // 1_000_000 = 0\r\n1000000 // 1_000_000 = 1\r\n2000000 // 1_000_000 = 2\r\n```\r\n\r\nSo a 1.5 XE award renders as `1`, a 0.999999 XE award renders as `0`, and a 0.5 XE award renders as `0`. Whole-XE awards are unaffected, which is why the bug hides: every award produced through the proposal path is whole-XE, and only a directly-set fractional award exposes it.\r\n\r\n### B. End-to-end shape (code trace — no live desk run)\r\n\r\nVerified by code trace. **No live desk instance was run** (no Postgres/docker on the verification VM), so the flow below is a trace of the exact code that executes, not a live end-to-end run:\r\n\r\n1. A team member sets a fractional award directly, e.g. `set_award(..., award_xe=1_500_000)` — accepted: `1_500_000 ≥ 0`, `≤ AWARD_MAX`, within the tier ceiling (`desk/services/tickets.py: 949-965`). The ticket is approved at `awarded` with `award_approved_at` set.\r\n2. `payout_rows` (`desk/services/reporters.py:605-...`) includes the ticket (bounty, `awarded`, approved amount, unpaid) with `\"award_xe\": 1500000`.\r\n3. `GET /v1/team/payouts` (JSON) shows `\"award_xe\": 1500000` — correct.\r\n4. `GET /v1/team/payouts.csv` shows `award_xe` as `1` — truncated. A treasurer paying 1 XE from the CSV underpays by 0.5 XE; with `award_xe=999999` the CSV shows `0` and the award is paid as nothing.\r\n\r\n## Dedup note\r\n\r\nClosest known work, by code reference — the live report list was not re-checked during this drafting pass, and the submitter should confirm against it before filing:\r\n\r\n- **XE-0711 / XE-0801** — `payout_rows` is the one source for the treasurer's JSON and CSV. This report is about the CSV rendering of that shared source, not about the source itself; the JSON side is correct.\r\n- **XE-0973** — `AWARD_MAX` (a million XE in micro-XE). Cited here only for the unit the bound is expressed in.\r\n- No known report covers the `// 1_000_000` truncation in the CSV export.\r\n\r\n## Suggested fix direction\r\n\r\n- Render the award in the CSV with its fractional part — e.g. a decimal XE column (`award_xe / 1_000_000`, formatted to 6 places), or keep the micro-XE integer the JSON uses and label the column as micro-XE — so the CSV and the JSON agree row for row.\r\n- Alternatively, reject fractional awards in `set_award` (whole-XE only, matching the proposal path), so the truncation can never bite. That is the stricter fix and it changes what the team route accepts; the rendering fix is the smaller, safer one.\r\n- Whichever is chosen, add a test that sets a fractional award (1,500,000 micro-XE) and asserts the CSV and JSON agree.\r\n\r\n## Payout address\r\n\r\n052e33e0ed9c43e2bdf07faff9a90d25642b51d53d96f49f5d45b81f6584b3da\r\n\r\n## References (file:line; desk @ 186af22)\r\n\r\n| Location | What it shows |\r\n|---|---|\r\n| `desk/api/team.py:481` | `award_xe=r[\"award_xe\"] // 1_000_000` — the truncating render |\r\n| `desk/api/team.py:470-472` | `payouts_csv` docstring: the file is \"for the mainnet-launch payout\" |\r\n| `desk/api/team.py:314-332` | JSON `payouts` returns `r[\"award_xe\"]` raw — untruncated, disagrees with the CSV |\r\n| `desk/services/reporters.py:605` | `payout_rows`: the shared source; `\"award_xe\": t.award_xe or 0` in micro-XE |\r\n| `desk/services/tickets.py:923` | `AWARD_MAX = 1_000_000 * 1_000_000` — the bound is in micro-XE |\r\n| `desk/services/tickets.py:949-965` | `set_award`: checks only `≥ 0`, `≤ AWARD_MAX`, tier ceiling — no whole-XE requirement |\r\n| `desk/services/tickets.py:926-940` | `_check_ceiling`: ceiling check in micro-XE, no whole-XE requirement |\r\n| `desk/services/proposals.py:48-53` | Proposal path rejects non-integer `award_xe` — only the proposal path is whole-XE |\r\n| `desk/services/proposals.py:187-191` | `decide` converts with `int(value) * 1_000_000` |","patch_refs":[],"thread":[{"id":2141,"source":"desk","source_ref":"reply:1508","author":"Joseph Denne","team":true,"body":"Thank you for this report. We have read it against the code and it is being handled. The assessment and any award follow the fix. https://bounty.xe.network/XE-1736","created_at":"2026-11-10T14:00:19.792775+00:00"}]}