Omniscia Mantissa Finance Audit

veMNT Code Style Findings

veMNT Code Style Findings

MNE-01C: Loop Iterator Optimizations

TypeSeverityLocation
Gas OptimizationveMNT.sol:L218, L226

Description:

The linked for loops increment / decrement their iterator "safely" due to Solidity's built - in safe arithmetics (post-0.8.X).

Example:

contracts/veMNT.sol
218for (uint256 i = 0; i < masterMantisListSize; i++) {

Recommendation:

We advise the increment / decrement operations to be performed in an unchecked code block as the last statement within each for loop to optimize their execution cost.

Alleviation (418ee413ad8e26f7eea383764c19953ff31b2bf3):

The referenced loop iterator increment statements have been optimized by relocating them to the end of each for loop's body and performing them within unchecked code blocks.

MNE-02C: Potentially Redundant Shift Operation

TypeSeverityLocation
Gas OptimizationveMNT.sol:L73

Description:

The referenced operation is meant to replace the element at index with the last element of the array so as to "preserve" the last element of the array in case an element in the middle of the array was meant to be removed.

This operation is inefficient in case index is equal to masterMantisList.length - 1.

Example:

contracts/veMNT.sol
71function removeMasterMantis(uint256 index, address _masterMantis) external onlyOwner {
72 require(masterMantisList[index] == _masterMantis, "Wrong index");
73 masterMantisList[index] = masterMantisList[masterMantisList.length-1];
74 masterMantisList.pop();
75 emit MasterMantisRemoved(_masterMantis);
76}

Recommendation:

We advise the operation to not be performed when the index to be removed is the last element in the array, optimizing the function's gas cost in such a case.

Alleviation (418ee413ad8e26f7eea383764c19953ff31b2bf3):

The shift operation is now optimally performed solely when the element to be removed is not the last element of the array, significantly reducing the function's gas cost in such a case.

MNE-03C: Redundant Parenthesis Statement

TypeSeverityLocation
Code StyleveMNT.sol:L233

Description:

The referenced statement is redundantly wrapped in parenthesis (()).

Example:

contracts/veMNT.sol
233require(from == address(0) || to == address(0) || (!whitelisted[from] && to == marketplace) || (from == marketplace), "Transfer not allowed");

Recommendation:

We advise them to be safely omitted, increasing the legibility of the codebase.

Alleviation (418ee413ad8e26f7eea383764c19953ff31b2bf3):

The redundant parenthesis statement has been safely omitted from the codebase as advised.

MNE-04C: Repetitive Value Literal

TypeSeverityLocation
Code StyleveMNT.sol:L175, L176

Description:

The linked value literal is repeated across the codebase multiple times.

Example:

contracts/veMNT.sol
175mntLpAmount = user.amount * percent / 1e4;

Recommendation:

We advise it to be set to a constant variable instead optimizing the legibility of the codebase.

Alleviation (418ee413ad8e26f7eea383764c19953ff31b2bf3):

The Mantissa Finance team stated that the repetition occurs solely twice and as such they deem it inconsequential and wish to acknowledge it.