-
Notifications
You must be signed in to change notification settings - Fork 211
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
Save gas and clean the upper bits of computed pool address properly #291
Open
shuhuiluo
wants to merge
10
commits into
Uniswap:main
Choose a base branch
from
shuhuiluo:gas-savings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e3bf4ea
Refactor `_v2Swap` to resolve stack too deep error
shuhuiluo 2b2ea49
Compute pair address using inline assembly in `UniswapV2Library.pairF…
shuhuiluo 8deab37
Rewrite `V3SwapRouter.computePoolAddress` using inline assembly and c…
shuhuiluo d16a6d9
Run Hardhat gas snapshot to demonstrate `computePoolAddress` optimiza…
shuhuiluo b3bfe32
Add Foundry test `UniswapV3Test` for more granular gas comparison
shuhuiluo bade844
Replace conditional statements with bitwise operations
shuhuiluo bc568ac
Uncheck loop index
shuhuiluo 65cad3d
Refactor to address comments
shuhuiluo 68baa9c
Improve readability
shuhuiluo 1ff67ff
Further optimize pool address calculation
shuhuiluo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
UniversalRouterTest:testCallModule() (gas: 6639) | ||
UniversalRouterTest:testSupportsInterface() (gas: 9045) | ||
UniversalRouterTest:testSweepERC1155() (gas: 70732) | ||
UniversalRouterTest:testSweepERC1155InsufficientOutput() (gas: 60170) | ||
UniversalRouterTest:testSweepERC1155NotFullAmount() (gas: 70713) | ||
UniversalRouterTest:testSweepETH() (gas: 58089) | ||
UniversalRouterTest:testSweepETHInsufficientOutput() (gas: 76030) | ||
UniversalRouterTest:testSweepToken() (gas: 82345) | ||
UniversalRouterTest:testSweepTokenInsufficientOutput() (gas: 82056) | ||
V2DaiWeth:testExactInput0For1() (gas: 107336) | ||
V2DaiWeth:testExactInput0For1FromRouter() (gas: 249776) | ||
V2DaiWeth:testExactInput1For0() (gas: 107408) | ||
V2DaiWeth:testExactInput1For0FromRouter() (gas: 249939) | ||
V2DaiWeth:testExactOutput0For1() (gas: 108235) | ||
V2DaiWeth:testExactOutput0For1FromRouter() (gas: 250864) | ||
V2DaiWeth:testExactOutput1For0() (gas: 108659) | ||
V2DaiWeth:testExactOutput1For0FromRouter() (gas: 251105) | ||
V2MockMock:testExactInput0For1() (gas: 106677) | ||
V2MockMock:testExactInput0For1FromRouter() (gas: 249531) | ||
V2MockMock:testExactInput1For0() (gas: 106636) | ||
V2MockMock:testExactInput1For0FromRouter() (gas: 249639) | ||
V2MockMock:testExactOutput0For1() (gas: 106852) | ||
V2MockMock:testExactOutput0For1FromRouter() (gas: 250050) | ||
V2MockMock:testExactOutput1For0() (gas: 107027) | ||
V2MockMock:testExactOutput1For0FromRouter() (gas: 250137) | ||
V2MockWeth:testExactInput0For1() (gas: 101507) | ||
V2MockWeth:testExactInput0For1FromRouter() (gas: 245121) | ||
V2MockWeth:testExactInput1For0() (gas: 101553) | ||
V2MockWeth:testExactInput1For0FromRouter() (gas: 245575) | ||
V2MockWeth:testExactOutput0For1() (gas: 101685) | ||
V2MockWeth:testExactOutput0For1FromRouter() (gas: 245640) | ||
V2MockWeth:testExactOutput1For0() (gas: 102817) | ||
V2MockWeth:testExactOutput1For0FromRouter() (gas: 246750) | ||
V2WethApe:testExactInput0For1() (gas: 112115) | ||
V2WethApe:testExactInput0For1FromRouter() (gas: 249479) | ||
V2WethApe:testExactInput1For0() (gas: 106933) | ||
V2WethApe:testExactInput1For0FromRouter() (gas: 249595) | ||
V2WethApe:testExactOutput0For1() (gas: 113146) | ||
V2WethApe:testExactOutput0For1FromRouter() (gas: 250672) | ||
V2WethApe:testExactOutput1For0() (gas: 108132) | ||
V2WethApe:testExactOutput1For0FromRouter() (gas: 250728) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I like the gas savings here. Wonder if it's worth a comment:
to get a feel for what this is doing at a glance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I think that's pretty helpful for readability, one for the V3Lib would probably make sense too. (sorry, missed that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.