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

[BUG] Precision Issue in calculate_propotional_apy Function #912

Open
AtelyPham opened this issue Feb 6, 2025 · 0 comments
Open

[BUG] Precision Issue in calculate_propotional_apy Function #912

AtelyPham opened this issue Feb 6, 2025 · 0 comments
Assignees
Labels
bug 🪲 Something isn't working

Comments

@AtelyPham
Copy link
Member

We have identified a precision issue in the calculate_propotional_apy function within the rewards.rs file. The function currently uses the Percent type for calculations, which leads to unexpected results due to its whole number representation.

Problem

When calculating the proportional APY, multiplying two Percent values (e.g., 10% and 2%) results in 0% due to rounding down to the nearest whole percentage. This is causing inaccuracies in the APY calculations.

Steps to Reproduce:

  1. Call the calculate_propotional_apy function with total_deposit and deposit_cap such that the propotion is 10%.
  2. Use an original_apy of 2%.
  3. Observe that the resulting APY is 0%.

Expected Behavior:

The function should return a more precise APY value, reflecting the actual multiplication result (e.g., 0.2%).

Impact

This issue affects the accuracy of APY calculations, potentially leading to incorrect reward distributions.

Screenshot

Screenshots of the test I conducted to verify the results of the calculate_proportional_apy function.

Image

Image

@AtelyPham AtelyPham added the bug 🪲 Something isn't working label Feb 6, 2025
@github-project-automation github-project-automation bot moved this to Not Started 🕧 in Webb Universe Feb 6, 2025
@AtelyPham AtelyPham moved this from Not Started 🕧 to Planning 🗺️ in Webb Universe Feb 6, 2025
@1xstj 1xstj assigned 1xstj and unassigned shekohex Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
Status: Planning 🗺️
Development

No branches or pull requests

3 participants