_isWrappedFCash involves reasonably large gas usage and is called for each position twice. It is enough to call it once and save the results in memory allocated array for reuse.
Proof of Concept
_isWrappedFCash is called 2 times more often than it's needed:
_isWrappedFCash involves reasonably large gas usage and is called for each position twice. It is enough to call it once and save the results in memory allocated array for reuse.
Proof of Concept
_isWrappedFCash is called 2 times more often than it's needed:
https://github.com/code-423n4/2022-06-notional-coop/blob/6f8c325f604e2576e2fe257b6b57892ca181509a/index-coop-notional-trade-module/contracts/protocol/modules/v1/NotionalTradeModule.sol#L596-L626
Recommended Mitigation Steps
Consider saving the flags to memory array and use it instead of calling _isWrappedFCash in the second cycle.