Omniscia Evergon Labs Audit
IntervalVirtualAmountMultiplierFacetStorage Code Style Findings
IntervalVirtualAmountMultiplierFacetStorage Code Style Findings
IVF-01C: Inefficient Code Structure
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | IntervalVirtualAmountMultiplierFacetStorage.sol:L177, L181-L185, L190 |
Description:
The IntervalVirtualAmountMultiplierFacetStorage::applyVirtualAmountMultiplier function is slightly inefficient as it will break a for loop and execute further statements when unnecessary as the multiplier is guaranteed to be non-zero in such a case.
Example:
158function applyVirtualAmountMultiplier(159 Layout storage l,160 uint256 campaignId,161 uint256 nftId,162 uint256 totalAmountStaked163) internal returns (uint256) {164 CampaignInfo storage campaignInfoLocal = l.campaignInfoLocal[campaignId];165 uint256[] memory amountsStaked = campaignInfoLocal.amountsStaked;166 uint256 virtualAmount = totalAmountStaked;167
168 if (totalAmountStaked >= amountsStaked[0]) {169 uint256 length = amountsStaked.length;170 uint256 multiplier;171
172 for (uint256 i = 1; i < length; i++) {173 if (totalAmountStaked < amountsStaked[i]) {174 multiplier = campaignInfoLocal.amountStakedMultipliers[i - 1];175 virtualAmount = (virtualAmount * multiplier) / DIVIDER;176 l.amountMultiplierForNftId[nftId] = multiplier;177 break;178 }179 }180
181 if (multiplier == 0) {182 multiplier = campaignInfoLocal.amountStakedMultipliers[length - 1];183 virtualAmount = (virtualAmount * multiplier) / DIVIDER;184 l.amountMultiplierForNftId[nftId] = multiplier;185 }186 } else {187 l.amountMultiplierForNftId[nftId] = DIVIDER;188 }189
190 return virtualAmount;191}Recommendation:
We advise the code to return the virtualAmount calculated instead of breaking and the highlighted if conditional to be omitted as it would no longer be necessary, optimizing the code's overall gas cost.
Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):
The code was updated per our recommendation, minimizing the required statements to yield a value and thus optimizing its gas cost.
IVF-02C: Non-Standard Storage Slot Definition
| Type | Severity | Location |
|---|---|---|
| Standard Conformity | ![]() | IntervalVirtualAmountMultiplierFacetStorage.sol:L51 |
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:
49/// @dev Unique identifier for the storage slot where the Layout struct is stored.50bytes32 internal constant STORAGE_SLOT =51 keccak256("evergonlabs.Staking.virtualAmountMultiplier.storage.IntervalVirtualAmountMultiplierFacetStorage");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.
IVF-03C: Repetitive Value Literal
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | IntervalVirtualAmountMultiplierFacetStorage.sol:L104 |
Description:
The linked value literal is repeated across the codebase multiple times.
Example:
104if (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.
