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

Magic number #433

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open

Magic number #433

wants to merge 7 commits into from

Conversation

Mati0x
Copy link
Contributor

@Mati0x Mati0x commented Sep 17, 2024

@Mati0x Mati0x linked an issue Sep 17, 2024 that may be closed by this pull request
Copy link

vercel bot commented Sep 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gardens-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 6:32pm

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Review of Changes

This PR introduces a potential issue in how spending limits are calculated. It appears to be attempting to use a different formula, but the implementation is incomplete and may lead to incorrect results.

File: apps/web/components/Forms/PoolForm.tsx

Issue:

  • A new variable maxRatioNum2 is introduced but never used in the subsequent calculation of weightNum. This suggests either an incomplete implementation or dead code.

Suggested Fix:

  • Clarify the intended use of maxRatioNum2.
  • If the intention is to use this new calculation for weightNum, update the formula accordingly. If not, remove the unused variable.
// apps/web/components/Forms/PoolForm.tsx
const maxRatioNum = spendingLimit / MAX_RATIO_CONSTANT;
// Remove or clarify the purpose of this calculation
// const maxRatioNum2 = spendingLimit / (1 - Math.sqrt(minimumConviction)); 

const weightNum = minimumConviction * maxRatioNum ** 2; 

File: apps/web/components/PoolHeader.tsx

Issue:

  • The original calculation of spendingLimit is commented out and replaced with a new formula. However, it's unclear if this new formula is intended to be a direct replacement or serves a different purpose.

Suggested Fix:

  • Provide context for the change in spendingLimit calculation.
  • Explain the reasoning behind the new formula and its relation to the original.
  • If the new calculation is intended to replace the old one, ensure it produces the expected results and doesn't introduce logic errors.
// apps/web/components/PoolHeader.tsx
// Explain why this is commented out and the reasoning behind the new calculation
// const spendingLimit = spendingLimitPct * MAX_RATIO_CONSTANT; 
const spendingLimit = 
  (strategy.config.maxRatio / CV_SCALE_PRECISION) * 
  (1 - Math.sqrt(minimumConviction / 100)) * 
  100; 

Review Summary

This PR needs clarification on the intended changes to the spending limit calculation. The addition of unused variables and commented-out code without explanation makes the intent unclear and raises concerns about potential errors.

Please address the issues outlined above to ensure the changes are correctly implemented and the code remains maintainable.

Corantin
Corantin previously approved these changes Sep 26, 2024
Copy link

@Corantin Corantin left a comment

Choose a reason for hiding this comment

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

GG

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.

Fix: maxRatio magic number
2 participants