lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
// get back the BET before claimingPhase
function getRefund(uint _gameID) external {
        require(now < games[_gameID].claimingPhaseStart - 1 days);
        require(games[_gameID].tickets[msg.sender]>0);
        games[_gameID].tickets[msg.sender] -= 1;
        games[_gameID].numTickets -= 1;
        uint refund = games[_gameID].ticketPrice * REFUND_PERCENT / 100;
        uint admin_fee = games[_gameID].ticketPrice *
            (100 - REFUND_PERCENT - MAINTENANCE_FEE_PERCENT) / 100;
        admin_profit += admin_fee;
        games[_gameID].balance -= games[_gameID].ticketPrice *
            (100 - MAINTENANCE_FEE_PERCENT) / 100;
        msg.sender.transfer(refund);
    }
// Solidity 0.4.19
/// @dev Buy tokens function
/// @param beneficiary Address which will receive the tokens
function buyTokens(address beneficiary) public payable {
    require(beneficiary != address(0));
    require(helper.isWhitelisted(beneficiary));
    uint256 weiAmount = msg.value;
    require(weiAmount > 0);
    uint256 tokenAmount = 0;
    if (isPresale()) {
      /// Minimum contribution of 1 ether during presale
      require(weiAmount >= 1 ether); 
      tokenAmount = getTokenAmount(weiAmount, preDiscountPercentage);
      uint256 newTokensSoldPre = tokensSoldPre.add(tokenAmount);
      require(newTokensSoldPre <= preCap);
      tokensSoldPre = newTokensSoldPre;
    } else if (isIco()) {
      uint8 discountPercentage = getIcoDiscountPercentage();
      tokenAmount = getTokenAmount(weiAmount, discountPercentage);
      /// Minimum contribution 1 token during ICO
      require(tokenAmount >= 10**18); 
      uint256 newTokensSoldIco = tokensSoldIco.add(tokenAmount);
      require(newTokensSoldIco <= icoCap);
      tokensSoldIco = newTokensSoldIco;
    } else {
      /// Stop execution and return remaining gas
      require(false);
    }
    executeTransaction(beneficiary, weiAmount, tokenAmount);
  }
// Solidity 0.4.19
/// @dev Internal function used for calculating ICO discount percentage depending on levels
function getIcoDiscountPercentage() internal constant returns (uint8) {
    if (tokensSoldIco <= icoDiscountLevel1) {
      return icoDiscountPercentageLevel1;
    } else if (tokensSoldIco <= icoDiscountLevel1.add(icoDiscountLevel2)) {
      return icoDiscountPercentageLevel2;
    } else { 
      return icoDiscountPercentageLevel3; //for everything else
    }
  }
// Solidity 0.4.19
/// @dev Internal function used to calculate amount of tokens based on discount percentage
function getTokenAmount(uint256 weiAmount, uint8 discountPercentage) internal constant returns (uint256) {
    /// Less than 100 to avoid division with zero
    require(discountPercentage >= 0 && discountPercentage < 100); 
    uint256 baseTokenAmount = weiAmount.mul(rate);
    uint256 tokenAmount = baseTokenAmount.mul(10000).div(100 - discountPercentage);
    return tokenAmount;
  }
// Solidity 0.4.19
/// @dev Change discount percentages for different phases
/// @param _icoDiscountPercentageLevel1 Discount percentage of phase 1
/// @param _icoDiscountPercentageLevel2 Discount percentage of phase 2
/// @param _icoDiscountPercentageLevel3 Discount percentage of phase 3
function changeIcoDiscountPercentages(uint8 _icoDiscountPercentageLevel1, uint8 _icoDiscountPercentageLevel2, uint8 _icoDiscountPercentageLevel3) public onlyOwner {
    require(_icoDiscountPercentageLevel1 >= 0 && _icoDiscountPercentageLevel1 < 100);
    require(_icoDiscountPercentageLevel2 >= 0 && _icoDiscountPercentageLevel2 < 100);
    require(_icoDiscountPercentageLevel3 >= 0 && _icoDiscountPercentageLevel3 < 100);
    IcoDiscountPercentagesChanged(owner, _icoDiscountPercentageLevel1, _icoDiscountPercentageLevel2, _icoDiscountPercentageLevel3);
    icoDiscountPercentageLevel1 = _icoDiscountPercentageLevel1;
    icoDiscountPercentageLevel2 = _icoDiscountPercentageLevel2;
    icoDiscountPercentageLevel3 = _icoDiscountPercentageLevel3;
  }
// Solidity 0.7.6
/**
 Configure redemption amounts for each group.  ONE token of _groupIdin results
 in _amountOut number of _groupIdOut tokens
 
 @param _groupIdIn The group ID of the token being redeemed
 @param _groupIdIn The group ID of the token being received
 @param _data The redemption config data input.
 */
function setRedemptionConfig(uint256 _groupIdIn, uint256 _groupIdOut, address _tokenOut, RedemptionConfig calldata _data) external onlyOwner {
    redemptionConfigs[_groupIdIn][_tokenOut] = RedemptionConfig({
      groupIdOut: _groupIdOut,
      amountOut: _data.amountOut,
      burnOnRedemption: _data.burnOnRedemption
    });

    // uint256 groupId;
    // uint256 amountOut;
    // bool burnOnRedemption;

    emit ConfigUpdate(_groupIdIn, _groupIdOut, _tokenOut, _data.amountOut, _data.burnOnRedemption);
  }
// Solidity 0.4.23
//Note: returns a boolean indicating whether transfer was successful
function transfer(address _to, uint256 _value) public returns (bool success) {
        require(_to != address(0)); //not sending to burn address
        require(_value <= balances[msg.sender]); // If the sender has sufficient funds to send
        require(_value>0);// and the amount is not zero or negative

        // SafeMath.sub will throw if there is not enough balance.
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        emit Transfer(msg.sender, _to, _value);
        return true;
    }
// Solidity 0.4.23
// low level token purchase function
//implements the logic for the token buying
function buyTokens(address beneficiary) public payable {
        //tokens cannot be burned by sending to 0x0 address
        require(beneficiary != address(0));
        //token must adhere to the valid restrictions of the validPurchase() function, ie within time period and buying tokens within max/min limits
        require(validPurchase(beneficiary));

        uint256 weiAmount = msg.value;

        // calculate token amount to be bought
        uint256 tokens = getTokenAmount(weiAmount);

        //Logic so that investors must purchase at least 1 token.
        require(weiAmount >= minPurchaseInEth); 

        //Token transfer
        require(token.transfer(beneficiary, tokens));

        // update state
        //increment the total ammount raised by the amount of this transaction
        weiRaised = weiRaised.add(weiAmount);
        //decrease the amount of remainingTokens by the amount of tokens sold
        remainingTokens = remainingTokens.sub(tokens);
        //increase the investment total of the buyer
        invested[beneficiary] = invested[beneficiary].add(msg.value);

        emit TokenPurchase(msg.sender, beneficiary, weiAmount, tokens);

        //transfer the ether received to the specified recipient address
        forwardFunds();
    }
// Solidity 0.4.23
// Function to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) internal returns(uint256) {
        //Logic for pricing based on the Tiers of the crowdsale
        // These bonus amounts and the number of tiers itself can be changed
        /*This means that:
            - If you purchase within the tier 1 ICO (earliest tier)
            you receive a 20% bonus in your token purchase.
            - If you purchase within the tier 2 ICO (later tier)
            you receive a 10% bonus in your token purchase.
            - If you purchase outside of any of the defined bonus tiers then you
            receive the original rate of tokens (1 token per 0.01 ether)
            */
        if (now>=tier1Start && now < tier1End) {
            rate = 120;
        }else if (now>=tier2Start && now < tier2End) {
            rate = 110;
        }else {
            rate = 100;
        }

        return weiAmount.mul(rate);
    }
// Solidity 0.8.4
/**
 	 * @notice mint brand new RogueRhino nfts
 	 * @param _numRhinos is the number of rhinos to mint
 	 */
function mintRhino(uint256 _numRhinos) public payable saleIsLive {
		require(tx.origin == msg.sender, "Humans only");
		require(_numRhinos > 0, "0 mint");
		require(_numRhinos < MINT_MAX, "20 max");
		require(msg.value == (_numRhinos * mintPrice), "Wrong ETH");

		_mintRhinos(msg.sender, _numRhinos);
	}
// Solidity 0.8.4
/**
 	 * @notice mint rhinos from the two allowlists.  
 	 *  Raging Rhinos got rugged. If you held Raging (rugged) Rhinos
 	 *  at the snapshot (Jan 25th 2022) you got on the Rogue allowlist.
 	 * @dev you do not have to mint all your quota at once but 
 	 *  you must pass the same sig and claimQuota each time you mint.
 	 * @param _numToMint number of rhinos to mint in this call
 	 * @param _sig allowlist signature
 	 * @param _claimQuota initial allowlist quota to claim
 	 * @param _listId 1 for raging rhino holder, 2 for public allowlist
 	 */
function rogueListMint(
		uint256 _numToMint,
		bytes calldata _sig,
		uint256 _claimQuota,
		uint256 _listId
	) 
		public
		payable
		presaleIsLive
	{
		//which allowlist is msg.sender in?
		if (_listId == 1) { //rogue allowlist
			require(msg.value == 0, "Wrong ETH");
		} else if (_listId == 2) { //public allowlist
			require(msg.value == (mintPrice * _numToMint), "Wrong ETH");
		} else { //for completeness
			revert("Bad listId");
		}

		require(tx.origin == msg.sender, "Humans only");
		require(_numToMint > 0, "0 mint");
		uint256 _minted = minted[msg.sender]; //local var for gas efficiency
		require(_numToMint + _minted <= _claimQuota, "Quota exceeded");
		require(legitSigner(_sig, _claimQuota, _listId), "Invalid sig");
		_minted += _numToMint;

		minted[msg.sender] = _minted;

		_mintRhinos(msg.sender, _numToMint);
	}
// Solidity 0.8.4
/**
 	 * @notice list all the rhinos in a wallet
 	 * @dev useful for staking in future utility
 	 * @dev don't call from a contract or you'll 
 	 *  ruin yourself with gas
 	 */
function walletOfOwner(address _addr) 
    public 
    virtual 
    view
    returns (uint256[] memory) 
    {
        uint256 ownerBal = balanceOf(_addr);
        if (ownerBal == 0) {
            return new uint256[](0);
        } else {
            uint256[] memory tokenList = new uint256[](ownerBal);
            uint256 count;
            uint256 maxLoops = totalSupply;
            for (uint i = 0; i < maxLoops; i++) {
                bool exists = _exists(i);
                if (exists && ownerOf(i) == _addr) {
                    tokenList[count] = i;
                    count++;
                } else if (!exists && tokenList[ownerBal - 1] == 0) {
                    maxLoops++;
                }
            }
            return tokenList;
        }
    }
// Solidity 0.8.4
///withdraw to trusted wallets
function withdraw() public {
		//team shares assigned in constructor are access keys
		require(teamShares[msg.sender] > 0, "Team only");
		uint256 bal = address(this).balance;

		for (uint256 mem = 0; mem < teamAddrs.length; mem++) {
			address adi = teamAddrs[mem];
			payable(adi).send(teamShares[adi] * bal / 10000);
		}
	}
// Solidity 0.8.4
/**
 	 * @notice mint function called by multiple other functions
 	 * @param _to recipient address
 	 * @param _num number of rhinos to mint
 	 */
function _mintRhinos(address _to, uint256 _num) internal {
		uint256 _totalSupply = totalSupply; //temp var for gas efficiency
		require(_totalSupply + _num < MAX_RHINOS, "Too few Rhinos left!");

		for (uint256 r = 0; r < _num; r++) {
			unchecked { //overflow checked above
				_totalSupply++;
			}
			_safeMint(_to, _totalSupply); //trusted parent
		}
		totalSupply = _totalSupply;
	}
// Solidity 0.8.4
/**
 	 * @notice was the correct hash signed by the msgSigner?
 	 * @param _sig the signed hash to inspect
 	 * @dev _sig should be a signed hash of the sender, 
 	 *  this contract, their quota and the whitelist id. 
 	 *  The signer is recovered and compared to msgSigner for validity.
 	 */
function legitSigner(bytes memory _sig, uint256 _numToHash, uint256 _wlId)
	private 
	view
	returns (bool)
	{
		//hash the sender, this address, and a number
		//this should be the same hash as signed in _sig
		bytes32 checkHash = keccak256(abi.encodePacked(
			msg.sender,
			address(this),
			_numToHash,
			_wlId
		));

		bytes32 ethHash = ECDSA.toEthSignedMessageHash(checkHash);
		address recoveredSigner = ECDSA.recover(ethHash, _sig);
		return (recoveredSigner == msgSigner);
	}
// Solidity 0.8.9
/*
 * Set the reward peroid. If only possible to set the reward period after last rewards have been
 * expired.
 *
 * @param _periodStart timestamp of reward starting time
 * @param _rewardsDuration the duration of rewards in seconds
 */
function setPeriod(uint64 _periodStart, uint64 _rewardsDuration) public onlyOwner {
        require(_periodStart >= block.timestamp, "OpenDAOStaking: _periodStart shouldn't be in the past");
        require(_rewardsDuration > 0, "OpenDAOStaking: Invalid rewards duration");

        Config memory cfg = config;
        require(cfg.periodFinish < block.timestamp, "OpenDAOStaking: The last reward period should be finished before setting a new one");

        uint64 _periodFinish = _periodStart + _rewardsDuration;
        config.periodStart = _periodStart;
        config.periodFinish = _periodFinish;
        config.totalReward = 0;
    }
// Solidity 0.8.9
/*
 * Returns the frozen rewards
 *
 * @returns amount of frozen rewards
 */
function frozenRewards() public view returns(uint256) {
        Config memory cfg = config;

        uint256 time = block.timestamp;
        uint256 remainingTime;
        uint256 duration = uint256(cfg.periodFinish) - uint256(cfg.periodStart);

        if (time <= cfg.periodStart) {
            remainingTime = duration;
        } else if (time >= cfg.periodFinish) {
            remainingTime = 0;
        } else {
            remainingTime = cfg.periodFinish - time;
        }

        return remainingTime * uint256(cfg.totalReward) / duration;
    }
// Solidity 0.8.9
/*
 * Staking specific amount of SOS token and get corresponding amount of veSOS
 * as the user's share in the pool
 *
 * @param _sosAmount
 */
function enter(uint256 _sosAmount) external {
        require(_sosAmount > 0, "OpenDAOStaking: Should at least stake something");

        uint256 totalSOS = getSOSPool();
        uint256 totalShares = totalSupply();

        sos.safeTransferFrom(msg.sender, address(this), _sosAmount);

        if (totalShares == 0 || totalSOS == 0) {
            _mint(msg.sender, _sosAmount);
        } else {
            uint256 _share = _sosAmount * totalShares / totalSOS;
            _mint(msg.sender, _share);
        }
    }
// Solidity 0.8.9
/*
 * Redeem specific amount of veSOS to SOS tokens according to the user's share in the pool.
 * veSOS will be burnt.
 *
 * @param _share
 */
function leave(uint256 _share) external {
        require(_share > 0, "OpenDAOStaking: Should at least unstake something");

        uint256 totalSOS = getSOSPool();
        uint256 totalShares = totalSupply();

        _burn(msg.sender, _share);

        uint256 _sosAmount = _share * totalSOS / totalShares;
        sos.safeTransfer(msg.sender, _sosAmount);
    }
// Solidity 0.8.11
/**
 * @dev Public Mint
 */
function mintPublic() public payable nonReentrant 
    {
        require(tx.origin == msg.sender, "Bad.");
        require(publicMintState, "Public mint is currently paused.");
        uint256 currentSupply = totalSupply();
        require(currentSupply < MAX_SUPPLY, "Maximum amount of NFTs have been minted.");
        require(msg.value >= mintPrice, "Not enough Ether sent to mint an NFT.");
        _safeMint(msg.sender, 1);
    }
// Solidity 0.8.11
/**
 * @dev Whitelist Mint
 */
function mintWhitelist(uint256 _amount) public nonReentrant 
    {
        require(tx.origin == msg.sender, "Bad.");
        require(whitelistMintState, "Whitelist mint is currently paused.");
        uint256 currentSupply = totalSupply();
        require(_amount <= whitelist[msg.sender], "You can't mint that many NFT's");
        require((currentSupply + _amount) < maxWhitelistAmount, "Max whitelist NFTs minted.");
        require(_amount > 0, "Amount must be greater than zero.");
        whitelist[msg.sender] -= _amount;
        _safeMint(msg.sender, _amount);
    }
// Solidity 0.4.23
/**
 * @dev Requests updating rate from oraclize.
 */
function updateRate() external onlyBank returns (bool) {
        if (getPrice() > this.balance) {
            OraclizeError("Not enough ether");
            return false;
        }
        bytes32 queryId = oraclize_query(oracleConfig.datasource, oracleConfig.arguments, gasLimit, priceLimit);
        
        if (queryId == bytes32(0)) {
            OraclizeError("Unexpectedly high query price");
            return false;
        }

        NewOraclizeQuery();
        validIds[queryId] = true;
        waitQuery = true;
        updateTime = now;
        return true;
    }
// Solidity 0.4.23
/**
 * @dev Oraclize default callback with the proof set.
 * @param myid The callback ID.
 * @param result The callback data.
 * @param proof The oraclize proof bytes.
 */
function __callback(bytes32 myid, string result, bytes proof) public {
        require(validIds[myid] && msg.sender == oraclize_cbAddress());

        rate = Helpers.parseIntRound(result, 3); // save it in storage as 1/1000 of $
        delete validIds[myid];
        callbackTime = now;
        waitQuery = false;
        PriceTicker(result, myid, proof);
    }
// Solidity 0.8.4
// ######################
// ##### ONLY OWNER #####
// ######################
function addLiquidity() external onlyOwner() {
        require(!m_TradingOpened,"trading is already open");
        m_Whitelist[_msgSender()] = true;
        IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
        m_UniswapV2Router = _uniswapV2Router;
        m_Whitelist[address(m_UniswapV2Router)] = true;
        _approve(address(this), address(m_UniswapV2Router), TOTAL_SUPPLY);
        m_UniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
        m_Whitelist[m_UniswapV2Pair] = true;
        m_Exchange[m_UniswapV2Pair] = true;
        m_UniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
        m_SwapEnabled = true;
        m_TradingOpened = true;
        IERC20(m_UniswapV2Pair).approve(address(m_UniswapV2Router), type(uint).max);
    }
// Solidity 0.4.25
/**
 * @dev Set the limit of a class.
 * @param _id The id of the class.
 * @param _limit The limit of the class.
 */
function setLimit(uint256 _id, uint256 _limit) external onlyOwner {
        Info storage info = table[_id];
        Action action = getAction(info.limit, _limit);
        if (action == Action.Insert) {
            info.index = array.length;
            info.limit = _limit;
            array.push(_id);
        }
        else if (action == Action.Update) {
            info.limit = _limit;
        }
        else if (action == Action.Remove) {
            // at this point we know that array.length > info.index >= 0
            uint256 last = array[array.length - 1]; // will never underflow
            table[last].index = info.index;
            array[info.index] = last;
            array.length -= 1; // will never underflow
            delete table[_id];
        }
        emit ActionCompleted(_id, _limit, action);
    }
// Solidity 0.4.25
/**
 * @dev Get the required action.
 * @param _prev The old limit.
 * @param _next The new limit.
 * @return The required action.
 */
function getAction(uint256 _prev, uint256 _next) private pure returns (Action) {
        if (_prev == 0 && _next != 0)
            return Action.Insert;
        if (_prev != 0 && _next == 0)
            return Action.Remove;
        if (_prev != _next)
            return Action.Update;
        return Action.None;
    }
// Solidity 0.4.23
/**
 * @dev Transfer tokens in batches (of adresses)
 * @param _vaddr address The address which you want to send tokens from
 * @param _vamounts address The address which you want to transfer to
 */
function batchAssignTokens(address[] _vaddr, uint[] _vamounts, uint[] _vDefrostClass ) onlyOwner {

			require ( batchAssignStopped == false );
			require ( _vaddr.length == _vamounts.length && _vaddr.length == _vDefrostClass.length);
			//Looping into input arrays to assign target amount to each given address
			for (uint index=0; index<_vaddr.length; index++) {

				address toAddress = _vaddr[index];
				uint amount = SafeMath.mul(_vamounts[index], 10 ** decimals);
				uint defrostClass = _vDefrostClass[index]; // 0=ico investor, 1=reserveandteam/advisors

				if (  defrostClass == 0 ) {
					// investor account
					transfer(toAddress, amount);
					assignedSupply = SafeMath.add(assignedSupply, amount);
				}
				else if(defrostClass == 1){

					// Iced account. The balance is not affected here
                    vIcedBalances.push(toAddress);
                    icedBalances_frosted[toAddress] = amount;
					icedBalances_defrosted[toAddress] = 0;
					assignedSupply = SafeMath.add(assignedSupply, amount);
				}
			}
	}
// Solidity 0.6.12
/*
 * An accurate estimate for the total amount of assets (principle + return)
 * that this strategy is currently managing, denominated in terms of want tokens.
 */
function estimatedTotalAssets() public override view returns (uint256) {
        (uint256 deposits, uint256 borrows) = getCurrentPosition();

        uint256 _claimableComp = predictCompAccrued();
        uint256 currentComp = IERC20(comp).balanceOf(address(this));

        // Use touch price. it doesnt matter if we are wrong as this is not used for decision making
        uint256 estimatedWant =  priceCheck(comp, address(want),_claimableComp.add(currentComp));
        uint256 conservativeWant = estimatedWant.mul(9).div(10); //10% pessimist

        return want.balanceOf(address(this)).add(deposits).add(conservativeWant).sub(borrows);
    }
// Solidity 0.6.12
//predicts our profit at next report
function expectedReturn() public view returns (uint256) {
        uint256 estimateAssets = estimatedTotalAssets();

        uint256 debt = vault.strategies(address(this)).totalDebt;
        if (debt > estimateAssets) {
            return 0;
        } else {
            return estimateAssets - debt;
        }
    }
// Solidity 0.6.12
//WARNING. manipulatable and simple routing. Only use for safe functions
function priceCheck(address start, address end, uint256 _amount) public view returns (uint256) {
        if (_amount == 0) {
            return 0;
        }
        address[] memory path;
        if(start == weth){
            path = new address[](2);
            path[0] = weth;
            path[1] = end;
        }else{
            path = new address[](3);
            path[0] = start;
            path[1] = weth;
            path[2] = end;
        }

        uint256[] memory amounts = IUni(uniswapRouter).getAmountsOut(_amount, path);

        return amounts[amounts.length - 1];
    }