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

Open
code423n4 opened this issue Mar 31, 2022 · 1 comment
Open

Gas Optimizations #35

code423n4 opened this issue Mar 31, 2022 · 1 comment
Labels
bug Something isn't working G (Gas Optimization) sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Gas : Global var updates code structure is unnecessarily big

updateGlobalVar

Instead of:

function updatePriceOracle(address _priceOracle) external onlyOwner {
        require(priceOracle != _priceOracle, 'UPO1');
        _updatePriceOracle(_priceOracle);
    }

    function _updatePriceOracle(address _priceOracle) internal {
        require(_priceOracle != address(0), 'IUPO1');

        priceOracle = _priceOracle;
        emit PriceOracleUpdated(_priceOracle);
    }

It could be:

function updatePriceOracle(address _priceOracle) external onlyOwner {
        require(priceOracle != _priceOracle, 'UPO1');
        require(_priceOracle != address(0), 'UPO2');
        priceOracle = _priceOracle;
        emit PriceOracleUpdated(_priceOracle);

    }

It was not specified how the contract size was fixed in the next release, so this might or might not apply.

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels Mar 31, 2022
code423n4 added a commit that referenced this issue Mar 31, 2022
@ritik99 ritik99 added the sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue label Apr 12, 2022
@ritik99
Copy link
Collaborator

ritik99 commented Apr 12, 2022

_updatePriceOracle is called during initialization as well, during which we do not need to perform the extra check that updatePriceOracle performs

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 disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

2 participants