Omniscia WagmiDAO Audit

FamilyContract Code Style Findings

FamilyContract Code Style Findings

FCT-01C: Redundant Memory Declaration

TypeSeverityLocation
Gas OptimizationInformationalFamilyContract.sol:L76, L78

Description:

The linked statements perform a memory declaration of a storage value, write over it with an in-memory value and emit an event right after with the value read from storage before the write and the input argument of the function.

Example:

FamilyContract.sol
75function _setOwner(address newOwner) private {
76 address oldOwner = _owner;
77 _owner = newOwner;
78 emit OwnershipTransferred(oldOwner, newOwner);
79}

Recommendation:

We advise the event emission to be relocated before the storage write to directly utilize the storage member and render the in-memory variable declaration redundant within the code.

Alleviation:

The statements were adjusted as per our recommendation.

FCT-02C: Redundant Storage Reads

TypeSeverityLocation
Gas OptimizationInformationalFamilyContract.sol:L760, L767, L774, L781, L788, L794, L800, L806, L812

Description:

The linked event emissions read the value meant to be emitted from storage redundantly.

Example:

FamilyContract.sol
753function setSwapPath(address[] calldata _swapPath) external onlyOwner {
754 require(_swapPath.length > 1 && _swapPath[0] == address(usdc) && _swapPath[_swapPath.length - 1] == address(wagmi), "invalid swap path");
755 swapPath = _swapPath;
756 swapPathReverse = new address[](_swapPath.length);
757 for(uint256 i=0; i<_swapPath.length; i++)
758 swapPathReverse[i] = _swapPath[_swapPath.length - 1 - i];
759
760 emit SwapPathChanged(swapPath);
761}

Recommendation:

We advise the in-memory value that the variables were written to prior to the event's emission to be utilized instead, reducing each function's execution cost by one SLOAD operation.

Alleviation:

All event emission instances were properly updated to use the in-memory value ones instead.

FCT-03C: Redundant Visibility Specifier

TypeSeverityLocation
Gas OptimizationInformationalFamilyContract.sol:L701

Description:

The linked variable has a public visibility specifier yet is meant to represent an internally accessible constant.

Example:

FamilyContract.sol
701address public constant dead = 0x000000000000000000000000000000000000dEaD;

Recommendation:

We advise it to be set as private or internal greatly optimizing the deployment size and gas cost of the contract.

Alleviation:

The dead variable has now been set to private optimizing the codebase.

FCT-04C: Redundant constructor Implementation

TypeSeverityLocation
Gas OptimizationInformationalFamilyContract.sol:L602-L604

Description:

The linked constructor implementation is redundant as its statements assign storage values equivalent to the existing default ones.

Example:

FamilyContract.sol
597bool private _paused;
598
599/**
600 * @dev Initializes the contract in unpaused state.
601 */
602constructor() {
603 _paused = false;
604}

Recommendation:

We advise the constructor implementation to be safely omitted optimizing the codebase's gas cost.

Alleviation:

The constructor has been safely omitted.