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 #8

Closed
code423n4 opened this issue Apr 28, 2022 · 1 comment
Closed

Gas Optimizations #8

code423n4 opened this issue Apr 28, 2022 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Cache variables for gas optimization

File
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/core/contracts/dex/DexAddressProvider.sol#L21
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/core/contracts/liquidityMining/v2/PARMinerV2.sol#L40-L43

Current code;

  modifier onlyManager() {
    require(_a.controller().hasRole(_a.controller().MANAGER_ROLE(), msg.sender), "LM010");
    _;
  }

Recommendation

  modifier onlyManager() {
    IAccessController c = _a.controller();
    require(c.hasRole(c.MANAGER_ROLE(), msg.sender), "LM010");
    _;
  }

File:
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/core/contracts/inception/AdminInceptionVault.sol#L149-L154

Same issue, consider cache _a.core() in a local variable to avoid a external call.


Files:
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/supervaults/contracts/SuperVault.sol#L137-L157
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/supervaults/contracts/SuperVault.sol#L187-L208
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/supervaults/contracts/SuperVault.sol#L289-L291

Same issue, consider cache a.core() in a local variable to avoid a external calls.


Files:
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/supervaults/contracts/SuperVault.sol#L233
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/supervaults/contracts/SuperVault.sol#L255
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/supervaults/contracts/SuperVault.sol#L292

Consider caching IERC20(a.stablex()

Current

   require(IERC20(a.stablex()).transfer(msg.sender, IERC20(a.stablex()).balanceOf(address(this))));

Recomendattion

   IERC20 _stablex = IERC20(a.stablex());
   require(_stablex.transfer(msg.sender, _stablex.balanceOf(address(this))));

Files:
https://github.com/code-423n4/2022-04-mimo/blob/f088e83f79b5ec66fb5eb39e6bb9fe33f446dd49/supervaults/contracts/SuperVault.sol#L369-L371

Consider caching ga.mimo()

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Apr 28, 2022
code423n4 added a commit that referenced this issue Apr 28, 2022
@code423n4 code423n4 mentioned this issue May 2, 2022
@gzeoneth
Copy link
Member

gzeoneth commented Jun 5, 2022

Duplicate of #2

@gzeoneth gzeoneth marked this as a duplicate of #2 Jun 5, 2022
@gzeoneth gzeoneth closed this as completed Jun 5, 2022
@gzeoneth gzeoneth added the duplicate This issue or pull request already exists label Jun 5, 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 duplicate This issue or pull request already exists G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

2 participants