Omniscia Vector Finance Audit

Ownable Code Style Findings

Ownable Code Style Findings

OWN-01C: Redundant Invocation of Getter Function

TypeSeverityLocation
Gas OptimizationInformationalOwnable.sol:L44

Description:

The linked require check redundantly invokes the owner getter function instead of utilizing the _owner variable directly.

Example:

contracts/utils/Ownable.sol
40/**
41 * @dev Throws if called by any account other than the owner.
42 */
43modifier onlyOwner() {
44 require(owner() == msg.sender, "Ownable: caller is not the owner");
45 _;
46}

Recommendation:

We advise the variable to be utilized directly to optimize the gas cost of its execution.

Alleviation:

The _owner variable is now used directly in the require check.

OWN-02C: Redundant Local Variable Declaration

TypeSeverityLocation
Gas OptimizationInformationalOwnable.sol:L76, L78

Description:

The OwnershipTransferred event within _transferOwnership is emitted after its value is updated thus necessitating a local variable.

Example:

contracts/utils/Ownable.sol
71/**
72 * @dev Transfers ownership of the contract to a new account (`newOwner`).
73 * Internal function without access restriction.
74 */
75function _transferOwnership(address newOwner) internal virtual {
76 address oldOwner = _owner;
77 _owner = newOwner;
78 emit OwnershipTransferred(oldOwner, newOwner);
79}

Recommendation:

We advise the event to be emitted before the value of _owner changes thus allowing it to directly read and utilize the value of _owner optimizing the gas cost of the function.

Alleviation:

The statements were properly updated to reflect our recommendation in full.