Skip to content

feat: enhance fixed-point normalization and add test cases for edge v… - #387

Merged
Sadeequ merged 1 commit into
StellarFlow-Network:mainfrom
Meet-hybrid:feature/multi-hop-fixedpoint-guards
Jun 1, 2026
Merged

feat: enhance fixed-point normalization and add test cases for edge v…#387
Sadeequ merged 1 commit into
StellarFlow-Network:mainfrom
Meet-hybrid:feature/multi-hop-fixedpoint-guards

Conversation

@Meet-hybrid

Copy link
Copy Markdown
Contributor

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

@drips-wave

drips-wave Bot commented Jun 1, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Sadeequ
Sadeequ merged commit ca57555 into StellarFlow-Network:main Jun 1, 2026
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.

⚖️ Mathematics | Bit-Shifted Fixed-Point Multi-Hop Conversion Guards

2 participants