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

CS-V2Gov-052: Possible Code Simplifications #119

Open
danielattilasimon opened this issue Dec 25, 2024 · 0 comments
Open

CS-V2Gov-052: Possible Code Simplifications #119

danielattilasimon opened this issue Dec 25, 2024 · 0 comments

Comments

@danielattilasimon
Copy link
Contributor

Some parts of the code may be simplified, to make them more easily understandable and maintainable. Below is a non-exhaustive list of such snippets:

  1. In withdrawLQTY() there is an if-else clause ensuring that the user's unallocatedOffset goes to 0 in case of a complete withdrawal. However, the fraction formula used in the if branch would already yield offsetDecrease == unallocatedOffset in this case, without the need for a special case.

  2. In allocateLQTY(), the FSM check on DISABLED initiatives is redundant: the require will never fail. This is because the previous check on "active votes" already implies that, for all other states, both deltas should be non-positive. In fact, this holds not just for the DISABLED state, but also UNREGISTERABLE.

  3. In _allocateLQTY(), updating the GlobalState is done by subtracting the prevInitiativeState and adding the new initiativeState. However, this could be simplified by simply adding the relevant user-supplied delta, and suppressing the prevInitiativeState altogether.

  4. All payout snippets (in claimForInitiative(), BribeInitiative.claimBribes(), CurveV2GaugeRewards._depositIntoGauge()) include some capping logic, to account for potential errors leading to insolvency. However, the main source of rounding errors that led to broken accounting (i.e. using the average timestamp to represent lines) has been removed in [Version 3]. Moreover, should some other sources of error be left undiscovered, this mitigation still does not adequately protect against them: it only makes sure that the "last" payout does not revert, possibly at the expense of other destinations of those funds, without addressing the root cause that led to incorrect payout calculations.

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

No branches or pull requests

1 participant