Omniscia Boson Protocol Audit
DRFeeMutualizer Code Style Findings
DRFeeMutualizer Code Style Findings
DRF-01C: Code Repetition
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | DRFeeMutualizer.sol: • I-1: L255-L260 • I-2: L465-L470 |
Description:
The referenced code block is implemented by the imported FundsBase::validateIncomingPayment function.
Example:
250function deposit(address _tokenAddress, uint256 _amount) external payable nonReentrant {251 address msgSender = _msgSender();252 if (depositRestrictedToOwner && msgSender != owner()) revert DepositsRestrictedToOwner();253 if (_amount == 0) revert InvalidAmount();254
255 if (_tokenAddress == address(0)) {256 if (msg.value != _amount) revert BosonErrors.InsufficientValueReceived();257 } else {258 if (msg.value != 0) revert BosonErrors.NativeNotAllowed();259 transferFundsIn(_tokenAddress, msgSender, _amount);260 }261
262 poolBalances[_tokenAddress] += _amount;263 emit FundsDeposited(msgSender, _tokenAddress, _amount);264}Recommendation:
We advise the function to be invoked, optimizing the code's syntax.
Alleviation (efd5d1a8f23c3bca7c25273ea4c912a367250119):
The code was updated to utilize the FundsBase::validateIncomingPayment function correctly, addressing this exhibit.
DRF-02C: Inefficient mapping Lookups
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | DRFeeMutualizer.sol: • I-1: L135, L138 • I-2: L182, L185 • I-3: L342-L344, L379 • I-4: L518, L521 |
Description:
The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.
Example:
182uint256 agreementId = sellerToTokenToDisputeResolverToAgreement[_sellerId][_tokenAddress][_disputeResolverId];183if (agreementId == 0 && _disputeResolverId != 0) {184 // If no specific agreement exists, check for "any dispute resolver" agreement185 agreementId = sellerToTokenToDisputeResolverToAgreement[_sellerId][_tokenAddress][0];Recommendation:
As the lookups internally perform an expensive keccak256 operation, we advise the lookups to be cached wherever possible to a single local declaration that either holds the value of the mapping in case of primitive types or holds a storage pointer to the struct contained.
As the compiler's optimizations may take care of these caching operations automatically at-times, we advise the optimization to be selectively applied, tested, and then fully adopted to ensure that the proposed caching model indeed leads to a reduction in gas costs.
Alleviation (efd5d1a8f23c3bca7c25273ea4c912a367250119):
All mapping lookup pairs highlighted have been optimized per our recommendation.
DRF-03C: Redundant Parenthesis Statements
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | DRFeeMutualizer.sol: • I-1: L412 • I-2: L413 |
Description:
The referenced statements are redundantly wrapped in parenthesis' (()).
Example:
412(agreement.startTime > 0 && agreement.refundOnCancel) &&Recommendation:
We advise them to be safely omitted, increasing the legibility of the codebase.
Alleviation (efd5d1a8f23c3bca7c25273ea4c912a367250119):
The redundant parenthesis in the referenced statements have been safely omitted.
