code-423n4 / 2021-11-overlay-findings

1 stars 0 forks source link

Changing function visibility from public to external can save gas #110

Closed code423n4 closed 2 years ago

code423n4 commented 3 years ago

Handle

defsec

Vulnerability details

Impact

There are a few functions declared as public that are never called internally within the contract. It is best practice to mark such functions as external instead, as this saves gas (especially in the case where the function takes arguments, as external functions can read arguments directly from calldata instead of having to allocate memory).

Proof of Concept

  1. https://github.com/code-423n4/2021-11-overlay/blob/914bed22f190ebe7088194453bab08c424c3f70c/contracts/market/OverlayV1Market.sol#L88

  2. https://github.com/code-423n4/2021-11-overlay/blob/914bed22f190ebe7088194453bab08c424c3f70c/contracts/shims/OverlayV1UniswapV3MarketZeroLambdaShim.sol#L41

  3. https://github.com/code-423n4/2021-11-overlay/blob/914bed22f190ebe7088194453bab08c424c3f70c/contracts/shims/OverlayV1UniswapV3MarketZeroLambdaShim.sol#L34

Tools Used

Code Review

Recommended Mitigation Steps

All of the public functions in the contract are not called internally, so access can be changed to external to reduce gas.

mesozoic-technology commented 3 years ago

Agreed, I would put this under the final housekeeping stage that we were going to do.

mikeyrf commented 2 years ago

duplicate #6 - public to external

dmvt commented 2 years ago

duplicate of #25, not #6