feat: enhance fixed-point normalization and add test cases for edge v… - #387
Merged
Sadeequ merged 1 commit intoJun 1, 2026
Conversation
|
@Meet-hybrid Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Description
This PR introduces precision guards for multi‑hop currency conversions to prevent truncation drift and rounding errors in cross‑currency rate translations.
Changes
Added scaling constants:
INTERIOR_SCALE = 10^14 for intermediate multiplication products.
FIXED_POINT_SCALE = 10^7 for final normalization footprint.
Updated conversion functions to:
Scale intermediates up by INTERIOR_SCALE before division loops.
Normalize final results back down to FIXED_POINT_SCALE before returning metrics.
Introduced guard checks to ensure:
No overflow during intermediate scaling.
Accurate normalization of final values.
Added unit tests covering:
Single‑hop conversions (baseline correctness).
Multi‑hop conversions (e.g., GHS → XLM → NGN).
Precision stability across chained hops.
Consistency of results regardless of path length.
Acceptance Criteria
Total precision maintained at the standard 10^7 fixed‑point footprint.
Multi‑hop conversions produce consistent, auditable results.
Tests confirm no integer truncation beyond expected bounds.
Issue Link
Closes #368