Omniscia Alliance Block Audit
TreasuryOperatedFeature Code Style Findings
TreasuryOperatedFeature Code Style Findings
TOF-01C: Data Mutability Optimization
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | Informational | TreasuryOperatedFeature.sol:L13, L15-L19 |
Description:
The setExternalRewardToken function is meant to sanitize the input token address and assign it to its contract-level variable only once as it is invoked solely within constructors in the codebase of the project.
Example:
contracts/pool-features/TreasuryOperatedFeature.sol
15function setExternalRewardToken(address _externalRewardToken) internal {16 require(externalRewardToken == address(0x0), "External reward token already set");17 require(_externalRewardToken != address(0x0), "External reward token should not be 0");18 externalRewardToken = _externalRewardToken;19}Recommendation:
As the variables are only assigned to once during derivative contract constructors, we advise that the code block within setThrottleParams is instead set to be of a constructor that performs the exact same statements, permitting the introduction of the immutable mutability specifier in the variable declaration of L13, greatly optimizing the codebase.
Alleviation:
The setter function was properly replaced by a constructor with the same statements that permits the utilization of the immutable mutability specifier.