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

Dawn Blossoms Plucked at Dusk #38

Merged
merged 9 commits into from
Jul 29, 2024
Merged

Conversation

shuhuiluo
Copy link
Contributor

@shuhuiluo shuhuiluo commented May 27, 2024

Latest optimizations from V4.

shuhuiluo added 9 commits May 17, 2024 00:17
The existing assembly code calculating the 'ratio' variable in TickMath.sol has been refactored for simplicity and efficiency. This result is achieved by removing an unnecessary mask operation and replacing it with a more straightforward expression that improves code readability and reduces complexity.
The `amountRemainingAbs` variable in SwapMath.sol was removed to simplify code logic. The conversion to an unsigned integer is now performed directly where required, which eliminates the need for the intermediate variable. This change improves code readability and maintainability.
…Bitmap

In this commit, new test cases are added for TickMath.t.sol to examine the 'Revert_GetSqrtRatioAtTick' and 'Revert_GetTickAtSqrtRatio' methods; and also added new functions to test bitmap manipulations in TickBitmap.t.sol such as 'flipTick' and 'isInitialized'. Additionally, existing test cases are modified to improve coverage and enhance test robustness.
The calculation method for the bit mask in the TickBitmap module has been changed. The new calculation approach "(2 << bitPos) - 1" replaces the previous "(1 << (bitPos + 1)) - 1" resulting in better efficiency and clarity. The changes are reflected throughout the TickBitmap module ensuring that all functions using this calculation are now updated.
This commit improves readability with clearer variable naming and avoids implicit upcasting in SqrtPriceMath.sol. We have replaced certain variable names for better understanding of the operations being carried out. This includes replacing `liquidity256` with `_liquidity`, and `sign` with `roundUp`. The commit also replaces `amount >> 160 == 0` check for overflow with `amount <= type(uint160).max`.
The changes center around improving code readability in TickMath.sol. The assembly block has been condensed for simplifying the flow of code. Also added are clarifying inline comments regarding the operations involving 'ratio' and 'sqrtPriceX96' variables.
Refactored the SwapMath module to optimize fee pips calculation. This was achieved by caching the feePips value to prevent redundant typecasts. This reduces computational overhead and may improve performance.
@shuhuiluo
Copy link
Contributor Author

@gnarlycow

@gnarlycow gnarlycow merged commit a0d408a into Aperture-Finance:main Jul 29, 2024
1 of 2 checks passed
@shuhuiluo shuhuiluo deleted the misc branch July 29, 2024 17:23
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