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

Minimize numerical error while calculating costs #736

Closed
renauter opened this issue Jun 12, 2023 · 1 comment
Closed

Minimize numerical error while calculating costs #736

renauter opened this issue Jun 12, 2023 · 1 comment
Assignees
Labels
type_bug Something isn't working
Milestone

Comments

@renauter
Copy link
Collaborator

When we calculate costs we usually need to convert those from USD to TFT or to get them from price rate over some duration.

By doing so we have to deal with double division and convert the result back to integer since we operate with integers on chain.

Each time we do this we introduce some numerical error by getting rid of some small "after comma" digits.

To minimize this numerical error (btw, which is one of the reason we use usd units instead of musd) it is suggested to use a rounding operation before converting back to integer.

@renauter renauter added the type_bug Something isn't working label Jun 12, 2023
@renauter renauter added this to the 2.5.0 milestone Jun 12, 2023
@renauter renauter self-assigned this Jun 12, 2023
@renauter renauter added this to 3.11.x Jun 12, 2023
@renauter renauter moved this to In Progress in 3.11.x Jun 13, 2023
@renauter renauter moved this from In Progress to Verification in 3.11.x Jun 14, 2023
@mohamedamer453
Copy link

Verified from #726

The value is now rounded before the conversion.

@github-project-automation github-project-automation bot moved this from Verification to Done in 3.11.x Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type_bug Something isn't working
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants