lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.7
//to see the price of minting
function mintCost() public view returns(uint) {
        if (saleState_ == State.NoSale) {
            return mintCost_;
        }
        else {
            uint incrementPeriods = (block.timestamp - saleLaunchTime) / 300;
            if (mintCost_ <= (incrementPeriods * 0.00017361 ether)) {
                return 0;
            }
            else {
                return mintCost_ - (incrementPeriods * 0.00017361 ether);
            }
        }
    }
// Solidity 0.4.12
/// @dev Accepts ether and creates new edan tokens.
function createTokens() payable external {
      if (isFinalized) throw;
      if (block.number < fundingStartBlock) throw;
      if (block.number > fundingEndBlock) throw;
      if (msg.value == 0) throw;

      uint256 tokens = safeMult(msg.value, ExchangeRate); // check that we're not over totals
      uint256 checkedSupply = safeAdd(totalSupply, tokens);

      // return money if something goes wrong
      if (tokenCreationCap < checkedSupply) throw;  // odd fractions won't be found

      totalSupply = checkedSupply;
      balances[msg.sender] += tokens;  // safeAdd not needed; bad semantics to use here
      Createedan(msg.sender, tokens);  // logs token creation
    }
// Solidity 0.4.12
/// @dev Ends the funding period and sends the ETH home
function finalize() external {
      if (isFinalized) throw;
      if (msg.sender != ethFundDeposit) throw; // locks finalize to the ultimate ETH owner
      if(totalSupply < tokenCreationMin) throw;      // have to sell minimum to move to operational
      if(block.number <= fundingEndBlock && totalSupply != tokenCreationCap) throw;
      // move to operational
      isFinalized = true;
      if(!ethFundDeposit.send(this.balance)) throw;  // send the eth to EDAN 
    }
// Solidity 0.4.12
/// @dev Allows contributors to recover their ether in the case of a failed funding campaign.
function refund() external {
      if(isFinalized) throw;                       // prevents refund if operational
      if (block.number <= fundingEndBlock) throw; // prevents refund until sale period is over
      if(totalSupply >= tokenCreationMin) throw;  // no refunds if we sold enough
      if(msg.sender == edanFundDeposit) throw;    // EDAN  not entitled to a refund
      uint256 edanVal = balances[msg.sender];
      if (edanVal == 0) throw;
      balances[msg.sender] = 0;
      totalSupply = safeSubtract(totalSupply, edanVal); // extra safe
      uint256 ethVal = edanVal / ExchangeRate;     // should be safe; previous throws covers edges
      LogRefund(msg.sender, ethVal);               // log it 
      if (!msg.sender.send(ethVal)) throw;       // if you're using a contract; make sure it works with .send gas limits
    }
// Solidity 0.5.2
// Creates a new token type and assings _initialSupply to minter
function _create(uint256 _initialSupply, address _to, string memory _name) internal returns (uint256 _id) {

        _id = ++nonce;
        balances[_id][_to] = _initialSupply;
        _totalSupplies[_id] = _initialSupply;

        // Transfer event with mint semantic
        emit TransferSingle(msg.sender, address(0x0), _to, _id, _initialSupply);

        emit URI(string(abi.encodePacked(baseTokenURI(),Strings.uint2str(_id))), _id);

        if (bytes(_name).length > 0)
            emit CreationName(_name, _id);

    }
// Solidity 0.8.4
/**
 @notice This function is used to invest in given balancer pool using ETH/ERC20 Tokens
 @param _FromTokenContractAddress The token used for investment (address(0x00) if ether)
 @param _ToBalancerPoolAddress The address of balancer pool
 @param _toTokenContractAddress The token with which we are adding liquidity
 @param _amount The amount of fromToken to invest
 @param _minPoolTokens Minimum quantity of pool tokens to receive. Reverts otherwise
 @param _swapTarget indicates the execution target for swap.
 @param swapData indicates the callData for execution
 @param affiliate Affiliate address
 @return LPTRec quantity of Balancer pool tokens acquired
 */
function ZapIn(
        address _FromTokenContractAddress,
        address _ToBalancerPoolAddress,
        address _toTokenContractAddress,
        uint256 _amount,
        uint256 _minPoolTokens,
        address _swapTarget,
        bytes calldata swapData,
        address affiliate
    ) external payable stopInEmergency returns (uint256 LPTRec) {
        require(
            BalancerFactory.isBPool(_ToBalancerPoolAddress),
            "Invalid Balancer Pool"
        );

        // get incoming tokens
        uint256 toInvest =
            _pullTokens(_FromTokenContractAddress, _amount, affiliate, true);

        LPTRec = _performZapIn(
            _FromTokenContractAddress,
            _ToBalancerPoolAddress,
            toInvest,
            _toTokenContractAddress,
            _swapTarget,
            swapData
        );

        require(LPTRec >= _minPoolTokens, "High Slippage");

        IERC20(_ToBalancerPoolAddress).safeTransfer(msg.sender, LPTRec);

        emit zapIn(msg.sender, _ToBalancerPoolAddress, LPTRec);

        return LPTRec;
    }
// Solidity 0.5.17
// Polka Party Team - always failing *Removed Require* Better solution is needed
// uniswap - Ensure the provided reward amount is not more than the balance in the contract.
// This keeps the reward rate in the right range, preventing overflows due to
// very high values of rewardRate in the earned and rewardsPerToken functions;
// Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
//
// uint balance = rewardsToken.balanceOf(address(this));
// require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high");
function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution setReward(address(0)) {
        if (block.timestamp >= periodFinish) {
             rewardRate = reward.div(rewardsDuration);
        // base instructions 
             lastUpdateTime = block.timestamp;
             periodFinish = block.timestamp.add(rewardsDuration);
        } else {
            uint256 remaining = periodFinish.sub(block.timestamp);
            uint256 leftover = remaining.mul(rewardRate);
             rewardRate = reward.add(leftover).div(rewardsDuration);
        // base instructions 
             lastUpdateTime = block.timestamp;
             periodFinish = block.timestamp.add(rewardsDuration);
        }
        emit RewardAdded(reward);
    }
// Solidity 0.4.19
// Retrieve the encrypted key to decrypt a resource referenced by an accepted proposal.
function getEncryptedResourceDecryptionKey(uint256 proposalId, uint256 resourceId) external view returns (bytes) {
        require(proposalId < proposalCount);
        require(ProposalState.AcceptedByResourceSetCreator == statesByProposalId[proposalId]);
        require(resourceId < resourceCount);

        uint256[] memory validResourceIds = resourceSetsById[proposalsById[proposalId].resourceSetId].uniqueResourceIdsSortedAscending;
        require(0 < validResourceIds.length);

        if (1 == validResourceIds.length) {
            require(resourceId == validResourceIds[0]);

        } else {
            uint256 lowIndex = 0;
            uint256 highIndex = validResourceIds.length.sub(1);
            uint256 middleIndex = lowIndex.add(highIndex).div(2);

            while (resourceId != validResourceIds[middleIndex]) {
                require(lowIndex <= highIndex);

                if (validResourceIds[middleIndex] < resourceId) {
                    lowIndex = middleIndex.add(1);
                } else {
                    highIndex = middleIndex.sub(1);
                }

                middleIndex = lowIndex.add(highIndex).div(2);
            }
        }

        return encryptedDecryptionKeysByProposalIdAndResourceId[proposalId][resourceId];
    }
// Solidity 0.4.19
// This function moves a proposal to a final state of `RejectedByResourceSetCreator' and sends tokens to the
// destinations described by the proposal's transfers.
//
// The caller should encrypt each decryption key corresponding
// to each resource in the proposal's resource set first with the public key of the proposal's creator and then with
// the private key assoicated with the public key referenced in the resource set. The caller should concatenate
// these encrypted values and pass the resulting byte array as 'concatenatedResourceDecryptionKeys'.
// The length of each encrypted decryption key should be provided in the 'concatenatedResourceDecryptionKeyLengths'.
// The index of each value in 'concatenatedResourceDecryptionKeyLengths' must correspond to an index in the resource
// set referenced by the proposal.
function acceptProposal(
        uint256 proposalId,
        bytes concatenatedResourceDecryptionKeys,
        uint256[] concatenatedResourceDecryptionKeyLengths
    ) external
    {
        require(proposalId < proposalCount);
        require(ProposalState.Pending == statesByProposalId[proposalId]);

        Proposal memory proposal = proposalsById[proposalId];
        require(msg.sender == resourceSetsById[proposal.resourceSetId].creator);

        storeEncryptedDecryptionKeys(
            proposalId,
            concatenatedResourceDecryptionKeys,
            concatenatedResourceDecryptionKeyLengths
        );

        transferTokensFromEscrow(proposal.tokenTransferSetId);

        statesByProposalId[proposalId] = ProposalState.AcceptedByResourceSetCreator;
    }
// Solidity 0.8.11
// For marketing etc.
function devMint(uint256 quantity) external onlyOwner {
        require(totalSupply() + quantity <= devMintQty, "too many already minted before dev mint");
        require(quantity % maxBatchSize == 0, "can only mint a multiple of the maxBatchSize");
        uint256 numChunks = quantity / maxBatchSize;
        for (uint256 i = 0; i < numChunks; i++) {
            _safeMint(msg.sender, maxBatchSize);
        }
        tokenDistributor.updateRewardOnMint(msg.sender);
        bulliesBalance[msg.sender] += quantity;
    }
// Solidity 0.8.9
// Internal function transfer can only be called by this contract
//  Emit Transfer Event event 
function _transfer(address _from, address _to, uint256 _value) internal {
        // Ensure sending is to valid address! 0x0 address cane be used to burn() 
        require(_to != address(0));
        balanceOf[_from] = balanceOf[_from] - (_value);
        balanceOf[_to] = balanceOf[_to] + (_value);
        emit Transfer(_from, _to, _value);
    }
// Solidity 0.4.16
/**
 * @dev Calculate amount of vested tokens at a specific time
 * @param tokens uint256 The amount of tokens granted
 * @param time uint64 The time to be checked
 * @param start uint64 The time representing the beginning of the grant
 * @param cliff uint64  The cliff period, the period before nothing can be paid out
 * @param vesting uint64 The vesting period
 * @return An uint256 representing the amount of vested tokens of a specific grant
 *  transferableTokens
 *   |                         _/--------   vestedTokens rect
 *   |                       _/
 *   |                     _/
 *   |                   _/
 *   |                 _/
 *   |                /
 *   |              .|
 *   |            .  |
 *   |          .    |
 *   |        .      |
 *   |      .        |
 *   |    .          |
 *   +===+===========+---------+----------> time
 *      Start       Cliff    Vesting
 */
function calculateVestedTokens(
  uint256 tokens,
  uint256 time,
  uint256 start,
  uint256 cliff,
  uint256 vesting) public constant returns (uint256)
  {
    // Shortcuts for before cliff and after vesting cases.
    if (time < cliff) return 0;
    if (time >= vesting) return tokens;

    // Interpolate all vested tokens.
    // As before cliff the shortcut returns 0, we can use just calculate a value
    // in the vesting rect (as shown in above's figure)

    // vestedTokens = (tokens * (time - start)) / (vesting - start)
    uint256 vestedTokens = SafeMath.div(
    SafeMath.mul(
    tokens,
    SafeMath.sub(time, start)
    ),
    SafeMath.sub(vesting, start)
    );

    return vestedTokens;
  }
// Solidity 0.5.7
// @notice Takes order from 0x and returns bool indicating if it is successful
// @param _addresses [exchange, src, dst]
// @param _data Data to send with call
// @param _value Value to send with call
// @param _amount Amount being sold
function takeOrder(address[3] memory _addresses, bytes memory _data, uint _value, uint _amount) private returns(bool, uint, uint) {
        bool success;

        (success, ) = _addresses[0].call.value(_value)(_data);

        uint tokensLeft = _amount;
        uint tokensReturned = 0;
        if (success){
            // check how many tokens left from _src
            if (_addresses[1] == KYBER_ETH_ADDRESS) {
                tokensLeft = address(this).balance;
            } else {
                tokensLeft = ERC20(_addresses[1]).balanceOf(address(this));
            }

            // check how many tokens are returned
            if (_addresses[2] == KYBER_ETH_ADDRESS) {
                TokenInterface(WETH_ADDRESS).withdraw(TokenInterface(WETH_ADDRESS).balanceOf(address(this)));
                tokensReturned = address(this).balance;
            } else {
                tokensReturned = ERC20(_addresses[2]).balanceOf(address(this));
            }
        }

        return (success, tokensReturned, tokensLeft);
    }
// Solidity 0.5.7
/// @notice Returns the best estimated price from 2 exchanges
/// @param _amount Amount of source tokens you want to exchange
/// @param _srcToken Address of the source token
/// @param _destToken Address of the destination token
/// @return (address, uint) The address of the best exchange and the exchange price
function getBestPrice(uint _amount, address _srcToken, address _destToken, uint _exchangeType) public returns (address, uint) {
        uint expectedRateKyber;
        uint expectedRateUniswap;
        uint expectedRateOasis;


        if (_exchangeType == 1) {
            return (OASIS_WRAPPER, getExpectedRate(OASIS_WRAPPER, _srcToken, _destToken, _amount));
        }

        if (_exchangeType == 2) {
            return (KYBER_WRAPPER, getExpectedRate(KYBER_WRAPPER, _srcToken, _destToken, _amount));
        }

        if (_exchangeType == 3) {
            expectedRateUniswap = getExpectedRate(UNISWAP_WRAPPER, _srcToken, _destToken, _amount);
            expectedRateUniswap = expectedRateUniswap * (10 ** (18 - getDecimals(_destToken)));
            return (UNISWAP_WRAPPER, expectedRateUniswap);
        }

        expectedRateKyber = getExpectedRate(KYBER_WRAPPER, _srcToken, _destToken, _amount);
        expectedRateUniswap = getExpectedRate(UNISWAP_WRAPPER, _srcToken, _destToken, _amount);
        expectedRateUniswap = expectedRateUniswap * (10 ** (18 - getDecimals(_destToken)));
        expectedRateOasis = getExpectedRate(OASIS_WRAPPER, _srcToken, _destToken, _amount);

        if ((expectedRateKyber >= expectedRateUniswap) && (expectedRateKyber >= expectedRateOasis)) {
            return (KYBER_WRAPPER, expectedRateKyber);
        }

        if ((expectedRateOasis >= expectedRateKyber) && (expectedRateOasis >= expectedRateUniswap)) {
            return (OASIS_WRAPPER, expectedRateOasis);
        }

        if ((expectedRateUniswap >= expectedRateKyber) && (expectedRateUniswap >= expectedRateOasis)) {
            return (UNISWAP_WRAPPER, expectedRateUniswap);
        }
    }
// Solidity 0.5.7
/// @notice Takes a feePercentage and sends it to wallet
/// @param _amount Dai amount of the whole trade
/// @return feeAmount Amount in Dai owner earned on the fee
function takeFee(uint _amount, address _token) internal returns (uint feeAmount) {
        uint fee = SERVICE_FEE;

        if (Discount(DISCOUNT_ADDRESS).isCustomFeeSet(msg.sender)) {
            fee = Discount(DISCOUNT_ADDRESS).getCustomServiceFee(msg.sender);
        }

        if (fee == 0) {
            feeAmount = 0;
        } else {
            feeAmount = _amount / SERVICE_FEE;
            if (_token == KYBER_ETH_ADDRESS) {
                WALLET_ID.transfer(feeAmount);
            } else {
                ERC20(_token).transfer(WALLET_ID, feeAmount);
            }
        }
    }
// Solidity 0.4.24
// ------------------------------------------------------------------------
// Function to mint tokens within the cap limit
// @param _to The address that will receive the minted tokens.
// @param _amount The amount of tokens to mint.
// @return A boolean that indicates if the operation was successful.
// ------------------------------------------------------------------------
function mint(address _to, uint256 _amount) hasMintPermission canMint public returns (bool) {
    require(_amount <= batchlimits);
    require(_totalSupply.add(_amount) <= cap);
    _totalSupply = _totalSupply.add(_amount);
    balances[_to] = balances[_to].add(_amount);
    emit Mint(_to, _amount);
    emit Transfer(address(0), _to, _amount);
    return true;
  }
// Solidity 0.8.4
// @dev 1) Ends the previous auction if it hasn't been ended already
//      2) Mints a new Mxtter Token
//      3) Create a new zora auction with the minted token
//      4) Creates a min bid on the auction to kick off the timer
//      5) Updates curent auction ID
function newAuction() external onlyOwner {
        // Will revert if auction was already ended by someone else
        try auctionHouse.endAuction(curAuctionId) {
            emit Log("ended auction", curAuctionId);
        } catch {
            emit Log("auction already ended", curAuctionId);
        }

        uint256 tokenId = mxtterToken.mintToken(
            address(this),
            preGenerativeURI
        );
        uint256 auctionId = auctionHouse.createAuction(
            tokenId,
            address(mxtterToken),
            duration,
            reservePrice,
            payable(0x0000000000000000000000000000000000000000),
            0,
            0x0000000000000000000000000000000000000000
        );
        auctionHouse.createBid{value: reservePrice}(auctionId, reservePrice);
        curAuctionId = auctionId;

        emit NewAuction(tokenId, auctionId, mxtterToken.getTokenHash(tokenId));
    }
// Solidity 0.8.9
/// @inheritdoc	IERC2981Royalties
function royaltyInfo(
		uint256,
		uint256 _value
	)
		external
		view
		override
		returns (address receiver, uint256 royaltyAmount)
	{
		RoyaltyInfo memory royalties = _royalties;
		receiver = royalties.recipient;
		royaltyAmount = (_value * royalties.amount) / 10000;
	}
// Solidity 0.8.4
// claim for hodl
function claimDAO() public {
        require(
            rally.balanceOf(msg.sender) >= rallyBalance || 
            bank.balanceOf(msg.sender) >= bankBalance ||
            fwb.balanceOf(msg.sender) >= fwbBalance ||
            ff.balanceOf(msg.sender) >= ffBalance,
            "low balance"
        );
        require(!daoClaimed[msg.sender], "already claimed");
        require(limit > 0, "out of supply");
        _mintSeed(1, msg.sender);
        limit = limit.sub(1);
        daoClaimed[msg.sender] = true;
    }
// Solidity 0.8.7
// mintPreSale allows for minting by allowed addresses during the pre-sale.
function mintPreSale(
        uint8 quantity,
        bytes32[] calldata merkleProof)
        external
        payable
        nonReentrant
        preSaleActive
        canMintTunes(quantity)
        isCorrectPayment(SALE_PRICE, quantity)
        isValidMerkleProof(merkleProof, preSaleMerkleRoot)
    {
        uint256 numAlreadyMinted = mintCounts[msg.sender];

        require(
            numAlreadyMinted + quantity <= MAX_PER_WALLET_PRESALE,
            "Max tunes to mint in Presale is one"
        );

        require(
            totalSupply() + quantity <= maxPreSaleTunes,
            "Not enough tunes remaining to mint"
        );

        mintCounts[msg.sender] = numAlreadyMinted + quantity;

            _safeMint(msg.sender, quantity);
    }
// Solidity 0.5.12
/**
 * @dev Take orders by their orderID.
 * @param orderIDs Array of order ids to be taken.
 * @param buyers Array of buyers.
 * @param quantity Array of quantity per purchase.
 * @param timeOutBlockNumber Time-out block number.
 */
function takeOrders(
        bytes32[] calldata orderIDs,
        address[] calldata buyers,
        uint256[] calldata quantity,
        uint256 timeOutBlockNumber
    ) external whenNotPaused checkBatchLength(orderIDs.length) checkTimeOut(timeOutBlockNumber) {
        require(
            orderIDs.length == buyers.length && buyers.length == quantity.length,
            "Exchange: orders and buyers not equal"
        );

        for (uint256 i = 0; i < orderIDs.length; i = i + 1) {
            takeOrder(orderIDs[i], buyers[i], quantity[i], timeOutBlockNumber);
        }
    }
// Solidity 0.5.12
/**
 * @dev Let investor make an order, providing the approval is done beforehand.
 * @param isComplete If this order can be filled partially (by default), or can only been taken as a whole.
 * @param sellToken Address of the token to be sold in this order.
 * @param sellAmount Total amount of token that is planned to be sold in this order.
 * @param buyToken Address of the token to be purchased in this order.
 * @param buyAmount Total amount of token planned to be bought by the maker
 * @param timeOutBlockNumber Time-out block number.
 */
function makeOrder(
        bytes32 orderID,
        address specificTaker, // if no one, just pass address(0)
        address seller,
        bool isComplete,
        ISygnumToken sellToken,
        uint256 sellAmount,
        ISygnumToken buyToken,
        uint256 buyAmount,
        uint256 timeOutBlockNumber
    )
        public
        whenNotPaused
        checkTimeOut(timeOutBlockNumber)
        onlyPaired(address(buyToken), address(sellToken))
        whenNotFrozen(address(buyToken), address(sellToken))
    {
        address _seller = isTrader(msg.sender) ? seller : msg.sender;
        _makeOrder(orderID, specificTaker, _seller, isComplete, sellToken, sellAmount, buyToken, buyAmount);
    }
// Solidity 0.5.12
/**
 * @dev Cancel an order by its maker or a trader.
 * @param orderID Order ID.
 */
function cancelOrder(bytes32 orderID) public {
        require(orders.exists(orderID), "Exchange: order ID does not exist");
        Order memory theOrder = order[orderID];
        require(
            isTrader(msg.sender) || (isNotPaused() && theOrder.maker == msg.sender),
            "Exchange: not eligible to cancel this order or the exchange is paused"
        );
        theOrder.sellToken.unblock(theOrder.maker, theOrder.sellAmount);
        orders.remove(orderID);
        delete order[orderID];
        emit CancelledOrder(orderID, msg.sender, theOrder.sellToken, theOrder.buyToken);
    }
// Solidity 0.5.12
/**
 * @dev Internal take order
 * @param orderID Order ID.
 * @param buyer Address of a seller, if applies.
 * @param quantity Amount to purchase.
 */
function _takeOrder(
        bytes32 orderID,
        address buyer,
        uint256 quantity
    ) private {
        require(orders.exists(orderID), "Exchange: order ID does not exist");
        require(buyer != address(0), "Exchange: buyer cannot be set to an empty address");
        require(quantity > 0, "Exchange: quantity cannot be zero");
        Order memory theOrder = order[orderID];
        require(
            theOrder.specificTaker == address(0) || theOrder.specificTaker == buyer,
            "Exchange: not specific taker"
        );
        require(!isFrozen(address(theOrder.buyToken), address(theOrder.sellToken)), "Exchange: tokens are frozen");
        uint256 spend = 0;
        uint256