Omniscia Myso Finance Audit
UniV2Chainlink Code Style Findings
UniV2Chainlink Code Style Findings
UVC-01C: Inefficient mapping
Lookups
Type | Severity | Location |
---|---|---|
Gas Optimization | UniV2Chainlink.sol:L56, L60, L63 |
Description:
The linked statements perform key-based lookup operations on mapping
declarations from storage multiple times for the same key redundantly.
Example:
56if (!isLpToken[collToken] && !isLpToken[loanToken]) {57 revert Errors.NoLpTokens();58}59uint256 loanTokenDecimals = IERC20Metadata(loanToken).decimals();60uint256 collTokenPriceRaw = isLpToken[collToken]61 ? getLpTokenPrice(collToken)62 : getPriceOfToken(collToken);63uint256 loanTokenPriceRaw = isLpToken[loanToken]64 ? getLpTokenPrice(loanToken)65 : getPriceOfToken(loanToken);
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 (c740f7c6b5ebd365618fd2d7ea77370599e1ca11):
The referenced mapping
lookups have been optimized by caching their result to local in-memory variables that are consequently utilized wherever they were performed.
UVC-02C: Redundant Parenthesis Statement
Type | Severity | Location |
---|---|---|
Code Style | UniV2Chainlink.sol:L69 |
Description:
The referenced statement is redundantly wrapped in parenthesis (()
).
Example:
69(loanTokenPriceRaw);
Recommendation:
We advise them to be safely omitted, increasing the legibility of the codebase.
Alleviation (c740f7c6b5ebd365618fd2d7ea77370599e1ca11):
The redundant parenthesis statement has been omitted as advised.