Omniscia fetchai Audit

InterestManager Code Style Findings

InterestManager Code Style Findings

IMR-01C: Code Standardization

TypeSeverityLocation
Code StyleInformationalInterestManager.sol:L255-L270

Description:

The linked segment of code does not properly conform to a standardized format and can be increased in legibility with easier maintainability as well.

Example:

contracts/ALP/InterestManager.sol
255if (isInitialized == 0) {
256 bytes32[] memory hashNames = generateAllHashNames();
257 uint256[] memory values = new uint256[](4);
258
259 values[0] = contractRegistry.getUint256(INIT_TOKEN_ISC_LP);
260 values[1] = contractRegistry.getUint256(INIT_TOKEN_XSC);
261 values[2] = contractRegistry.getUint256(INIT_TOKEN_ISC_LL);
262 values[3] = 1; // True
263
264 require(values[0] != 0, "InterestManger: cannot initialize token values to zero");
265 require(values[1] != 0, "InterestManger: cannot initialize token values to zero");
266 require(values[2] != 0, "InterestManger: cannot initialize token values to zero");
267
268 tokenValueStorageContract.setAllValues(hashNames, values, block.timestamp);
269 emit UpdateTokenValues(hashNames, values, block.timestamp);
270}

Recommendation:

We advise the 4 value literal set as the length of the values array to be replaced by hashNames.length, the values until values.length - 1 to be set via a for loop that iterates on the hashNames and finally the last element of the array (values[values.length - 1]) to be set as 1. This will also permit the require checks to be applied within the for loop.

Alleviation:

The Atomix team has stated that they desire to retain the codebase as is due to the loop adjustments we recommended introducing a greater level of complexity and ultimately diminishing the readability of the codebase.