lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/**
 * @notice Adds or removes addresses from the whitelist - can be called by anyone with a valid signature
 * @param _investor is the address to whitelist
 * @param _fromTime is the moment when the sale lockup period ends and the investor can freely sell his tokens
 * @param _toTime is the moment when the purchase lockup period ends and the investor can freely purchase tokens from others
 * @param _expiryTime is the moment till investors KYC will be validated. After that investor need to do re-KYC
 * @param _canBuyFromSTO is used to know whether the investor is restricted investor or not.
 * @param _validFrom is the time that this signature is valid from
 * @param _validTo is the time that this signature is valid until
 * @param _nonce nonce of signature (avoid replay attack)
 * @param _v issuer signature
 * @param _r issuer signature
 * @param _s issuer signature
 */
function modifyWhitelistSigned(
        address _investor,
        uint256 _fromTime,
        uint256 _toTime,
        uint256 _expiryTime,
        bool _canBuyFromSTO,
        uint256 _validFrom,
        uint256 _validTo,
        uint256 _nonce,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    ) public {
        /*solium-disable-next-line security/no-block-members*/
        require(_validFrom <= now, "ValidFrom is too early");
        /*solium-disable-next-line security/no-block-members*/
        require(_validTo >= now, "ValidTo is too late");
        require(!nonceMap[_investor][_nonce], "Already used signature");
        nonceMap[_investor][_nonce] = true;
        bytes32 hash = keccak256(
            abi.encodePacked(this, _investor, _fromTime, _toTime, _expiryTime, _canBuyFromSTO, _validFrom, _validTo, _nonce)
        );
        _checkSig(hash, _v, _r, _s);
        //Passing a _time == 0 into this function, is equivalent to removing the _investor from the whitelist
        whitelist[_investor] = TimeRestriction(_fromTime, _toTime, _expiryTime, _canBuyFromSTO);
        /*solium-disable-next-line security/no-block-members*/
        emit ModifyWhitelist(_investor, now, msg.sender, _fromTime, _toTime, _expiryTime, _canBuyFromSTO);
    }
// Solidity 0.4.24
/**
 * @notice Used to verify the signature
 */
function _checkSig(bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s) internal view {
        //Check that the signature is valid
        //sig should be signing - _investor, _fromTime, _toTime & _expiryTime and be signed by the issuer address
        address signer = ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)), _v, _r, _s);
        require(signer == Ownable(securityToken).owner() || signer == signingAddress, "Incorrect signer");
    }
// Solidity 0.6.1
/// @dev Returns sparse array
function getFundHoldings() external returns (uint[] memory, address[] memory) {
        uint[] memory _quantities = new uint[](ownedAssets.length);
        address[] memory _assets = new address[](ownedAssets.length);
        for (uint i = 0; i < ownedAssets.length; i++) {
            address ofAsset = ownedAssets[i];
            // assetHoldings formatting: mul(exchangeHoldings, 10 ** assetDecimal)
            uint quantityHeld = assetHoldings(ofAsset);
            _assets[i] = ofAsset;
            _quantities[i] = quantityHeld;
        }
        return (_quantities, _assets);
    }
// Solidity 0.6.1
// prices are quoted in DENOMINATION_ASSET so they use denominationDecimals
function calcGav() public returns (uint gav) {
        for (uint i = 0; i < ownedAssets.length; ++i) {
            address asset = ownedAssets[i];
            // assetHoldings formatting: mul(exchangeHoldings, 10 ** assetDecimals)
            uint quantityHeld = assetHoldings(asset);
            // Dont bother with the calculations if the balance of the asset is 0
            if (quantityHeld == 0) {
                continue;
            }
            // gav as sum of mul(assetHoldings, assetPrice) with formatting: mul(mul(exchangeHoldings, exchangePrice), 10 ** shareDecimals)
            gav = add(
                gav,
                IPriceSource(priceSource()).convertQuantity(
                    quantityHeld, asset, DENOMINATION_ASSET
                )
            );
        }
        return gav;
    }
// Solidity 0.6.1
/// @notice Reward all fees and perform some updates
/// @dev Anyone can call this
function triggerRewardAllFees()
        external
        amguPayable(false)
        payable
    {
        updateOwnedAssets();
        uint256 gav;
        uint256 feesInDenomination;
        uint256 feesInShares;
        uint256 nav;
        (gav, feesInDenomination, feesInShares, nav,,) = performCalculations();
        uint256 totalSupply = Shares(routes.shares).totalSupply();
        FeeManager(routes.feeManager).rewardAllFees();
        atLastAllocation = Calculations({
            gav: gav,
            nav: nav,
            allocatedFees: feesInDenomination,
            totalSupply: totalSupply,
            timestamp: block.timestamp
        });
    }
// Solidity 0.6.1
/// @dev Check holdings for all assets, and adjust list
function updateOwnedAssets() public {
        for (uint i = 0; i < ownedAssets.length; i++) {
            address asset = ownedAssets[i];
            if (
                assetHoldings(asset) == 0 &&
                !(asset == address(DENOMINATION_ASSET)) &&
                ITrading(routes.trading).getOpenMakeOrdersAgainstAsset(asset) == 0
            ) {
                _removeFromOwnedAssets(asset);
            }
        }
    }
// Solidity 0.6.1
/// @dev Just pass if asset not in list
function _removeFromOwnedAssets(address _asset) internal {
        if (!isInAssetList[_asset]) { return; }

        isInAssetList[_asset] = false;
        for (uint i; i < ownedAssets.length; i++) {
            if (ownedAssets[i] == _asset) {
                ownedAssets[i] = ownedAssets[ownedAssets.length - 1];
                ownedAssets.pop();
                break;
            }
        }
        emit AssetRemoval(_asset);
    }
// Solidity 0.4.19
// admin initiates a request that the insurance fee be changed
function requestChangeInsuranceFees(uint80 _transferFeeNumerator,
                                        uint80 _transferFeeDenominator,
                                        uint80 _mintFeeNumerator,
                                        uint80 _mintFeeDenominator,
                                        uint256 _mintFeeFlat,
                                        uint80 _burnFeeNumerator,
                                        uint80 _burnFeeDenominator,
                                        uint256 _burnFeeFlat) public onlyAdminOrOwner {
        uint deferBlock = computeDeferBlock();
        changeInsuranceFeesOperation = ChangeInsuranceFeesOperation(_transferFeeNumerator,
                                                                    _transferFeeDenominator,
                                                                    _mintFeeNumerator,
                                                                    _mintFeeDenominator,
                                                                    _mintFeeFlat,
                                                                    _burnFeeNumerator,
                                                                    _burnFeeDenominator,
                                                                    _burnFeeFlat,
                                                                    admin,
                                                                    deferBlock);
        ChangeInsuranceFeesOperationEvent(_transferFeeNumerator,
                                          _transferFeeDenominator,
                                          _mintFeeNumerator,
                                          _mintFeeDenominator,
                                          _mintFeeFlat,
                                          _burnFeeNumerator,
                                          _burnFeeDenominator,
                                          _burnFeeFlat,
                                          deferBlock);
    }
// Solidity 0.4.19
// after a day, beneficiary of a mint request finalizes it by providing the
// index of the request (visible in the MintOperationEvent accompanying the original request)
function finalizeMint(uint index) public onlyAdminOrOwner {
        MintOperation memory op = mintOperations[index];
        require(op.admin == admin); //checks that the requester's adminship has not been revoked
        require(op.deferBlock <= block.number); //checks that enough time has elapsed
        address to = op.to;
        uint256 amount = op.amount;
        delete mintOperations[index];
        child.mint(to, amount);
    }
// Solidity 0.4.19
// after a day, admin finalizes the insurance fee change
function finalizeChangeInsuranceFees() public onlyAdminOrOwner {
        require(changeInsuranceFeesOperation.admin == admin);
        require(changeInsuranceFeesOperation.deferBlock <= block.number);
        uint80 _transferFeeNumerator = changeInsuranceFeesOperation._transferFeeNumerator;
        uint80 _transferFeeDenominator = changeInsuranceFeesOperation._transferFeeDenominator;
        uint80 _mintFeeNumerator = changeInsuranceFeesOperation._mintFeeNumerator;
        uint80 _mintFeeDenominator = changeInsuranceFeesOperation._mintFeeDenominator;
        uint256 _mintFeeFlat = changeInsuranceFeesOperation._mintFeeFlat;
        uint80 _burnFeeNumerator = changeInsuranceFeesOperation._burnFeeNumerator;
        uint80 _burnFeeDenominator = changeInsuranceFeesOperation._burnFeeDenominator;
        uint256 _burnFeeFlat = changeInsuranceFeesOperation._burnFeeFlat;
        delete changeInsuranceFeesOperation;
        child.changeInsuranceFees(_transferFeeNumerator,
                                  _transferFeeDenominator,
                                  _mintFeeNumerator,
                                  _mintFeeDenominator,
                                  _mintFeeFlat,
                                  _burnFeeNumerator,
                                  _burnFeeDenominator,
                                  _burnFeeFlat);
    }
// Solidity 0.5.12
//always removing in renBTC, else use normal method
function removeLiquidityOneCoinThenBurn(bytes calldata _btcDestination, uint256 _token_amounts, uint256 min_amount) external {
        uint256 startRenbtcBalance = RENBTC.balanceOf(address(this));
        require(curveToken.transferFrom(msg.sender, address(this), _token_amounts));
        exchange.remove_liquidity_one_coin(_token_amounts, 0, min_amount);
        uint256 endRenbtcBalance = RENBTC.balanceOf(address(this));
        uint256 renbtcWithdrawn = endRenbtcBalance.sub(startRenbtcBalance);

        // Burn and send proceeds to the User
        uint256 burnAmount = registry.getGatewayBySymbol("BTC").burn(_btcDestination, renbtcWithdrawn);
        emit Burn(burnAmount);
    }
// Solidity 0.4.21
/**
 * @notice Start airdrop
 * @param _multiplierPercent Multiplier of the airdrop
 */
function startAirdrop(uint256 _multiplierPercent) onlyOwner external returns(bool){
        pause();
        require(multiplierPercent == 0);                 //This means airdrop was finished
        require(_multiplierPercent > PERCENT_DIVIDER);   //Require that after airdrop amount of tokens will be greater than before
        currentAirdrop = currentAirdrop.add(1);
        multiplierPercent = _multiplierPercent;
        undropped = totalSupply();
        assert(multiplierPercent.mul(undropped) > 0);   //Assert that wrong multiplier will not result in owerflow in airdropAmount()
        AirdropStart(multiplierPercent, currentAirdrop);
    }
// Solidity 0.4.21
/**
 * @notice Execute airdrop for a bunch of addresses. Should be repeated for all addresses with non-zero amount of tokens.
 * @dev This function can be called by anyone, not only the owner
 * @param holders Array of token holder addresses.
 * @return true if success
 */
function drop(address[] holders) external returns(bool){
        for(uint256 i=0; i < holders.length; i++){
            address holder = holders[i];
            if(!isAirdropped(holder)){
                uint256 balance = balances[holder];
                undropped = undropped.sub(balance);
                balances[holder] = airdropAmount(balance);
                uint256 amount = balances[holder].sub(balance);
                totalSupply_ = totalSupply_.add(amount);
                Transfer(address(0), holder, amount);
                setAirdropped(holder);
            }
        }
    }
// Solidity 0.5.5
/**
 * @param _value the amount of money to burn
 */
function burn(uint256 _value) public returns (bool success) {
        require(balanceOf[msg.sender] >= _value);   // Check if the sender has enough
        balanceOf[msg.sender] -= _value;            // Subtract from the sender
        totalSupply -= _value;                      // Updates totalSupply
        emit Burn(msg.sender, _value);
        return true;
    }
// Solidity 0.5.5
/**
 * @param _from the address of the sender
 * @param _value the amount of money to burn
 */
function burnFrom(address _from, uint256 _value) public returns (bool success) {
        require(balanceOf[_from] >= _value);                // Check if the targeted balance is enough
        require(_value <= allowance[_from][msg.sender]);    // Check allowance
        balanceOf[_from] -= _value;                         // Subtract from the targeted balance
        allowance[_from][msg.sender] -= _value;             // Subtract from the sender's allowance
        totalSupply -= _value;                              // Update totalSupply
        emit Burn(_from, _value);
        return true;
    }
// Solidity 0.5.8
// function testrevenue(address _game) public view returns (uint256, bool, bool, uint256){
//     uint256 ethfee;
//     uint256 hbfee;
//     address local_game = _game;
//     IERC721 erc721Address = IERC721(_game);
//     for (uint i = 0; i < Games[_game].tokenIdSale.length; i++) {
//         uint256 _tokenId = Games[_game].tokenIdSale[i];
//         if (Games[local_game].tokenPrice[_tokenId].tokenOwner == erc721Address.ownerOf(_tokenId)) {
//             if (Games[local_game].tokenPrice[_tokenId].fee >= 0) {
//                 ethfee = ethfee.add(Games[local_game].tokenPrice[_tokenId].fee);
//                 if(Games[local_game].tokenPrice[_tokenId].isHightlight == 1) ethfee = ethfee.add(Games[local_game].hightLightFee);
//             }
//             else if (Games[local_game].tokenPrice[_tokenId].hbfee >= 0) {
//                 hbfee = hbfee.add(Games[local_game].tokenPrice[_tokenId].hbfee);
//                 if(Games[local_game].tokenPrice[_tokenId].isHightlight == 1) hbfee = hbfee.add(Games[local_game].hightLightFee.mul(HBWALLETExchange).div(2).div(10 ** 16));
//             }
//         }
//         if(i== Games[local_game].tokenIdSale.length-1) {
//             uint256 eth = address(this).balance;
//             uint256 hb = hbwalletToken.balanceOf(address(this));
//             return (ethfee, Games[local_game].tokenPrice[_tokenId].tokenOwner == erc721Address.ownerOf(_tokenId), 
//             Games[local_game].tokenPrice[_tokenId].fee >= 0, ethfee.add(Games[local_game].hightLightFee));
//         }
//     }
// }
function revenue() public view returns (uint256, uint){

        uint256 ethfee;
        uint256 hbfee;
        for(uint j = 0; j< arrGames.length; j++) {

            address _game = arrGames[j];
            IERC721 erc721Address = IERC721(arrGames[j]);
            for (uint i = 0; i < Games[_game].tokenIdSale.length; i++) {
                uint256 _tokenId = Games[_game].tokenIdSale[i];
                if (Games[_game].tokenPrice[_tokenId].tokenOwner == erc721Address.ownerOf(_tokenId)) {
                    if (Games[_game].tokenPrice[_tokenId].fee >= 0) {
                        ethfee = ethfee.add(Games[_game].tokenPrice[_tokenId].fee);
                        if(Games[_game].tokenPrice[_tokenId].isHightlight == 1) ethfee = ethfee.add(Games[_game].hightLightFee);
                    }
                    else if (Games[_game].tokenPrice[_tokenId].hbfee >= 0) {
                        hbfee = hbfee.add(Games[_game].tokenPrice[_tokenId].hbfee);
                        if(Games[_game].tokenPrice[_tokenId].isHightlight == 1) hbfee = hbfee.add(Games[_game].hightLightFee.mul(HBWALLETExchange).div(2).div(10 ** 16));
                    }
                }
            }
        }

        uint256 eth = address(this).balance.sub(ethfee);
        uint256 hb = hbwalletToken.balanceOf(address(this)).sub(hbfee);
        return (eth, hb);
    }
// Solidity 0.8.4
/// @notice Enables calling multiple methods in a single call to this contract.
function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
        results = new bytes[](data.length);
        unchecked {for (uint256 i = 0; i < data.length; i++) {
            (bool success, bytes memory result) = address(this).delegatecall(data[i]);
            if (!success) {
                if (result.length < 68) revert();
                assembly {result := add(result, 0x04)}
                revert(abi.decode(result, (string)));
            }
            results[i] = result;}}
    }
// Solidity 0.8.4
/// @notice Enter Meowshi. Deposit xSUSHI `amount`. Mint MEOW for `to`.
function meow(address to, uint256 amount) external returns (uint256 shares) {
        ISushiBar(sushiBar).transferFrom(msg.sender, address(bento), amount); // forward to BENTO for skim
        (, shares) = bento.deposit(IERC20(sushiBar), address(bento), address(this), amount, 0);
        meowMint(to, shares * multiplier);
    }
// Solidity 0.8.0
// Sets the price for the NFT's 
function getHeroPrice() public view returns (uint256) {
    uint currentSupply = totalSupply();
    if (currentSupply >= 0 && currentSupply < 501){
        return 35000000000000000;
    }else if(currentSupply >= 501 && currentSupply < 5000){
        return 65000000000000000;
    }else if(currentSupply >= 5001){
        return 70000000000000000;
    }
   }
// Solidity 0.8.0
// minting function for stakes 
function mintForStakers(uint256 numNFTs) public payable onlyRole(STAKER_ROLE){
    require(hasSaleStarted, "Sale has not started");
    require(stakerSupply > 0, "Staker reserve is empty!");
    require(msg.value >= getHeroPrice() * numNFTs, "Incorrect ether value");
    require(stakerSupply - numNFTs >= 0, "Exceeds retail supply");
    require(numNFTs <= priceRange(), "Number of NFTs would exceed the price range");
    
    for (uint i = 0; i < numNFTs; i++) {
      uint mintIndex = totalSupply() + 1; // +1 so it doesn't start on index 0.
      _safeMint(msg.sender, mintIndex);
    }
      
    if (startingIndexBlock == 0 && (totalSupply() == retailSupply)) {
      startingIndexBlock = block.number;}
      
    stakerSupply = stakerSupply - numNFTs;
    stakerMinted = stakerMinted + numNFTs;
  }
// Solidity 0.7.1
/**
 * @dev Returns the value for `variable` at the indexed sample.
 */
function getInstantValue(
        mapping(uint256 => bytes32) storage samples,
        IPriceOracle.Variable variable,
        uint256 index
    ) external view returns (uint256) {
        bytes32 sample = samples[index];
        _require(sample.timestamp() > 0, Errors.ORACLE_NOT_INITIALIZED);

        int256 rawInstantValue = sample.instant(variable);
        return LogCompression.fromLowResLog(rawInstantValue);
    }
// Solidity 0.7.1
/**
 * @dev Returns the time average weighted price corresponding to `query`.
 */
function getTimeWeightedAverage(
        mapping(uint256 => bytes32) storage samples,
        IPriceOracle.OracleAverageQuery memory query,
        uint256 latestIndex
    ) external view returns (uint256) {
        _require(query.secs != 0, Errors.ORACLE_BAD_SECS);

        int256 beginAccumulator = getPastAccumulator(samples, query.variable, latestIndex, query.ago + query.secs);
        int256 endAccumulator = getPastAccumulator(samples, query.variable, latestIndex, query.ago);
        return LogCompression.fromLowResLog((endAccumulator - beginAccumulator) / int256(query.secs));
    }
// Solidity 0.5.1
///@notice Add item to progject vote list
/// @dev It must be call from owner before startVote()
/// @param _prjName   - string, project name for vote.
/// @param _prjAddress   - address, only this address can get 
/// reward if project will win.
function addProjectToVote(string calldata _prjName, address _prjAddress) 
    external 
    payable 
    onlyOwner
    {
        require(currentStage == StageName.preList, "Can't add item after vote has starting!");
        require(_prjAddress != address(0),"Address must be valid!");
        bytes32 hash = keccak256(bytes(_prjName));
        require( projects[hash].prjAddress == address(0), 
            "It seems like this item allready exist!"
        );
        projects[hash] = PrjProperties({
                prjAddress: _prjAddress,
                voteCount: 0,
                prjWeiRaised: 0
            });
    }
// Solidity 0.5.1
///@notice Make vote for sender
/// @dev Sender must send enough ether
/// @param _prjName   - string, project name for vote.
function vote(string calldata _prjName) external payable {
        require(currentStage == StageName.inProgress,
            "Vote disable now!"
        
        );
        require(msg.value >= MINETHVOTE, "Please send more ether!");
        bytes32 hash = keccak256(bytes(_prjName));
        PrjProperties memory currentBet = projects[hash];//Storage - or   other place!!!!
        require(currentBet.prjAddress != address(0), 
            "It seems like there is no item with that name"
        );
        projects[hash].voteCount = currentBet.voteCount + 1;
        projects[hash].prjWeiRaised = currentBet.prjWeiRaised + msg.value;
        emit NewBet(msg.sender, msg.value, _prjName);
        //Check for new winner
        if  (currentBet.voteCount + 1 > projects[keccak256(bytes(currentWinner))].voteCount)
            currentWinner = _prjName;
        //Check vote end    
        if  (now >= voteFinishDate)
            currentStage = StageName.voteFinished;
            emit VoteFinished(msg.sender, uint64(now));
        
    }
// Solidity 0.5.17
// Mint weebTEND with TEND
function mint(uint256 amount) public {
        require(amount <= TEND.balanceOf(msg.sender), ">TEND.balanceOf");
        uint256 totalStakedTendiesBefore = getTotalStakedTendies();
        
        // Stake tendies
        TEND.safeTransferFrom(msg.sender, address(this), amount);
    
        uint256 totalStakedTendiesAfter = getTotalStakedTendies();
        
        if (totalSupply() == 0) {
            return super._mint(msg.sender, amount.mul(INITIAL_SUPPLY_MULTIPLIER));
        }

        uint256 mintAmount = (totalStakedTendiesAfter.sub(totalStakedTendiesBefore))
            .mul(totalSupply())
            .div(totalStakedTendiesBefore);
        
        emit Mint(msg.sender, mintAmount, block.timestamp);
        return super._mint(msg.sender, mintAmount);
    }
// Solidity 0.5.17
// Burn weebTEND to get collected TEND
function burn(uint256 amount) public nonReentrant {
        require(amount <= balanceOf(msg.sender), ">weebTEND.balanceOf");
        
        // Burn weebTEND
        uint256 proRataTend = getTotalStakedTendies().mul(amount).div(totalSupply());
        super._burn(msg.sender, amount);
        emit Burn(msg.sender, amount, block.timestamp);

        // Calculate burn fee and transfer underlying TEND
        uint256 _fee = proRataTend.mul(_burnFeeRate).div(_burnFeeBase);
        TEND.safeTransfer(msg.sender, proRataTend.sub(_fee));
        feesCollected += _fee;
    }
// Solidity 0.6.12
// Utility function to verify geth style signatures
function verifySig(
		address _signer,
		bytes32 _theHash,
		uint8 _v,
		bytes32 _r,
		bytes32 _s
	) private pure returns (bool) {
		bytes32 messageDigest =
			keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _theHash));
		return _signer == ecrecover(messageDigest, _v, _r, _s);
	}