Omniscia Euler Finance Audit
ProtocolConfig Code Style Findings
ProtocolConfig Code Style Findings
PCG-01C: Optimization of Structure Assignments
Type | Severity | Location |
---|---|---|
Gas Optimization | ProtocolConfig.sol:L174-L175, L195-L196 |
Description:
A structure assignment that is performed entry-by-entry is more optimal than an overwrite, as the overwrite has implicit memory expansion costs due to instantiating a struct
entry before assigning it to the respective data location.
Example:
174_interestFeeRanges[vault] =175 InterestFeeRange({exists: exists_, minInterestFee: minInterestFee_, maxInterestFee: maxInterestFee_});
Recommendation:
We advise the referenced assignments to be performed key-by-key, optimizing their overall gas cost.
Alleviation (fb2dd77a6ff9b7f710edb48e7eb5437e0db4fc1a):
The Euler Finance team evaluated this exhibit and opted to acknowledge it as the optimization would be observed in infrequently invoked functions and thus was assessed as inconsequential.
PCG-02C: Repetitive Value Literal
Type | Severity | Location |
---|---|---|
Code Style | ProtocolConfig.sol:L137, L151, L172, L193 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
137if (newProtocolFeeShare > 1e4) revert E_InvalidConfigValue();
Recommendation:
We advise it to be set to a constant
variable instead, optimizing the legibility of the codebase.
In case the constant
has already been declared, we advise it to be properly re-used across the code.
Alleviation (fb2dd77a6ff9b7f710edb48e7eb5437e0db4fc1a):
The referenced repetitive value literal 1e4
has been declared as a constant
at the Constants
contract under the label CONFIG_SCALE
, optimizing the legibility of the codebase.
PCG-03C: Variable Grouping
Type | Severity | Location |
---|---|---|
Code Style | ProtocolConfig.sol:L28-L29, L35-L36 |
Description:
The referenced variables are meant to represent the default configuration of the ProtocolFeeConfig
, however, their declarations are separated by multiple variables.
Example:
28/// @dev protocol fee receiver, unless a vault has it configured otherwise29address public feeReceiver;30
31/// @dev min interest fee, except for vaults configured otherwise32uint16 internal minInterestFee;33/// @dev max interest fee, except for vaults configured otherwise34uint16 internal maxInterestFee;35/// @dev protocol fee share, except for vaults configured otherwise36uint16 internal protocolFeeShare;
Recommendation:
We advise them to be located together, optimizing the legibility of the code.
Alleviation (fb2dd77a6ff9b7f710edb48e7eb5437e0db4fc1a):
The protocolFeeShare
variable was relocated right after the feeReceiver
, optimizing the code's legibility.