The storage variable s has been retrieved in the line above. The bridge address can therefore be directly fetched from it instead of making another internal function call.
Recommended Mitigation Steps
Storage storage s = getStorage();
address bridge = s.cBridge;
G04: Redundant non-zero address check on _anyswapData.token
If _anyswapData.token is the zero address, calling IAnyswapToken(_anyswapData.token).underlying(); would revert with a call to a non-contract account. Hence the check _anyswapData.token != address(0) is not necessary. Alternatively, shift the check to be before the call to fetch the underlying token address IAnyswapToken(_anyswapData.token).underlying();.
G01: Redundant literal boolean comparisons
Line References
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/DexManagerFacet.sol#L20
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/DexManagerFacet.sol#L34
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/DexManagerFacet.sol#L47
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/DexManagerFacet.sol#L66
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/Swapper.sol#L16
Description
Since the referenced lines are expressions that evaluate to booleans, there isn’t a need to check against the boolean literals
true
andfalse
Recommended Mitigation Steps
Replace
if (condition == true)
andif (condition == false)
toif (condition)
andif (!condition)
respectively.G02: Unused constant
MAX_INT
Line References
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Libraries/LibSwap.sol#L8
Description
MAX_INT
is declared but not used in theLibSwap
contract. It can thus be removed.G03: Replace
_bridge()
withs.cBridge
Line References
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/CBridgeFacet.sol#L143-L144
Description
The storage variable
s
has been retrieved in the line above. The bridge address can therefore be directly fetched from it instead of making another internal function call.Recommended Mitigation Steps
G04: Redundant non-zero address check on
_anyswapData.token
Line References
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/AnyswapFacet.sol#L37
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/AnyswapFacet.sol#L80
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Facets/AnyswapFacet.sol#L145
Description
If
_anyswapData.token
is the zero address, callingIAnyswapToken(_anyswapData.token).underlying();
would revert with a call to a non-contract account. Hence the check_anyswapData.token != address(0)
is not necessary. Alternatively, shift the check to be before the call to fetch the underlying token addressIAnyswapToken(_anyswapData.token).underlying();
.Recommended Mitigation Steps
or remove the checks.
G05: Duplicate condition checks in
LibSwap#swap()
can be combinedLine References
https://github.com/code-423n4/2022-03-lifinance/blob/main/src/Libraries/LibSwap.sol#L33-L39
Description
The condition
if(!LibAsset.isNativeAsset(fromAssetId))
is checked twice. They should be combined to save gas.Recommended Mitigation Steps