sujithsomraaj / lifi-stargate-v2-audit

3 Day Review [10 Jun 2024 - 13 Jun 2024]
0 stars 0 forks source link

Redundant `reserveRecoverGas` param in `_swapAndCompleteBridgeTokens` function #7

Open sujithsomraaj opened 5 months ago

sujithsomraaj commented 5 months ago

Context: ReceiverStargateV2.sol#L147

Description: The function _swapAndCompleteBridgeTokens executes a destination chain swap post-stargate bridging. This function is invoked through the lzCompose call from the Layerzero endpoint.

This function has a parameter called reserveRecoverGas, which is always passed as true in all possible paths. Hence, the function could be simplified by removing the parameter to optimize gas.

Recommendation: Consider removing the unused parameter from the function.

    function _swapAndCompleteBridgeTokens(
        bytes32 _transactionId,
        LibSwap.SwapData[] memory _swapData,
        address assetId,
        address payable receiver,
        uint256 amount,
-        bool reserveRecoverGas
    ) private {
-    uint256 _recoverGas = reserveRecoverGas ? recoverGas : 0;
+    uint256 _recoverGas = recoverGas;

LI.FI:

Researcher:

0xDEnYO commented 5 months ago

Great suggestion. Removed it.