lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.8
/// @dev Crowdfunding contract issues new tokens for address. Returns success.
/// @param _for Address of receiver.
/// @param tokenCount Number of tokens to issue.
function issueTokens(address _for, uint tokenCount)
        external
        payable
        onlyMinter
        returns (bool)
    {
        if (tokenCount == 0) {
            return false;
        }

        if (add(totalSupply, tokenCount) > maxTotalSupply) {
            throw;
        }

        totalSupply = add(totalSupply, tokenCount);
        balances[_for] = add(balances[_for], tokenCount);
        Issuance(_for, tokenCount);
        return true;
    }
// Solidity 0.4.8
/// @dev Function to change address that is allowed to do emission.
/// @param newAddress Address of new emission contract.
function changeMinter(address newAddress)
        public
        onlyFounder
        returns (bool)
    {   
        // Forbid previous emission contract to distribute tokens minted during ICO stage
        delete allowed[allocationAddressICO][minter];

        minter = newAddress;

        // Allow emission contract to distribute tokens minted during ICO stage
        allowed[allocationAddressICO][minter] = balanceOf(allocationAddressICO);
    }
// Solidity 0.4.8
/// @dev Contract constructor function sets initial token balances.
function HumaniqToken(address founderAddress)
    {   
        // Set founder address
        founder = founderAddress;

        // Allocate all created tokens during ICO stage to allocationAddressICO.
        balances[allocationAddressICO] = ICOSupply;

        // Allocate all created tokens during preICO stage to allocationAddressPreICO.
        balances[allocationAddressPreICO] = preICOSupply;

        // Allow founder to distribute tokens minted during preICO stage
        allowed[allocationAddressPreICO][founder] = preICOSupply;

        // Give 14 percent of all tokens to founders.
        balances[multisig] = div(mul(ICOSupply, 14), 86);

        // Set correct totalSupply and limit maximum total supply.
        totalSupply = add(ICOSupply, balances[multisig]);
        totalSupply = add(totalSupply, preICOSupply);
        maxTotalSupply = mul(totalSupply, 5);
    }
// Solidity 0.4.8
/// @dev Returns bonus for the specific moment
/// @param timestamp Time of investment (in seconds)
function getBonus(uint timestamp)
        public
        constant
        returns (uint)
    {   
        if (timestamp > endDate) {
            throw;
        }

        if (startDate > timestamp) {
            return 1499;  // 49.9%
        }

        uint icoDuration = timestamp - startDate;
        if (icoDuration >= 16 days) {
            return 1000;  // 0%
        } else if (icoDuration >= 9 days) {
            return 1125;  // 12.5%
        } else if (icoDuration >= 2 days) {
            return 1250;  // 25%
        } else {
            return 1499;  // 49.9%
        }
    }
// Solidity 0.4.8
/// @dev Issues tokens for users who made BTC purchases.
/// @param beneficiary Address the tokens will be issued to.
/// @param investment Invested amount in Wei
/// @param timestamp Time of investment (in seconds)
function fixInvestment(address beneficiary, uint investment, uint timestamp)
        external
        onlyFounder
        minInvestment(investment)
        returns (uint)
    {   

        // Calculate number of tokens to mint
        uint tokenCount = calculateTokens(investment, timestamp);

        // Update fund's and user's balance and total supply of tokens.
        tokensDistributed = add(tokensDistributed, tokenCount);

        // Distribute tokens.
        if (!humaniqToken.transferFrom(allocationAddress, beneficiary, tokenCount)) {
            // Tokens could not be issued.
            throw;
        }

        return tokenCount;
    }
// Solidity 0.4.21
// change restricted releaseXX account
function changeReleaseAccount(address _owner, address _newowner) internal returns (bool) {
    require(balances[_newowner] == 0);
    require(releaseTime[_owner] != 0 );
    require(releaseTime[_newowner] == 0 );
    balances[_newowner] = balances[_owner];
    releaseTime[_newowner] = releaseTime[_owner];
    balances[_owner] = 0;
    releaseTime[_owner] = 0;
    return true;
  }
// Solidity 0.4.21
/**
 * @dev Function to mint tokens
 * @param _to The address that will recieve the minted tokens.
 * @param _amount The amount of tokens to mint.
 * @param _releaseTime The (optional) freeze time - KYC & bounty accounts.
 * @return A boolean that indicates if the operation was successful.
 */
function mint(address _to, uint256 _amount, uint256 _releaseTime) internal canMint returns (bool) {
    totalSupply = totalSupply.add(_amount);
    balances[_to] = balances[_to].add(_amount);
    if ( _releaseTime > 0 ) {
        releaseTime[_to] = _releaseTime;
    }
    emit Transfer(0x0, _to, _amount);
    return true;
  }
// Solidity 0.4.21
// ETH Course in USD
// constructor
function ArconaToken(uint256 _startSale,uint256 _finishSale,address _multisig,address _restricted,address _registerbot,address _certbot, address _release6m, address _release12m, address _release18m) public  {
        multisig = _multisig;
        restricted = _restricted;
        registerbot = _registerbot;
        certbot = _certbot;
        release6m = _release6m;
        release12m = _release12m;
        release18m = _release18m;
        startSale = _startSale;
        finishSale = _finishSale;
    }
// Solidity 0.4.21
// import preICO customers from 0x516130856e743090af9d7fd95d6fc94c8743a4e1
function importCustomer(address _customer, address _referral, uint _tokenAmount) public {
        require(msg.sender == registerbot || msg.sender == owner);
        require(_customer != address(0));
        require(now < startSale); // before ICO starts
        registered[_customer] = true;
        if (_referral != address(0) && _referral != _customer) {
            referral[_customer] = _referral;
        }
        mint(_customer, _tokenAmount, now + 99 * 1 years); // till KYC is completed
    }
// Solidity 0.4.24
/// @dev vest Detail : second unit
function vestTokensDetailInt(
                        address _beneficiary,
                        uint256 _startS,
                        uint256 _cliffS,
                        uint256 _durationS,
                        bool _revocable,
                        uint256 _tokensAmountInt) external onlyOwner {
        require(_beneficiary != address(0));

        uint256 tokensAmount = _tokensAmountInt * 10**uint256(decimals);

        if(vestingOf[_beneficiary] == 0x0) {
            TokenVesting vesting = new TokenVesting(_beneficiary, _startS, _cliffS, _durationS, _revocable, owner);
            vestingOf[_beneficiary] = address(vesting);
        }

        require(this.transferFrom(reserveTokensVault, vestingOf[_beneficiary], tokensAmount));
    }
// Solidity 0.4.24
/// @dev vest StartAt : day unit
function vestTokensStartAtInt(
                            address _beneficiary, 
                            uint256 _tokensAmountInt,
                            uint256 _startS,
                            uint256 _afterDay,
                            uint256 _cliffDay,
                            uint256 _durationDay ) public onlyOwner {
        require(_beneficiary != address(0));

        uint256 tokensAmount = _tokensAmountInt * 10**uint256(decimals);
        uint256 afterSec = _afterDay * daySecond;
        uint256 cliffSec = _cliffDay * daySecond;
        uint256 durationSec = _durationDay * daySecond;

        if(vestingOf[_beneficiary] == 0x0) {
            TokenVesting vesting = new TokenVesting(_beneficiary, _startS + afterSec, cliffSec, durationSec, true, owner);
            vestingOf[_beneficiary] = address(vesting);
        }

        require(this.transferFrom(reserveTokensVault, vestingOf[_beneficiary], tokensAmount));
    }
// Solidity 0.4.21
// BTC external payments
function foreignBuy(address _holder, uint256 _weiAmount, uint256 _rate) public {
        require(msg.sender == registerbot || msg.sender == owner);
        require(_weiAmount > 0);
        require(_rate > 0);
        registered[_holder] = true;
        uint tokens = _rate.mul(_weiAmount).div(1 ether);
        mint(_holder, tokens, now + 99 * 1 years); // till KYC is completed
        totalWeiSale = totalWeiSale.add(_weiAmount);
    }
// Solidity 0.7.6
/// @notice Function to deposit stablecoins
/// @param _amount Amount to deposit
/// @param _tokenIndex Type of stablecoin to deposit
function deposit(uint256 _amount, uint256 _tokenIndex) external {
        require(msg.sender == tx.origin || isTrustedForwarder(msg.sender), "Only EOA or Biconomy");
        require(_amount > 0, "Amount must > 0");

        uint256 _ETHPrice = _determineETHPrice(_tokenIndex);
        uint256 _pool = getAllPoolInETH(_ETHPrice);
        address _sender = _msgSender();
        Tokens[_tokenIndex].token.safeTransferFrom(_sender, address(this), _amount);
        uint256 _amtDeposit = _amount; // For event purpose
        if (Tokens[_tokenIndex].decimals == 6) {
            _amount = _amount.mul(1e12);
        }

        // Calculate network fee
        uint256 _networkFeePerc;
        if (_amount < networkFeeTier2[0]) {
            // Tier 1
            _networkFeePerc = networkFeePerc[0];
        } else if (_amount <= networkFeeTier2[1]) {
            // Tier 2
            _networkFeePerc = networkFeePerc[1];
        } else if (_amount < customNetworkFeeTier) {
            // Tier 3
            _networkFeePerc = networkFeePerc[2];
        } else {
            // Custom Tier
            _networkFeePerc = customNetworkFeePerc;
        }
        uint256 _fee = _amount.mul(_networkFeePerc).div(DENOMINATOR);
        _fees = _fees.add(_fee);
        _amount = _amount.sub(_fee);

        _balanceOfDeposit[_sender] = _balanceOfDeposit[_sender].add(_amount);
        uint256 _amountInETH = _amount.mul(_ETHPrice).div(1e18);
        uint256 _shares = totalSupply() == 0 ? _amountInETH : _amountInETH.mul(totalSupply()).div(_pool);

        _mint(_sender, _shares);
        emit Deposit(address(Tokens[_tokenIndex].token), _sender, _amtDeposit, _shares);
    }
// Solidity 0.7.6
/// @notice Function to invest funds into strategy
function invest() external onlyAdmin {
        Token memory _USDT = Tokens[0];
        Token memory _USDC = Tokens[1];
        Token memory _DAI = Tokens[2];

        // Transfer out network fees
        _fees = _fees.div(1e12); // Convert to USDT decimals
        if (_fees != 0 && _USDT.token.balanceOf(address(this)) > _fees) {
            uint256 _treasuryFee =  _fees.mul(2).div(5); // 40%
            _USDT.token.safeTransfer(treasuryWallet, _treasuryFee); // 40%
            _USDT.token.safeTransfer(communityWallet, _treasuryFee); // 40%
            _USDT.token.safeTransfer(strategist, _fees.sub(_treasuryFee).sub(_treasuryFee)); // 20%
            emit TransferredOutFees(_fees);
            _fees = 0;
        }

        uint256 _poolInUSD = getAllPoolInUSD().sub(_fees);

        // Calculation for keep portion of stablecoins and swap remainder to WETH
        uint256 _toKeepUSDT = _poolInUSD.mul(_USDT.percKeepInVault).div(DENOMINATOR);
        uint256 _toKeepUSDC = _poolInUSD.mul(_USDC.percKeepInVault).div(DENOMINATOR);
        uint256 _toKeepDAI = _poolInUSD.mul(_DAI.percKeepInVault).div(DENOMINATOR);
        _invest(_USDT.token, _toKeepUSDT);
        _invest(_USDC.token, _toKeepUSDC);
        _toKeepDAI = _toKeepDAI.mul(1e12); // Follow decimals of DAI
        _invest(_DAI.token, _toKeepDAI);

        // Invest all swapped WETH to strategy
        uint256 _balanceOfWETH = WETH.balanceOf(address(this));
        if (_balanceOfWETH > 0) {
            strategy.invest(_balanceOfWETH);
            emit ETHToInvest(_balanceOfWETH);
        }
    }
// Solidity 0.7.6
/// @notice Function to determine Curve index for swapTokenWithinVault()
/// @param _tokenIndex Index of stablecoin
/// @return stablecoin index use in Curve
function _determineCurveIndex(uint256 _tokenIndex) private pure returns (int128) {
        if (_tokenIndex == 0) {
            return 2;
        } else if (_tokenIndex == 1) {
            return 1;
        } else {
            return 0;
        }
    }
// Solidity 0.6.12
/**
 * @dev Contract initializer.
 * @param _logic Address of the initial implementation.
 * @param _data Data to send as msg.data to the implementation to initialize the proxied contract.
 * It should include the signature and the parameters of the function to be called, as described in
 * https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.
 * This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.
 */
function initialize(address _logic, bytes memory _data) public payable {
        require(_implementation() == address(0));
        assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
        _setImplementation(_logic);
        if (_data.length > 0) {
            (bool success, ) = _logic.delegatecall(_data);
            require(success);
        }
    }
// Solidity 0.7.6
/// @notice Function to swap between tokens with Uniswap
/// @param _amountIn Amount to swap
/// @param _fromToken Token to be swapped
/// @param _toToken Token to be received
/// @return _amounts Array that contain amount swapped
function _swapExactTokensForTokens(uint256 _amountIn, address _fromToken, address _toToken) private returns (uint256[] memory _amounts) {
        address[] memory _path = new address[](2);
        _path[0] = _fromToken;
        _path[1] = _toToken;
        uint256[] memory _amountsOut = router.getAmountsOut(_amountIn, _path);
        if (_amountsOut[1] > 0) {
            _amounts = router.swapExactTokensForTokens(_amountIn, 0, _path, address(this), block.timestamp);
        } else {
            // Not enough amount to swap
            uint256[] memory _zeroReturn = new uint256[](2);
            _zeroReturn[0] = 0;
            _zeroReturn[1] = 0;
            return _zeroReturn;
        }
    }
// Solidity 0.7.6
/// @notice Function to set new network fee for deposit amount tier 2
/// @param _networkFeeTier2 Array that contains minimum and maximum amount of tier 2 (18 decimals)
function setNetworkFeeTier2(uint256[] calldata _networkFeeTier2) external onlyOwner {
        require(_networkFeeTier2[0] != 0, "Minimun amount cannot be 0");
        require(_networkFeeTier2[1] > _networkFeeTier2[0], "Maximun amount must greater than minimun amount");
        /**
         * Network fees have three tier, but it is sufficient to have minimun and maximun amount of tier 2
         * Tier 1: deposit amount < minimun amount of tier 2
         * Tier 2: minimun amount of tier 2 <= deposit amount <= maximun amount of tier 2
         * Tier 3: amount > maximun amount of tier 2
         */
        uint256[] memory oldNetworkFeeTier2 = networkFeeTier2;
        networkFeeTier2 = _networkFeeTier2;
        emit SetNetworkFeeTier2(oldNetworkFeeTier2, _networkFeeTier2);
    }
// Solidity 0.7.6
/// @notice Function to set new network fee percentage
/// @param _networkFeePerc Array that contains new network fee percentage for tier 1, tier 2 and tier 3
function setNetworkFeePerc(uint256[] calldata _networkFeePerc) external onlyOwner {
        require(
            _networkFeePerc[0] < 3000 &&
                _networkFeePerc[1] < 3000 &&
                _networkFeePerc[2] < 3000,
            "Network fee percentage cannot be more than 30%"
        );
        /**
         * _networkFeePerc content a array of 3 element, representing network fee of tier 1, tier 2 and tier 3
         * For example networkFeePerc is [100, 75, 50]
         * which mean network fee for Tier 1 = 1%, Tier 2 = 0.75% and Tier 3 = 0.5%
         */
        uint256[] memory oldNetworkFeePerc = networkFeePerc;
        networkFeePerc = _networkFeePerc;
        emit SetNetworkFeePerc(oldNetworkFeePerc, _networkFeePerc);
    }
// Solidity 0.7.6
/// @notice Function to migrate all funds from old strategy contract to new strategy contract
function migrateFunds() external onlyOwner {
        require(unlockTime <= block.timestamp && unlockTime.add(1 days) >= block.timestamp, "Function locked");
        require(WETH.balanceOf(address(strategy)) > 0, "No balance to migrate");
        require(pendingStrategy != address(0), "No pendingStrategy");

        uint256 _amount = WETH.balanceOf(address(strategy));
        WETH.safeTransferFrom(address(strategy), pendingStrategy, _amount);

        // Set new strategy
        address oldStrategy = address(strategy);
        strategy = ICitadelStrategy(pendingStrategy);
        pendingStrategy = address(0);
        canSetPendingStrategy = true;

        // Approve new strategy
        WETH.safeApprove(address(strategy), type(uint256).max);
        WETH.safeApprove(oldStrategy, 0);

        unlockTime = 0; // Lock back this function
        emit MigrateFunds(oldStrategy, address(strategy), _amount);
    }
// Solidity 0.7.6
/// @notice Function to get exact USD amount of pool in vault
/// @return Exact USD amount of pool in vault (no decimals)
function _getVaultPoolInUSD() private view returns (uint256) {
        uint256 _vaultPoolInUSD = (Tokens[0].token.balanceOf(address(this)).mul(1e12))
            .add(Tokens[1].token.balanceOf(address(this)).mul(1e12))
            .add(Tokens[2].token.balanceOf(address(this)))
            .sub(_fees);
            // In very rare case that fees > vault pool, above calculation will raise error
            // Use getReimburseTokenAmount() to get some stablecoin from strategy
        return _vaultPoolInUSD.div(1e18);
    }
// Solidity 0.7.6
/// @notice Function to determine ETH price based on stablecoin
/// @param _tokenIndex Type of stablecoin to determine
/// @return Price of ETH (18 decimals)
function _determineETHPrice(uint256 _tokenIndex) private view returns (uint256) {
        address _priceFeedContract;
        if (address(Tokens[_tokenIndex].token) == 0xdAC17F958D2ee523a2206206994597C13D831ec7) { // USDT
            _priceFeedContract = 0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46; // USDT/ETH
        } else if (address(Tokens[_tokenIndex].token) == 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) { // USDC
            _priceFeedContract = 0x986b5E1e1755e3C2440e960477f25201B0a8bbD4; // USDC/ETH
        } else { // DAI
            _priceFeedContract = 0x773616E4d11A78F511299002da57A0a94577F1f4; // DAI/ETH
        }
        return _getPriceFromChainlink(_priceFeedContract);
    }
// Solidity 0.8.6
// ----- PUBLIC METHODS ----- //
//emits Transfer event
function mintUniqly(uint256 numUniqlies) external payable {
        require(_saleStarted, "Sale not started yet");
        uint256 requiredValue = numUniqlies * _tokenPrice;
        uint256 mintIndex = totalSupply();
        require(msg.value >= requiredValue, "Not enough ether");
        require(
            (numUniqlies + mintIndex) <= _maxUniqly,
            "You cannot buy that many tokens"
        );

        for (uint256 i = 0; i < numUniqlies; i++) {
            _safeMint(msg.sender, mintIndex);
            mintIndex++;
        }
        // send back ETH if one overpay by accident
        if (requiredValue < msg.value) {
            payable(msg.sender).transfer(msg.value - requiredValue);
        }
    }
// Solidity 0.8.6
// ----- OWNERS METHODS ----- //
function getRandomNumber(uint256 adminProvidedSeed)
        external
        onlyOwner
        returns (bytes32)
    {
        require(totalSupply() >= _maxUniqly, "Sale must be ended");
        require(randomResult == 0, "Random number already initiated");
        require(address(this).balance >= 10 ether, "min 10 ETH balance required");
        require(
            LINK.balanceOf(address(this)) >= fee,
            "Not enough LINK"
        );
        return requestRandomness(keyHash, fee, adminProvidedSeed);
    }
// Solidity 0.5.17
/**
 * @dev Returns the current implementation of a proxy.
 * This is needed because only the proxy admin can query it.
 * @return The address of the current implementation of the proxy.
 */
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
    // We need to manually run the static call since the getter cannot be flagged as view
    // bytes4(keccak256("implementation()")) == 0x5c60da1b
    (bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
    require(success);
    return abi.decode(returndata, (address));
  }
// Solidity 0.5.17
/**
 * @dev Returns the admin of a proxy. Only the admin can query it.
 * @return The address of the current admin of the proxy.
 */
function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address) {
    // We need to manually run the static call since the getter cannot be flagged as view
    // bytes4(keccak256("admin()")) == 0xf851a440
    (bool success, bytes memory returndata) = address(proxy).staticcall(hex"f851a440");
    require(success);
    return abi.decode(returndata, (address));
  }
// Solidity 0.8.11
/*
 	 * @dev Withdraws the contracts balance to owner and DAO.
 	 */
function withdraw() public onlyOwner {
		// Reserve 30% for DAO treasury
		(bool hs, ) = payable(DAO_TREASURY_ADDRESS).call{ value: (address(this).balance * 30) / 100 }("");
		require(hs, "DAO tranfer failed");

		// owner only
		(bool os, ) = payable(owner()).call{ value: address(this).balance }("");
		require(os, "owner transfer failed");
	}
// Solidity 0.8.11
/*
 	 * @dev Mints doggos when presale is enabled.
 	 */
function presaleMintDoggo(uint256 quantity, bytes32[] calldata merkleProof)
		external
		payable
		whenNotPaused
		whenPreSale
		nonReentrant
	{
		require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");

		if (_msgSender() != owner()) {
			require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
			require(
				MerkleProof.verify(merkleProof, PRE_SALE_MERKLE_ROOT, keccak256(abi.encodePacked(_msgSender()))),
				"Address not on the list"
			);
			require(_numberMinted(_msgSender()) + quantity <= PRE_SALE_MAX_MINT_AMOUNT, "presale mint limit reached");
			require(msg.value >= COST * quantity, "incorrect ether value");
		}

		_mintDoggo(_msgSender(), quantity);
	}
// Solidity 0.8.11
/*
 	 * @dev Mints doggos when presale is disabled.
 	 */
function mintDoggo(uint256 quantity) external payable whenNotPaused whenNotPreSale nonReentrant {
		require(totalSupply() + quantity < MAX_SUPPLY, "max supply reached");

		if (_msgSender() != owner()) {
			require(totalSupply() + quantity < MAX_PUBLIC_SUPPLY, "max public supply reached");
			require(_numberMinted(_msgSender()) + quantity <= MAX_MINT_AMOUNT, "mint limit reached");
			require(msg.value >= COST * quantity, "incorrect ether value");
		}

		_mintDoggo(_msgSender(), quantity);
	}
// Solidity 0.4.24
/**
 * @dev schedule lock
 */
function scheduleLock(
    Direction _restriction,
    uint256 _startAt, uint256 _endAt, bool _scheduleInverted)
    public onlyAuthority returns (bool)
  {
    require(_startAt <= _endAt, "LOR02");
    lock = ScheduledLock(
      _restriction,
      _startAt,
      _endAt,
      _scheduleInverted
    );
    emit LockDefinition(
      lock.restriction, lock.startAt, lock.endAt, lock.scheduleInverted);
  }
// Solidity 0.8.7
// Dutch-ish Auction
function currentPrice(uint256 tulipNumber) public view returns (uint256 price) {
        if (tulipNumber == latestNewTulipForSale) {
            // if currently in auction
            uint256 initialPrice = 1000 ether;
            uint256 decayPeriod = 1 days;
            // price = initial_price - initial_price * (current_time - start_time) / decay_period
            uint256 elapsedTime = block.timestamp - tulips[tulipNumber].listingTime;
            if (elapsedTime >= decayPeriod) return 0;
            return initialPrice - ((initialPrice * elapsedTime) / decayPeriod);
        } else {
            // if not in auction
            return tulips[tulipNumber].price;
        }
    }