Payout CSV truncates fractional XE awards (floor division drops the sub-XE part)
Report
Summary
The 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.
Impact
- 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.
- 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. - 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.
Severity reasoning
- 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.
- 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.
Root cause
Two facts combine:
-
The CSV floor-divides the award.
desk/api/team.py:481(payouts_csv):cells = dict(r, award_xe=r["award_xe"] // 1_000_000, reporter_id=r["reporter_id"] or "")award_xeis 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. -
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.
Precondition confirmed — fractional awards are storable:
set_award(desk/services/tickets.py:949-965) checks only that the amount is≥ 0,≤ AWARD_MAX(1_000_000 * 1_000_000micro-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.- Only the proposal path is whole-XE:
desk/services/proposals.py:48-53rejects a non-integeraward_xe("award_xe is a whole number of XE, 0 or more"), anddecideconverts withint(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.
Reproduction
A. The rendering line, executed (verbatim arithmetic)
The exact expression from desk/api/team.py:481, run in Python:
1500000 // 1_000_000 = 1
999999 // 1_000_000 = 0
500000 // 1_000_000 = 0
1000000 // 1_000_000 = 1
2000000 // 1_000_000 = 2
So 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.
B. End-to-end shape (code trace — no live desk run)
Verified 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:
- 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 atawardedwithaward_approved_atset. payout_rows(desk/services/reporters.py:605-...) includes the ticket (bounty,awarded, approved amount, unpaid) with"award_xe": 1500000.GET /v1/team/payouts(JSON) shows"award_xe": 1500000— correct.GET /v1/team/payouts.csvshowsaward_xeas1— truncated. A treasurer paying 1 XE from the CSV underpays by 0.5 XE; withaward_xe=999999the CSV shows0and the award is paid as nothing.
Dedup note
Closest 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:
- XE-0711 / XE-0801 —
payout_rowsis 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. - XE-0973 —
AWARD_MAX(a million XE in micro-XE). Cited here only for the unit the bound is expressed in. - No known report covers the
// 1_000_000truncation in the CSV export.
Suggested fix direction
- 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. - 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. - Whichever is chosen, add a test that sets a fractional award (1,500,000 micro-XE) and asserts the CSV and JSON agree.
Payout address
052e33e0ed9c43e2bdf07faff9a90d25642b51d53d96f49f5d45b81f6584b3da
References (file:line; desk @ 186af22)
| Location | What it shows |
|---|---|
desk/api/team.py:481 |
award_xe=r["award_xe"] // 1_000_000 — the truncating render |
desk/api/team.py:470-472 |
payouts_csv docstring: the file is "for the mainnet-launch payout" |
desk/api/team.py:314-332 |
JSON payouts returns r["award_xe"] raw — untruncated, disagrees with the CSV |
desk/services/reporters.py:605 |
payout_rows: the shared source; "award_xe": t.award_xe or 0 in micro-XE |
desk/services/tickets.py:923 |
AWARD_MAX = 1_000_000 * 1_000_000 — the bound is in micro-XE |
desk/services/tickets.py:949-965 |
set_award: checks only ≥ 0, ≤ AWARD_MAX, tier ceiling — no whole-XE requirement |
desk/services/tickets.py:926-940 |
_check_ceiling: ceiling check in micro-XE, no whole-XE requirement |
desk/services/proposals.py:48-53 |
Proposal path rejects non-integer award_xe — only the proposal path is whole-XE |
desk/services/proposals.py:187-191 |
decide converts with int(value) * 1_000_000 |
Thread
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