Status
Integrator-facing docs are already in the README (kwh quantization note) and OpenAPI (TokenRequest.kwh). This issue is about whether to improve the quantization rule for kWh top-ups — not about missing documentation.
Current behavior
Amount.generateAmountBitString() maps kwh onto 0.1 kWh steps: ceil when < 1, truncate when ≥ 1. Inherited from NectarAPI; unchanged in NXT STS. Changing it would alter token output for the same inputs.
Examples today:
Requested kwh |
Effective credit |
0.01 |
0.1 (ceil) |
0.11 |
0.2 (ceil) |
1.19 |
1.1 (truncate) |
Candidate improvement: round to nearest 0.1
A fairer rule would be:
- Quantize to the nearest 0.1 kWh (suggest round half up for ties, e.g.
1.15 → 1.2).
- If the requested amount is positive but would quantize to
0, use 0.1 instead (never issue empty credit for a real top-up).
That keeps the “don’t round down to zero” protection, but stops using always-ceil below 1 kWh and always-truncate above it. Average error would be smaller and small/large purchases would be treated consistently.
Requested kwh |
Current |
Nearest (with min 0.1 if > 0) |
0.01 |
0.1 |
0.1 (min credit) |
0.11 |
0.2 |
0.1 |
1.19 |
1.1 |
1.2 |
Alternatives
- Always ceil / always truncate
- Reject requests that are not exact multiples of
0.1 (push policy to the caller)
- Leave STS as-is; pre-quantize in the backend
Any change is a deliberate compatibility break and needs product + test-vector sign-off.
Proposed default until decided
No change in released behavior. Prefer caller pre-quantization to multiples of 0.1.
If we ever change it
Status
Integrator-facing docs are already in the README (
kwhquantization note) and OpenAPI (TokenRequest.kwh). This issue is about whether to improve the quantization rule for kWh top-ups — not about missing documentation.Current behavior
Amount.generateAmountBitString()mapskwhonto 0.1 kWh steps: ceil when< 1, truncate when≥ 1. Inherited from NectarAPI; unchanged in NXT STS. Changing it would alter token output for the same inputs.Examples today:
kwh0.010.1(ceil)0.110.2(ceil)1.191.1(truncate)Candidate improvement: round to nearest 0.1
A fairer rule would be:
1.15→1.2).0, use0.1instead (never issue empty credit for a real top-up).That keeps the “don’t round down to zero” protection, but stops using always-ceil below 1 kWh and always-truncate above it. Average error would be smaller and small/large purchases would be treated consistently.
kwh0.010.10.1(min credit)0.110.20.11.191.11.2Alternatives
0.1(push policy to the caller)Any change is a deliberate compatibility break and needs product + test-vector sign-off.
Proposed default until decided
No change in released behavior. Prefer caller pre-quantization to multiples of
0.1.If we ever change it