Omniscia Olympus DAO Audit

ERC20Permit Code Style Findings

ERC20Permit Code Style Findings

ERP-01C: Improper Error Name

TypeSeverityLocation
Code StyleInformationalERC20Permit.sol:L56

Description:

The error name references another contract that does not exist in the codebase.

Example:

contracts/types/ERC20Permit.sol
56require(signer != address(0) && signer == owner, "ZeroSwapPermit: Invalid signature");

Recommendation:

We advise the error to be renamed.

Alleviation:

The error message has been corrected to utilize the contract's name instead.

ERP-02C: Redundant Visibility Specifiers

TypeSeverityLocation
Gas OptimizationInformationalERC20Permit.sol:L15, L17

Description:

The linked variables are meant to be internally available constant variables.

Example:

contracts/types/ERC20Permit.sol
14// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
15bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
16
17bytes32 public DOMAIN_SEPARATOR;

Recommendation:

We advise them to be set as private or internal to reduce the codebase bloat and bytecode size of the contract.

Alleviation:

Visibility specifiers were adjusted for both variables to ensure they are no longer exposed publicly.

ERP-03C: Suboptimal Code Style

TypeSeverityLocation
Code StyleInformationalERC20Permit.sol:L14, L15

Description:

The PERMIT_TYPEHASH variable has the hash declared as its assignment and the keccak256 instruction as its comment.

Example:

contracts/types/ERC20Permit.sol
14// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
15bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

Recommendation:

We advise these to be reversed as the one-way association of keccak256 is not guaranteed from a hash to its value but rather from a value to its hash. Additionally, validation of the values would have less implications as the keccak256 instruction is guaranteed to be performed properly. To note, assigning a constant to a keccak256 instruction's result does not affect gas cost as the value is pre-calculated by the compiler.

Alleviation:

The typehash is now properly assigned to the evaluation of a keccak256 instruction and is set as immutable to benefit from the gas optimization of evaluating the expression once.