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

[FIX] Asset group decimal error #35

Merged
merged 2 commits into from
Oct 30, 2024
Merged

Conversation

iboss-ptk
Copy link
Collaborator

When asset weights in the same group having decimal places over 18, there could be the case where the resulted weight is decreased when it shouldn't. Considering a group where

previous weights: A = 1, B = 0
updated weights: A = 1/3, B = 2/3

But due to precision loss, A = 0.333333333333333333, B = 0.666666666666666666 which resulted in 0.999999999999999999 which is viewed as decreasing weight and bypass the limiter (decreasing weight shoud not be prohibited even if it's not yet below the bound as it improves the pool balances but this case does not).

The fix is delaying division and sum the normalized value first as opposed to just sum the denom weights.

@iboss-ptk iboss-ptk requested a review from crnbarr93 October 28, 2024 09:18
Copy link
Collaborator

@crnbarr93 crnbarr93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@iboss-ptk iboss-ptk merged commit 21d909a into main Oct 30, 2024
1 check passed
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.

2 participants