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

Gas Optimizations #90

Open
code423n4 opened this issue May 7, 2022 · 1 comment
Open

Gas Optimizations #90

code423n4 opened this issue May 7, 2022 · 1 comment
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

contracts/PermissionlessBasicPoolFactory.sol
:112 the require() function refunds any left over gas to the user in case it reverts. Calling the function before setting the variables will save the user gas in case the function reverts. I suggest moving the function to line 103.
:185 instead of testing the pool.totalDepositsWei < pool.maximumDepositsWei case each time the deposit() function is ran, I suggest to save the pool state as a boolean, e.g. "bool isFull" which is set to FALSE at initiation and to true within the if loop of line 186

contracts/FixedPricePassThruGate.sol
:51 remove if qualification (is there any reason for the msg.value to be non-zero if it passes the require() on row 48?)

contracts/SpeedBumpPriceGate.sol
:55 change if evaluation from < to <= to save on computations in the case where priceFloor and lastPrice - decay are the same
:77 remove if qualification (is there any reasons for the msg.value to be non-zero if it passes require() on row 67?)

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels May 7, 2022
code423n4 added a commit that referenced this issue May 7, 2022
@illuzen
Copy link
Collaborator

illuzen commented May 10, 2022

112: valid
185: this would involve two checks instead of one in the typical case that the pool is not full
51: debatable and duplicate
55: valid, but very unlikely
77: debatable and duplicate

@illuzen illuzen closed this as completed May 12, 2022
@itsmetechjay itsmetechjay reopened this May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

3 participants