Omniscia Evergon Labs Audit

ContinuousVirtualLockMultiplierFacetStorage Code Style Findings

ContinuousVirtualLockMultiplierFacetStorage Code Style Findings

CVM-01C: Inefficient Code Structure

Description:

The referenced statements will break the for loop that attempts to find the timelock period range that the timelock specified falls in and will return the multiplier after evaluating whether it is zero which accommodates for the case whereby no multiplier has been identified.

Example:

packages/contracts/contracts/subInternalFacets/virtualLockMultiplier/continuousVirtualLockMultiplier/ContinuousVirtualLockMultiplierFacetStorage.sol
237for (uint256 i = 1; i < length; i++) {
238 if (timeLockPeriod < timeLockPeriods[i]) {
239 uint256 stepper = ((timeLockPeriod - timeLockPeriods[i - 1]) *
240 (timeLockMultipliers[i] - timeLockMultipliers[i - 1])) /
241 (timeLockPeriods[i] - timeLockPeriods[i - 1]);
242 multiplier = timeLockMultipliers[i - 1] + stepper;
243
244 break;
245 }
246}
247
248if (multiplier == 0) {
249 multiplier = timeLockMultipliers[length - 1];
250}
251
252return multiplier;

Recommendation:

We advise the overall code to be optimized by returning the timeLockMultipliers[i - 1] + stepper expression directly, and by omitting the if branch evaluating whether the multiplier is 0 as the multiplier would be guaranteed to be zero at that point permitting the timeLockMultipliers[length - 1] value to be yielded directly.

Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):

The code was updated as advised reducing its gas cost under all invocation scenarios.

CVM-02C: Non-Standard Storage Slot Definition

Description:

The referenced declaration will define a storage slot for use by a facet of the system's main EIP-2535 Diamond, however, the way it is declared does not adhere to the latest standards.

Example:

packages/contracts/contracts/subInternalFacets/virtualLockMultiplier/continuousVirtualLockMultiplier/ContinuousVirtualLockMultiplierFacetStorage.sol
63/// @dev Unique identifier for the storage slot where the Layout struct is stored.
64bytes32 internal constant STORAGE_SLOT =
65 keccak256("evergonlabs.Staking.virtualLockMultiplier.storage.ContinuousVirtualLockMultiplierFacetStorage");

Recommendation:

We advise the EIP-7201 name-spaced layout approach to be adhered to similarly to OpenZeppelin and other relevant standard libraries, ensuring consistency among the ecosystem's widely utilized libraries and conforming to the latest standards.

Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):

The referenced slot definition has been updated to its standardized EIP-7201 representation, addressing this exhibit.

CVM-03C: Repetitive Value Literal

Description:

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

Example:

packages/contracts/contracts/subInternalFacets/virtualLockMultiplier/continuousVirtualLockMultiplier/ContinuousVirtualLockMultiplierFacetStorage.sol
118if (GeneralStorage.layout().campaignsInfo[campaignId].state != 1) {

Recommendation:

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

In case the constant has already been declared, we advise it to be properly re-used across the code.

Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):

The referenced literal has been properly introduced as part of the GeneralStakingStorage declarations and specifically as an ON_CREATION state, addressing this exhibit.