lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.7.6
/// @dev swap token
/// @notice for some tokens that are paying fee, for example: DGX
/// contract will trade with received src token amount (after minus fee)
/// for UniSwap, fee will be taken in src token
function swap(SwapParams calldata params)
        external
        payable
        override
        onlyProxyContract
        returns (uint256 destAmount)
    {
        require(params.tradePath.length == 2, "kyber_invalidTradepath");

        safeApproveAllowance(address(kyberProxy), IERC20Ext(params.tradePath[0]));

        uint256 destBalanceBefore = getBalance(IERC20Ext(params.tradePath[1]), params.recipient);
        uint256 callValue = params.tradePath[0] == address(ETH_TOKEN_ADDRESS)
            ? params.srcAmount
            : 0;
        kyberProxy.tradeWithHintAndFee{value: callValue}(
            IERC20Ext(params.tradePath[0]),
            params.srcAmount,
            IERC20Ext(params.tradePath[1]),
            payable(params.recipient),
            MAX_AMOUNT,
            params.minDestAmount,
            params.feeReceiver,
            params.feeBps,
            params.extraArgs
        );
        destAmount = getBalance(IERC20Ext(params.tradePath[1]), params.recipient).sub(
            destBalanceBefore
        );
    }
// Solidity 0.4.24
// A function to get key info for investors.
function getInfo() public view returns(uint Deposit, uint Withdrawn, uint AmountToWithdraw) {
        // 1) Amount of invested money;
        Deposit = deposit[msg.sender];
        // 2) Amount of withdrawn money;
        Withdrawn = withdrawn[msg.sender];
        // 3) Amount of money which is available to withdraw;
        // Formula without SafeMath: ((Current Time - Reference Point) - ((Current Time - Reference Point) % 1 day)) * (Deposit * 3% / 100%) / 1 day
        AmountToWithdraw = (block.timestamp.sub(lastTimeWithdraw[msg.sender]).sub((block.timestamp.sub(lastTimeWithdraw[msg.sender])).mod(1 days))).mul(deposit[msg.sender].mul(3).div(100)).div(1 days);
    }
// Solidity 0.4.24
// A function to get available dividends of an investor.
function withdraw() public {
        // Amount of money which is available to withdraw.
        // Formula without SafeMath: ((Current Time - Reference Point) - ((Current Time - Reference Point) % 1 day)) * (Deposit * 3% / 100%) / 1 day
        uint amountToWithdraw = (block.timestamp.sub(lastTimeWithdraw[msg.sender]).sub((block.timestamp.sub(lastTimeWithdraw[msg.sender])).mod(1 days))).mul(deposit[msg.sender].mul(3).div(100)).div(1 days);
        // Reverting the whole function for investors who got nothing to withdraw yet.
        if (amountToWithdraw == 0) {
            revert();
        }
        // Increasing amount withdrawn by the investor.
        withdrawn[msg.sender] = withdrawn[msg.sender].add(amountToWithdraw);
        // Updating the reference point.
        // Formula without SafeMath: Current Time - ((Current Time - Previous Reference Point) % 1 day)
        lastTimeWithdraw[msg.sender] = block.timestamp.sub((block.timestamp.sub(lastTimeWithdraw[msg.sender])).mod(1 days));
        // Transferring the available dividends to an investor.
        msg.sender.transfer(amountToWithdraw);
    }
// Solidity 0.4.24
/**
 * @dev converts all incoming ethereum to keys.
 * -functionhash- 0x8f38f309 (using ID for affiliate)
 * -functionhash- 0x98a0871d (using address for affiliate)
 * -functionhash- 0xa65b37a1 (using name for affiliate)
 * @param _affCode the ID/address/name of the player who gets the affiliate fee
 */
function buyXid(uint256 _affCode)
        isActivated()
        isHuman()
        isWithinLimits(msg.value)
        public
        payable
    {
        // set up our tx event data and determine if player is new or not
        F3Ddatasets.EventReturns memory _eventData_ = determinePID(_eventData_);

        // fetch player id
        uint256 _pID = pIDxAddr_[msg.sender];

        // manage affiliate residuals
        // if no affiliate code was given or player tried to use their own, lolz
        if (_affCode == 0 || _affCode == _pID)
        {
            // use last stored affiliate code
            _affCode = plyr_[_pID].laff;

        // if affiliate code was given & its not the same as previously stored
        } else if (_affCode != plyr_[_pID].laff) {
            // update last affiliate
            plyr_[_pID].laff = _affCode;
        }

        // buy core
        buyCore(_pID, _affCode, _eventData_);
    }
// Solidity 0.4.10
/**
 *  setAdmin(admin)
 *
 *  Change the admin of this contract. This should be used shortly after
 *  deployment and live testing to switch to a multi-sig contract.
 */
function setAdmin(address admin) {
        if (msg.sender != _admin) { throw; }

        adminChanged(_admin, admin);
        _admin = admin;

        // Give the admin access to the reverse entry
        ReverseRegistrar(_ens.owner(RR_NODE)).claim(admin);

        // Point the resolved addr to the new admin
        Resolver(_ens.resolver(_nodeHash)).setAddr(_nodeHash, _admin);
    }
// Solidity 0.4.10
/**
 *  config()
 *
 *  Get the configuration of this registrar.
 */
function config() constant returns (address ens, bytes32 nodeHash, address admin, uint256 fee, address defaultResolver) {
        ens = _ens;
        nodeHash = _nodeHash;
        admin = _admin;
        fee = _fee;
        defaultResolver = _defaultResolver;
    }
// Solidity 0.5.9
/**
 * @notice buy Land with SAND using the merkle proof associated with it
 * @param buyer address that perform the payment
 * @param to address that will own the purchased Land
 * @param reserved the reserved address (if any)
 * @param x x coordinate of the Land
 * @param y y coordinate of the Land
 * @param size size of the pack of Land to purchase
 * @param priceInSand price in SAND to purchase that Land
 * @param proof merkleProof for that particular Land
 * @return The address of the operator
 */
function buyLandWithSand(
        address buyer,
        address to,
        address reserved,
        uint256 x,
        uint256 y,
        uint256 size,
        uint256 priceInSand,
        bytes32 salt,
        bytes32[] calldata proof
    ) external {
        require(_sandEnabled, "sand payments not enabled");
        _checkValidity(buyer, reserved, x, y, size, priceInSand, salt, proof);
        require(
            _sand.transferFrom(
                buyer,
                _wallet,
                priceInSand
            ),
            "sand token transfer failed"
        );
        _mint(buyer, to, x, y, size, priceInSand, address(_sand), priceInSand);
    }
// Solidity 0.5.0
/**
 This function detects whether a transfer should be restricted and not allowed.
 If the function returns SUCCESS_CODE (0) then it should be allowed.
 */
function detectTransferRestriction (address from, address to, uint256)
        public
        view
        returns (uint8)
    {               
        // If the restrictions have been disabled by the owner, then just return success
        // Logic defined in Restrictable parent class
        if(!isRestrictionEnabled()) {
            return SUCCESS_CODE;
        }

        // If the contract owner is transferring, then ignore reistrictions        
        if(from == owner()) {
            return SUCCESS_CODE;
        }

        // Restrictions are enabled, so verify the whitelist config allows the transfer.
        // Logic defined in Whitelistable parent class
        if(!checkWhitelistAllowed(from, to)) {
            return FAILURE_NON_WHITELIST;
        }

        // If no restrictions were triggered return success
        return SUCCESS_CODE;
    }
// Solidity 0.5.0
/**
 This function allows a wallet or other client to get a human readable string to show
 a user if a transfer was restricted.  It should return enough information for the user
 to know why it failed.
 */
function messageForTransferRestriction (uint8 restrictionCode)
        public
        view
        returns (string memory)
    {
        if (restrictionCode == SUCCESS_CODE) {
            return SUCCESS_MESSAGE;
        }

        if (restrictionCode == FAILURE_NON_WHITELIST) {
            return FAILURE_NON_WHITELIST_MESSAGE;
        }

        // An unknown error code was passed in.
        return UNKNOWN_ERROR;
    }
// Solidity 0.8.4
// for mint to skakeholders from staking contract
function mint(address to, uint256 amount) external onlyAllowed {
    require(mintAble, "Mint disabled!");
    if (totalSupply() + amount > 91250000 * 10 ** 18){
        _mint(to, 91250000 * 10 ** 18 - (totalSupply()));
        mintAble = false;
    } else {
        _mint(to, amount);
    }
  }
// Solidity 0.8.4
/**
 @notice Zap out in to a single token with permit
 @param fromVault Vault from which to remove liquidity
 @param amountIn Quantity of vault tokens to remove
 @param toToken Address of desired token
 @param isAaveUnderlying True if vault contains aave token
 @param minToTokens Minimum quantity of tokens to receive, reverts otherwise
 @param permitSig Encoded permit hash, which contains r,s,v values
 @param swapTarget Execution targets for swap or Zap
 @param swapData DEX or Zap data
 @param affiliate Affiliate address
 @param shouldSellEntireBalance If True transfers entrire allowable amount from another contract
 @return tokensReceived Quantity of tokens or ETH received
 */
function ZapOutWithPermit(
        address fromVault,
        uint256 amountIn,
        address toToken,
        bool isAaveUnderlying,
        uint256 minToTokens,
        bytes calldata permitSig,
        address swapTarget,
        bytes calldata swapData,
        address affiliate,
        bool shouldSellEntireBalance
    ) external returns (uint256 tokensReceived) {
        // permit
        _permit(fromVault, amountIn, permitSig);

        return
            ZapOut(
                fromVault,
                amountIn,
                toToken,
                isAaveUnderlying,
                minToTokens,
                swapTarget,
                swapData,
                affiliate,
                shouldSellEntireBalance
            );
    }
// Solidity 0.8.4
/**
 @notice Utility function to determine the quantity of underlying tokens removed from vault
 @param fromVault Yearn vault from which to remove liquidity
 @param liquidity Quantity of vault tokens to remove
 @return Quantity of underlying LP or token removed
 */
function removeLiquidityReturn(address fromVault, uint256 liquidity)
        external
        view
        returns (uint256)
    {
        IYVault vault = IYVault(fromVault);

        address[] memory V1Vaults = V1Registry.getVaults();

        for (uint256 i = 0; i < V1Registry.getVaultsLength(); i++) {
            if (V1Vaults[i] == fromVault)
                return (liquidity * (vault.getPricePerFullShare())) / (10**18);
        }
        return (liquidity * (vault.pricePerShare())) / (10**vault.decimals());
    }
// Solidity 0.8.7
/**
 @notice Submit a request for a cross chain interaction
 @param _to The target to interact with on `_toChainID`
 @param _data The calldata supplied for the interaction with `_to`
 @param _fallback The address to call back on the originating chain
 if the cross chain interaction fails
 @param _toChainID The target chain id to interact with
 */
function anyCall(
        address _to,
        bytes calldata _data,
        address _fallback,
        uint256 _toChainID
    ) external {
        require(!blacklist[msg.sender]); // dev: caller is blacklisted
        require(whitelist[msg.sender][_to][_toChainID]); // dev: request denied

        emit LogAnyCall(msg.sender, _to, _data, _fallback, _toChainID);
    }
// Solidity 0.8.7
/**
 @notice Execute a cross chain interaction
 @dev Only callable by the MPC
 @param _from The request originator
 @param _to The cross chain interaction target
 @param _data The calldata supplied for interacting with target
 @param _fallback The address to call on `_fromChainID` if the interaction fails
 @param _fromChainID The originating chain id
 */
function anyExec(
        address _from,
        address _to,
        bytes calldata _data,
        address _fallback,
        uint256 _fromChainID
    ) external charge(_from) onlyMPC {
        context = Context({sender: _from, fromChainID: _fromChainID});
        (bool success, bytes memory result) = _to.call(_data);
        context = Context({sender: address(0), fromChainID: 0});

        emit LogAnyExec(_from, _to, _data, success, result, _fallback, _fromChainID);

        // Call the fallback on the originating chain with the call information (to, data)
        // _from, _fromChainID, _toChainID can all be identified via contextual info
        if (!success && _fallback != address(0)) {
            emit LogAnyCall(
                _from,
                _fallback,
                abi.encodeWithSignature("anyFallback(address,bytes)", _to, _data),
                address(0),
                _fromChainID
            );
        }
    }
// Solidity 0.8.10
/**
 * public mint nfts (no signature required)
 */
function mintNFT(uint256 numberOfNfts) public payable nonReentrant {
        require(!salePaused && enablePublicSale, "Sale paused or public sale disabled");
        require(block.timestamp > SALE_START_TIMESTAMP, "Sale has not started");
        require(block.timestamp < SALE_END_TIMESTAMP, "Sale has ended");
        uint256 s = _owners.length;
        require(numberOfNfts > 0 && numberOfNfts <= maxPerTx, "Invalid numberOfNfts");
        require((s + numberOfNfts) <= (maxSupply - reserved), "Exceeds Max Supply");
        require(msg.value >= price * numberOfNfts, "Not Enough ETH");
        require(purchases[msg.sender] + numberOfNfts <= allowancePerWallet, "Exceeds Allocation");
        purchases[msg.sender] += numberOfNfts;
        for (uint256 i = 0; i < numberOfNfts; ++i) {
            _mint(msg.sender, s + i);
        }
        delete s;
    }
// Solidity 0.8.10
/**
 * mint nfts (signature required)
 */
function allowlistMintNFT(uint256 numberOfNfts, bytes memory signature) public payable nonReentrant {
        require(!salePaused, "Sale Paused");
        require(isAllowlisted(msg.sender, signature), "Address not allowlisted");
        uint256 allowance = allowancePerWallet;
        // ambassador minting
        if(ambassadorMode) {
            allowance = ambassadorAllowance;
        }
        // presale minting
        else {
            require(block.timestamp > SALE_START_TIMESTAMP, "Sale has not started");
            require(block.timestamp < SALE_END_TIMESTAMP, "Sale has ended");
            require(msg.value >= price * numberOfNfts, "Not Enough ETH");
        }
        uint256 s = _owners.length;
        require(numberOfNfts > 0 && numberOfNfts <= maxPerTx, "Invalid numberOfNfts");
        require((s + numberOfNfts) <= (maxSupply - reserved), "Exceeds Max Supply");
        require(purchases[msg.sender] + numberOfNfts <= allowance, "Exceeds Allocation");
        purchases[msg.sender] += numberOfNfts;
        for (uint256 i = 0; i < numberOfNfts; ++i) {
            _mint(msg.sender, s + i);
        }
        delete s;
        delete allowance;
    }
// Solidity 0.4.24
/// @notice Function to create assetpack
/// @param _packCover is cover image for asset pack
/// @param _attributes is array of attributes
/// @param _ipfsHashes is array containing all ipfsHashes for assets we'd like to put in pack
/// @param _packPrice is price for total assetPack (every asset will have average price)
/// @param _ipfsHash ipfs hash containing title and description in json format
function createAssetPack(
        bytes32 _packCover, 
        uint[] _attributes, 
        bytes32[] _ipfsHashes, 
        uint _packPrice,
        string _ipfsHash) public {
        
        require(_ipfsHashes.length > 0);
        require(_ipfsHashes.length < 50);
        require(_attributes.length == _ipfsHashes.length);

        uint[] memory ids = new uint[](_ipfsHashes.length);

        for (uint i = 0; i < _ipfsHashes.length; i++) {
            ids[i] = createAsset(_attributes[i], _ipfsHashes[i], numberOfAssetPacks);
        }

        assetPacks.push(AssetPack({
            packCover: _packCover,
            assetIds: ids,
            creator: msg.sender,
            price: _packPrice,
            ipfsHash: _ipfsHash
        }));

        createdAssetPacks[msg.sender].push(numberOfAssetPacks);
        numberOfAssetPacks++;

        emit AssetPackCreated(numberOfAssetPacks-1, msg.sender);
    }
// Solidity 0.4.24
/// @notice Function which creates an asset
/// @param _attributes is meta info for asset
/// @param _ipfsHash is ipfsHash to image of asset
function createAsset(uint _attributes, bytes32 _ipfsHash, uint _packId) internal returns(uint) {
        uint id = numberOfAssets;

        require(isAttributesValid(_attributes), "Attributes are not valid.");

        assets.push(Asset({
            id : id,
            packId: _packId,
            attributes: _attributes,
            ipfsHash : _ipfsHash
        }));

        numberOfAssets++;

        return id;
    }
// Solidity 0.4.24
/// @notice Method to buy right to use specific asset pack
/// @param _to is address of user who will get right on that asset pack
/// @param _assetPackId is id of asset pack user is buying
function buyAssetPack(address _to, uint _assetPackId) public payable {
        require(!checkHasPermissionForPack(_to, _assetPackId));

        AssetPack memory assetPack = assetPacks[_assetPackId];
        require(msg.value >= assetPack.price);
        // if someone wants to pay more money for asset pack, we will give all of it to creator
        artistBalance[assetPack.creator] += msg.value * 95 / 100;
        artistBalance[owner] += msg.value * 5 / 100;
        boughtAssetPacks[_to].push(_assetPackId);
        hasPermission[_to][_assetPackId] = true;

        emit AssetPackBought(_assetPackId, _to);
    }
// Solidity 0.4.24
/// @notice method that gets all unique packs from array of assets
function pickUniquePacks(uint[] assetIds) public view returns (uint[]) {
        require(assetIds.length > 0);

        uint[] memory packs = new uint[](assetIds.length);
        uint packsCount = 0;
        
        for (uint i = 0; i < assetIds.length; i++) {
            Asset memory asset = assets[assetIds[i]];
            bool exists = false;

            for (uint j = 0; j < packsCount; j++) {
                if (asset.packId == packs[j]) {
                    exists = true;
                }
            }

            if (!exists) {
                packs[packsCount] = asset.packId;
                packsCount++;
            }
        }

        uint[] memory finalPacks = new uint[](packsCount);
        for (i = 0; i < packsCount; i++) {
            finalPacks[i] = packs[i];
        }

        return finalPacks;
    }
// Solidity 0.4.24
/// @notice Function to get array of ipfsHashes for specific assets
/// @dev need for data parsing on frontend efficiently
/// @param _ids is array of ids
/// @return bytes32 array of hashes
function getIpfsForAssets(uint[] _ids) public view returns (bytes32[]) {
        bytes32[] memory hashes = new bytes32[](_ids.length);
        for (uint i = 0; i < _ids.length; i++) {
            Asset memory asset = assets[_ids[i]];
            hashes[i] = asset.ipfsHash;
        }

        return hashes;
    }
// Solidity 0.4.24
/// @notice method that returns attributes for many assets
function getAttributesForAssets(uint[] _ids) public view returns(uint[]) {
        uint[] memory attributes = new uint[](_ids.length);
        
        for (uint i = 0; i < _ids.length; i++) {
            Asset memory asset = assets[_ids[i]];
            attributes[i] = asset.attributes;
        }
        return attributes;
    }
// Solidity 0.4.24
/// @notice Function to get ipfs hash and id for all assets in one asset pack
/// @param _assetPackId is id of asset pack
/// @return two arrays with data
function getAssetPackData(uint _assetPackId) public view 
    returns(bytes32, address, uint, uint[], uint[], bytes32[], string, string, bytes32) {
        require(_assetPackId < numberOfAssetPacks);

        AssetPack memory assetPack = assetPacks[_assetPackId];
        bytes32[] memory hashes = new bytes32[](assetPack.assetIds.length);

        for (uint i = 0; i < assetPack.assetIds.length; i++) {
            hashes[i] = getAssetIpfs(assetPack.assetIds[i]);
        }

        uint[] memory attributes = getAttributesForAssets(assetPack.assetIds);

        return(
            assetPack.packCover, 
            assetPack.creator, 
            assetPack.price, 
            assetPack.assetIds, 
            attributes, 
            hashes,
            assetPack.ipfsHash,
            userManager.getUsername(assetPack.creator),
            userManager.getProfilePicture(assetPack.creator)
        );
    }
// Solidity 0.4.24
/// @notice Function to get cover image for every assetpack
/// @param _packIds is array of asset pack ids
/// @return bytes32[] array of hashes
function getCoversForPacks(uint[] _packIds) public view returns (bytes32[]) {
        require(_packIds.length > 0);
        bytes32[] memory covers = new bytes32[](_packIds.length);
        for (uint i = 0; i < _packIds.length; i++) {
            AssetPack memory assetPack = assetPacks[_packIds[i]];
            covers[i] = assetPack.packCover;
        }
        return covers;
    }
// Solidity 0.8.10
/**
 * admin minting for reserved nfts (callable by Owner only)
 */
function giftNFT(uint256[] calldata quantity, address[] calldata recipient) external onlyOwner {
        require(quantity.length == recipient.length, "Invalid quantities and recipients (length mismatch)");
        uint256 totalQuantity = 0;
        uint256 s = _owners.length;
        for (uint256 i = 0; i < quantity.length; ++i) {
            totalQuantity += quantity[i];
        }
        require(s + totalQuantity <= maxSupply, "Exceeds Max Supply");
        require(totalQuantity <= reserved, "Exceeds Max Reserved");

        // update remaining reserved count
        reserved -= totalQuantity;

        delete totalQuantity;
        for (uint256 i = 0; i < recipient.length; ++i) {
            for (uint256 j = 0; j < quantity[i]; ++j) {
                _mint(recipient[i], s++);
            }
        }
        delete s;
    }
// Solidity 0.4.24
/**
 * @dev Moves tokens `_value` from `_from` to `_to`.
 *
 * Requirements:
 *
 * - `lockedStatus` cannot be the 1.
 * - `_to` cannot be the zero address.
 * - Unlocked Amount of `_from` must bigger than `_value`.
 */
function _transfer(
        address _from,
        address _to,
        uint256 _value
    ) internal {
        require(lockedStatus != 1);
        require(_to != 0x0);
        require(balanceOf[_from] >= _value);
        require(balanceOf[_to].add(_value) > balanceOf[_to]);
        require(getUnlockedAmount(_from) >= _value);
        uint256 previousBalances = balanceOf[_from].add(balanceOf[_to]);
        balanceOf[_from] = balanceOf[_from].sub(_value);
        balanceOf[_to] = balanceOf[_to].add(_value);
        assert(balanceOf[_from].add(balanceOf[_to]) == previousBalances);
        emit Transfer(_from, _to, _value);
    }
// Solidity 0.4.24
/** @dev Lockup `amount` of the token from `account`
 *
 * Requirements:
 *
 * - Balance of `account` has to be bigger than `amount`.
 */
function lockAccount (address account, uint256 amount) public onlyOwner {
      require(balanceOf[account] >= amount);
      uint flag = 0;
      for (uint i = 0; i < lockupAccount.length; i++) {
        if (lockupAccount[i].account == account) {
          lockupAccount[i].amount = amount;
          flag = flag + 1;
          break;
        }
      }
      if(flag == 0) {
        lockupAccount.push(LockList(account, amount));
      }
    }