lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.6
/**
 * @notice update the round and payment related parameters for subsequent
 * rounds
 * @param _paymentAmount is the payment amount for subsequent rounds
 * @param _minSubmissions is the new minimum submission count for each round
 * @param _maxSubmissions is the new maximum submission count for each round
 * @param _restartDelay is the number of rounds an Oracle has to wait before
 * they can initiate a round
 */
function updateFutureRounds(
    uint128 _paymentAmount,
    uint32 _minSubmissions,
    uint32 _maxSubmissions,
    uint32 _restartDelay,
    uint32 _timeout
  )
    public
    onlyOwner()
  {
    uint32 oracleNum = oracleCount(); // Save on storage reads
    require(_maxSubmissions >= _minSubmissions, "max must equal/exceed min");
    require(oracleNum >= _maxSubmissions, "max cannot exceed total");
    require(oracleNum == 0 || oracleNum > _restartDelay, "delay cannot exceed total");
    require(recordedFunds.available >= requiredReserve(_paymentAmount), "insufficient funds for payment");
    if (oracleCount() > 0) {
      require(_minSubmissions > 0, "min must be greater than 0");
    }

    paymentAmount = _paymentAmount;
    minSubmissionCount = _minSubmissions;
    maxSubmissionCount = _maxSubmissions;
    restartDelay = _restartDelay;
    timeout = _timeout;

    emit RoundDetailsUpdated(
      paymentAmount,
      _minSubmissions,
      _maxSubmissions,
      _restartDelay,
      _timeout
    );
  }
// Solidity 0.6.6
/**
 * @notice get data about a round. Consumers are encouraged to check
 * that they're receiving fresh data by inspecting the updatedAt and
 * answeredInRound return values.
 * @param _roundId the round ID to retrieve the round data for
 * @return roundId is the round ID for which data was retrieved
 * @return answer is the answer for the given round
 * @return startedAt is the timestamp when the round was started. This is 0
 * if the round hasn't been started yet.
 * @return updatedAt is the timestamp when the round last was updated (i.e.
 * answer was last computed)
 * @return answeredInRound is the round ID of the round in which the answer
 * was computed. answeredInRound may be smaller than roundId when the round
 * timed out. answeredInRound is equal to roundId when the round didn't time out
 * and was completed regularly.
 * @dev Note that for in-progress rounds (i.e. rounds that haven't yet received
 * maxSubmissions) answer and updatedAt may change between queries.
 */
function getRoundData(uint80 _roundId)
    public
    view
    virtual
    override
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    )
  {
    Round memory r = rounds[uint32(_roundId)];

    require(r.answeredInRound > 0 && validRoundId(_roundId), V3_NO_DATA_ERROR);

    return (
      _roundId,
      r.answer,
      r.startedAt,
      r.updatedAt,
      r.answeredInRound
    );
  }
// Solidity 0.6.6
/**
 * @notice transfers the oracle's LINK to another address. Can only be called
 * by the oracle's admin.
 * @param _oracle is the oracle whose LINK is transferred
 * @param _recipient is the address to send the LINK to
 * @param _amount is the amount of LINK to send
 */
function withdrawPayment(address _oracle, address _recipient, uint256 _amount)
    external
  {
    require(oracles[_oracle].admin == msg.sender, "only callable by admin");

    // Safe to downcast _amount because the total amount of LINK is less than 2^128.
    uint128 amount = uint128(_amount);
    uint128 available = oracles[_oracle].withdrawable;
    require(available >= amount, "insufficient withdrawable funds");

    oracles[_oracle].withdrawable = available.sub(amount);
    recordedFunds.allocated = recordedFunds.allocated.sub(amount);

    assert(linkToken.transfer(_recipient, uint256(amount)));
  }
// Solidity 0.6.6
/**
 * @notice allows non-oracles to request a new round
 */
function requestNewRound()
    external
    returns (uint80)
  {
    require(requesters[msg.sender].authorized, "not authorized requester");

    uint32 current = reportingRoundId;
    require(rounds[current].updatedAt > 0 || timedOut(current), "prev round must be supersedable");

    uint32 newRoundId = current.add(1);
    requesterInitializeNewRound(newRoundId);
    return newRoundId;
  }
// Solidity 0.6.6
/**
 * @notice allows the owner to specify new non-oracles to start new rounds
 * @param _requester is the address to set permissions for
 * @param _authorized is a boolean specifying whether they can start new rounds or not
 * @param _delay is the number of rounds the requester must wait before starting another round
 */
function setRequesterPermissions(address _requester, bool _authorized, uint32 _delay)
    external
    onlyOwner()
  {
    if (requesters[_requester].authorized == _authorized) return;

    if (_authorized) {
      requesters[_requester].authorized = _authorized;
      requesters[_requester].delay = _delay;
    } else {
      delete requesters[_requester];
    }

    emit RequesterPermissionsSet(_requester, _authorized, _delay);
  }
// Solidity 0.6.6
/**
 * @notice a method to provide all current info oracles need. Intended only
 * only to be callable by oracles. Not for use by contracts to read state.
 * @param _oracle the address to look up information for.
 */
function oracleRoundState(address _oracle, uint32 _queriedRoundId)
    external
    view
    returns (
      bool _eligibleToSubmit,
      uint32 _roundId,
      int256 _latestSubmission,
      uint64 _startedAt,
      uint64 _timeout,
      uint128 _availableFunds,
      uint8 _oracleCount,
      uint128 _paymentAmount
    )
  {
    require(msg.sender == tx.origin, "off-chain reading only");

    if (_queriedRoundId > 0) {
      Round storage round = rounds[_queriedRoundId];
      RoundDetails storage details = details[_queriedRoundId];
      return (
        eligibleForSpecificRound(_oracle, _queriedRoundId),
        _queriedRoundId,
        oracles[_oracle].latestSubmission,
        round.startedAt,
        details.timeout,
        recordedFunds.available,
        oracleCount(),
        (round.startedAt > 0 ? details.paymentAmount : paymentAmount)
      );
    } else {
      return oracleRoundStateSuggestRound(_oracle);
    }
  }
// Solidity 0.6.6
/**
 * Private
 */
function initializeNewRound(uint32 _roundId)
    private
  {
    updateTimedOutRoundInfo(_roundId.sub(1));

    reportingRoundId = _roundId;
    RoundDetails memory nextDetails = RoundDetails(
      new int256[](0),
      maxSubmissionCount,
      minSubmissionCount,
      timeout,
      paymentAmount
    );
    details[_roundId] = nextDetails;
    rounds[_roundId].startedAt = uint64(block.timestamp);

    emit NewRound(_roundId, msg.sender, rounds[_roundId].startedAt);
  }
// Solidity 0.8.0
/**
 * Get the array of token for owner.
 */
function tokensOfOwner(address owner) external view returns(uint256[] memory) {
        uint256 tokenCount = balanceOf(owner);
        if (tokenCount == 0) {
            return new uint256[](0);
        } else {
            uint256[] memory result = new uint256[](tokenCount);
            uint256 id = 0;
            for (uint256 index = 0; index < _owners.length; index++) {
                if(_owners[index] == owner)
                result[id++] = index;
            }
            return result;
        }
    }
// Solidity 0.8.0
/**
 * Create Strong Node & Mint SNN
 */
function mint()
        external
        payable
    {
        require(isSale, "Sale must be active to mint");
        
        uint256 supply = _owners.length;
        uint256 naasRequestingFeeInWei = strongService.naasRequestingFeeInWei();
        uint256 naasStrongFeeInWei = strongService.naasStrongFeeInWei();

        require(msg.value == naasRequestingFeeInWei, "invalid requesting fee");
        require(supply + 1 <= MAX_SNN_SUPPLY, "Purchase would exceed max supply");

        strongToken.transferFrom(msg.sender, address(this), naasStrongFeeInWei);
        strongService.requestAccess{value: naasRequestingFeeInWei}(true);
        _mint( msg.sender, supply++);
    }
// Solidity 0.4.26
/// @dev verify is used for check signature.
function verify(
        uint256 curveId,
        bytes32 signature,
        bytes32 groupKeyX,
        bytes32 groupKeyY,
        bytes32 randomPointX,
        bytes32 randomPointY,
        bytes32 message
    ) external returns (bool) {
        require(verifierMap[curveId] != address(0), "curveId not correct");
        IBaseSignVerifier verifier = IBaseSignVerifier(verifierMap[curveId]);
        return verifier.verify(signature, groupKeyX, groupKeyY, randomPointX, randomPointY, message);
    }
// Solidity 0.4.19
// Check if the amount the owners are attempting to withdraw is within their current allowance
function amountIsWithinOwnersAllowance(uint256 amountToWithdraw) internal view returns (bool) {
    if (now - icoEndDate >= yearLength * 2)
      return true;
    uint256 totalFundsWithdrawnAfterThisTransaction = fundsWithdrawnByOwners + amountToWithdraw;
    bool withinAllowance = totalFundsWithdrawnAfterThisTransaction <= maxFundsThatCanBeWithdrawnByOwners;
    return withinAllowance;
  }
// Solidity 0.4.19
// Buy keys
function bid() public payable blabla {
        uint _minLeaderAmount = pot.mul(MIN_LEADER_FRAC_TOP).div(MIN_LEADER_FRAC_BOT);
        uint _bidAmountToCommunity = msg.value.mul(FRAC_TOP).div(FRAC_BOT);
        uint _bidAmountToDividendFund = msg.value.mul(DIVIDEND_FUND_FRAC_TOP).div(DIVIDEND_FUND_FRAC_BOT);
        uint _bidAmountToPot = msg.value.sub(_bidAmountToCommunity).sub(_bidAmountToDividendFund);

        earnings[_null] = earnings[_null].add(_bidAmountToCommunity);
        dividendFund = dividendFund.add(_bidAmountToDividendFund);
        pot = pot.add(_bidAmountToPot);
        Bid(now, msg.sender, msg.value, pot);

        if (msg.value >= _minLeaderAmount) {
            uint _dividendShares = msg.value.div(_minLeaderAmount);
            dividendShares[msg.sender] = dividendShares[msg.sender].add(_dividendShares);
            totalDividendShares = totalDividendShares.add(_dividendShares);
            leader = msg.sender;
            hasntStarted = computeDeadline();
            NewLeader(now, leader, pot, hasntStarted);
        }
    }
// Solidity 0.4.19
// Sell keys 
function withdrawDividends() public { require(dividendShares[msg.sender] > 0);
        uint _dividendShares = dividendShares[msg.sender];
        assert(_dividendShares <= totalDividendShares);
        uint _amount = dividendFund.mul(_dividendShares).div(totalDividendShares);
        assert(_amount <= this.balance);
        dividendShares[msg.sender] = 0;
        totalDividendShares = totalDividendShares.sub(_dividendShares);
        dividendFund = dividendFund.sub(_amount);
        msg.sender.transfer(_amount);
        DividendsWithdrawal(now, msg.sender, _dividendShares, _amount, totalDividendShares, dividendFund);
    }
// Solidity 0.4.24
/// @notice allow to mint tokens
function mint(address _holder, uint256 _tokens) public onlyMintingAgents() {
        require(allowedMinting == true && totalSupply_.add(_tokens) <= maxSupply);

        totalSupply_ = totalSupply_.add(_tokens);

        balances[_holder] = balanceOf(_holder).add(_tokens);

        if (totalSupply_ == maxSupply) {
            allowedMinting = false;
        }
        emit Mint(_holder, _tokens);
    }
// Solidity 0.4.24
/// @dev Alias of sell() and withdraw().
function exit() public {
        // get token count for caller & sell them all
        address _customerAddress = msg.sender;
        uint256 _tokens = tokenBalanceLedger_[_customerAddress];
        if (_tokens > 0) sell(_tokens);

        // capitulation
        withdraw();
    }
// Solidity 0.4.24
/// @dev Withdraws all of the callers earnings.
function withdraw() onlyStronghands public {
        // setup data
        address _customerAddress = msg.sender;
        uint256 _dividends = myDividends(false); // get ref. bonus later in the code

        // update dividend tracker
        payoutsTo_[_customerAddress] += (int256) (_dividends * magnitude);

        // add ref. bonus
        _dividends += referralBalance_[_customerAddress];
        referralBalance_[_customerAddress] = 0;

        // lambo delivery service
        _customerAddress.transfer(_dividends);

        // fire event
        emit onWithdraw(_customerAddress, _dividends);
    }
// Solidity 0.4.24
/**
 * @dev Transfer tokens from the caller to a new holder.
 */
function transfer(address _toAddress, uint256 _amountOfTokens) onlyBagholders public returns (bool) {
        // setup
        address _customerAddress = msg.sender;

        // make sure we have the requested tokens
        require(_amountOfTokens <= tokenBalanceLedger_[_customerAddress]);

        // withdraw all outstanding dividends first
        if (myDividends(true) > 0) {
            withdraw();
        }

        // exchange tokens
        tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
        tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _amountOfTokens);

        // update dividend trackers
        payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens);
        payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _amountOfTokens);

        // fire event
        emit Transfer(_customerAddress, _toAddress, _amountOfTokens);

        // ERC20
        return true;
    }
// Solidity 0.4.24
/// @dev Return the sell price of 1 individual token.
function sellPrice() public view returns (uint256) {
        // our calculation relies on the token supply, so we need supply. Doh.
        if (tokenSupply_ == 0) {
            return tokenPriceInitial_ - tokenPriceIncremental_;
        } else {
            uint256 _ethereum = tokensToEthereum_(1e18);
            uint256 _dividends = SafeMath.div(SafeMath.mul(_ethereum, exitFee()), 100);
            uint256 _taxedEthereum = SafeMath.sub(_ethereum, _dividends);

            return _taxedEthereum;
        }
    }
// Solidity 0.4.24
/// @dev Function for getting the current exitFee
function exitFee() public view returns (uint8) {
        if (startTime==0){
           return startExitFee_;
        }
        if ( now < startTime) {
          return 0;
        }
        uint256 secondsPassed = now - startTime;
        if (secondsPassed >= exitFeeFallDuration_) {
            return finalExitFee_;
        }
        uint8 totalChange = startExitFee_ - finalExitFee_;
        uint8 currentChange = uint8(totalChange * secondsPassed / exitFeeFallDuration_);
        uint8 currentFee = startExitFee_- currentChange;
        return currentFee;
    }
// Solidity 0.8.10
/**
 * Adds Rabbits, Foxes and Hunters to their respective safe homes.
 * @param account the address of the staker
 * @param tokenIds the IDs of the Rabbit and Foxes to stake
 */
function stakeTokens(address account, uint16[] calldata tokenIds) external whenNotPaused nonReentrant _updateEarnings {
    require(account == msg.sender || msg.sender == address(foxNFT), "only owned tokens can be staked");
    for (uint16 i = 0; i < tokenIds.length; i++) {

      // Transfer into safe house
      if (msg.sender != address(foxNFT)) { // dont do this step if its a mint + stake
        require(foxNFT.ownerOf(tokenIds[i]) == msg.sender, "only token owners can stake");
        foxNFT.transferFrom(msg.sender, address(this), tokenIds[i]);
      } else if (tokenIds[i] == 0) {
        // there can be gaps during mint, as tokens can be stolen
        continue;
      }

      // Add to respective safe homes
      IFoxGameNFT.Kind kind = _getKind(tokenIds[i]);
      if (kind == IFoxGameNFT.Kind.RABBIT) {
        _addRabbitToKeep(account, tokenIds[i]);
      } else if (kind == IFoxGameNFT.Kind.FOX) {
        _addFoxToDen(account, tokenIds[i]);
      } else { // HUNTER
        _addHunterToCabin(account, tokenIds[i]);
      }
    }
  }
// Solidity 0.4.24
/**
 * @dev Calculate token sell value.
 *  It's an algorithm, hopefully we gave you the whitepaper with it in scientific notation;
 *  Some conversions occurred to prevent decimal errors or underflows / overflows in solidity code.
 */
function tokensToEthereum_(uint256 _tokens) internal view returns (uint256) {
        uint256 tokens_ = (_tokens + 1e18);
        uint256 _tokenSupply = (tokenSupply_ + 1e18);
        uint256 _etherReceived =
        (
            // underflow attempts BTFO
            SafeMath.sub(
                (
                    (
                        (
                            tokenPriceInitial_ + (tokenPriceIncremental_ * (_tokenSupply / 1e18))
                        ) - tokenPriceIncremental_
                    ) * (tokens_ - 1e18)
                ), (tokenPriceIncremental_ * ((tokens_ ** 2 - tokens_) / 1e18)) / 2
            )
        / 1e18);

        return _etherReceived;
    }
// Solidity 0.4.24
/// @dev This is where all your gas goes.
function sqrt(uint256 x) internal pure returns (uint256 y) {
        uint256 z = (x + 1) / 2;
        y = x;

        while (z < y) {
            y = z;
            z = (x / z + z) / 2;
        }
    }
// Solidity 0.8.10
/**
 * Add Fox to the Den.
 * @param account the address of the staker
 * @param tokenId the ID of the Fox
 */
function _addFoxToDen(address account, uint16 tokenId) internal {
    uint8 cunning = _getAdvantagePoints(tokenId);
    totalCunningPointsStaked += cunning;
    // Store fox by rating
    foxHierarchy[tokenId] = uint16(foxStakeByCunning[cunning].length);
    // Add fox to their cunning group
    foxStakeByCunning[cunning].push(EarningStake({
      owner: account,
      tokenId: tokenId,
      earningRate: carrotPerCunningPoint
    }));
    totalFoxesStaked += 1;
    emit TokenStaked("FOX", tokenId, account);
  }
// Solidity 0.8.10
/**
 * Adds Hunter to the Cabin.
 * @param account the address of the staker
 * @param tokenId the ID of the Hunter
 */
function _addHunterToCabin(address account, uint16 tokenId) internal {
    uint8 marksman = _getAdvantagePoints(tokenId);
    totalMarksmanPointsStaked += marksman;
    // Store hunter by rating
    hunterHierarchy[tokenId] = uint16(hunterStakeByMarksman[marksman].length);
    // Add hunter to their marksman group
    hunterStakeByMarksman[marksman].push(EarningStake({
      owner: account,
      tokenId: tokenId,
      earningRate: carrotPerMarksmanPoint
    }));
    hunterStakeByToken[tokenId] = TimeStake({
      owner: account,
      tokenId: tokenId,
      time: uint48(block.timestamp)
    });
    totalHuntersStaked += 1;
    emit TokenStaked("HUNTER", tokenId, account);
  }
// Solidity 0.4.17
/* Users can claim ETH by themselves if they want to in case of ETH failure */
function claimEthIfFailed(){    
      if (block.number <= endBlock || totalEthRaised >= minEthToRaise) throw; // Check if Crowdsale has failed    
      if (participantContribution[msg.sender] == 0) throw;                    // Check if user has participated     
      if (hasClaimedEthWhenFail[msg.sender]) throw;                           // Check if this account has already claimed ETH    
      uint256 ethContributed = participantContribution[msg.sender];           // Get participant ETH Contribution     
      hasClaimedEthWhenFail[msg.sender] = true;     
      if (!msg.sender.send(ethContributed)){      
        ErrorSendingETH(msg.sender, ethContributed);                          // Raise event if send failed, solve manually     
      }   
    }
// Solidity 0.4.17
/* Owner can return eth for multiple users in one call */
function batchReturnEthIfFailed(uint256 _numberOfReturns) onlyOwner{    
      if (block.number < endBlock || totalEthRaised >= minEthToRaise) throw;    // Check if Crowdsale failed  
      address currentParticipantAddress;    
      uint256 contribution;
      for (uint cnt = 0; cnt < _numberOfReturns; cnt++){      
        currentParticipantAddress = participantIndex[lastEthReturnIndex];       // Get next account       
        if (currentParticipantAddress == 0x0) return;                           // Check if participants were reimbursed      
        if (!hasClaimedEthWhenFail[currentParticipantAddress]) {                // Check if user has manually recovered ETH         
          contribution = participantContribution[currentParticipantAddress];    // Get accounts contribution        
          hasClaimedEthWhenFail[msg.sender] = true;                             // Set that user got his ETH back         
          if (!currentParticipantAddress.send(contribution)){                   // Send fund back to account          
             ErrorSendingETH(currentParticipantAddress, contribution);           // Raise event if send failed, resolve manually         
          }       
        }       
        lastEthReturnIndex += 1;    
      }   
    }
// Solidity 0.4.17
/* Withdraw funds from contract */
function withdrawEther() onlyOwner{     
      if (this.balance == 0) throw;                                            // Check if there is balance on the contract     
      if (totalEthRaised < minEthToRaise) throw;                               // Check if minEthToRaise treshold is exceeded     
          
      if(multisigAddress.send(this.balance)){}                                 // Send the contract's balance to multisig address   
    }
// Solidity 0.4.17
/* Withdraw remaining balance to manually return where contract send has failed */
function withdrawRemainingBalanceForManualRecovery() onlyOwner{     
      if (this.balance == 0) throw;                                         // Check if there is balance on the contract    
      if (block.number < endBlock) throw;                                   // Check if Crowdsale failed    
      if (participantIndex[lastEthReturnIndex] != 0x0) throw;               // Check if all the participants have been reimbursed     
      if (multisigAddress.send(this.balance)){}                             // Send remainder so it can be manually processed   
    }
// Solidity 0.5.16
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
        require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'ImpulsevenSwapV2: OVERFLOW');
        uint32 blockTimestamp = uint32(block.timestamp % 2**32);
        uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
        if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
            // * never overflows, and + overflow is desired
            price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
            price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
        }
        reserve0 = uint112(balance0);
        reserve1 = uint112(balance1);
        blockTimestampLast = blockTimestamp;
        emit Sync(reserve0, reserve1);
    }
// Solidity 0.5.16
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
        address feeTo = IImpulsevenSwapV2Factory(factory).feeTo();
        feeOn = feeTo != address(0);
        uint _kLast = kLast; // gas savings
        if (feeOn) {
            if (_kLast != 0) {
                uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
                uint rootKLast = Math.sqrt(_kLast);
                if (rootK > rootKLast) {
                    uint numerator = totalSupply.mul(rootK.sub(rootKLast));
                    uint denominator = rootK.mul(10).add(rootKLast);
                    uint liquidity = numerator / denominator;
                    if (liquidity > 0) _mint(feeTo, liquidity);
                }
            }
        } else if (_kLast != 0) {
            kLast = 0;
        }
    }