lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.6.12
/// @notice Borrows token, converts to collateral, and adds to position
/// @dev Called through the DSProxy
/// @param _exData Exchange data
/// @param _cAddresses Coll/Debt addresses [cCollAddress, cBorrowAddress]
/// @param _gasCost Gas cost for specific transaction
function boost(
        ExchangeData memory _exData,
        address[2] memory _cAddresses, // cCollAddress, cBorrowAddress
        uint256 _gasCost
    ) public payable {
        enterMarket(_cAddresses[0], _cAddresses[1]);

        address payable user = payable(getUserAddress());

        uint maxBorrow = getMaxBorrow(_cAddresses[1], address(this));
        uint borrowAmount = (_exData.srcAmount > maxBorrow) ? maxBorrow : _exData.srcAmount;

        require(CTokenInterface(_cAddresses[1]).borrow(borrowAmount) == 0);

        address collToken = getUnderlyingAddr(_cAddresses[0]);
        address borrowToken = getUnderlyingAddr(_cAddresses[1]);

        uint swapAmount = 0;

        if (collToken != borrowToken) {
            _exData.dfsFeeDivider = isAutomation() ? AUTOMATIC_SERVICE_FEE : MANUAL_SERVICE_FEE;
            _exData.user = user;

            _exData.srcAmount = borrowAmount;
            (, swapAmount) = _sell(_exData);

             swapAmount -= getGasCost(swapAmount, _gasCost, _cAddresses[1]);
        } else {
            swapAmount = borrowAmount;
            swapAmount -= getGasCost(swapAmount, _gasCost, _cAddresses[1]);
        }

        approveCToken(collToken, _cAddresses[0]);

        if (collToken != ETH_ADDRESS) {
            require(CTokenInterface(_cAddresses[0]).mint(swapAmount) == 0);
        } else {
            CEtherInterface(_cAddresses[0]).mint{value: swapAmount}(); // reverts on fail
        }

        // handle 0x fee
        tx.origin.transfer(address(this).balance);

        // log amount, collToken, borrowToken
        logger.Log(address(this), msg.sender, "CompoundBoost", abi.encode(_exData.srcAmount, swapAmount, collToken, borrowToken));
    }
// Solidity 0.7.4
// Wind down pool exists just in case one of the pools is broken
function wind_down_pool(uint256 pool, uint256 epoch) external {
    require(msg.sender == team_address || msg.sender == governance, "must be team or governance");
    require(epoch == 15, "v1.15: only epoch 15");
    uint256 current_epoch = get_current_epoch();
    require(epoch < current_epoch, "cannot wind down future epoch");

    if (pool == uint(-1)) {
      require(!epoch_wound_down[epoch], "epoch already wound down");
      epoch_wound_down[epoch] = true;

      // Team Funds - https://miro.medium.com/max/568/1*8vnnKp4JzzCA3tNqW246XA.png
      uint256 team_sfi = 54 * 1 ether;
      SFI(SFI_address).mint_SFI(team_address, team_sfi);
    } else {
      uint256 rewardSFI = 0;
      if (pool < pool_SFI_rewards.length) {
        rewardSFI = pool_SFI_rewards[pool];
        SFI(SFI_address).mint_SFI(pools[pool], rewardSFI);
      }
      ISaffronPool(pools[pool]).wind_down_epoch(epoch, rewardSFI);
    }
  }
// Solidity 0.7.4
// Deploy all capital in pool (funnel 100% of pooled base assets into best adapter)
function deploy_all_capital() external override {
    require(block.timestamp >= last_deploy + (deploy_interval), "deploy call too soon" );
    last_deploy = block.timestamp;

    // DAI/Compound
    ISaffronPool pool = ISaffronPool(pools[0]);
    IERC20 base_asset = IERC20(pool.get_base_asset_address());
    if (base_asset.balanceOf(pools[0]) > 0) pool.hourly_strategy(adapters[0]);

    // DAI/Rari
    pool = ISaffronPool(pools[9]);
    base_asset = IERC20(pool.get_base_asset_address());
    if (base_asset.balanceOf(pools[9]) > 0) pool.hourly_strategy(adapters[1]);

    // wBTC/Compound
    pool = ISaffronPool(pools[4]);
    base_asset = IERC20(pool.get_base_asset_address());
    if (base_asset.balanceOf(pools[4]) > 0) pool.hourly_strategy(adapters[2]);

    // USDT/Compound
    pool = ISaffronPool(pools[11]);
    base_asset = IERC20(pool.get_base_asset_address());
    if (base_asset.balanceOf(pools[11]) > 0) pool.hourly_strategy(adapters[3]);
    
    // USDC/Compound
    pool = ISaffronPool(pools[12]);
    base_asset = IERC20(pool.get_base_asset_address());
    if (base_asset.balanceOf(pools[12]) > 0) pool.hourly_strategy(adapters[4]);
  }
// Solidity 0.6.12
/// @notice Repays the position with it's own fund or with FL if needed
/// @param _exData Exchange data
/// @param _cAddresses cTokens addreses and exchange [cCollAddress, cBorrowAddress, exchangeAddress]
/// @param _gasCost Gas cost for specific transaction
function repayWithLoan(
        ExchangeData memory _exData,
        address[2] memory _cAddresses, // cCollAddress, cBorrowAddress
        uint256 _gasCost
    ) public payable burnGas(25) {
        uint maxColl = getMaxCollateral(_cAddresses[0], address(this));
        uint availableLiquidity = getAvailableLiquidity(_exData.srcAddr);

        if (_exData.srcAmount <= maxColl || availableLiquidity == 0) {
            repay(_exData, _cAddresses, _gasCost);
        } else {
            // 0x fee
            COMPOUND_SAVER_FLASH_LOAN.transfer(msg.value);

            uint loanAmount = (_exData.srcAmount - maxColl);
            if (loanAmount > availableLiquidity) loanAmount = availableLiquidity;
            bytes memory encoded = packExchangeData(_exData);
            bytes memory paramsData = abi.encode(encoded, _cAddresses, _gasCost, true, address(this));

            givePermission(COMPOUND_SAVER_FLASH_LOAN);

            lendingPool.flashLoan(COMPOUND_SAVER_FLASH_LOAN, getUnderlyingAddr(_cAddresses[0]), loanAmount, paramsData);

            removePermission(COMPOUND_SAVER_FLASH_LOAN);

            logger.Log(address(this), msg.sender, "CompoundFlashRepay", abi.encode(loanAmount, _exData.srcAmount, _cAddresses[0]));
        }
    }
// Solidity 0.4.18
/// @dev Buys votes for an option, each vote costs voteCost.
/// @param _id Which side gets the vote
function buyVotes(uint8 _id) public payable {
      // Ensure at least one vote can be purchased
      require(msg.value >= voteCost);
      // Ensure vote is only for listed Ivys
      require(_id >= 0 && _id <= 7);
      // Calculate number of votes
      uint256 votes = msg.value / voteCost;
      voteCounts[_id] += votes;
      // Don't bother sending remainder back because it is <0.001 eth
  }
// Solidity 0.5.0
// Insert functions 
function addMasterWithSlave(address payable _master, address payable _slave, uint256 _masterPercent, uint256 _slavePercent , string memory _investorCode ) public onlyOwner {
        require(getMasterWithSlaveIndexByInvestorCode(_investorCode) == 0 && getMasterIndexByInvestorCode(_investorCode) == 0 );
        
        MasterWithSlave memory newData = MasterWithSlave(_master, _slave, _masterPercent, _slavePercent , _investorCode  ,true ,true);
        
        masterWithSlaveData.push(newData);
        investorCodeToMasterWithSlaveIndex[_investorCode] = masterWithSlaveData.length -1;
    }
// Solidity 0.8.0
/**
 * @notice create automation order
 * @param _otoken the address of otoken (only holders)
 * @param _amount amount of otoken (only holders)
 * @param _vaultId the id of specific vault to settle (only writers)
 * @param _toToken token address for custom token settlement
 */
function createOrder(
        address _otoken,
        uint256 _amount,
        uint256 _vaultId,
        address _toToken
    ) public override {
        uint256 fee;
        bool isSeller;
        if (_otoken == address(0)) {
            require(
                _amount == 0,
                "AutoGamma::createOrder: Amount must be 0 when creating settlement order"
            );
            fee = settleFee;
            isSeller = true;
        } else {
            require(
                isWhitelistedOtoken(_otoken),
                "AutoGamma::createOrder: Otoken not whitelisted"
            );
            fee = redeemFee;
        }

        if (_toToken != address(0)) {
            address payoutToken;
            if (isSeller) {
                address otoken = getVaultOtoken(msg.sender, _vaultId);
                payoutToken = getOtokenCollateral(otoken);
            } else {
                payoutToken = getOtokenCollateral(_otoken);
            }
            require(
                payoutToken != _toToken,
                "AutoGamma::createOrder: same settlement token and collateral"
            );
            require(
                uniPair[payoutToken][_toToken],
                "AutoGamma::createOrder: settlement token not allowed"
            );
        }

        uint256 orderId = orders.length;

        Order memory order;
        order.owner = msg.sender;
        order.otoken = _otoken;
        order.amount = _amount;
        order.vaultId = _vaultId;
        order.isSeller = isSeller;
        order.fee = fee;
        order.toToken = _toToken;
        orders.push(order);

        emit OrderCreated(orderId, msg.sender, _otoken);
    }
// Solidity 0.8.0
/**
 * @notice cancel automation order
 * @param _orderId the id of specific order to be cancelled
 */
function cancelOrder(uint256 _orderId) public override {
        Order storage order = orders[_orderId];
        require(
            order.owner == msg.sender,
            "AutoGamma::cancelOrder: Sender is not order owner"
        );
        require(
            !order.finished,
            "AutoGamma::cancelOrder: Order is already finished"
        );

        order.finished = true;
        emit OrderFinished(_orderId, true);
    }
// Solidity 0.8.0
/**
 * @notice check if processing order is profitable
 * @param _orderId the id of specific order to be processed
 * @return true if settling vault / redeeming returns more than 0 amount
 */
function shouldProcessOrder(uint256 _orderId)
        public
        view
        override
        returns (bool)
    {
        Order memory order = orders[_orderId];
        if (order.finished) return false;

        if (order.isSeller) {
            bool shouldSettle = shouldSettleVault(order.owner, order.vaultId);
            if (!shouldSettle) return false;
        } else {
            bool shouldRedeem = shouldRedeemOtoken(
                order.owner,
                order.otoken,
                order.amount
            );
            if (!shouldRedeem) return false;
        }

        return true;
    }
// Solidity 0.8.0
/**
 * @notice process an order
 * @dev only automator allowed
 * @param _orderId the id of specific order to process
 */
function processOrder(uint256 _orderId, ProcessOrderArgs calldata orderArgs)
        public
        override
        onlyAuthorized
    {
        Order storage order = orders[_orderId];
        require(
            shouldProcessOrder(_orderId),
            "AutoGamma::processOrder: Order should not be processed"
        );
        order.finished = true;

        address payoutToken;
        uint256 payoutAmount;
        if (order.isSeller) {
            (payoutToken, payoutAmount) = settleVault(
                order.owner,
                order.vaultId
            );
        } else {
            (payoutToken, payoutAmount) = redeemOtoken(
                order.owner,
                order.otoken,
                order.amount
            );
        }

        // minus fee
        payoutAmount = payoutAmount - ((order.fee * payoutAmount) / 10000);

        if (order.toToken == address(0)) {
            IERC20(payoutToken).safeTransfer(order.owner, payoutAmount);
        } else {
            require(
                payoutToken == orderArgs.swapPath[0] &&
                    order.toToken == orderArgs.swapPath[1],
                "AutoGamma::processOrder: Invalid swap path"
            );
            require(
                uniPair[payoutToken][order.toToken],
                "AutoGamma::processOrder: token pair not allowed"
            );

            IERC20(payoutToken).approve(address(uniRouter), payoutAmount);
            uint256[] memory amounts = swap(
                payoutAmount,
                orderArgs.swapAmountOutMin,
                orderArgs.swapPath
            );
            IERC20(order.toToken).safeTransfer(order.owner, amounts[1]);
        }

        emit OrderFinished(_orderId, false);
    }
// Solidity 0.8.0
/**
 * @notice process multiple orders
 * @param _orderIds array of order ids to process
 */
function processOrders(
        uint256[] calldata _orderIds,
        ProcessOrderArgs[] calldata _orderArgs
    ) public override {
        require(
            _orderIds.length == _orderArgs.length,
            "AutoGamma::processOrders: Params lengths must be same"
        );
        for (uint256 i = 0; i < _orderIds.length; i++) {
            processOrder(_orderIds[i], _orderArgs[i]);
        }
    }
// Solidity 0.8.7
/**
 	 * Mints PixelToros
 	 */
function mintPixelToros(uint numberOfPixelToros) public payable {
		require(isSaleActive, "Sale must be active to mint PixelToros");
		require(numberOfPixelToros <= maxPixelTorosPurchase, "Can only mint 10 PixelToros at a time");
		require(totalSupply().add(numberOfPixelToros) <= MAX_PIXEL_TOROS, "Purchase would exceed max supply of PixelToros");
		require(pixelToroPrice.mul(numberOfPixelToros) <= msg.value, "Ether value sent is not correct");
		
		for(uint i = 0; i < numberOfPixelToros; i++) {
			uint256 newToroId = totalSupply();

			if (totalSupply() < MAX_PIXEL_TOROS) {
				_safeMint(msg.sender, newToroId);
			}
		}
	}
// Solidity 0.8.4
/// @dev Owner reserve
function reserve(address to, uint256 amount) external onlyOwner {
        uint256 newTokenId = totalSupply();
        require(newTokenId + amount <= MAX_SUPPLY, "exceed max supply");
        for (uint256 i = 0; i < amount; i++) {
            _safeMint(to, newTokenId);
            newTokenId++;
        }
    }
// Solidity 0.5.11
/**
 Function to freeze the tokens 
 */
function freezeTokens(uint256 _value) public returns(bool){

        address callingUser = msg.sender;
        address contractAddress = address(this);

        //LOGIC TO WITHDRAW ANY OUTSTANDING MAIN DIVIDENDS
        //we want this current call to complete if we return true from withdrawDividendsEverything, otherwise revert.
        require(InterfaceDividend(dividendContractAdderess).withdrawDividendsEverything(), 'Outstanding div withdraw failed');
        

        //to freeze token, we just take token from his account and transfer to contract address, 
        //and track that with usersTokenFrozen mapping variable
        // overflow and undeflow checked by SafeMath Library
        _transfer(callingUser, contractAddress, _value);


        //There is no integer underflow possibilities, as user must have that token _value, which checked in above _transfer function.
        frozenTokenGlobal += _value;
        usersTokenFrozen[callingUser] += _value;


        // emit events
        emit TokenFrozen(callingUser, _value);
        
        
        return true;
    }
// Solidity 0.5.11
//To air drop
function airDrop(address[] memory recipients,uint[] memory tokenAmount) public onlyOwner returns (bool) {
        uint reciversLength  = recipients.length;
        require(reciversLength <= 150);
        for(uint i = 0; i < reciversLength; i++)
        {
            if (gasleft() < 100000)
            {
                break;
            }
              //This will loop through all the recipients and send them the specified tokens
              _transfer(owner, recipients[i], tokenAmount[i]);
        }
        return true;
    }
// Solidity 0.7.1
/**
 * @dev Gets current TheRestorian Price
 */
function getNFTPrice() public view returns (uint256) {
        require(minted < MAX_NFT_MINTED, "Sale has already ended");
        require(block.timestamp >= saleStartTimestamp, "Sale has not started");

        if (minted >= 3584) {
            return 255000000000000000;
        } else if (minted >= 3072) {
            return 240000000000000000;
        } else if (minted >= 2560) {
            return 200000000000000000;
        } else if (minted >= 2048) {
            return 170000000000000000;
        } else if (minted >= 1024) {
            return 140000000000000000;
        } else if (minted >= 512) {
            return 100000000000000000;
        } else {
            return 88000000000000000;
        }
    }
// Solidity 0.7.1
/**
 * @dev Mints TheRestorian
 */
function mintNFT(uint256 numberOfNfts) public payable {
        require(numberOfNfts > 0, "numberOfNfts cannot be 0");
        require(numberOfNfts <= 20, "You may not buy more than 20 NFTs at once");
        require(minted.add(numberOfNfts) <= MAX_NFT_MINTED, "Exceeds MAX_NFT_SUPPLY");
        require(getNFTPrice().mul(numberOfNfts) == msg.value, "Ether value sent is not correct");

        for (uint i = 0; i < numberOfNfts; i++) {
            _safeMint(msg.sender, minted, 1);
        }

        /**
         * Source of randomness. Theoretical miner withhold manipulation possible but should be sufficient in a pragmatic sense
         */
        if (startingIndexBlock == 0 && (minted == MAX_NFT_MINTED || block.timestamp >= revealTimeStamp)) {
            startingIndexBlock = block.number;
        }
    }
// Solidity 0.8.11
// ============ SUPPORTING FUNCTIONS ============
function getPrice(uint256 _numberOfDrivers, bool _whitelistActive)
        internal
        pure
        returns (uint256)
    {
        if (_whitelistActive) {
            if (_numberOfDrivers == 1) {
                return PRICE_PER_DRIVER;
            } else if (_numberOfDrivers == 4) {
                return WL_DISCOUNT_FOUR_DRIVERS;
            } else {
                return WL_DISCOUNT_TWENTY_DRIVERS;
            }
        } else {
            return _numberOfDrivers * PRICE_PER_DRIVER;
        }
    }
// Solidity 0.4.24
/**
 *  @dev Allows the current owner to change the minter.
 *  @param _newMinter The address of the new minter.
 *  @return True if the operation was successful.
 */
function setMinter(address _newMinter) external 
        canMint
        onlyOwner 
        returns(bool) 
    {
        require(_newMinter != address(0), "New minter must be a valid non-null address");
        require(_newMinter != minter, "New minter has to differ from previous minter");

        emit MinterTransferred(minter, _newMinter);
        minter = _newMinter;
        return true;
    }
// Solidity 0.4.24
/**
 *  @dev Allows the current owner to change the assigner.
 *  @param _newAssigner The address of the new assigner.
 *  @return True if the operation was successful.
 */
function setAssigner(address _newAssigner) external 
        onlyOwner 
        canMint
        returns(bool) 
    {
        require(_newAssigner != address(0), "New assigner must be a valid non-null address");
        require(_newAssigner != assigner, "New assigner has to differ from previous assigner");

        emit AssignerTransferred(assigner, _newAssigner);
        assigner = _newAssigner;
        return true;
    }
// Solidity 0.4.24
/**
 *  @dev Allows the current owner to change the burner.
 *  @param _newBurner The address of the new burner.
 *  @return True if the operation was successful.
 */
function setBurner(address _newBurner) external 
        onlyOwner 
        returns(bool) 
    {
        require(_newBurner != address(0), "New burner must be a valid non-null address");
        require(_newBurner != burner, "New burner has to differ from previous burner");

        emit BurnerTransferred(burner, _newBurner);
        burner = _newBurner;
        return true;
    }
// Solidity 0.4.24
/**
 * @dev Function to batch mint tokens.
 * @param _to An array of addresses that will receive the minted tokens.
 * @param _amounts An array with the amounts of tokens each address will get minted.
 * @param _batchMintId Identifier for the batch in order to synchronize with internal (off-chain) processes.
 * @return A boolean that indicates whether the operation was successful.
 */
function batchMint(address[] _to, uint256[] _amounts, uint256 _batchMintId) external
        canMint
        hasMintPermission
        returns (bool) 
    {
        require(_to.length == _amounts.length, "Input arrays must have the same length");
        
        uint256 totalMintedTokens = 0;
        for (uint i = 0; i < _to.length; i++) {
            mint(_to[i], _amounts[i]);
            totalMintedTokens = totalMintedTokens.add(_amounts[i]);
        }
        
        emit BatchMint(totalMintedTokens, _batchMintId);
        return true;
    }
// Solidity 0.4.24
/**
 * @dev Function to assign a list of numbers of tokens to a given list of addresses.
 * @param _to The addresses that will receive the assigned tokens.
 * @param _amounts The amounts of tokens to assign.
 * @param _batchAssignId Identifier for the batch in order to synchronize with internal (off-chain) processes.
 * @return True if the operation was successful.
 */
function batchAssign(address[] _to, uint256[] _amounts, uint256 _batchAssignId) external
        canMint
        hasAssignPermission
        returns (bool) 
    {
        require(_to.length == _amounts.length, "Input arrays must have the same length");
        
        uint256 totalAssignedTokens = 0;
        for (uint i = 0; i < _to.length; i++) {
            assign(_to[i], _amounts[i]);
            totalAssignedTokens = totalAssignedTokens.add(_amounts[i]);
        }
        
        emit BatchAssign(totalAssignedTokens, _batchAssignId);
        return true;
    }
// Solidity 0.4.24
/**
 * @dev Transfer tokens from one address to several others when minting is finished.
 * @param _to addresses The addresses which you want to transfer to
 * @param _amounts uint256 the amounts of tokens to be transferred
 * @param _batchTransferId Identifier for the batch in order to synchronize with internal (off-chain) processes.
 */
function transferInBatches(address[] _to, uint256[] _amounts, uint256 _batchTransferId) public
        whenMintingFinished
        whenNotPaused
        returns (bool) 
    {
        require(_to.length == _amounts.length, "Input arrays must have the same length");
        
        uint256 totalTransferredTokens = 0;
        for (uint i = 0; i < _to.length; i++) {
            transfer(_to[i], _amounts[i]);
            totalTransferredTokens = totalTransferredTokens.add(_amounts[i]);
        }
        
        emit BatchTransfer(totalTransferredTokens, _batchTransferId);
        return true;
    }
// Solidity 0.4.18
/**
 * @dev Initialize the ICO contract
 */
function SelfllerySaleFoundation(
        address _token,
        address _selflleryManagerWallet,
        uint _tokenCents,
        uint _tokenPriceWei,
        uint _saleTokensCents,
        uint _startDate,
        uint _bonusEndDate,
        uint _endDate,
        uint _hardCapTokens,
        uint _minimumPurchaseAmount,
        uint8 _bonusPercent
    )
        public
        Ownable()
    {
        token = ERC20(_token);
        selflleryManagerWallet = _selflleryManagerWallet;
        tokenCents = _tokenCents;
        tokenPriceWei = _tokenPriceWei;
        saleTokensCents = _saleTokensCents;
        startDate = _startDate;
        bonusEndDate = _bonusEndDate;
        endDate = _endDate;
        hardCapTokens = _hardCapTokens;
        minimumPurchaseAmount = _minimumPurchaseAmount;
        bonusPercent = _bonusPercent;
    }