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

Clarity and logic optimizations in DistributionManager #8

Open
LHerskind opened this issue Nov 16, 2021 · 1 comment
Open

Clarity and logic optimizations in DistributionManager #8

LHerskind opened this issue Nov 16, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@LHerskind
Copy link

The current DistributionManager have some low-hanging fruits in terms of clarity and logic optimizations.

Storage usage:

  • The current AssetData uses only 104 bits for the index with the word having 8 bits unused, as we are normally using 128 bits for these values, I suggest that we use the extra 8 bits to move closer to the normal index range.

Clarity:

  • The users mapping holds the indexes for each user, and it would be more clear if the naming showed this, suggesting that we rename it to userIndexes.

Logic / Gas optimizations:

  • emissionPerSecond is fetched at every call to _updateAssetStateInternal but is not used when block.timestamp == lastUpdateTimestamp, the fetching could be moved below this point to remove unnecessary reads.
  • In _updateAssetStateInternal the value assetConfig.lastUpdateTimestamp is updated in both branches of the if-else, so it may just be moved out in full, this would also allow us to remove the else case entirely.
@miguelmtzinf
Copy link

Some of the suggestions are addressed in the V3 of the incentives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants