lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.4.24
// ----------------------------------------------------------------------------
// Modifier
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Internal Function
// ----------------------------------------------------------------------------
function _brokerFeeDistribute(uint _price, uint _type, uint _brokerId, uint _subBrokerId) internal {
        address vipBroker = getBrokerAddress(_brokerId, 0);
        address broker = getBrokerAddress(_brokerId, _subBrokerId);
        require(vipBroker != address(0) && broker != address(0));
        uint totalShare = _price*rewardPercent[_type]/100;
        BrokerIncoming[vipBroker] = BrokerIncoming[vipBroker] + totalShare*15/100;
        BrokerIncoming[broker] = BrokerIncoming[broker] + totalShare*85/100;
        
        emit BrokerFeeDistrubution(_brokerId, vipBroker, totalShare*15/100, _subBrokerId, broker, totalShare*85/100);
    }
// Solidity 0.4.24
// ----------------------------------------------------------------------------
// Public Function
// ----------------------------------------------------------------------------
function registerBroker() public payable returns (uint) {
        require(vipBrokerNum > 0);
        require(msg.value >= vipBrokerFee);
        require(UserToIfBroker[msg.sender] == false);
        UserToIfBroker[msg.sender] = true;
        vipBrokerNum--;
        uint brokerId = 1000 - vipBrokerNum;
        BrokerIdToBrokers[brokerId].push(msg.sender);
        BrokerIdToSpots[brokerId] = subBrokerNum;
        emit BrokerRegistered(brokerId, msg.sender);
        return brokerId;
    }
// Solidity 0.8.6
/**
 * @notice Get reward schedule entry
 * @param index Index location
 * @return Rewards schedule entry
 */
function rewardScheduleEntry(uint256 index) public override view returns (RewardScheduleEntry memory) {
        RewardScheduleEntry memory entry;
        uint256 start = index * REWARD_SCHEDULE_ENTRY_LENGTH;
        entry.startTime = _rewardSchedule.toUint64(start);
        entry.epochDuration = _rewardSchedule.toUint64(start + 8);
        entry.rewardsPerEpoch = _rewardSchedule.toUint128(start + 16);
        return entry;
    }
// Solidity 0.4.21
// Get all token IDs of address
function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) 
    {
        uint256 tokenCount = balanceOf(_owner);
        
        if (tokenCount == 0) 
        {
            // Return an empty array
            return new uint256[](0);
        } else 
        {
            uint256[] memory result = new uint256[](tokenCount);
            uint256 resultIndex = 0;
            
            // We count on the fact that all cats have IDs starting at 1 and increasing
            // sequentially up to the totalCat count.
            uint256 tokenId;
            
            for (tokenId = 0; tokenId < packages.length; tokenId++) 
            {
                if (tokenOwner[tokenId] == _owner) 
                {
                    result[resultIndex] = tokenId;
                    resultIndex++;
                }
            }
        
            return result;
        }
    }
// Solidity 0.4.21
// ETH handler
function BuyPresalePackage(uint8 packageId, address referral) external payable
    {
        require(isActive);
        require(packageId < presalePackLimit.length);
        require(msg.sender != referral);
        require(presalePackLimit[packageId] > presalePackSold[packageId]);

        require(presaleTokenContract != RigCraftPresalePackageToken(address(0)));

        // check money
        require(msg.value >= presalePackagePrice[packageId]);
        
        presalePackSold[packageId]++;
        
        totalFundsSoFar += msg.value;
        
        presaleTokenContract.CreateToken(msg.sender, packageId, presalePackSold[packageId]);
        
        if(referral != address(0))
        {
            if(addressRefferedCount[referral] == 0)
            {
                referralAddressIndex.length += 1;
                referralAddressIndex[referralAddressIndex.length-1] = referral;
            }
            addressRefferedCount[referral] += 1;
            addressRefferredSpending[referral] += msg.value;
        }
    }
// Solidity 0.7.6
/**
 * @dev Update the treasury fee for this contract
 * defaults at 25% of taxFee, It can be set on only by YZY governance.
 * Note contract owner is meant to be a governance contract allowing YZY governance consensus
 */
function changeFeeInfo(
        uint16 treasuryFee,
        uint16 rewardFee,
        uint16 lotteryFee,
        uint16 swapRewardFee,
        uint16 burnFee
    ) external onlyOwner {
        _treasuryFee = treasuryFee;
        _rewardFee = rewardFee;
        _lotteryFee = lotteryFee;
        _swapRewardFee = swapRewardFee;
        _burnFee = burnFee;

        emit ChangedFeeInfo(_msgSender(), treasuryFee, rewardFee, lotteryFee, swapRewardFee, burnFee);
    }
// Solidity 0.7.6
// Get YZY reward per block
function getYzyPerBlockForYzyReward() public view returns (uint256) {
        uint256 multiplier = getMultiplier(_startBlock, block.number);
        
        if (multiplier == 0 || getTotalStakedAmount() == 0) {
            return 0;
        } else if (multiplier <= _firstRewardPeriod) {
            return _firstRewardAmount
                    .mul(uint256(_allocPointForYZYReward))
                    .mul(1 ether)
                    .div(getTotalStakedAmount())
                    .div(_firstRewardPeriod)
                    .div(10000);
        } else if (multiplier > _firstRewardPeriod && multiplier <= _secondRewardPeriod) {
            return _secondRewardAmount
                    .mul(uint256(_allocPointForYZYReward))
                    .mul(1 ether)
                    .div(getTotalStakedAmount())
                    .div(_secondRewardPeriod)
                    .div(10000);
        } else {
            return _collectedAmountForStakers.mul(1 ether).div(getTotalStakedAmount()).div(multiplier);
        }
    }
// Solidity 0.7.6
/**
 * @dev Stake LP Token to get YZY-ETH LP tokens
 */
function stakeLPToken(uint256 amount) external returns (bool) {
        require(!isContract(_msgSender()), "Vault: Could not be contract.");

        _yzyETHV2Pair.transferFrom(_msgSender(), address(this), amount);

        StakerInfo storage staker = _stakers[_msgSender()];

        if (staker.stakedAmount > 0) {
            claimYzyReward();
            claimSwapReward();
        } else {
            staker.lastClimedBlockForYzyReward = block.number;
            staker.lastClimedBlockForSwapReward = block.number;
        }

        staker.stakedAmount = staker.stakedAmount.add(amount);
        staker.lockedTo = _lockPeriod.add(block.timestamp);

        emit Staked(_msgSender(), amount);

        return _sendLotteryAmount();
    }
// Solidity 0.7.6
/**
 * @dev Unstake staked YZY-ETH LP tokens
 */
function unstake(uint256 amount) external returns (bool) {
        require(!isContract(_msgSender()), "Vault: Could not be contract.");

        StakerInfo storage staker = _stakers[_msgSender()];

        require(
            staker.stakedAmount > 0 &&
            amount > 0 &&
            amount <= staker.stakedAmount,
            "Vault: Invalid amount to unstake."
        );

        claimYzyReward();

        claimSwapReward();

        if (_enabledLock &&
            _stakers[_msgSender()].lockedTo > 0 &&
            block.timestamp < _stakers[_msgSender()].lockedTo
        ) {
            uint256 feeAmount = amount.mul(uint256(_earlyUnstakeFee)).div(10000);
            _yzyETHV2Pair.transfer(_daoTreasury, feeAmount); 
            _yzyETHV2Pair.transfer(_msgSender(), amount.sub(feeAmount));
        } else {
           _yzyETHV2Pair.transfer(_msgSender(), amount);
        }

        staker.stakedAmount = staker.stakedAmount.sub(amount);

        emit Unstaked(_msgSender(), amount);
        
        return _sendLotteryAmount();
    }
// Solidity 0.7.6
/**
 * @dev internal function to send lottery rewards
 */
function _sendLotteryAmount() internal returns (bool) {
        if (!_enabledLottery || _lotteryAmount <= 0)
            return false;
        
        uint256 usdcReserve = 0;
        uint256 ethReserve1 = 0;
        uint256 yzyReserve = 0;
        uint256 ethReserve2 = 0;
        address token0 = _usdcETHV2Pair.token0();

        if (token0 == address(_weth)){
            (ethReserve1, usdcReserve, ) = _usdcETHV2Pair.getReserves();
        } else {
            (usdcReserve, ethReserve1, ) = _usdcETHV2Pair.getReserves();
        }

        token0 = _yzyETHV2Pair.token0();

        if (token0 == address(_weth)){
            (ethReserve2, yzyReserve, ) = _yzyETHV2Pair.getReserves();
        } else {
            (yzyReserve, ethReserve2, ) = _yzyETHV2Pair.getReserves();
        }

        if (ethReserve1 <= 0 || yzyReserve <= 0)
            return false;

        uint256 yzyPrice = usdcReserve.mul(1 ether).div(ethReserve1).mul(ethReserve2).div(yzyReserve);
        uint256 lotteryValue = yzyPrice.mul(_lotteryAmount).div(1 ether);

        if (lotteryValue > 0 && lotteryValue >= _lotteryLimit) {
            uint256 amount = _lotteryLimit.mul(1 ether).div(yzyPrice);

            if (amount > _lotteryAmount)
                amount = _lotteryAmount;

            _yzy.transfer(_msgSender(), amount);
            _lotteryAmount = _lotteryAmount.sub(amount);
            _lotteryPaidOut = _lotteryPaidOut.add(amount);

            emit SentLotteryAmount(_msgSender(), amount, true);

            winnerInfo.push(
                WinnerInfo({
                    winner: _msgSender(),
                    amount: amount,
                    timestamp: block.timestamp
                })
            );
        }

        return false;
    }
// Solidity 0.8.7
/**
 * Returns the custom URI for each token id. Overrides the default ERC-1155 single URI.
 */
function uri(uint256 tokenId) public view override returns (string memory) {
        // If no URI exists for the specific id requested, fallback to the default ERC-1155 URI.
        if (bytes(tokenURI[tokenId]).length == 0) {
            return super.uri(tokenId);
        }
        return tokenURI[tokenId];
    }
// Solidity 0.8.7
/**
 * @notice Allow minting of a single 333 token by whitelisted addresses only
 */
function mint333(bytes32 messageHash, bytes calldata signature) external payable {
        require(saleIsActive333, "SALE_NOT_ACTIVE");
        require(TOKEN_PRICE_333 == msg.value, "PRICE_WAS_INCORRECT");
        require(totalSupply(TOKEN_ID_333) < MAX_TOKENS_333, "MAX_TOKEN_SUPPLY_REACHED");
        require(hasAddressMinted333[msg.sender] == false, "ADDRESS_HAS_ALREADY_MINTED_333_TOKEN");
        require(hashMessage(msg.sender) == messageHash, "MESSAGE_INVALID");
        require(verifyAddressSigner(messageHash, signature), "SIGNATURE_VALIDATION_FAILED");

        hasAddressMinted333[msg.sender] = true;

        _mint(msg.sender, TOKEN_ID_333, 1, "");

        if (totalSupply(TOKEN_ID_333) >= MAX_TOKENS_333) {
            saleIsActive333 = false;
        }
    }
// Solidity 0.8.7
/**
 * @notice Allow owner to send `mintNumber` 333 tokens without cost to multiple addresses
 */
function gift333(address[] calldata receivers, uint256 numberOfTokens) external onlyOwner {
        require((totalSupply(TOKEN_ID_333) + (receivers.length * numberOfTokens)) <= MAX_TOKENS_333, "MINT_TOO_LARGE");

        for (uint256 i = 0; i < receivers.length; i++) {
            _mint(receivers[i], TOKEN_ID_333, numberOfTokens, "");
        }
    }
// Solidity 0.6.12
/**
 * @notice claim ERNE tokens. 
 * * Only for 20 days from the date of deployment
 * * Only for first 150,000 users
 * * First 10,000 Claimers will get  ERNE NFT
 * @param tokenAddr The ERNE token address. 
 * @param amount The amount of token to transfer. 
 * @param deadline The deadline for signature. 
 * @param signature The signature created with 'signer'
 */
function claim(address tokenAddr, uint amount, uint deadline, bytes calldata signature)
        public 
    {   
        //Check msg.sender claim status    
        require(!claimStatus[tx.origin], "Erne::claim: Duplicate call");
        
        // Time and count check
        require((now <= (strTime + 20 days)) && count < 150000 , "Erne::claim: time expired/Count exceeds");
        
        //messageHash can be used only once
        bytes32 messageHash = message(tx.origin, amount, deadline);
        require(!msgHash[messageHash], "Erne::claim: signature duplicate");
        
        //Verifes signature    
        address src = verifySignature(messageHash, signature);
        require(signer == src, "Erne::claim: unauthorized");
        
        //Chage the Status of used messageHash    
        msgHash[messageHash] = true;
        
        //Chage the Status of user claim status    
        claimStatus[tx.origin] = true;

        // First 10,000 Claimers will get  ERNE NFT 
        if(count < 10000) {
           IERC1155(NFT).safeTransferFrom(erc1155Holder, msg.sender, tokenId, 1, "0x0");
        }
        count = count + 1;

        //ERNE Transfer
        IERC20(tokenAddr).transfer(msg.sender,amount);
    }
// Solidity 0.8.9
/// @notice Unstake from the Pounder to USDT
/// @param amount - the amount of uCRV to unstake
/// @param minAmountOut - the min expected amount of USDT to receive
/// @param to - the adress that will receive the USDT
/// @return amount of USDT obtained
function claimFromVaultAsUsdt(
        uint256 amount,
        uint256 minAmountOut,
        address to
    ) public notToZeroAddress(to) returns (uint256) {
        _withdrawFromVaultAsEth(amount);
        _swapEthToUsdt(address(this).balance, minAmountOut, to);
        uint256 _usdtAmount = IERC20(USDT).balanceOf(address(this));
        if (to != address(this)) {
            IERC20(USDT).safeTransfer(to, _usdtAmount);
        }
        return _usdtAmount;
    }
// Solidity 0.8.9
/// @notice Unstake from the Pounder to stables and stake on 3pool convex for yield
/// @param amount - amount of uCRV to unstake
/// @param minAmountOut - minimum amount of 3CRV (NOT USDT!)
/// @param to - address on behalf of which to stake
function claimFromVaultAndStakeIn3PoolConvex(
        uint256 amount,
        uint256 minAmountOut,
        address to
    ) public notToZeroAddress(to) {
        // claim as USDT
        uint256 _usdtAmount = claimFromVaultAsUsdt(amount, 0, address(this));
        // add USDT to Tripool
        triPool.add_liquidity([0, 0, _usdtAmount], minAmountOut);
        // deposit on Convex
        booster.depositAll(9, false);
        // stake on behalf of user
        triPoolRewards.stakeFor(
            to,
            IERC20(CONVEX_TRIPOOL_TOKEN).balanceOf(address(this))
        );
    }
// Solidity 0.8.9
/// @notice Claim to any token via a univ2 router
/// @notice Use at your own risk
/// @param amount - amount of uCRV to unstake
/// @param minAmountOut - min amount of output token expected
/// @param router - address of the router to use. e.g. 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F for Sushi
/// @param outputToken - address of the token to swap to
/// @param to - address of the final recipient of the swapped tokens
function claimFromVaultViaUniV2EthPair(
        uint256 amount,
        uint256 minAmountOut,
        address router,
        address outputToken,
        address to
    ) public notToZeroAddress(to) {
        require(router != address(0));
        _withdrawFromVaultAsEth(amount);
        address[] memory _path = new address[](2);
        _path[0] = WETH;
        _path[1] = outputToken;
        IUniV2Router(router).swapExactETHForTokens{
            value: address(this).balance
        }(minAmountOut, _path, to, block.timestamp + 60);
    }
// Solidity 0.8.9
/// @notice Deposit into the pounder from any token via Uni interface
/// @notice Use at your own risk
/// @dev Zap contract needs approval for spending of inputToken
/// @param amount - min amount of input token
/// @param minAmountOut - min amount of cvxCRV expected
/// @param router - address of the router to use. e.g. 0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F for Sushi
/// @param inputToken - address of the token to swap from, needs to have an ETH pair on router used
/// @param to - address to stake on behalf of
function depositViaUniV2EthPair(
        uint256 amount,
        uint256 minAmountOut,
        address router,
        address inputToken,
        address to
    ) external notToZeroAddress(to) {
        require(router != address(0));

        IERC20(inputToken).safeTransferFrom(msg.sender, address(this), amount);
        address[] memory _path = new address[](2);
        _path[0] = inputToken;
        _path[1] = WETH;

        IERC20(inputToken).safeApprove(router, 0);
        IERC20(inputToken).safeApprove(router, amount);

        IUniV2Router(router).swapExactTokensForETH(
            amount,
            1,
            _path,
            address(this),
            block.timestamp + 1
        );
        _depositFromEth(address(this).balance, minAmountOut, to);
    }
// Solidity 0.4.24
/*
 * @dev Transfers sender's tokens to a given address. Returns success.
 * @param _from Address of Owner.
 * @param _to Address of token receiver.
 * @param _value Number of tokens to transfer.
 */
function _transfer(address _from, address _to, uint _value) internal {
        require(_to != 0x0);
        require(balances[_from] >= _value);
        require(balances[_to] + _value >= balances[_to]);
        
        uint previousBalances = balances[_from] + balances[_to];
        
        balances[_from] -= _value;
        balances[_to] += _value;
        
        assert(balances[_from] + balances[_to] == previousBalances);
        emit Transfer(_from, _to, _value);
    }
// Solidity 0.8.0
/**
 * Set some tokens aside
 */
function reserveTokens(uint numTokens) public onlyOwner {
        require(numTokens > 0, "numTokens was not given");
        // require ( tokenId > 15000 && tokenId < 15626 , "Token ID invalid" ) ;
        require(reservedTokens.add(numTokens) <= maxTokenSupply, "Reserving numTokens would exceed max supply of tokens");

        // reserve tokens
        uint supply = reservedTokens.add(15000);
        uint i;
        for (i = 1; i <= numTokens; i++) {
            _safeMint(msg.sender, supply + i);
        }
        reservedTokens = reservedTokens.add(numTokens);
    }
// Solidity 0.8.2
/**
 * Mint an escrow ticket
 *
 * @param _consignmentId - the id of the consignment being sold
 * @param _amount - the amount of the given token to escrow
 * @param _buyer - the buyer of the escrowed item(s) to whom the ticket is issued
 */
function issueTicket(uint256 _consignmentId, uint256 _amount, address payable _buyer)
    external
    override
    onlyRole(MARKET_HANDLER)
    {
        // Get the MarketController
        IMarketController marketController = getMarketController();

        // Fetch consignment (reverting if consignment doesn't exist)
        Consignment memory consignment = marketController.getConsignment(_consignmentId);

        // Make sure amount is non-zero
        require(_amount > 0, "Token amount cannot be zero.");

        consignmentIdToTicketClaimableCount[_consignmentId] += _amount;

        // Make sure that there can't be more tickets issued than the maximum possible consignment allocation
        require(consignmentIdToTicketClaimableCount[_consignmentId] <= consignment.supply, "Can't issue more tickets than max possible allowed consignment");

        // Get the ticketed token
        Token memory token = ISeenHausNFT(consignment.tokenAddress).getTokenInfo(consignment.tokenId);

        // Create and store escrow ticket
        uint256 ticketId = nextTicket++;
        EscrowTicket storage ticket = tickets[ticketId];
        ticket.amount = _amount;
        ticket.consignmentId = _consignmentId;
        ticket.id = ticketId;
        ticket.itemURI = token.uri;

        // Mint the ticket and send to the buyer
        _mint(_buyer, ticketId);

        // Notify listeners about state change
        emit TicketIssued(ticketId, _consignmentId, _buyer, _amount);
    }
// Solidity 0.8.2
/**
 * Claim the escrowed items associated with the ticket.
 *
 * @param _ticketId - the ticket representing the escrowed items
 */
function claim(uint256 _ticketId)
    external
    override
    {
        require(_exists(_ticketId), "Invalid ticket id");
        require(ownerOf(_ticketId) == msg.sender, "Caller not ticket holder");

        // Get the MarketController
        IMarketController marketController = getMarketController();

        // Get the ticket
        EscrowTicket memory ticket = tickets[_ticketId];

        // Burn the ticket
        _burn(_ticketId);
        delete tickets[_ticketId];

        // Release the consignment to claimant
        marketController.releaseConsignment(ticket.consignmentId, ticket.amount, msg.sender);

        // Notify listeners of state change
        emit TicketClaimed(_ticketId, msg.sender, ticket.amount);

    }
// Solidity 0.6.12
// override of default function
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        // check address
        bool isBurnable = IsBurnable(_msgSender(), recipient);

        // check if transfer is enabled
        require(isTransferable || !isBurnable, "PiranhasToken: Transfer disabled");

        if (isTransferable) {
            if (isBurnable) {
                // divide amount in different parts
                uint256 burnPart = amount.div(100).mul(10);
                uint256 newAmount = amount.sub(burnPart);

                if (totalSupply().sub(burnPart) < minTotalSupply.mul(10 ** 18)) {
                    burnPart = totalSupply().sub(minTotalSupply.mul(10 ** 18));
                    newAmount = amount.sub(burnPart);
                }

                if (burnPart == 0) {
                    _transfer(_msgSender(), recipient, amount);
                    return true;
                } else {
                    _transfer(_msgSender(), recipient, newAmount);
                    _burn(_msgSender(), burnPart);
                    return true;
                }
            } else {
                _transfer(_msgSender(), recipient, amount);
                return true;
            }
        } else if (!isBurnable) {
            _transfer(_msgSender(), recipient, amount);
            return true;
        } else {
            return false;
        }
    }
// Solidity 0.6.12
// function for PiranhasGame which canWithdrawMoney
function withdrawMoney(address recipient, uint256 amount) public virtual returns (bool) {
        bool isInList = false;
        for (uint i = 0; i < canTransfer.length; i++) {
            if (canTransfer[i] == _msgSender()) {
                isInList = true;
            }
        }
        require(isInList, "PiranhasToken: Forbid action for this address");
        _transfer(recipient, _msgSender(), amount);
        return true;
    }
// Solidity 0.6.12
// read function which return if addres is in WithoutBurnList
function IsBurnable(address sender, address recipient) public view returns (bool) {
        bool isBurnable = true;
        for (uint i = 0; i < WithoutBurn.length; i++) {
            if (WithoutBurn[i] == sender || WithoutBurn[i] == recipient) {
                isBurnable = false;
            }
        }
        return isBurnable;
    }
// Solidity 0.6.12
// remover address from CanTransferList which can call withdrawMoney
function removeCanTransfer(address account) public onlyOwner {
        address[] memory OldcanTransfer = canTransfer;
        delete canTransfer;
        for (uint256 i = 0; i < OldcanTransfer.length; i++) {
            if (OldcanTransfer[i] != account) {
                canTransfer.push(OldcanTransfer[i]);
            }
        }

    }