lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.8.4
/*
 * @dev Burns the nft with the given _tokenId and sets `claimed` true
 */
function claim(uint256 _tokenId) external override nonReentrant {
        require(nftMetadata[_tokenId].token != address(0), 'INVALID_TOKEN_ID');
        require(nftMetadata[_tokenId].claimed == false, 'ALREADY_CLAIMED');
        require(block.timestamp >= nftMetadata[_tokenId].endTime, 'NFT_LOCKED');

        address owner = eqzYieldNft.ownerOf(_tokenId);

        nftMetadata[_tokenId].claimed = true;
        if (nftMetadata[_tokenId].nftType == NftTypes.bonus) {
            reservedPool = reservedPool - nftMetadata[_tokenId].amount;
        }

        eqzYieldNft.burn(_tokenId);
        require(
            IERC20(nftMetadata[_tokenId].token).transfer(owner, nftMetadata[_tokenId].amount),
            'TRANSFER_FAIL'
        );

        emit ClaimEvent(owner, _tokenId, nftMetadata[_tokenId].amount);
    }
// Solidity 0.8.4
/*
 * @dev Returns stakedAmount and reward
 * maxStaked = rewardPool / [multiplier * (interval / maxLockTime)^2]
 * reward = multiplier * stakeAmount * (interval / maxLockInterval)^2
 */
function _computeReward(uint256 desiredAmount, uint256 interval)
        internal
        view
        returns (uint256 stakeAmount, uint256 rewardAmount)
    {
        uint256 maxStaked = _getMaxStake(interval);
        stakeAmount = desiredAmount;
        if (stakeAmount > maxStaked) {
            stakeAmount = maxStaked;
        }
        rewardAmount = _getRewardAmount(stakeAmount, interval);
    }
// Solidity 0.8.4
/*
 * @dev Mint eqzYieldNft to sender, creates and adds nft metadata
 */
function _mintNft(
        address tokenAddress,
        uint256 amount,
        uint256 interval,
        NftTypes nftType
    ) internal returns (uint256) {
        tokenId++;
        uint256 currentTokenId = tokenId;
        eqzYieldNft.mint(msg.sender, currentTokenId);
        nftMetadata[currentTokenId] = NFTMetadata(
            tokenAddress,
            amount,
            block.timestamp,
            block.timestamp + interval,
            false,
            nftType
        );
        return currentTokenId;
    }
// Solidity 0.5.16
// SIP-75 Public keeper function to freeze a pynth that is out of bounds
function freezeRate(bytes32 currencyKey) external {
        InversePricing storage inverse = inversePricing[currencyKey];
        require(inverse.entryPoint > 0, "Cannot freeze non-inverse rate");
        require(!inverse.frozenAtUpperLimit && !inverse.frozenAtLowerLimit, "The rate is already frozen");

        uint rate = _getRate(currencyKey);

        if (rate > 0 && (rate >= inverse.upperLimit || rate <= inverse.lowerLimit)) {
            inverse.frozenAtUpperLimit = (rate == inverse.upperLimit);
            inverse.frozenAtLowerLimit = (rate == inverse.lowerLimit);
            uint currentRoundId = _getCurrentRoundId(currencyKey);
            roundFrozen[currencyKey] = currentRoundId;
            emit InversePriceFrozen(currencyKey, rate, currentRoundId, msg.sender);
        } else {
            revert("Rate within bounds");
        }
    }
// Solidity 0.5.16
// SIP-75 View to determine if freezeRate can be called safely
function canFreezeRate(bytes32 currencyKey) external view returns (bool) {
        InversePricing memory inverse = inversePricing[currencyKey];
        if (inverse.entryPoint == 0 || inverse.frozenAtUpperLimit || inverse.frozenAtLowerLimit) {
            return false;
        } else {
            uint rate = _getRate(currencyKey);
            return (rate > 0 && (rate >= inverse.upperLimit || rate <= inverse.lowerLimit));
        }
    }
// Solidity 0.8.0
/**
 * @notice overrides ERC20 transferFrom function to introduce tax functionality
 * @param from address amount is coming from
 * @param to address amount is going to
 * @param amount amount being sent
 */
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        require(balanceOf(from) >= amount, "ERC20: transfer amount exceeds balance");
        if(_taxActive && !_whitelisted[from] && !_whitelisted[to]) {
          uint256 tax = amount *_taxTotal / _taxPercision;
          amount = amount - tax;
          _transfer(from, address(this), tax);
        }
        _transfer(from, to, amount);
        return true;
    }
// Solidity 0.8.0
/**
 * @notice : overrides ERC20 transfer function to introduce tax functionality
 * @param to address amount is going to
 * @param amount amount being sent
 */
function transfer(address to, uint256 amount) public virtual override returns (bool) {
      address owner = _msgSender();
      require(balanceOf(owner) >= amount, "ERC20: transfer amount exceeds balance");
      if(_taxActive && !_whitelisted[owner] && !_whitelisted[to]) {
        uint256 tax = amount*_taxTotal/_taxPercision;
        amount = amount - tax;
        _transfer(owner, address(this), tax);
      }
      _transfer(owner, to, amount);
      return true;
    }
// Solidity 0.8.0
/**
 * @notice : adds address with tax amount to taxable addresses list
 * @param wallet address to add
 * @param _tax tax amount this address receives
 */
function addTaxRecipient(address wallet, uint16 _tax) external onlyOwner {
      require(_taxRecipients.length < 100, "Reached maximum number of tax addresses");
      require(wallet != address(0), "Cannot add 0 address");
      require(!_isTaxRecipient[wallet], "Recipient already added");
      require(_tax > 0 && _tax + _taxTotal <= _taxPercision/10, "Total tax amount must be between 0 and 10%");

      _isTaxRecipient[wallet] = true;
      _taxRecipients.push(wallet);
      _taxRecipientAmounts[wallet] = _tax;
      _taxTotal = _taxTotal + _tax;
      emit AddTaxRecipient(wallet, _tax);
    }
// Solidity 0.8.0
/**
 * @notice : updates address tax amount
 * @param wallet address to update
 * @param newTax new tax amount
 */
function updateTaxPercentage(address wallet, uint16 newTax) external onlyOwner {
      require(wallet != address(0), "Cannot add 0 address");
      require(_isTaxRecipient[wallet], "Not a tax address");

      uint16 currentTax = _taxRecipientAmounts[wallet];
      require(currentTax != newTax, "Tax already this amount for this address");

      if(currentTax < newTax) {
        uint16 diff = newTax - currentTax;
        require(_taxTotal + diff <= 10000, "Tax amount too high for current tax rate");
        _taxTotal = _taxTotal + diff;
      } else {
        uint16 diff = currentTax - newTax;
        _taxTotal = _taxTotal - diff;
      }
      _taxRecipientAmounts[wallet] = newTax;
      emit UpdateTaxPercentage(wallet, newTax);
    }
// Solidity 0.8.0
/**
 * @notice : remove address from taxed list
 * @param wallet address to remove
 */
function removeTaxRecipient(address wallet) external onlyOwner {
      require(wallet != address(0), "Cannot add 0 address");
      require(_isTaxRecipient[wallet], "Recipient has not been added");
      uint16 _tax = _taxRecipientAmounts[wallet];

      for(uint8 i = 0; i < _taxRecipients.length; i++) {
        if(_taxRecipients[i] == wallet) {
          _taxTotal = _taxTotal - _tax;
          _taxRecipientAmounts[wallet] = 0;
          _taxRecipients[i] = _taxRecipients[_taxRecipients.length - 1];
          _isTaxRecipient[wallet] = false;
          _taxRecipients.pop();
          emit RemoveTaxRecipient(wallet);

          break;
        }
      }
    }
// Solidity 0.8.0
/**
 * @notice : withdraws taxable amount to tax recipients
 */
function distributeTaxes() external onlyOwner {
      require(balanceOf(address(this)) > 0, "Nothing to withdraw");
      uint256 taxableAmount = balanceOf(address(this));
      for(uint8 i = 0; i < _taxRecipients.length; i++) {
        address taxAddress = _taxRecipients[i];
        if(i == _taxRecipients.length - 1) {
           _transfer(address(this), taxAddress, balanceOf(address(this)));
        } else {
          uint256 amount = taxableAmount * _taxRecipientAmounts[taxAddress]/_taxTotal;
          _transfer(address(this), taxAddress, amount);
        }
      }
    }
// Solidity 0.4.24
/**
 * Deposit ETH to get in line to be credited back the multiplier as a percent,
 * add that ETH to the pool, get the dividends and put them in the pool,
 * then pay out who we owe and buy more tokens.
 */
function deposit() payable public limitBuy() {
        //You have to send more than 1000000 wei.
        require(msg.value > 1000000);
        //Compute how much to pay them
        uint256 amountCredited = (msg.value * multiplier) / 100;
        //Get in line to be paid back.
        participants.push(Participant(msg.sender, amountCredited));
        //Increase the backlog by the amount owed
        backlog += amountCredited;
        //Increase the amount owed to this address
        creditRemaining[msg.sender] += amountCredited;
        //Emit a deposit event.
        emit Deposit(msg.value, msg.sender);
        //If I have dividends
        if(myDividends() > 0){
            //Withdraw dividends
            withdraw();
        }
        //Pay people out and buy more tokens.
        payout();
    }
// Solidity 0.5.17
/// @dev check that vault has sufficient funds is done by the call to vault
function earn(address strategy, uint256 amount) public updateEpoch {
        require(msg.sender == strategy, "!strategy");
        address token = IStrategy(strategy).want();
        require(approvedStrategies[token][strategy], "strat !approved");
        TokenStratInfo storage info = tokenStratsInfo[token];
        uint256 newInvestedAmount = investedAmounts[strategy].add(amount);
        require(newInvestedAmount <= capAmounts[strategy], "hit strategy cap");
        // update invested amount
        investedAmounts[strategy] = newInvestedAmount;
        // transfer funds to strategy
        info.vault.transferFundsToStrategy(strategy, amount);
    }
// Solidity 0.5.17
// handle vault withdrawal
function withdraw(address token, uint256 withdrawAmount) external updateEpoch {
        TokenStratInfo storage info = tokenStratsInfo[token];
        require(msg.sender == (address(info.vault)), "!vault");
        uint256 remainingWithdrawAmount = withdrawAmount;

        for (uint256 i = 0; i < info.strategies.length; i++) {
            if (remainingWithdrawAmount == 0) break;
            IStrategy strategy = info.strategies[i];
            // withdraw maximum amount possible
            uint256 actualWithdrawAmount = Math.min(
                investedAmounts[address(strategy)], remainingWithdrawAmount
            );
            // update remaining withdraw amt
            remainingWithdrawAmount = remainingWithdrawAmount.sub(actualWithdrawAmount);
            // update strat invested amt
            investedAmounts[address(strategy)] = investedAmounts[address(strategy)]
                    .sub(actualWithdrawAmount);
            // do the actual withdrawal
            strategy.withdraw(actualWithdrawAmount);
        }
    }
// Solidity 0.4.25
//process the fees, hdx20 appreciation, calcul results at the end of the race
function process_Taxes(  GameRoundData_s storage _GameRoundData ) private
    {
        uint32 turnround = _GameRoundData.extraData[0];
        
        if (turnround>0 && turnround<(1<<30))
        {  
            _GameRoundData.extraData[0] = turnround | (1<<30);
            
            uint256 _sharePrice = _GameRoundData.sharePrice;
             
            uint256 _potValue = _GameRoundData.treasureSupply.mul( _sharePrice ) / magnitude;
     
           
            uint256 _treasure = SafeMath.mul( _potValue , TreasureFees) / 100; 
            
            uint256 _appreciation = SafeMath.mul( _potValue , AppreciationFees) / 100; 
          
            uint256 _dev = SafeMath.mul( _potValue , DevFees) / 100;
           
            genTreasure = genTreasure.add( _treasure );
            
            //distribute devfees in hdx20 token
            if (_dev>0)
            {
                HDXcontract.buyTokenFromGame.value( _dev )( owner , address(0));
            }
            
            //distribute the profit to the token holders pure profit
            if (_appreciation>0 )
            {
               
                HDXcontract.appreciateTokenPrice.value( _appreciation )();
                
            }
            
          
            
            
        }
     
    }
// Solidity 0.6.12
// Withdraw partial funds
function withdraw(address _token, address _gauge, uint256 _amount) public returns(bool){
        require(msg.sender == operator, "!auth");
        uint256 _balance = IERC20(_token).balanceOf(address(this));
        if (_balance < _amount) {
            _amount = _withdrawSome(_gauge, _amount.sub(_balance));
            _amount = _amount.add(_balance);
        }
        IERC20(_token).safeTransfer(msg.sender, _amount);
        return true;
    }
// Solidity 0.4.23
// Function for token sell contract to call on transfers
function transferFromTokenSell(address _to, address _from, uint256 _amount) external onlyTokenSale returns (bool success) {
		require(_amount > 0);
		require(_to != 0x0);
		require(balanceOf(_from) >= _amount);
		decrementBalance(_from, _amount);
		addToBalance(_to, _amount);
		Transfer(_from, _to, _amount);
		return true;
	}
// Solidity 0.4.23
// Finalize private. If there are leftover TTT, overflow to presale
function finalizePrivatesale() external onlyTokenSale returns (bool success) {
		require(privatesaleFinalized == false);
		uint256 amount = balanceOf(privatesaleAddress);
		if (amount != 0) {
			addToBalance(presaleAddress, amount);
			decrementBalance(privatesaleAddress, amount);
		}
		privatesaleFinalized = true;
		PrivatesaleFinalized(amount);
		return true;
	}
// Solidity 0.4.23
// Finalize presale. If there are leftover TTT, overflow to crowdsale
function finalizePresale() external onlyTokenSale returns (bool success) {
		require(presaleFinalized == false && privatesaleFinalized == true);
		uint256 amount = balanceOf(presaleAddress);
		if (amount != 0) {
			addToBalance(crowdsaleAddress, amount);
			decrementBalance(presaleAddress, amount);
		}
		presaleFinalized = true;
		PresaleFinalized(amount);
		return true;
	}
// Solidity 0.4.23
// Finalize crowdsale. If there are leftover TTT, add 10% to airdrop, 20% to ecosupply, burn 70% at a later date
function finalizeCrowdsale(uint256 _burnAmount, uint256 _ecoAmount, uint256 _airdropAmount) external onlyTokenSale returns(bool success) {
		require(presaleFinalized == true && crowdsaleFinalized == false);
		uint256 amount = balanceOf(crowdsaleAddress);
		assert((_burnAmount.add(_ecoAmount).add(_airdropAmount)) == amount);
		if (amount > 0) {
			crowdsaleBurnAmount = _burnAmount;
			addToBalance(ecoSupplyAddress, _ecoAmount);
			addToBalance(crowdsaleBurnAddress, crowdsaleBurnAmount);
			addToBalance(crowdsaleAirdropAddress, _airdropAmount);
			decrementBalance(crowdsaleAddress, amount);
			assert(balanceOf(crowdsaleAddress) == 0);
		}
		crowdsaleFinalized = true;
		CrowdsaleFinalized(amount);
		return true;
	}
// Solidity 0.4.23
/**
 	* @dev Burns a specific amount of tokens. * added onlyOwner, as this will only happen from owner, if there are crowdsale leftovers
 	* @param _value The amount of token to be burned.
 	* @dev imported from https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/BurnableToken.sol
 	*/
function burn(uint256 _value) public onlyOwner {
		require(_value <= balances[msg.sender]);
		require(crowdsaleFinalized == true);
		// no need to require value <= totalSupply, since that would imply the
		// sender's balance is greater than the totalSupply, which *should* be an assertion failure

		address burner = msg.sender;
		balances[burner] = balances[burner].sub(_value);
		totalSupply_ = totalSupply_.sub(_value);
		Burn(burner, _value);
		Transfer(burner, address(0), _value);
	}
// Solidity 0.4.23
// Transfer tokens from the vested address. 50% available 12/01/2018, the rest available 06/01/2019
function transferFromVest(uint256 _amount) public onlyOwner {
		require(block.timestamp > firstVestStartsAt);
		require(crowdsaleFinalized == true);
		require(_amount > 0);
		if(block.timestamp > secondVestStartsAt) {
			// all tokens available for vest withdrawl
			require(_amount <= teamSupply);
			require(_amount <= balanceOf(teamSupplyAddress));
		} else {
			// only first vest available
			require(_amount <= (firstVestAmount - currentVestedAmount));
			require(_amount <= balanceOf(teamSupplyAddress));
		}
		currentVestedAmount = currentVestedAmount.add(_amount);
		addToBalance(msg.sender, _amount);
		decrementBalance(teamSupplyAddress, _amount);
		Transfer(teamSupplyAddress, msg.sender, _amount);
	}
// Solidity 0.7.6
/**
 * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
 * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
 */
function computeAddress(bytes32 salt, bytes memory bytecodeHash, address deployer) internal pure returns (address) {
        bytes32 bytecodeHashHash = keccak256(bytecodeHash);
        bytes32 _data = keccak256(
            abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHashHash)
        );
        return address(bytes20(_data << 96));
    }
// Solidity 0.4.24
/** @notice Allow us to transfer tokens that someone might've accidentally sent to this contract
 @param _tokenAddress this is the address of the token contract
 @param _recipient This is the address of the person receiving the tokens
 @param _amount This is the amount of tokens to send
 */
function transferForeignToken(
        address _tokenAddress,
        address _recipient,
        uint256 _amount)
        public
        onlyAdmin
        returns (bool)
    {
        require(_recipient != address(0), "recipient address can't be empty");
        // don't allow us to transfer RTC tokens stored in this contract
        require(_tokenAddress != TOKENADDRESS, "token can't be RTC");
        ERC20Interface eI = ERC20Interface(_tokenAddress);
        require(eI.transfer(_recipient, _amount), "token transfer failed");
        emit ForeignTokenTransfer(msg.sender, _recipient, _amount);
        return true;
    }
// Solidity 0.8.4
/// @inheritdoc IAloePredictionsDerivedState
function current()
        external
        view
        override
        returns (
            bool,
            uint176,
            uint128,
            uint128
        )
    {
        require(epoch != 0, "Aloe: No data yet");

        uint176 mean = computeMean();
        (uint256 lower, uint256 upper) = computeSemivariancesAbout(mean);
        return (
            didInvertPrices,
            mean,
            // Each proposal is a uniform distribution aiming to be `GROUND_TRUTH_STDDEV_SCALE` sigma wide.
            // So we have to apply a scaling factor (sqrt(6)) to make results more gaussian.
            uint128((Math.sqrt(lower) * SQRT_6) / (1000 * GROUND_TRUTH_STDDEV_SCALE)),
            uint128((Math.sqrt(upper) * SQRT_6) / (1000 * GROUND_TRUTH_STDDEV_SCALE))
        );
    }
// Solidity 0.8.4
/// @inheritdoc IAloePredictionsActions
function advance() external override lock {
        require(summaries[epoch].accumulators.stakeTotal != 0, "Aloe: No proposals with stake");
        require(uint32(block.timestamp) > epochExpectedEndTime(), "Aloe: Too early");
        epochStartTime = uint32(block.timestamp);

        if (epoch != 0) {
            (Bounds memory groundTruth, bool shouldInvertPricesNext) = fetchGroundTruth();
            emit FetchedGroundTruth(groundTruth.lower, groundTruth.upper, didInvertPrices);

            summaries[epoch - 1].groundTruth = groundTruth;
            didInvertPrices = shouldInvertPrices;
            shouldInvertPrices = shouldInvertPricesNext;

            _consolidateAccumulators(epoch - 1);
        }

        epoch++;
        INCENTIVE_VAULT.claimAdvanceIncentive(address(ALOE), msg.sender);
        emit Advanced(epoch, uint32(block.timestamp));
    }
// Solidity 0.8.2
/**
 * @dev See {IERC1155-balanceOf}.
 *
 * Requirements:
 *
 * - `account` cannot be the zero address.
 */
function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: balance query for the zero address");
        (address owner,,) = getData(id);
        if(owner == account) {
            return 1;
        }
        return 0;
    }
// Solidity 0.8.2
/**
 * @dev Returns the score of an amulet.
 *      0-3: Not an amulet
 *      4: common
 *      5: uncommon
 *      6: rare
 *      7: epic
 *      8: legendary
 *      9: mythic
 *      10+: beyond mythic
 */
function getScore(string memory amulet) public override pure returns(uint32) {
        uint256 hash = uint256(sha256(bytes(amulet)));
        uint maxlen = 0;
        uint len = 0;
        for(;hash > 0; hash >>= 4) {
            if(hash & 0xF == 8) {
                len += 1;
                if(len > maxlen) {
                    maxlen = len;
                }
            } else {
                len = 0;
            }
        }
        return uint32(maxlen);        
    }
// Solidity 0.8.2
/**
 * @dev Mint a new amulet.
 * @param data The ID and owner for the new token.
 */
function mint(MintData memory data) public override {
        require(data.owner != address(0), "ERC1155: mint to the zero address");
        require(_tokens[data.tokenId] == 0, "ERC1155: mint of existing token");

        _tokens[data.tokenId] = uint256(uint160(data.owner));
        emit TransferSingle(msg.sender, address(0), data.owner, data.tokenId, 1);

        _doSafeTransferAcceptanceCheck(msg.sender, address(0), data.owner, data.tokenId, 1, "");
    }
// Solidity 0.8.2
/**
 * @dev Reveals an amulet.
 * @param data The title, text, and offset URL for the amulet.
 */
function reveal(RevealData calldata data) public override {
        require(bytes(data.amulet).length <= 64, "Amulet: Too long");
        uint256 tokenId = uint256(keccak256(bytes(data.amulet)));
        (address owner, uint64 blockRevealed, uint32 score) = getData(tokenId);
        require(
            owner == msg.sender || isApprovedForAll(owner, msg.sender),
            "Amulet: reveal caller is not owner nor approved"
        );
        require(blockRevealed == 0, "Amulet: Already revealed");

        score = getScore(data.amulet);
        require(score >= 4, "Amulet: Score too low");

        setData(tokenId, owner, uint64(block.number), score);
        emit AmuletRevealed(tokenId, msg.sender, data.title, data.amulet, data.offsetURL);
    }
// Solidity 0.8.2
/**
 * @dev Returns the Amulet's owner address, the block it was revealed in, and its score.
 */
function getData(uint256 tokenId) public override view returns(address owner, uint64 blockRevealed, uint32 score) {
        uint256 t = _tokens[tokenId];
        owner = address(uint160(t));
        blockRevealed = uint64(t >> 160);
        score = uint32(t >> 224);
    }
// Solidity 0.8.2
/**************************************************************************
 * Internal/private methods
 *************************************************************************/
function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    )
        private
    {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver(to).onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }