Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tech]: Improve fixed numbers calculation precision #1314

Open
2 tasks
vovac12 opened this issue Jan 28, 2025 · 0 comments
Open
2 tasks

[Tech]: Improve fixed numbers calculation precision #1314

vovac12 opened this issue Jan 28, 2025 · 0 comments
Labels
tech Technical task

Comments

@vovac12
Copy link
Contributor

vovac12 commented Jan 28, 2025

Problem statement

Prevent overflow in fixed number calculations

Description

The current implementation uses i128 as the base for fixed number calculations. In certain cases, this leads to overflow during intermediate calculations, causing inaccuracies or failures in the computation.

To resolve this issue, we should replace i128 with 256-bit numbers (e.g., U256 or similar) for intermediate calculations. After the calculations are complete, results can be safely converted back to u128 for storage as balances

Definition of Done

  • Create fixed number type with 256 bit number as base
  • Replace fixed number type in critical parts of XYK pool calculations

Requirements

  • External interfaces should remain the same
  • Try to avoid of using types with dynamic allocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech Technical task
Projects
Status: No status
Development

No branches or pull requests

2 participants