Gravita-Protocol / Gravita-SmartContracts

GNU General Public License v3.0
49 stars 31 forks source link

[PFD-03C] Inefficient Pointer Type #380

Closed 0xfornax closed 1 year ago

0xfornax commented 1 year ago

PFD-03C: Inefficient Pointer Type

Type Severity Location
Gas Optimization PriceFeed.sol:L186

Description:

The referenced struct pointer has been set as memory yet only one of its members is read.

Example:

    OracleRecordV2 memory record = _isFallback ? fallbacks[_token] : oracles[_token];
    if (record.oracleAddress == address(0)) {
        _checkOwner();
    } else if (msg.sender != timelockAddress) {
        revert PriceFeed__TimelockOnlyError();
    }
}

Recommendation:

We advise it to be set as storage, optimizing the function's gas cost significantly.

0xfornax commented 1 year ago

Fixed.