Omniscia Myso Finance Audit

QuoteHandler Code Style Findings

QuoteHandler Code Style Findings

QHR-01C: Inefficient mapping Lookups

TypeSeverityLocation
Gas OptimizationQuoteHandler.sol:L52, L55, L89, L92, L95, L110, L113, L149, L153, L186, L217

Description:

The linked statements perform key-based lookup operations on mapping declarations from storage multiple times for the same key redundantly.

Example:

contracts/peer-to-peer/QuoteHandler.sol
52if (isOnChainQuote[lenderVault][onChainQuoteHash]) {
53 revert Errors.OnChainQuoteAlreadyAdded();
54}
55isOnChainQuote[lenderVault][onChainQuoteHash] = true;

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):

All referenced mapping lookups have been rigorously optimized, using local mapping pointers to optimize their lookup costs significantly.