Omniscia Evergon Labs Audit

TwoBorderAmountFacetStorage Code Style Findings

TwoBorderAmountFacetStorage Code Style Findings

TBF-01C: Ineffectual Usage of Safe Arithmetics

Description:

The linked mathematical operations are guaranteed to be performed safely by surrounding conditionals evaluated in either require checks or if-else constructs.

Example:

packages/contracts/contracts/campaignAmounts/twoBorderAmountFacet/TwoBorderAmountFacetStorage.sol
230if (packetsStaked <= amountOfPacketsToUnstake) {
231 revert CannotPartiallyUnstakeMoreOrEqualToStaked(
232 campaignId,
233 nftId,
234 amountOfPacketsToUnstake,
235 packetsStaked
236 );
237}
238
239uint256 minAmountOfPackets = l.campaignAmounts[campaignId].minAmountOfPackets;
240
241if (minAmountOfPackets > 0) {
242 if (packetsStaked - amountOfPacketsToUnstake < minAmountOfPackets) {
243 revert RemainingPacketsBelowMinRequired(
244 campaignId,
245 nftId,
246 packetsStaked - amountOfPacketsToUnstake,
247 minAmountOfPackets
248 );
249 }
250}

Recommendation:

Given that safe arithmetics are toggled on by default in pragma versions of 0.8.X, we advise the linked statements to be wrapped in unchecked code blocks thereby optimizing their execution cost.

Alleviation (b64b659786cf3c84bea52feb3a69f546ba3601f0):

The optimization has been applied as advised, wrapping the relevant statements in an unchecked code block so as to optimize them.

TBF-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/campaignAmounts/twoBorderAmountFacet/TwoBorderAmountFacetStorage.sol
75/// @dev Unique identifier for the storage slot where the Layout struct is stored.
76bytes32 internal constant STORAGE_SLOT =
77 keccak256("evergonlabs.Staking.amounts.storage.TwoBorderAmountFacetStorage");

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.

TBF-03C: Repetitive Value Literal

Description:

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

Example:

packages/contracts/contracts/campaignAmounts/twoBorderAmountFacet/TwoBorderAmountFacetStorage.sol
127if (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.