Assessment reports>EtherFi>Discussion>Unused variables could be removed

Unused variables could be removed

There are two instances of variables that are declared but not used:

  1. In the batchCancelDepositAsBnftHolder function, the variables numberOfEethValidators and numberOfEtherFanValidators are declared, and the value of these variables are increased depending upon the source of funds, but they are not used anywhere.

function batchCancelDepositAsBnftHolder(uint256[] calldata _validatorIds, address _caller) public whenNotPaused nonReentrant {
    require(msg.sender == liquidityPoolContract, "INCORRECT_CALLER");

    uint32 numberOfEethValidators;
    uint32 numberOfEtherFanValidators;
    for (uint256 x; x < _validatorIds.length; ++x) { 
        ILiquidityPool.SourceOfFunds source = bidIdToStakerInfo[_validatorIds[x]].sourceOfFund;
        require(source != ILiquidityPool.SourceOfFunds.DELEGATED_STAKING, "Wrong flow");

        if (source == ILiquidityPool.SourceOfFunds.EETH){
            numberOfEethValidators++;
        } else if (source == ILiquidityPool.SourceOfFunds.ETHER_FAN) {
            numberOfEtherFanValidators++;
        }

        if(nodesManager.phase(_validatorIds[x]) == IEtherFiNode.VALIDATOR_PHASE.WAITING_FOR_APPROVAL) {
            uint256 nftTokenId = _validatorIds[x];
            TNFTInterfaceInstance.burnFromCancelBNftFlow(nftTokenId);
            BNFTInterfaceInstance.burnFromCancelBNftFlow(nftTokenId);
        }

        _cancelDeposit(_validatorIds[x], _caller);
    }
}
  1. In the _cancelDeposit function, the variable validatorPhase is set as the phase of the validator ID but is not used anywhere.

function _cancelDeposit(uint256 _validatorId, address _caller) internal {
    require(bidIdToStakerInfo[_validatorId].staker == _caller, "INCORRECT_CALLER");

    IEtherFiNode.VALIDATOR_PHASE validatorPhase = nodesManager.phase(_validatorId);

    bidIdToStakerInfo[_validatorId].staker = address(0);
    nodesManager.unregisterValidator(_validatorId);

    // Call function in auction contract to re-initiate the bid that won
    auctionManager.reEnterAuction(_validatorId);

    bool isFullStake = (msg.sender != liquidityPoolContract);
    if (isFullStake) {
        _refundDeposit(msg.sender, stakeAmount);
    }

    emit DepositCancelled(_validatorId);
}

We recommend removing the unused variables to save gas.

This issue has been acknowledged by EtherFi, and fixes were implemented in the following commits:

Zellic © 2025Back to top ↑