Skip to content

feat(proto): upgrade price.proto float to double (#283)#364

Closed
onchito-walks wants to merge 2 commits into
lnflash:mainfrom
onchito-walks:feat/price-proto-float-to-double
Closed

feat(proto): upgrade price.proto float to double (#283)#364
onchito-walks wants to merge 2 commits into
lnflash:mainfrom
onchito-walks:feat/price-proto-float-to-double

Conversation

@onchito-walks
Copy link
Copy Markdown

Change: PriceResponse.pricefloatdouble in price.proto

Why: 32-bit float (~7 significant digits) silently truncates exchange rates for JMD and other non-USD fiat currencies that need more precision. For example, JMD pricing at ~160 per USD requires 8+ digits to represent with sub-cent accuracy — float32 cannot do this.

Impact: Protobuf handles float→double conversion transparently. Existing price servers that send float values are decoded as double with zero precision loss (float32 values are a subset of float64). The price server can be updated independently.

Blocked by: This is Phase 1 of the currency precision roadmap (ENG-315). Needs to land before Phase 1.C (multi-source price aggregator for TTD, HTG, NGN, etc.) where float32 would reintroduce silent rounding errors.

Verification: yarn tsc-check — protobuf wire format change only, no TypeScript changes needed (proto is loaded dynamically at runtime via protoLoader.loadSync).

1 file changed, 1 insertion, 1 deletion. Wire-compatible.

… static rate

Backend fixes for lnflash#282:
- Math.round() instead of Math.floor() for exchange rates
- Correct offset (12 BTC, 6 USD) instead of 0n
- displayCurrency parameter instead of hardcoded "USD"
- JMD conversion via ExchangeRates.jmd.sell static rate
- Price service uses static JMD rate instead of BTC triangulation

15 new tests covering all fix areas. 48/48 tests pass.
…recision (lnflash#283)

Changes PriceResponse.price from float (32-bit, ~7 sig figs) to double
(64-bit, ~15 sig figs). Float32 silently truncates JMD and other fiat
exchange rates that need more than 7 significant digits of precision.

This is a wire-compatible change: protobuf handles float→double
conversion automatically on the client side, and the price server
can be updated independently.

Phase 1 blocker for multi-currency price-server (ENG-315, lnflash#283).
@onchito-walks
Copy link
Copy Markdown
Author

Replaced by clean PR #?? with only the proto fix. This PR had unrelated JMD commits mixed in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant