lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
/// @dev allows users to start the reclaim process for staked tokens and stake rewards
/// @return bool on success
function initUnstake() external returns (bool) {

        // Require that the user has not already started the unstaked process
        require(stakeBalances[msg.sender].unstakeTime == 0);

        // Require that there was some amount staked
        require(stakeBalances[msg.sender].stakeBalance > 0);

        // Log time that user started unstaking
        stakeBalances[msg.sender].unstakeTime = now.div(timingVariable);

        // Subtract stake balance from totalScaleStaked
        totalScaleStaked = totalScaleStaked.sub(stakeBalances[msg.sender].stakeBalance);

        // Set this every time someone adjusts the totalScaleStaked amount
        setTotalStakingHistory();

        // Scale unstaked event
        emit Unstake(msg.sender, stakeBalances[msg.sender].stakeBalance);

        return true;
    }
// Solidity 0.4.24
/// @dev set the new totalStakingHistory mapping to the current timestamp and totalScaleStaked
function setTotalStakingHistory() private {

      // Get now in terms of the variable staking accuracy (days in Scale's case)
      uint _nowAsTimingVariable = now.div(timingVariable);

      // Set the totalStakingHistory as a timestamp of the totalScaleStaked today
      totalStakingHistory[_nowAsTimingVariable] = totalScaleStaked;
    }
// Solidity 0.4.24
// @dev anyone can call this function that mints Scale to the pool dedicated to Scale distribution to rewards pool
function poolIssue() public {

        // Do not allow tokens to be minted to the pool until the pool is set
        require(pool != address(0));

        // Make sure time has passed since last minted to pool
        require(now > poolTimeLastMinted);
        require(pool != address(0));

        uint _timePassedSinceLastMint; // The amount of time passed since the pool claimed in seconds
        uint _tokenMintCount; // The amount of new tokens to mint
        bool _mintingSuccess; // The success of minting the new Scale tokens

        // Calculate the number of seconds that have passed since the owner last took a claim
        _timePassedSinceLastMint = now.sub(poolTimeLastMinted);

        assert(_timePassedSinceLastMint > 0);

        // Determine the token mint amount, determined from the number of seconds passed and the ownerMintRate
        _tokenMintCount = calculateMintTotal(_timePassedSinceLastMint, poolMintRate);

        // Mint the owner's tokens; this also increases totalSupply
        _mintingSuccess = mint(pool, _tokenMintCount);

        require(_mintingSuccess);

        // New minting was a success! Set last time minted to current block.timestamp (now)
        poolTimeLastMinted = now;
    }
// Solidity 0.4.24
//BUY Ethminter
function EthTomining(address _addr)payable public{
        uint256 amount=msg.value;
        uint256 usdt=amount;
        uint256 _udst=amount;
        miner storage user=miners[_addr];
        require(amount>800000000000000000);
        if(usdt>40000000000000000000){
           usdt=amount*150/100;
           user.ETHV5+=1;
        }else{
            if (usdt > 25000000000000000000){
                    usdt = amount* 130 / 100;
                    user.ETHV4+=1;
                }
                else{
                    if (usdt > 9000000000000000000){
                        usdt = amount * 120 / 100;
                         user.ETHV3+=1;
                    }
                    else{
                        if (usdt > 4000000000000000000){
                            usdt = amount * 110 / 100;
                             user.ETHV2+=1;
                        }
                        else{
                          user.ETHV1+=1;  
                        }
                    }
                }
        }
        uint256 _transfer=amount*15/100;
        addressDraw.transfer(_transfer);
        TotalInvestment+=usdt;
        user.mining+=usdt;
        user._mining+=_udst;
        //user._mining+=_udst;
        user.lastDate=now;
        bomus(msg.sender,usdt,"Purchase success!");
    }
// Solidity 0.4.24
//BUY BEBminter
function BebTomining(uint256 _value,address _addr)public{
        uint256 usdt=_value* 10 ** 18;
        uint256 _udst=usdt/bebethex;
        uint256 bebudst=usdt/bebethex;
        miner storage user=miners[_addr];
        bebvv storage _user=bebvvs[_addr];
        require(usdt>40000000000000000000000);
        if(usdt>2000000000000000000000000){
           _udst=usdt/bebethexchuang*150/100;
           _user.BEBV5+=1; 
        }else{
            if (usdt > 400000000000000000000000){
                    _udst = usdt / bebethexchuang * 130 / 100;
                   _user.BEBV4+=1; 
                }
                else{
                    if (usdt > 200000000000000000000000){
                        _udst = usdt / bebethexchuang * 120 / 100;
                        _user.BEBV3+=1; 
                    }
                    else{
                        if (usdt > 120000000000000000000000){
                            _udst = usdt / bebethexchuang * 110 / 100;
                            _user.BEBV2+=1; 
                        }else{
                          _user.BEBV1+=1;  
                        }
                    }
                }
                
            }
        bebTokenTransfer.transferFrom(msg.sender,address(this),usdt);
        TotalInvestment+=_udst;
        user.mining+=_udst;
        user._mining+=bebudst;
        user.lastDate=now;
        bomus(msg.sender,usdt,"Purchase success!");
    }
// Solidity 0.8.7
/// Get the full uri to get the token meta data
function tokenURI(uint256 tokenId) public view virtual override returns (string memory)
    {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
        
        if(!isRevealed) {
            return _unrevealedUri;
        }

        string memory currentBaseURI = _baseURI();
        return bytes(currentBaseURI).length > 0
            ? string(abi.encodePacked(currentBaseURI, Strings.toString(tokenId+1), _baseExtension))
            : "";
    }
// Solidity 0.8.7
/// Mint a new Katana(s)
function mintToken(uint numberOfTokens) public payable {
        require(isSaleActive, "Sale is not active");
        require((totalSupply() + numberOfTokens) <= MAX_TOKEN, "Number of tokens requested are not available");
        require((mintPrice * numberOfTokens) <= msg.value, "Not enough ether value sent");
        
        require(numberOfTokens <= maxMintPublic, "Number of tokens requested exceeds the amount allowed per transaction. See 'maxMintPublic'");
        
        // mint the tokens
        _safeMint(msg.sender, numberOfTokens);
        
    }
// Solidity 0.8.7
/// Mint a new Katana(s) during presale
function premintToken(uint numberOfTokens, string calldata password) public payable {
        require(isSaleActive, "Sale is not active");
        require(isPrivateSaleActive, "presale is not active");
        require(keccak256(abi.encodePacked(password)) == premintPassword, "Premint password is not correct.");
        require((totalSupply() + numberOfTokens) <= MAX_PRESALE_TOKEN, "Number of tokens requested are not available");
        require((mintPrice * numberOfTokens) <= msg.value, "Not enough ether value sent");

        require((balanceOf(msg.sender) + numberOfTokens) <= maxMintPresale, "Number of tokens requested exceeds the amount allowed during the presale.");
        require(numberOfTokens <= maxMintPresale, "Number of tokens requested exceeds the amount allowed during the presale. See 'maxMintPresale'");

        // mint the tokens
        _safeMint(msg.sender, numberOfTokens);
    }
// Solidity 0.8.0
// Inspired from CyberKongz! Thanks for everything you are doing.
function isValidBiome(uint256 _id) public pure returns(bool) {
        if (_id >> 96 != 0x000000000000000000000000547e4f8fcE41fE8e46dbe7554B9153Ea087311d7)
			return false;
		if (_id & 0x000000000000000000000000000000000000000000000000000000ffffffffff != 1)
			return false;
		uint256 id = (_id & 0x0000000000000000000000000000000000000000ffffffffffffff0000000000) >> 40;
		if (id > 207 || id < 2 || id == 80 || id == 102 || id == 159 || id == 195 || id == 196 || id == 197)
			return false;
		return true;
    }
// Solidity 0.8.0
// Helper to list all the Biomes of a wallet
function walletOfOwner(address _owner) public view returns(uint256[] memory) {
        uint256 tokenCount = balanceOf(_owner);

        uint256[] memory tokensId = new uint256[](tokenCount);
        for(uint256 i; i < tokenCount; i++){
            tokensId[i] = tokenOfOwnerByIndex(_owner, i);
        }
        return tokensId;
    }
// Solidity 0.8.0
/**
 * Reserve for the team and giveaways
 */
function reserve() public onlyOwner {
        require(RESERVATION_COMPLETED == false, "You already reserved your tokens");

        for (uint i = 0; i < RESERVE_AMOUNT; i++) {
            uint mintIndex = totalSupply();
            _safeMint(msg.sender, mintIndex);
        }
        RESERVATION_COMPLETED = true;
    }
// Solidity 0.8.0
/**
 * Mints NFTs
 */
function mintClown(uint numberOfTokens) public payable returns (uint[] memory) {
        require(SALE_ACTIVE, "Sale must be active to mint a Clown");
        require(totalSupply().add(numberOfTokens) <= MAX_SUPPLY, "Purchase would exceed the max supply of Clownz");
        require(NFT_MAIN_SALE_PRICE.mul(numberOfTokens) <= msg.value, "Ether value sent is not correct");
        require(numberOfTokens <= MAX_PURCHASE, "Can only mint 20 tokens at a time");
        uint[] memory result = new uint[](numberOfTokens);

        for(uint i = 0; i < numberOfTokens; i++) {
            uint mintIndex = totalSupply();
            if (mintIndex < MAX_SUPPLY) {
                _safeMint(msg.sender, mintIndex);
            }
            result[i] = mintIndex;
        }
        return result;
    }
// Solidity 0.8.0
/**
 * Mints NTFs in presale
 */
function mintClownPresale(uint numberOfTokens) public payable returns (uint[] memory) {
        require(PRESALE_ACTIVE, "Presale must be active to mint a Clown in presale");
        require(NFT_PRESALE_PRICE.mul(numberOfTokens) <= msg.value, "Ether value is not correct");
        require(_whitelist[msg.sender], "You have to be whitelisted to mint in presale");
        require(_whitelistMinted[msg.sender].add(numberOfTokens) <= MAX_PURCHASE_PRESALE, "Can only mint 4 tokens per address in presale");
        uint[] memory result = new uint[](numberOfTokens);

        for (uint i = 0; i < numberOfTokens; i++) {
            uint mintIndex = totalSupply();
            if (totalSupply() < MAX_SUPPLY) {
                _safeMint(msg.sender, mintIndex);
            }
            result[i] = mintIndex;
        }
        _whitelistMinted[msg.sender] = _whitelistMinted[msg.sender].add(numberOfTokens);
        return result;
    }
// Solidity 0.8.0
/**
 * @dev Retuns ids of the tokens that are owned by the given address.
 */
function getOwnedTokens(address owner) external view returns (uint[] memory) {
        uint[] memory result = new uint[](_balances[owner]);
        uint counter = 0;
        for (uint i = 0; i < _tokensMinted; i++) {
            if (_owners[i] == owner) {
                result[counter] = i;
                counter = counter.add(1);
            }
        }
        return result;
    }
// Solidity 0.8.2
// Minting function with signature for txn relayers
function mintWithSig(
    address account,
    uint256 id,
    bytes memory data,
    bytes memory sig,
    uint256 blockExpiry
  ) external {
    bytes32 message = getMintSigningHash(blockExpiry, account, id).toEthSignedMessageHash();
    require(ECDSA.recover(message, sig) == signVerifier, 'Permission to call this function failed');
    require(block.number < blockExpiry, 'Sig expired');

    mintNonces[account]++;

    _mint(account, id, 1, data);
  }
// Solidity 0.4.20
//
// Construction helpers
//
function getContracts(IController _controller, bytes32 _orderId) private view returns (Contracts memory) {
        IOrders _orders = IOrders(_controller.lookup("Orders"));
        IMarket _market = _orders.getMarket(_orderId);
        uint256 _outcome = _orders.getOutcome(_orderId);
        return Contracts({
            orders: _orders,
            market: _market,
            completeSets: ICompleteSets(_controller.lookup("CompleteSets")),
            denominationToken: _market.getDenominationToken(),
            longShareToken: _market.getShareToken(_outcome),
            shortShareTokens: getShortShareTokens(_market, _outcome),
            augur: _controller.getAugur()
        });
    }
// Solidity 0.8.3
/// @notice withdraw up to all user deposited
function withdraw(address _lpToken, uint256 _amount)
        external
        override
        nonReentrant
        notPaused
    {
        require(
            pools[_lpToken].lastUpdatedAt > 0,
            "Blacksmith: pool does not exists"
        );
        _updatePool(_lpToken);

        User storage user = users[_lpToken][msg.sender];
        _claimRewards(_lpToken, user);
        uint256 amount = user.amount > _amount ? _amount : user.amount;
        user.amount = user.amount - amount;
        pools[_lpToken].amount = pools[_lpToken].amount - amount;
        _updateUserWriteoffs(_lpToken);

        _safeTransfer(_lpToken, amount);
        emit Withdraw(msg.sender, _lpToken, amount);
    }
// Solidity 0.8.3
/// @notice extend the current bonus program, the program has to be active (endTime is in the future)
function extendBonus(
        address _lpToken,
        uint256 _poolBonusId,
        address _bonusTokenAddr,
        uint256 _transferAmount
    ) external override nonReentrant notPaused {
        require(
            _isAuthorized(allowedTokenAuthorizers[_lpToken][_bonusTokenAddr]),
            "BonusRewards: not authorized caller"
        );

        Bonus memory bonus = pools[_lpToken].bonuses[_poolBonusId];
        require(
            bonus.bonusTokenAddr == _bonusTokenAddr,
            "BonusRewards: bonus and id dont match"
        );
        require(
            bonus.endTime > block.timestamp,
            "BonusRewards: bonus program ended, please start a new one"
        );

        IERC20 bonusTokenAddr = IERC20(_bonusTokenAddr);
        uint256 balanceBefore = bonusTokenAddr.balanceOf(address(this));
        bonusTokenAddr.safeTransferFrom(
            msg.sender,
            address(this),
            _transferAmount
        );
        uint256 received = bonusTokenAddr.balanceOf(address(this)) -
            balanceBefore;
        // endTime is based on how much tokens transfered v.s. planned weekly rewards
        uint48 endTime = uint48(
            (received * WEEK) / bonus.weeklyRewards + bonus.endTime
        );

        pools[_lpToken].bonuses[_poolBonusId].endTime = endTime;
        pools[_lpToken].bonuses[_poolBonusId].remBonus =
            bonus.remBonus +
            received;
    }
// Solidity 0.8.3
/// @notice add pools and authorizers to add bonus tokens for pools, combine two calls into one. Only reason we add pools is when bonus tokens will be added
function addPoolsAndAllowBonus(
        address[] calldata _lpTokens,
        address[] calldata _bonusTokenAddrs,
        address[] calldata _authorizers
    ) external override onlyOwner notPaused {
        // add pools
        uint256 currentTime = block.timestamp;
        for (uint256 i = 0; i < _lpTokens.length; i++) {
            address _lpToken = _lpTokens[i];
            require(
                IERC20(_lpToken).decimals() <= 18,
                "BonusRewards: lptoken decimals > 18"
            );
            if (pools[_lpToken].lastUpdatedAt == 0) {
                pools[_lpToken].lastUpdatedAt = currentTime;
                poolList.push(_lpToken);
            }

            // add bonus tokens and their authorizers (who are allowed to add the token to pool)
            for (uint256 j = 0; j < _bonusTokenAddrs.length; j++) {
                address _bonusTokenAddr = _bonusTokenAddrs[j];
                allowedTokenAuthorizers[_lpToken][
                    _bonusTokenAddr
                ] = _authorizers;
                bonusTokenAddrMap[_bonusTokenAddr] = 1;
            }
        }
    }
// Solidity 0.8.3
/// @notice update pool's bonus per staked token till current block timestamp, do nothing if pool does not exist
function _updatePool(address _lpToken) private {
        Pool storage pool = pools[_lpToken];
        uint256 poolLastUpdatedAt = pool.lastUpdatedAt;
        if (poolLastUpdatedAt == 0 || block.timestamp <= poolLastUpdatedAt)
            return;
        pool.lastUpdatedAt = block.timestamp;
        uint256 lpTotal = pool.amount;
        if (lpTotal == 0) return;

        for (uint256 i = 0; i < pool.bonuses.length; i++) {
            Bonus storage bonus = pool.bonuses[i];
            if (
                poolLastUpdatedAt < bonus.endTime &&
                bonus.startTime < block.timestamp
            ) {
                uint256 bonusForTime = _calRewardsForTime(
                    bonus,
                    poolLastUpdatedAt
                );
                bonus.accRewardsPerToken =
                    bonus.accRewardsPerToken +
                    bonusForTime /
                    lpTotal;
            }
        }
    }
// Solidity 0.8.3
/// @notice transfer upto what the contract has
function _safeTransfer(address _token, uint256 _amount)
        private
        returns (uint256 _transferred)
    {
        IERC20 token = IERC20(_token);
        uint256 balance = token.balanceOf(address(this));
        if (balance > _amount) {
            token.safeTransfer(msg.sender, _amount);
            _transferred = _amount;
        } else if (balance > 0) {
            token.safeTransfer(msg.sender, balance);
            _transferred = balance;
        }
    }
// Solidity 0.8.3
// only owner or authorized users from list
function _isAuthorized(address[] memory checkList)
        private
        view
        returns (bool)
    {
        if (msg.sender == owner()) return true;

        for (uint256 i = 0; i < checkList.length; i++) {
            if (msg.sender == checkList[i]) {
                return true;
            }
        }
        return false;
    }
// Solidity 0.4.22
/**
 * Transfer tokens from the caller to a new holder.
 * Remember, there's a 15% fee here as well.
 */
function transfer(address _toAddress, uint256 _amountOfTokens)
        onlyBagholders()
        public
        returns(bool)
    {
        // setup
        address _customerAddress = msg.sender;
        
        // make sure we have the requested tokens
        // also disables transfers until ambassador phase is over
        // ( we dont want whale premines )
        require(!onlyAmbassadors && _amountOfTokens <= tokenBalanceLedger_[_customerAddress]);
        
        // withdraw all outstanding dividends first
        if(myDividends(true) > 0) withdraw();
        
        // liquify 15% of the tokens that are transfered
        // these are dispersed to shareholders
        uint256 _tokenFee = SafeMath.div(_amountOfTokens, dividendFee_);
        uint256 _taxedTokens = SafeMath.sub(_amountOfTokens, _tokenFee);
        uint256 _dividends = tokensToEthereum_(_tokenFee);
  
        // burn the fee tokens
        tokenSupply_ = SafeMath.sub(tokenSupply_, _tokenFee);

        // exchange tokens
        tokenBalanceLedger_[_customerAddress] = SafeMath.sub(tokenBalanceLedger_[_customerAddress], _amountOfTokens);
        tokenBalanceLedger_[_toAddress] = SafeMath.add(tokenBalanceLedger_[_toAddress], _taxedTokens);
        
        // update dividend trackers
        payoutsTo_[_customerAddress] -= (int256) (profitPerShare_ * _amountOfTokens);
        payoutsTo_[_toAddress] += (int256) (profitPerShare_ * _taxedTokens);
        
        // disperse dividends among holders
        profitPerShare_ = SafeMath.add(profitPerShare_, (_dividends * magnitude) / tokenSupply_);
        
        // fire event
        Transfer(_customerAddress, _toAddress, _taxedTokens);
        
        // ERC20
        return true;
    }
// Solidity 0.8.0
/**
 * @dev Mint
 * @param owner address to set ownership to
 */
function mint(address owner) external {
        require(minters[msg.sender] || owner == msg.sender, "This address cannot mint");
        // NOTE - we don't require this so external callers don't blow up if a note already exists
        if(ownerTokenId[owner] == 0) {
            _tokenIds.increment();
            uint256 newItemId = _tokenIds.current();
            _safeMint(owner, newItemId);
            ownerTokenId[owner] = newItemId;
        }
    }
// Solidity 0.6.10
/**
 * Takes a real unit and divides by the position multiplier to return the virtual unit
 */
function _convertRealToVirtualUnit(int256 _realUnit) internal view returns(int256) {
        int256 virtualUnit = _realUnit.conservativePreciseDiv(positionMultiplier);

        // These checks ensure that the virtual unit does not return a result that has rounded down to 0
        if (_realUnit > 0 && virtualUnit == 0) {
            revert("Virtual unit conversion invalid");
        }

        return virtualUnit;
    }
// Solidity 0.6.10
/**
 * Loops through all of the positions and returns the smallest absolute value of 
 * the virtualUnit.
 *
 * @return Min virtual unit across positions denominated as int256
 */
function _getPositionsAbsMinimumVirtualUnit() internal view returns(int256) {
        // Additional assignment happens in the loop below
        uint256 minimumUnit = uint256(-1);

        for (uint256 i = 0; i < components.length; i++) {
            address component = components[i];

            // A default position exists if the default virtual unit is > 0
            uint256 defaultUnit = _defaultPositionVirtualUnit(component).toUint256();
            if (defaultUnit > 0 && defaultUnit < minimumUnit) {
                minimumUnit = defaultUnit;
            }

            address[] memory externalModules = _externalPositionModules(component);
            for (uint256 j = 0; j < externalModules.length; j++) {
                address currentModule = externalModules[j];

                uint256 virtualUnit = _absoluteValue(
                    _externalPositionVirtualUnit(component, currentModule)
                );
                if (virtualUnit > 0 && virtualUnit < minimumUnit) {
                    minimumUnit = virtualUnit;
                }
            }
        }

        return minimumUnit.toInt256();        
    }
// Solidity 0.6.12
// to withdraw token from the contract
function transferTokenBack(address TokenAddress)
        external
        onlyOwner
        returns (uint256)
    {
        IERC20 Token = IERC20(TokenAddress);
        uint256 balance = Token.balanceOf(address(this));
        if (balance > 0) {
            Token.safeTransfer(msg.sender, balance);
        }

        uint256 ETHbalance = address(this).balance;
        if (ETHbalance > 0) {
            msg.sender.transfer(ETHbalance);
        }

        return balance;
    }
// Solidity 0.8.7
/**
 * @dev Edit whitelist
 */
function editWhitelist(address[] calldata walletsToAdd, address[] calldata walletsToRemove) external onlyOwner {
        for (uint256 i = 0; i < walletsToAdd.length; i++) {
            isWhitelisted[walletsToAdd[i]] = true;
        }
        for (uint256 i = 0; i < walletsToRemove.length; i++) {
            isWhitelisted[walletsToRemove[i]] = false;
        }

        emit SetWhitelist(walletsToAdd, walletsToRemove);
    }