Omniscia Boson Protocol Audit
ExchangeHandlerFacet Code Style Findings
ExchangeHandlerFacet Code Style Findings
EHF-01C: Inefficient mapping Lookups
| Type | Severity | Location |
|---|---|---|
| Gas Optimization | ![]() | ExchangeHandlerFacet.sol:L993, L1001, L1005, L1013 |
Description:
The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.
Example:
991if (_condition.method == EvaluationMethod.SpecificToken) {992 // How many times has this token id been used to commit to offers in the group?993 uint256 commitCount = lookups.conditionalCommitsByTokenId[_tokenId][_groupId];994
995 require(commitCount < _condition.maxCommits, MAX_COMMITS_TOKEN_REACHED);996
997 allow = holdsSpecificToken(_buyer, _condition, _tokenId);998
999 if (allow) {1000 // Increment number of commits to the group for this token id if they are allowed to commit1001 lookups.conditionalCommitsByTokenId[_tokenId][_groupId] = ++commitCount;1002 }1003} else if (_condition.method == EvaluationMethod.Threshold) {1004 // How many times has this address committed to offers in the group?1005 uint256 commitCount = lookups.conditionalCommitsByAddress[_buyer][_groupId];1006
1007 require(commitCount < _condition.maxCommits, MAX_COMMITS_ADDRESS_REACHED);1008
1009 allow = holdsThreshold(_buyer, _condition, _tokenId);1010
1011 if (allow) {1012 // Increment number of commits to the group for this address if they are allowed to commit1013 lookups.conditionalCommitsByAddress[_buyer][_groupId] = ++commitCount;1014 }1015} else {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.
Alleviation (2b9f60b6c3323fd234b570089ceff924cdb5851c):
All highlighted mapping lookups have been adequately optimized, addressing this exhibit.
EHF-02C: Redundant Parenthesis Statement
| Type | Severity | Location |
|---|---|---|
| Code Style | ![]() | ExchangeHandlerFacet.sol:L1065 |
Description:
The referenced statement is redundantly wrapped in parenthesis (()).
Example:
1065return (IERC721(_condition.tokenAddress).ownerOf(_tokenId) == _buyer);Recommendation:
We advise them to be safely omitted, increasing the legibility of the codebase.
Alleviation (2b9f60b6c3):
The redundant parenthesis statement was removed in an interim PR, however, the final commit still contains it rendering this exhibit "partially" alleviated.
Alleviation (584e7d054c):
The redundant parenthesis statement has been properly removed in the latest commit hash evaluated by the audit, rendering this exhibit alleviated.
