Omniscia Keyko Audit
CommunityAdminImplementation Code Style Findings
CommunityAdminImplementation Code Style Findings
CAI-01C: Inefficient Event Storage Reads
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | CommunityAdminImplementation.sol:L194, L196, L206, L208 |
Description:
All linked events emit
the values of variables in storage that were written to by the function itself with in-memory values.
Example:
187/**188 * @notice Updates the address of the treasury189 *190 * @param newTreasury_ address of the new treasury contract191 */192function updateTreasury(ITreasury newTreasury_) external override onlyOwner {193 address oldTreasuryAddress = address(_treasury);194 _treasury = newTreasury_;195
196 emit TreasuryUpdated(oldTreasuryAddress, address(_treasury));197}198
199/**200 * @notice Updates the address of the the communityTemplate201 *202 * @param newCommunityTemplate address of the new communityTemplate contract203 */204function updateCommunityTemplate(ICommunity newCommunityTemplate) external override onlyOwner {205 address oldCommunityTemplateAddress = address(newCommunityTemplate);206 _communityTemplate = newCommunityTemplate;207
208 emit CommunityTemplateUpdated(oldCommunityTemplateAddress, address(newCommunityTemplate));209}
Recommendation:
We advise the in-memory values from the function arguments to be utilized directly significantly reducing the gas cost of those functions.
Alleviation:
The event
emission statements have been optimised accordingly.
CAI-02C: Redundant Security Modifier
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | CommunityAdminImplementation.sol:L508 |
Description:
The onlyOwner
modifier applied to the deployCommunity
function is redundant as it is applied to the outer-level of wherever deployCommunity
is also invoked.
Example:
497function deployCommunity(498 address firstManager_,499 uint256 claimAmount_,500 uint256 maxClaim_,501 uint256 decreaseStep_,502 uint256 baseInterval_,503 uint256 incrementInterval_,504 uint256 minTranche_,505 uint256 maxTranche_,506 ICommunity previousCommunity_,507 address[] memory managerBlockList_508) internal onlyOwner returns (address) {
Recommendation:
We advise it to be removed from the internal
counterpart to optimize its gas cost.
Alleviation:
The redundant access control has been omitted from the codebase.
CAI-03C: Redundant User-Defined Getter Functions
Type | Severity | Location |
---|---|---|
Code Style | Informational | CommunityAdminImplementation.sol:L140-L166 |
Description:
All linked functions can be omitted from the codebase by declaring the corresponding variables returned as public
and renaming them.
Example:
140/**141 * @notice Returns the cUsd contract address142 */143function cUSD() external view override returns (IERC20) {144 return _cUSD;145}146
147/**148 * @notice Returns the CommunityAdmin contract address149 */150function treasury() external view override returns (ITreasury) {151 return _treasury;152}153
154/**155 * @notice Returns the state of a community156 *157 * @param communityAddress_ address of the community158 */159function communities(address communityAddress_)160 external161 view162 override163 returns (CommunityState)164{165 return _communities[communityAddress_];166}
Recommendation:
We advise this to be done so to significantly reduce the code size of the contract and ensure ease-of-maintenance of the codebase.
Alleviation:
The variables were renamed and adjusted as advised.
CAI-04C: Redundant Visibility Specifier
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | CommunityAdminImplementation.sol:L27 |
Description:
The linked variable is meant to be an internally accessible constant
yet is declared as public
.
Example:
27uint256 public constant VERSION = 1;
Recommendation:
We advise the public
specifier to be replaced by either an internal
or private
one given the variable has no use outside of the contract and can be represented by its literal form.
Alleviation:
The variable is no longer part of the codebase rendering this exhibit irrelevant.