lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.6
/**
 * @dev Set a token with a specific crew collection
 * @param _crewId The ERC721 tokenID for the crew member
 * @param _collId The set ID to assign the crew member to
 * @param _mod An optional modifier ranging from 0 (default) to 10,000
 */
function setToken(uint _crewId, uint _collId, uint _mod) external onlyManagers {
    require(address(_generators[_collId]) != address(0), "CrewFeatures: collection must be defined");
    _crewCollection[_crewId] = _collId;

    if (_mod > 0) {
      _crewModifiers[_crewId] = _mod;
    }
  }
// Solidity 0.5.7
// ============ Only-Solo Functions ============
function getTradeCost(
        uint256 inputMarketId,
        uint256 outputMarketId,
        Account.Info memory /* makerAccount */,
        Account.Info memory takerAccount,
        Types.Par memory oldInputPar,
        Types.Par memory newInputPar,
        Types.Wei memory inputWei,
        bytes memory /* data */
    )
        public
        /* view */
        returns (Types.AssetAmount memory)
    {
        Require.that(
            g_migrators[takerAccount.owner],
            FILE,
            "Migrator not approved",
            takerAccount.owner
        );

        Require.that(
            inputMarketId == SAI_MARKET && outputMarketId == DAI_MARKET,
            FILE,
            "Invalid markets"
        );

        // require that SAI amount is getting smaller (closer to zero)
        if (oldInputPar.isPositive()) {
            Require.that(
                inputWei.isNegative(),
                FILE,
                "inputWei must be negative"
            );
            Require.that(
                !newInputPar.isNegative(),
                FILE,
                "newInputPar cannot be negative"
            );
        } else if (oldInputPar.isNegative()) {
            Require.that(
                inputWei.isPositive(),
                FILE,
                "inputWei must be positive"
            );
            Require.that(
                !newInputPar.isPositive(),
                FILE,
                "newInputPar cannot be positive"
            );
        } else {
            Require.that(
                inputWei.isZero() && newInputPar.isZero(),
                FILE,
                "inputWei must be zero"
            );
        }

        /* return the exact opposite amount of SAI in DAI */
        return Types.AssetAmount ({
            sign: !inputWei.sign,
            denomination: Types.AssetDenomination.Wei,
            ref: Types.AssetReference.Delta,
            value: inputWei.value
        });
    }
// Solidity 0.8.7
// concatenate the baseURI with the tokenId
function tokenURI(uint256 tokenId) public view virtual override returns(string memory) {
        require(_exists(tokenId), "token does not exist");

        if (tokenIdToFrozenForArt[tokenId]) {
            string memory lockedBaseURI = _lockedBaseURI();
            return bytes(lockedBaseURI).length > 0 ? string(abi.encodePacked(lockedBaseURI, Strings.toString(tokenIdToMetadataId[tokenId]))) : "";
        }

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, Strings.toString(tokenIdToMetadataId[tokenId]))) : "";
    }
// Solidity 0.8.7
// Used to request a 3D body for your voxmon
// Freezes transfers re-rolling a voxmon
function request3DArt(uint256 tokenId) external {
        require(block.timestamp >= artStartTime, "you cannot freeze your Voxmon yet");
        require(ownerOf(tokenId) == msg.sender, "you must own this token to request Art");
        require(tokenIdToFrozenForArt[tokenId] == false, "art has already been requested for that Voxmon");
        tokenIdToFrozenForArt[tokenId] = true;

        emit artRequestedEvent(msg.sender, tokenId);
    }
// Solidity 0.8.7
// Mint a Voxmon
// Cost is 0.07 ether
function mint(address recipient) payable public returns (uint256) {
        require(_isTokenAvailable(), "max live supply reached, to get a new Voxmon you\'ll need to reroll an old one");
        require(msg.value >= MINT_COST, "not enough ether, minting costs 0.07 ether");
        require(block.timestamp >= startingTime, "public mint hasn\'t started yet");

        _tokensMinted.increment();
        
        uint256 newTokenId = _tokensMinted.current();
        uint256 metadataId = _tokensMinted.current() + _tokensRerolled.current();
        
        _mint(recipient, newTokenId);
        tokenIdToMetadataId[newTokenId] = metadataId;

        emit mintEvent(recipient, newTokenId, metadataId);

        return newTokenId;
    }
// Solidity 0.8.7
// Mint multiple Voxmon
// Cost is 0.07 ether per Voxmon
function mint(address recipient, uint256 numberToMint) payable public returns (uint256[] memory) {
        require(numberToMint > 0);
        require(numberToMint <= 10, "max 10 voxmons per transaction");
        require(msg.value >= MINT_COST * numberToMint);

        uint256[] memory tokenIdsMinted = new uint256[](numberToMint);

        for(uint i = 0; i < numberToMint; i++) {
            tokenIdsMinted[i] = mint(recipient);
        }

        return tokenIdsMinted;
    }
// Solidity 0.8.7
// Mint a free Voxmon
function preReleaseMint(address recipient) public returns (uint256) {
        require(remainingPreReleaseMints[msg.sender] > 0, "you have 0 remaining pre-release mints");
        remainingPreReleaseMints[msg.sender] = remainingPreReleaseMints[msg.sender] - 1;

        require(_isTokenAvailable(), "max live supply reached, to get a new Voxmon you\'ll need to reroll an old one");

        _tokensMinted.increment();
        
        uint256 newTokenId = _tokensMinted.current();
        uint256 metadataId = _tokensMinted.current() + _tokensRerolled.current();
        
        _mint(recipient, newTokenId);
        tokenIdToMetadataId[newTokenId] = metadataId;

        emit mintEvent(recipient, newTokenId, metadataId);

        return newTokenId;
    }
// Solidity 0.8.7
// Mint multiple free Voxmon
function preReleaseMint(address recipient, uint256 numberToMint) public returns (uint256[] memory) {
        require(remainingPreReleaseMints[msg.sender] >= numberToMint, "You don\'t have enough remaining pre-release mints");

        uint256[] memory tokenIdsMinted = new uint256[](numberToMint);

        for(uint i = 0; i < numberToMint; i++) {
            tokenIdsMinted[i] = preReleaseMint(recipient);
        }

        return tokenIdsMinted;
    }
// Solidity 0.8.7
// Re-Roll a Voxmon
// Cost is 0.01 ether 
function reroll(uint256 tokenId) payable public returns (uint256) {
        require(ownerOf(tokenId) == msg.sender, "you must own this token to reroll");
        require(msg.value >= REROLL_COST, "not enough ether, rerolling costs 0.03 ether");
        require(tokenIdToFrozenForArt[tokenId] == false, "this token is frozen");
        
        _tokensRerolled.increment();
        uint256 newMetadataId = _tokensMinted.current() + _tokensRerolled.current();

        tokenIdToMetadataId[tokenId] = newMetadataId;
        
        emit rerollEvent(msg.sender, tokenId, newMetadataId);

        return newMetadataId;
    }
// Solidity 0.8.2
/**
 * @dev For each boosted vault, poke all the over boosted accounts.
 * @param _vaultAccounts     An array of PokeVaultAccounts structs
 */
function poke(PokeVaultAccounts[] memory _vaultAccounts) external {
        uint vaultCount = _vaultAccounts.length;
        for(uint i = 0; i < vaultCount; i++) {
            PokeVaultAccounts memory vaultAccounts = _vaultAccounts[i];
            address boostVaultAddress = vaultAccounts.boostVault;
            require(boostVaultAddress != address(0), "blank vault address");
            IBoostedVaultWithLockup boostVault = IBoostedVaultWithLockup(boostVaultAddress);

            uint accountsLength = vaultAccounts.accounts.length;
            for(uint j = 0; j < accountsLength; j++) {
                address accountAddress = vaultAccounts.accounts[j];
                require(accountAddress != address(0), "blank address");
                boostVault.pokeBoost(accountAddress);
            }
        }
    }
// Solidity 0.8.12
// public sale
function safeMint(uint8 count) external payable {
        require(saleState == 3, "public sale is not begun");
        require(count > 0 && count <= 3, "invalid count");

        uint256 price = tokenPrice * count;
        require(msg.value >= price, "insufficient value");
        payable(owner()).transfer(price);
        payable(_msgSender()).transfer(msg.value - price);

        require(balanceOf(_msgSender()) < 9, "public sale max total buy reached");

        for (uint256 i = 0; i < count; i++) {
            _safeMint(_msgSender(), _tokenId++);
        }
    }
// Solidity 0.8.9
// burn tokens, allowing sent ETH to be converted according to gweiPerGoof
function burnTokens(uint256 amount) private {
        if (msg.value > 0 && gweiPerGoof > 0) {
            uint256 converted = (msg.value * 1 gwei) / gweiPerGoof;
            if (converted >= amount) {
                amount = 0;
            } else {
                amount -= converted;
            }
        }
        if (amount > 0) {
            _burn(msg.sender, amount);
        }
    }
// Solidity 0.5.0
// This is the function that will be called postLoan
// i.e. Encode the logic to handle your flashloaned funds here
function callFunction(
        address sender,
        Account.Info memory account,
        bytes memory data
    ) public {
        MyCustomData memory mcd = abi.decode(data, (MyCustomData));

        IERC20 token1 = IERC20(mcd.loanedToken);
        IERC20 token2 = IERC20(mcd.otherToken);

        // STEP 1 - TRADE LOANED TOKEN TO OTHER TOKEN ////////////////////////////////

        token1.approve(OneSplitAddress,0);
        token1.approve(OneSplitAddress,mcd.repayAmount-2);

        (uint256 returnAmount1, uint256[] memory distribution1) = IOneSplit(
            OneSplitAddress
        ).getExpectedReturn(
            token1,
            token2,
            mcd.repayAmount-2,
            10,
            0
        );

        uint256 balanceBefore1 = token2.balanceOf(address(this));

        IOneSplit(OneSplitAddress).swap(
            token1,
            token2,
            mcd.repayAmount-2,
            returnAmount1,
            distribution1,
            0
        );

        uint256 balanceAfter1 = token2.balanceOf(address(this));

        uint256 result1 = balanceAfter1 - balanceBefore1;

        // STEP 2 - TRADE OTHER TOKEN BACK TO LOANED TOKEN ///////////////////////////

        token2.approve(OneSplitAddress,0);
        token2.approve(OneSplitAddress,result1);

        (uint256 returnAmount2, uint256[] memory distribution2) = IOneSplit(
            OneSplitAddress
        ).getExpectedReturn(
            token2,
            token1,
            result1,
            10,
            0
        );

        uint256 balanceBefore2 = token1.balanceOf(address(this));

        IOneSplit(OneSplitAddress).swap(
            token2,
            token1,
            result1,
            returnAmount2,
            distribution2,
            0
        );

        uint256 balanceAfter2 = token1.balanceOf(address(this));

        uint256 result2 = balanceAfter2 - balanceBefore2;

        // STEP 3 - CALCULATE PROFIT /////////////////////////////////////////////////

        require(mcd.repayAmount < (result2-mcd.gasFee), "No profit.");
    }
// Solidity 0.4.21
/**
 * @dev transfer token for a specified address and forward the parameters to token recipient if any
 * @param _to The address to transfer to.
 * @param _value The amount to be transferred.
 * @param _param1 Parameter 1 for the token recipient
 * @param _param2 Parameter 2 for the token recipient
 * @param _param3 Parameter 3 for the token recipient
 */
function transferWithParams(address _to, uint256 _value, uint256 _param1, uint256 _param2, uint256 _param3) onlyPayloadSize(5 * 32) external returns (bool) {
        require(_to != address(0));
        require(_value <= balances[msg.sender]);

        // SafeMath.sub will throw if there is not enough balance.
        balances[msg.sender] = balances[msg.sender].sub(_value);
        balances[_to] = balances[_to].add(_value);
        emit Transfer(msg.sender, _to, _value);

        _invokeTokenRecipient(msg.sender, _to, _value, _param1, _param2, _param3);

        return true;
    }
// Solidity 0.7.5
/**
 * @dev Buyouts a position's collateral
 * @param asset The address of the main collateral token of a position
 * @param user The owner of a position
 **/
function buyout(address asset, address user) public nonReentrant {
        require(vault.liquidationBlock(asset, user) != 0, "Unit Protocol: LIQUIDATION_NOT_TRIGGERED");
        uint startingPrice = vault.liquidationPrice(asset, user);
        uint blocksPast = block.number.sub(vault.liquidationBlock(asset, user));
        uint devaluationPeriod = vaultManagerParameters.devaluationPeriod(asset);
        uint debt = vault.getTotalDebt(asset, user);
        uint penalty = debt.mul(vault.liquidationFee(asset, user)).div(DENOMINATOR_1E2);
        uint mainAssetInPosition = vault.collaterals(asset, user);
        uint colInPosition = vault.colToken(asset, user);

        uint mainToLiquidator;
        uint colToLiquidator;
        uint mainToOwner;
        uint colToOwner;
        uint repayment;

        (mainToLiquidator, colToLiquidator, mainToOwner, colToOwner, repayment) = _calcLiquidationParams(
            devaluationPeriod,
            blocksPast,
            startingPrice,
            debt.add(penalty),
            mainAssetInPosition,
            colInPosition
        );

        _liquidate(
            asset,
            user,
            mainToLiquidator,
            colToLiquidator,
            mainToOwner,
            colToOwner,
            repayment,
            penalty
        );
    }
// Solidity 0.5.8
/**
 * @notice The aim is to create a conditional payment and find someone to buy the counter position
 *
 * Parameters to forward to master contract:
 * @param long .. Decide if you want to be in the long or short position of your contract.
 * @param dueDate .. Set a due date of your contract. Make sure this is supported by us. Use OD.exchange to avoid conflicts here.
 * @param strikePrice .. Choose a strike price which will be used at due date for calculation of your payout. Make sure that the format is correct. Use OD.exchange to avoid mistakes.
 */
function createContractWithBounty (
        bool long,
        uint256 dueDate,
        uint256 strikePrice
    )
        payable
        public
    {
        // New conditional payment must be created before deadline exceeded
        require(now < deadline);

        // Only once per creator address
        require(!bountyPermission[msg.sender]);
        bountyPermission[msg.sender] = true;

        // Only first customers can get bounty
        numberOfGivenBounties += 1;
        require(numberOfGivenBounties <= maxNumberOfBounties);

        // Create new conditional payment in master contract:
        Master master = Master(masterAddress);
        address newConditionalPayment = master.createConditionalPayment.value(msg.value)(
            msg.sender,
            long,
            dueDate,
            strikePrice
        );

        // Attribute conditional payment to creator
        creatorsConditionalPaymentAddress[msg.sender] = newConditionalPayment;
    }
// Solidity 0.5.8
/**
 *  @notice Withdraw the bounty after creation of conditional payment and finding counter party
 */
function withdrawBounty ()
        public
    {
        // Creator needs to have permission
        require(bountyPermission[msg.sender]);
        bountyPermission[msg.sender] = false;

        // Only one withdraw per creator
        require(!gotBounty[msg.sender]);
        gotBounty[msg.sender] = true;

        ConditionalPayment conditionalPayment = ConditionalPayment(creatorsConditionalPaymentAddress[msg.sender]);

        // Conditional payment needs to have at least one counter party
        require(conditionalPayment.countCounterparties() > 0);

        msg.sender.transfer(bounty);
    }
// Solidity 0.5.8
/**
 * @notice Owner can withdraw bounty permission if creators did not succeed to find a taker before the deadline
 */
function withdrawPermission (address unsuccessfulCreator)
        public
        onlyByOwner
        deadlineExceeded
    {
        // Unsuccessful criterium
        ConditionalPayment conditionalPayment = ConditionalPayment(creatorsConditionalPaymentAddress[unsuccessfulCreator]);
        require(conditionalPayment.countCounterparties() == 0);

        // Disqualify creator from bounty
        bountyPermission[unsuccessfulCreator] = false;
        creatorsConditionalPaymentAddress[msg.sender] = 0x0000000000000000000000000000000000000000;

        numberOfGivenBounties -= 1;
    }
// Solidity 0.8.9
//Transfer functionality///
//transfer function, every transfer runs through this function
function _transfer(address sender, address recipient, uint256 amount) private{
        require(sender != address(0), "Transfer from zero");
        require(recipient != address(0), "Transfer to zero");
        
        //Manually Excluded adresses are transfering tax and lock free
        bool isExcluded = (_excluded.contains(sender) || _excluded.contains(recipient));
        
        //Transactions from and to the contract are always tax and lock free
        bool isContractTransfer=(sender==address(this) || recipient==address(this));
        
        //transfers between uniswapV2Router and uniswapV2Pair are tax and lock free
        address uniswapV2Router=address(_uniswapV2Router);
        bool isLiquidityTransfer = ((sender == _uniswapV2PairAddress && recipient == uniswapV2Router) 
        || (recipient == _uniswapV2PairAddress && sender == uniswapV2Router));

        //differentiate between buy/sell/transfer to apply different taxes/restrictions
        bool isBuy=sender==_uniswapV2PairAddress|| sender == uniswapV2Router;
        bool isSell=recipient==_uniswapV2PairAddress|| recipient == uniswapV2Router;

        //Pick transfer
        if(isContractTransfer || isLiquidityTransfer || isExcluded){
            _feelessTransfer(sender, recipient, amount);
        }
        else{ 
            //once trading is enabled, it can't be turned off again
            require(tradingEnabled,"trading not yet enabled");
            _taxedTransfer(sender,recipient,amount,isBuy,isSell);
        }
    }
// Solidity 0.8.9
//Feeless transfer only transfers and autostakes
function _feelessTransfer(address sender, address recipient, uint256 amount) private{
        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "Transfer exceeds balance");
        //Removes token and handles staking
        _removeToken(sender,amount);
        //Adds token and handles staking
        _addToken(recipient, amount);
        
        emit Transfer(sender,recipient,amount);

    }
// Solidity 0.8.9
//Total shares equals circulating supply minus excluded Balances
function _getTotalShares() public view returns (uint256){
        uint256 shares=_circulatingSupply;
        //substracts all excluded from shares, excluded list is limited to 30
        // to avoid creating a Honeypot through OutOfGas exeption
        for(uint i=0; i<_excludedFromStaking.length(); i++){
            shares-=_balances[_excludedFromStaking.at(i)];
        }
        return shares;
    }
// Solidity 0.8.9
//adds Token to balances, adds new ETH to the toBePaid mapping and resets staking
function _addToken(address addr, uint256 amount) private {
        //the amount of token after transfer
        uint256 newAmount=_balances[addr]+amount;
        
        if(isExcludedFromStaking(addr)){
           _balances[addr]=newAmount;
           return;
        }
        
        //gets the payout before the change
        uint256 payment=_newDividentsOf(addr);
        //resets dividents to 0 for newAmount
        alreadyPaidShares[addr] = profitPerShare * newAmount;
        //adds dividents to the toBePaid mapping
        toBePaid[addr]+=payment; 
        //sets newBalance
        _balances[addr]=newAmount;
    }
// Solidity 0.8.7
/**
 * This function can help owner to add larger than one addresses cap.
 */
function setBuyerCapBatch(address[] memory buyers, uint256[] memory amount) public onlyOwner onlyOpened {
        require(buyers.length == amount.length, "Presale: buyers length and amount length not match");
        require(buyers.length <= 100, "Presale: the max size of batch is 100.");
        
        for(uint256 i = 0; i < buyers.length; i ++) {
            _buyers_[buyers[i]].cap = amount[i];
        }
    }
// Solidity 0.8.9
//gets the not dividents of a staker that aren't in the toBePaid mapping 
//returns wrong value for excluded accounts
function _newDividentsOf(address staker) private view returns (uint256) {
        uint256 fullPayout = profitPerShare * _balances[staker];
        // if theres an overflow for some unexpected reason, return 0, instead of 
        // an exeption to still make trades possible
        if(fullPayout<alreadyPaidShares[staker]) return 0;
        return (fullPayout - alreadyPaidShares[staker]) / DistributionMultiplier;
    }
// Solidity 0.8.9
//distributes ETH between marketing share and dividends 
function _distributeStake(uint256 ETHAmount) private {
        // Deduct marketing Tax
        uint256 marketingSplit = (ETHAmount * StakingShare) / 100;
        uint256 amount = ETHAmount - marketingSplit;

       marketingBalance+=marketingSplit;
       
        if (amount > 0) {
            totalStakingReward += amount;
            uint256 totalShares=_getTotalShares();
            //when there are 0 shares, add everything to marketing budget
            if (totalShares == 0) {
                marketingBalance += amount;
            }else{
                //Increases profit per share based on current total shares
                profitPerShare += ((amount * DistributionMultiplier) / totalShares);
            }
        }
    }
// Solidity 0.8.9
//withdraws all dividents of address
function claimBTC(address addr) private{
        require(!_isWithdrawing);
        _isWithdrawing=true;
        uint256 amount;
        if(isExcludedFromStaking(addr)){
            //if excluded just withdraw remaining toBePaid ETH
            amount=toBePaid[addr];
            toBePaid[addr]=0;
        }
        else{
            uint256 newAmount=_newDividentsOf(addr);
            //sets payout mapping to current amount
            alreadyPaidShares[addr] = profitPerShare * _balances[addr];
            //the amount to be paid 
            amount=toBePaid[addr]+newAmount;
            toBePaid[addr]=0;
        }
        if(amount==0){//no withdraw if 0 amount
            _isWithdrawing=false;
            return;
        }
        totalPayouts+=amount;
        address[] memory path = new address[](2);
        path[0] = _uniswapV2Router.WETH(); //WETH
        path[1] = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;  //WETH

        _uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}(
        0,
        path,
        addr,
        block.timestamp);
        
        emit OnWithdrawBTC(amount, addr);
        _isWithdrawing=false;
    }