Repository navigation
fix: JMD currency precision — round settlement amounts, fix display price bias, direct JMD rate - #350
Closed
onchito-walks wants to merge 2 commits into
Closed
onchito-walks wants to merge 2 commits into
onchito-walks wants to merge 2 commits into
Conversation
…ervice - Round settlement amounts in asCurrency() instead of preserving floats - Use Math.round() instead of Math.floor() for exchangeRateCurrencySats - Short-circuit USD→JMD price via ExchangeRates.jmd.sell instead of BTC triangulation - Add regression tests for rounding, sign preservation, and display-price base Bounty: lnflash#282 Payout: 1Ast5dKr9z1bLWFBnyh6WDQSgyL7EHJosp Co-authored-by: rdthree <[email protected]>
10/10 tests passing on Node v20.18.1. Co-authored-by: rdthree <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
USD and BTC transaction amounts were stored as floats instead of integers, display prices were biased downward by Math.floor(), and JMD display price was triangulated through BTC instead of using the configured rate directly.
Root cause
asCurrency()did not round before casting to UsdCents/SatoshissettlementDisplayPrice.baseusedMath.floor()instead ofMath.round()ExchangeRates.jmd.sellChanges
src/app/wallets/get-transactions-for-wallet.ts— rounds before castsrc/services/price/index.ts— Math.round for display price base, direct JMD ratetest/flash/unit/app/wallets/get-transactions-for-wallet.spec.ts— 10 new testsTest evidence
Payout
BTC:
1Ast5dKr9z1bLWFBnyh6WDQSgyL7EHJospBuilt by @onchito-walks · operated by @rdthree
Closes #282