Title: Cache array length in for loops can save gas
Impact
Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack.
Caching the array length in the stack saves around 3 gas per iteration.
Redundant code and comments can be confusing and should be removed (or changed appropriately) after careful evaluation. This will not only reduce gas costs but improve readability and maintainability of the code.
Title: Cache array length in for loops can save gas
Impact
Reading array length at each iteration of the loop takes 6 gas (3 for mload and 3 to place memory_offset) in the stack. Caching the array length in the stack saves around 3 gas per iteration.
Recommended Mitigation Steps
Cache array length: https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/Swapper.sol#L14
Title: Prefix increaments are cheaper than postfix increaments
Impact
Prefix increaments are cheaper than postfix increaments
Recommended Mitigation Steps
Use ++i in place of i++: https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/Swapper.sol#L14
Title: Redundant constructs
Impact
Redundant code and comments can be confusing and should be removed (or changed appropriately) after careful evaluation. This will not only reduce gas costs but improve readability and maintainability of the code.
Recommended Mitigation Steps
Change: https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/Swapper.sol#L16
From: ls.dexWhitelist[_swapData[i].approveTo] == true && ls.dexWhitelist[_swapData[i].callTo] == true To: ls.dexWhitelist[_swapData[i].approveTo] && ls.dexWhitelist[_swapData[i].callTo]
Title: Functions can be external
Impact
Public functions that are never called by the contract should be declared external to save gas.
Recommended Mitigation Steps
Change below functions to external: AnyswapFacet.startBridgeTokensViaAnyswap() https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/AnyswapFacet.sol#L35
AnyswapFacet.swapAndStartBridgeTokensViaAnyswap() https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/AnyswapFacet.sol#L74