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

Open
code423n4 opened this issue Jun 18, 2022 · 2 comments
Open

Gas Optimizations #156

code423n4 opened this issue Jun 18, 2022 · 2 comments
Labels
bug Something isn't working G (Gas Optimization) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons valid

Comments

@code423n4
Copy link
Contributor

gas

Title: Declaring var in the returns()

https://github.com/Badger-Finance/vested-aura/blob/v0.0.2/contracts/MyStrategy.sol#L161-L166

Remove L162 and declare protectedTokens inside the returns can save gas
Change to:

    function getProtectedTokens() public view virtual override returns (address[2] memory protectedTokens) { // @audit-info: declare here
        protectedTokens[0] = want; // AURA
        protectedTokens[1] = address(AURABAL);
    }

It can save 178 gas per call

Title: Using && inside require()

https://github.com/Badger-Finance/vested-aura/blob/v0.0.2/contracts/MyStrategy.sol#L184-L187

Instead of using && to validate, using multiple require can save 15 execution gas fee per call (although it will cost more in deployment gas fee).
Change to:

        require(
            balanceOfPool() == 0,
            "You have to wait for unlock or have to manually rebalance out of it"
        );
        require(
            LOCKER.balanceOf(address(this)) == 0,
            "You have to wait for unlock or have to manually rebalance out of it"
        );

Title: using < 32 bytes string to revert

https://github.com/Badger-Finance/vested-aura/blob/v0.0.2/contracts/MyStrategy.sol#L186

Strings are broken into 32 byte chunks for operations. Revert error strings over 32 bytes therefore consume extra gas than shorter strings

Title:

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

Title: Declaring var in the returns()

Would like to see proof

Rest is the usual

@GalloDaSballo GalloDaSballo added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Jun 19, 2022
@GalloDaSballo
Copy link
Collaborator

Screenshot 2022-06-20 at 18 54 29

Advice given doesn't compile

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) sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons valid
Projects
None yet
Development

No branches or pull requests

3 participants