Omniscia 0xPhase Audit

FixedRateInterest Code Style Findings

FixedRateInterest Code Style Findings

FRI-01C: Redundant Duplicate Getter Definition

TypeSeverityLocation
Gas OptimizationFixedRateInterest.sol:L10, L29-L33

Description:

The fixedInterest variable of FixedRateInterest is declared as public yet also possesses a manual FixedRateInterest::getInterest getter function.

Example:

vault/interests/fixed/FixedRateInterest.sol
9contract FixedRateInterest is Ownable, IInterest {
10 uint256 public fixedInterest;
11
12 /// @notice Constructor for the FixedRateInterest contract
13 /// @param owner_ The owner address
14 /// @param initialFixedInterest_ The initial fixed interest
15 constructor(address owner_, uint256 initialFixedInterest_) {
16 fixedInterest = initialFixedInterest_;
17
18 _transferOwnership(owner_);
19 }
20
21 /// @notice Sets the fixed interest
22 /// @param newInterest The new fixed interest
23 /// @custom:protected onlyOwner
24 function setFixedInterest(uint256 newInterest) external onlyOwner {
25 fixedInterest = newInterest;
26 }
27
28 /// @inheritdoc IInterest
29 function getInterest(
30 IVault
31 ) external view override returns (uint256 interest) {
32 interest = fixedInterest;
33 }
34}

Recommendation:

We advise either of the two getter functions to be omitted, the former of which we advise to be removed by adjusting the fixedInterest to internal and prefixing its name with an underscore (_) to conform to the official Solidity style guidelines.

Alleviation (3dd3d7bf0c2693b2f9c23bacedfa420393f7ea84):

The previously-public fixedInterest variable has been set as internal and aptly renamed to _fixedInterest, no longer generating a redundant duplicate getter function and thus alleviating this exhibit.