Omniscia Keyko Audit

CommunityAdminImplementation Code Style Findings

CommunityAdminImplementation Code Style Findings

CAI-01C: Inefficient Event Storage Reads

Description:

All linked events emit the values of variables in storage that were written to by the function itself with in-memory values.

Example:

contracts/community/CommunityAdminImplementation.sol
187/**
188 * @notice Updates the address of the treasury
189 *
190 * @param newTreasury_ address of the new treasury contract
191 */
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 communityTemplate
201 *
202 * @param newCommunityTemplate address of the new communityTemplate contract
203 */
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

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:

contracts/community/CommunityAdminImplementation.sol
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

Description:

All linked functions can be omitted from the codebase by declaring the corresponding variables returned as public and renaming them.

Example:

contracts/community/CommunityAdminImplementation.sol
140/**
141 * @notice Returns the cUsd contract address
142 */
143function cUSD() external view override returns (IERC20) {
144 return _cUSD;
145}
146
147/**
148 * @notice Returns the CommunityAdmin contract address
149 */
150function treasury() external view override returns (ITreasury) {
151 return _treasury;
152}
153
154/**
155 * @notice Returns the state of a community
156 *
157 * @param communityAddress_ address of the community
158 */
159function communities(address communityAddress_)
160 external
161 view
162 override
163 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

Description:

The linked variable is meant to be an internally accessible constant yet is declared as public.

Example:

contracts/community/CommunityAdminImplementation.sol
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.