Omniscia Euler Finance Audit

ProtocolConfig Code Style Findings

ProtocolConfig Code Style Findings

PCG-01C: Optimization of Structure Assignments

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:

src/ProtocolConfig/ProtocolConfig.sol
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

Description:

The linked value literal is repeated across the codebase multiple times.

Example:

src/ProtocolConfig/ProtocolConfig.sol
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

Description:

The referenced variables are meant to represent the default configuration of the ProtocolFeeConfig, however, their declarations are separated by multiple variables.

Example:

src/ProtocolConfig/ProtocolConfig.sol
28/// @dev protocol fee receiver, unless a vault has it configured otherwise
29address public feeReceiver;
30
31/// @dev min interest fee, except for vaults configured otherwise
32uint16 internal minInterestFee;
33/// @dev max interest fee, except for vaults configured otherwise
34uint16 internal maxInterestFee;
35/// @dev protocol fee share, except for vaults configured otherwise
36uint16 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.