Omniscia Evergon Labs Audit

FractionFactory Code Style Findings

FractionFactory Code Style Findings

FFY-01C: Redundant Calculations

Description:

The referenced calculations involving the _registry are performed on an immutable argument and thus can be pre-calculated to optimize the function's gas cost.

Example:

contracts/dataManagers/fractionalizers/FractionFactory.sol
121/// @inheritdoc IFractionFactory
122function calculateDeployFee(
123 uint32[] calldata chainIds,
124 string memory name_,
125 string memory symbol_,
126 uint256 nftId_,
127 uint256 amountToBeMinted_
128) external view returns (uint256 totalNativeFee) {
129 bytes32 salt = keccak256(abi.encodePacked(_msgSender(), nftId_));
130 bytes32 estimationDatapoint = DataPoint.unwrap(DataPoints.encode(_registry, 0));
131 bytes memory message = _buildLzSendMessage(estimationDatapoint, salt, name_, symbol_, nftId_, amountToBeMinted_);
132
133 // Prepare target chain ids and fees, verify we have enough funds
134 OmnichainAddress[] memory estimationDatamanagers = new OmnichainAddress[](chainIds.length);
135 for (uint256 i; i < chainIds.length; i++) {
136 uint32 chainId = chainIds[i];
137 uint32 eid = _targetChainEid(chainId);
138 estimationDatamanagers[i] = OmnichainAddresses.encode(chainId, address(this));
139 totalNativeFee += _estimateFee(eid, message, DEPLOY_GAS_LIMIT);
140 }
141
142 totalNativeFee += IAccessManagerOmnichain(_dataIndex).estimateApproveOmnichainDataManagers(
143 DataPoint.wrap(estimationDatapoint),
144 estimationDatamanagers,
145 true
146 );
147}

Recommendation:

We advise them to be done so, optimizing the code's gas cost.

Alleviation (c6b23c23d8bcd8cce85049ad959cbd711a37126b):

The _estimationDatapoint has been configured as a contract-level immutable variable that is set to the resulting unwrapped data point, optimizing the code's runtime gas cost.

FFY-02C: Suboptimal Struct Declaration Style

Description:

The linked declaration style of a struct is using index-based argument initialization.

Example:

contracts/dataManagers/fractionalizers/FractionFactory.sol
234MessagingReceipt memory receipt = _lzSend(eid, message, opts, MessagingFee(nativeFee[i], 0), refundAddress);

Recommendation:

We advise the key-value declaration format to be utilized instead, greatly increasing the legibility of the codebase.

Alleviation (c6b23c23d8bcd8cce85049ad959cbd711a37126b):

The key-value declaration style has been properly utilized for the relevant struct entry, optimizing the code's legibility.