code-423n4 / 2021-12-yetifinance-findings

0 stars 0 forks source link

Remove unnecessary variables can make the code simpler and save some gas #282

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2021-12-nftx/blob/194073f750b7e2c9a886ece34b6382b4f1355f36/nftx-protocol-v2/contracts/solidity/NFTXSimpleFeeDistributor.sol#L162-L163

      bytes memory payload = abi.encodeWithSelector(INFTXLPStaking.receiveRewards.selector, _vaultId, amountToSend);
      (bool success, ) = address(_receiver.receiver).call(payload);

payload is unnecessary as it's being used only once. Can be changed to:

      (bool success, ) = address(_receiver.receiver).call(
        abi.encodeWithSelector(INFTXLPStaking.receiveRewards.selector, _vaultId, amountToSend)
      );

https://github.com/code-423n4/2021-12-nftx/blob/194073f750b7e2c9a886ece34b6382b4f1355f36/nftx-protocol-v2/contracts/solidity/NFTXMarketplaceZap.sol#L312-L313

    uint256 remaining = WETH.balanceOf(address(this));
    WETH.transfer(to, remaining);

remaining is unnecessary as it's being used only once. Can be changed to:

    WETH.transfer(to, WETH.balanceOf(address(this)));
kingyetifinance commented 2 years ago

NFTX Contract.