lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.4
// ------------------------------------------------------------------------
// Checks if there is any uunLockedCoins available
// ------------------------------------------------------------------------
function _updateUnLockedCoins(address _from, uint tokens) private returns (bool success) {
            // if unLockedCoins are greater than "tokens" of "to", initiate transfer
            if(unLockedCoins[_from] >= tokens){
                return true;
            }
            // if unLockedCoins are less than "tokens" of "to", update unLockedCoins by checking record with "now" time
            else{
                _updateRecord(_from);
                // check if unLockedCoins are greater than "token" of "to", initiate transfer
                if(unLockedCoins[_from] >= tokens){
                    return true;
                }
                // otherwise revert
                else{
                    revert();
                }
            }
        }
// Solidity 0.5.4
// ------------------------------------------------------------------------
// Unlock the coins if lockingPeriod is expired
// ------------------------------------------------------------------------
function _updateRecord(address _address) private returns (bool success){
            PC[] memory tempArray = record[_address];
            uint tempCount = 0;
            for(uint i=0; i < tempArray.length; i++){
                if(tempArray[i].lockingPeriod < now && tempArray[i].added == false){
                    tempCount = tempCount.add(tempArray[i].coins);
                    tempArray[i].added = true;
                    record[_address][i] = PC(tempArray[i].lockingPeriod, tempArray[i].coins, tempArray[i].added);
                }
            }
            unLockedCoins[_address] = unLockedCoins[_address].add(tempCount);
            return true;
        }
// Solidity 0.6.12
// Update the given pool's TOKEN allocation point and deposit fee. Can only be called by the owner.
function set(uint256 _pid, uint256 _allocPoint, uint16 _depositFeeBP, uint256 totalMaxRewardToken, bool _withUpdate)
        public
        onlyOwner
    {
        require(_depositFeeBP <= 10000, "set: invalid deposit fee basis points");

        if (_withUpdate) {
            massUpdatePools();
        }

        require(poolInfo[_pid].totalRewardTokens <= totalMaxRewardToken, "set: totalMaxRewardToken is invalid");

        totalAllocPoint = totalAllocPoint.sub(poolInfo[_pid].allocPoint).add(_allocPoint);

        poolInfo[_pid].allocPoint = _allocPoint;
        poolInfo[_pid].depositFeeBP = _depositFeeBP;
        poolInfo[_pid].totalMaxRewardTokens = totalMaxRewardToken;
    }
// Solidity 0.4.18
//
// Check crowdsale state and calibrate it
//
function checkCrowdsaleState() internal returns (bool) {
        if (ethRaised >= maxCap && crowdsaleState != state.crowdsaleEnded) {// Check if max cap is reached
            crowdsaleState = state.crowdsaleEnded;
            CrowdsaleEnded(block.number);
            // Raise event
            return true;
        }

        if (now >= END_TIME) {
            crowdsaleState = state.crowdsaleEnded;
            CrowdsaleEnded(block.number);
            // Raise event
            return true;
        }

        if (now >= BEGIN_TIME && now < END_TIME) {// Check if we are in crowdsale state
            if (crowdsaleState != state.crowdsale) {// Check if state needs to be changed
                crowdsaleState = state.crowdsale;
                // Set new state
                CrowdsaleStarted(block.number);
                // Raise event
                return true;
            }
        }

        return false;
    }
// Solidity 0.4.18
//
// Owner can batch return contributors contributions(eth)
//
function batchReturnEthIfFailed(uint _numberOfReturns) onlyOwner public {
        require(crowdsaleState != state.crowdsaleEnded);
        // Check if crowdsale has ended
        require(ethRaised < minCap);
        // Check if crowdsale has failed
        address currentParticipantAddress;
        uint contribution;
        for (uint cnt = 0; cnt < _numberOfReturns; cnt++) {
            currentParticipantAddress = contributorIndexes[nextContributorToClaim];
            // Get next unclaimed participant
            if (currentParticipantAddress == 0x0) return;
            // Check if all the participants were compensated
            if (!hasClaimedEthWhenFail[currentParticipantAddress]) {// Check if participant has already claimed
                contribution = contributorList[currentParticipantAddress].contributionAmount;
                // Get contribution of participant
                hasClaimedEthWhenFail[currentParticipantAddress] = true;
                // Set that he has claimed
                balances[currentParticipantAddress] = 0;
                if (!currentParticipantAddress.send(contribution)) {// Refund eth
                    ErrorSendingETH(currentParticipantAddress, contribution);
                    // If there is an issue raise event for manual recovery
                }
            }
            nextContributorToClaim += 1;
            // Repeat
        }
    }
// Solidity 0.4.18
// Parking off     
function parkingOff (address node) public {
        if (!parkingSwitches[msg.sender].initialized) revert();

        // Calculate the amount depending on rate
        uint256 amount = (now - parkingSwitches[msg.sender].startTime) * parkingSwitches[msg.sender].fixedRate;
        // Maximum can be predefinedAmount, if it less than that, return tokens
        amount = amount > parkingSwitches[msg.sender].predefinedAmount ? parkingSwitches[msg.sender].predefinedAmount : amount;

        balances[node] = balances[node] + amount;
        reservedFundsParking[msg.sender] = reservedFundsParking[msg.sender] - amount;

        //  
        if (reservedFundsParking[msg.sender] > 0) {
            balances[msg.sender] = balances[msg.sender] + reservedFundsParking[msg.sender];
            // all tokens taken, set to 0
            reservedFundsParking[msg.sender] = 0;
        }

        // Uninitialize
        parkingSwitches[msg.sender].node = 0;
        parkingSwitches[msg.sender].startTime = 0;
        parkingSwitches[msg.sender].endTime = 0;
        parkingSwitches[msg.sender].fixedRate = 0;
        parkingSwitches[msg.sender].initialized = false;
        parkingSwitches[msg.sender].predefinedAmount = 0;
    }
// Solidity 0.8.6
/**
 * @notice Create a bond by depositing `amount` of `principal`.
 * Principal will be transferred from `msg.sender` using `allowance`.
 * @param amount Amount of principal to deposit.
 * @param minAmountOut The minimum **SOLACE** or **xSOLACE** out.
 * @param depositor The bond recipient, default msg.sender.
 * @param stake True to stake, false to not stake.
 * @return payout The amount of SOLACE or xSOLACE in the bond.
 * @return bondID The ID of the newly created bond.
 */
function deposit(
        uint256 amount,
        uint256 minAmountOut,
        address depositor,
        bool stake
    ) external override returns (uint256 payout, uint256 bondID) {
        // pull tokens
        SafeERC20.safeTransferFrom(principal, msg.sender, address(this), amount);
        // accounting
        return _deposit(amount, minAmountOut, depositor, stake);
    }
// Solidity 0.8.6
/**
 * @notice Create a bond by depositing `amount` of `principal`.
 * Principal will be transferred from `depositor` using `permit`.
 * Note that not all ERC20s have a permit function, in which case this function will revert.
 * @param amount Amount of principal to deposit.
 * @param minAmountOut The minimum **SOLACE** or **xSOLACE** out.
 * @param depositor The bond recipient, default msg.sender.
 * @param stake True to stake, false to not stake.
 * @param deadline Time the transaction must go through before.
 * @param v secp256k1 signature
 * @param r secp256k1 signature
 * @param s secp256k1 signature
 * @return payout The amount of SOLACE or xSOLACE in the bond.
 * @return bondID The ID of the newly created bond.
 */
function depositSigned(
        uint256 amount,
        uint256 minAmountOut,
        address depositor,
        bool stake,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external override returns (uint256 payout, uint256 bondID) {
        // permit
        IERC20Permit(address(principal)).permit(depositor, address(this), amount, deadline, v, r, s);
        // pull tokens
        SafeERC20.safeTransferFrom(principal, depositor, address(this), amount);
        // accounting
        return _deposit(amount, minAmountOut, depositor, stake);
    }
// Solidity 0.8.6
/**
 * @notice Approve of a specific `tokenID` for spending by `spender` via signature.
 * @param spender The account that is being approved.
 * @param tokenID The ID of the token that is being approved for spending.
 * @param deadline The deadline timestamp by which the call must be mined for the approve to work.
 * @param v Must produce valid secp256k1 signature from the holder along with `r` and `s`.
 * @param r Must produce valid secp256k1 signature from the holder along with `v` and `s`.
 * @param s Must produce valid secp256k1 signature from the holder along with `r` and `v`.
 */
function permit(
        address spender,
        uint256 tokenID,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external override {
        require(_exists(tokenID), "query for nonexistent token");
        require(block.timestamp <= deadline, "permit expired");

        uint256 nonce = _nonces[tokenID]++; // get then increment
        bytes32 digest =
            keccak256(
                abi.encodePacked(
                    "\x19\x01",
                    DOMAIN_SEPARATOR(),
                    keccak256(abi.encode(_PERMIT_TYPEHASH, spender, tokenID, nonce, deadline))
                )
            );
        address owner = ownerOf(tokenID);
        require(spender != owner, "cannot permit to self");

        if (Address.isContract(owner)) {
            require(IERC1271(owner).isValidSignature(digest, abi.encodePacked(r, s, v)) == 0x1626ba7e, "unauthorized");
        } else {
            address recoveredAddress = ecrecover(digest, v, r, s);
            require(recoveredAddress != address(0), "invalid signature");
            require(recoveredAddress == owner, "unauthorized");
        }

        _approve(spender, tokenID);
    }
// Solidity 0.8.6
/**
 * @notice Lists all tokens.
 * Order not specified.
 * @dev This function is more useful off chain than on chain.
 * @return tokenIDs The list of token IDs.
 */
function listTokens() public view override returns (uint256[] memory tokenIDs) {
        uint256 tokenCount = totalSupply();
        tokenIDs = new uint256[](tokenCount);
        for(uint256 index = 0; index < tokenCount; index++) {
            tokenIDs[index] = tokenByIndex(index);
        }
        return tokenIDs;
    }
// Solidity 0.8.0
/// @notice Makes permit calls indicated by a struct
/// @param data the struct which has the permit calldata
function _permitCall(PermitData[] memory data) internal {
        // Make the permit call to the token in the data field using
        // the fields provided.
        if (data.length != 0) {
            // We make permit calls for each indicated call
            for (uint256 i = 0; i < data.length; i++) {
                data[i].tokenContract.permit(
                    msg.sender,
                    data[i].spender,
                    data[i].amount,
                    data[i].expiration,
                    data[i].v,
                    data[i].r,
                    data[i].s
                );
            }
        }
    }
// Solidity 0.8.0
/// @notice This function sets approvals on all ERC20 tokens.
/// @param tokens An array of token addresses which are to be approved
/// @param spenders An array of contract addresses, most likely curve and
/// balancer pool addresses
/// @param amounts An array of amounts for which at each index, the spender
/// from the same index in the spenders array is approved to use the token
/// at the equivalent index of the token array on behalf of this contract
function setApprovalsFor(
        address[] memory tokens,
        address[] memory spenders,
        uint256[] memory amounts
    ) external onlyAuthorized {
        require(tokens.length == spenders.length, "Incorrect length");
        require(tokens.length == amounts.length, "Incorrect length");
        for (uint256 i = 0; i < tokens.length; i++) {
            // Below call is to make sure that previous allowance shouldn't revert the transaction
            // It is just a safety pattern to use.
            IERC20(tokens[i]).safeApprove(spenders[i], uint256(0));
            IERC20(tokens[i]).safeApprove(spenders[i], amounts[i]);
        }
    }
// Solidity 0.8.0
/// @notice Swaps an amount of curve LP tokens for a single root token
/// @param _zap See ZapCurveLpOut
/// @param _lpTokenAmount This is the amount of lpTokens we are swapping
/// with
/// @param _minRootTokenAmount This is the minimum amount of "root" tokens
/// the user expects to swap for. Used only in the final zap when executed
/// under zapOut
/// @param _recipient The address which the outputs tokens are to be sent
/// to. When there is a second zap to occur, in the first zap the recipient
/// should be this address
function _zapCurveLpOut(
        ZapCurveLpOut memory _zap,
        uint256 _lpTokenAmount,
        uint256 _minRootTokenAmount,
        address payable _recipient
    ) internal returns (uint256 rootAmount) {
        // Flag to detect if we are sending to recipient
        bool transferToRecipient = address(this) != _recipient;
        uint256 beforeAmount = _zap.rootToken == _ETH_CONSTANT
            ? address(this).balance
            : _getBalanceOf(IERC20(_zap.rootToken));

        if (_zap.curveRemoveLiqFnIsUint256) {
            ICurvePool(_zap.curvePool).remove_liquidity_one_coin(
                _lpTokenAmount,
                uint256(int256(_zap.rootTokenIdx)),
                _minRootTokenAmount
            );
        } else {
            ICurvePool(_zap.curvePool).remove_liquidity_one_coin(
                _lpTokenAmount,
                _zap.rootTokenIdx,
                _minRootTokenAmount
            );
        }

        // ETH case
        if (_zap.rootToken == _ETH_CONSTANT) {
            // Get ETH balance of current contract
            rootAmount = address(this).balance - beforeAmount;
            // if address does not equal this contract we send funds to recipient
            if (transferToRecipient) {
                // Send rootAmount of ETH to the user-specified recipient
                _recipient.transfer(rootAmount);
            }
        } else {
            // Get balance of root token that was swapped
            rootAmount = _getBalanceOf(IERC20(_zap.rootToken)) - beforeAmount;
            // Send tokens to recipient
            if (transferToRecipient) {
                IERC20(_zap.rootToken).safeTransferFrom(
                    address(this),
                    _recipient,
                    rootAmount
                );
            }
        }
    }
// Solidity 0.4.19
/**
 * @notice token contructor.
 * @param _teamAddress is the address of the developer team
 */
function AssetUNR(address _teamAddress) public {
        require(msg.sender != _teamAddress);
        totalSupply = 100000000 * (10 ** decimals); //100 million tokens initial supply;
        balances[msg.sender] = 88000000 * (10 ** decimals); //88 million supply is initially holded by contract creator for the ICO, marketing and bounty
        balances[_teamAddress] = 11900000 * (10 ** decimals); //11.9 million supply is initially holded by developer team
        balances[0xFAB6368b0F7be60c573a6562d82469B5ED9e7eE6] = 100000 * (10 ** decimals); //0.1 million supply is initially holded by contract writer
        
        Transfer(0, this, totalSupply);
        Transfer(this, msg.sender, balances[msg.sender]);
        Transfer(this, _teamAddress, balances[_teamAddress]);
        Transfer(this, 0xFAB6368b0F7be60c573a6562d82469B5ED9e7eE6, balances[0xFAB6368b0F7be60c573a6562d82469B5ED9e7eE6]);
    }
// Solidity 0.4.20
/**
 *   @dev Contract constructor function
 */
function Play2liveICO(
        address _preSaleToken,
        address _Company,
        address _OperationsFund,
        address _FoundersFund,
        address _PartnersFund,
        address _AdvisorsFund,
        address _BountyFund,
        address _Manager,
        address _Controller_Address1,
        address _Controller_Address2,
        address _Controller_Address3,
        address _Oracle
        ) public {
        preSaleToken = Presale(_preSaleToken);
        Company = _Company;
        OperationsFund = _OperationsFund;
        FoundersFund = _FoundersFund;
        PartnersFund = _PartnersFund;
        AdvisorsFund = _AdvisorsFund;
        BountyFund = _BountyFund;
        Manager = _Manager;
        Controller_Address1 = _Controller_Address1;
        Controller_Address2 = _Controller_Address2;
        Controller_Address3 = _Controller_Address3;
        Oracle = _Oracle;
    }
// Solidity 0.4.20
/**
 *   @dev Function to finish ICO
 *   Sets ICO status to IcoFinished and  emits tokens for funds
 */
function finishIco() external managerOnly {
        require(statusICO == StatusICO.IcoStarted || statusICO == StatusICO.IcoPaused);
        uint alreadyMinted = LUC.totalSupply();
        uint totalAmount = alreadyMinted.mul(1000).div(publicIcoPart);
        LUC.mintTokens(OperationsFund, operationsPart.mul(totalAmount).div(1000));
        LUC.mintTokens(FoundersFund, foundersPart.mul(totalAmount).div(1000));
        LUC.mintTokens(PartnersFund, partnersPart.mul(totalAmount).div(1000));
        LUC.mintTokens(AdvisorsFund, advisorsPart.mul(totalAmount).div(1000));
        LUC.mintTokens(BountyFund, bountyPart.mul(totalAmount).div(1000));
        statusICO = StatusICO.IcoFinished;
        LogFinishICO();
    }
// Solidity 0.4.20
/**
 *   @dev Function to issue tokens for investors who paid in ether
 *   @param _investor     address which the tokens will be issued tokens
 *   @param _lucValue     number of LUC tokens
 */
function buy(address _investor, uint _lucValue) internal {
        require(statusICO == StatusICO.PreIcoStarted || statusICO == StatusICO.IcoStarted);
        uint bonus = getBonus(_lucValue);
        uint total = _lucValue.add(bonus);
        require(soldAmount + _lucValue <= hardCap);
        LUC.mintTokens(_investor, total);
        soldAmount = soldAmount.add(_lucValue);
    }
// Solidity 0.5.17
// user can also burn by sending token to address(0), but this function will emit Burned event
function burn(uint256 _amount) public returns (bool) {
        require (_amount != 0, "burn amount should not be zero");
        require(balances[msg.sender] >= _amount);
        totalSupply_ = totalSupply_.sub(_amount);
        balances[msg.sender] = balances[msg.sender].sub(_amount);
        emit Burned(msg.sender, _amount);
        emit Transfer(msg.sender, address(0), _amount);
        _moveDelegates(delegates[msg.sender], address(0), _amount);
        return true;
    }
// Solidity 0.6.12
/**
 * @dev Attribution to the awesome delta.financial contracts
 */
function marketParticipationAgreement()
        public
        pure
        returns (string memory)
    {
        return
            "I understand that I am interacting with a smart contract. I understand that tokens commited are subject to the token issuer and local laws where applicable. I have reviewed the code of this smart contract and understand it fully. I agree to not hold developers or other people associated with the project liable for any losses or misunderstandings";
    }
// Solidity 0.6.12
/**
 * @notice Commit ETH to buy tokens on auction.
 * @param _beneficiary Auction participant ETH address.
 */
function commitEth(
        address payable _beneficiary,
        bool readAndAgreedToMarketParticipationAgreement
    ) public payable {
        require(
            paymentCurrency == ETH_ADDRESS,
            "BatchAuction: payment currency is not ETH"
        );

        require(msg.value > 0, "BatchAuction: Value must be higher than 0");
        if (readAndAgreedToMarketParticipationAgreement == false) {
            revertBecauseUserDidNotProvideAgreement();
        }
        _addCommitment(_beneficiary, msg.value);
    }
// Solidity 0.6.12
/**
 * @notice Checks if amout not 0 and makes the transfer and adds commitment.
 * @dev Users must approve contract prior to committing tokens to auction.
 * @param _from User ERC20 address.
 * @param _amount Amount of approved ERC20 tokens.
 */
function commitTokensFrom(
        address _from,
        uint256 _amount,
        bool readAndAgreedToMarketParticipationAgreement
    ) public nonReentrant {
        require(
            paymentCurrency != ETH_ADDRESS,
            "BatchAuction: Payment currency is not a token"
        );
        if (readAndAgreedToMarketParticipationAgreement == false) {
            revertBecauseUserDidNotProvideAgreement();
        }
        require(_amount > 0, "BatchAuction: Value must be higher than 0");
        _safeTransferFrom(paymentCurrency, msg.sender, _amount);
        _addCommitment(_from, _amount);
    }
// Solidity 0.6.12
/**
 * @notice Updates commitment for this address and total commitment of the auction.
 * @param _addr Auction participant address.
 * @param _commitment The amount to commit.
 */
function _addCommitment(address _addr, uint256 _commitment) internal {
        require(
            block.timestamp >= marketInfo.startTime &&
                block.timestamp <= marketInfo.endTime,
            "BatchAuction: outside auction hours"
        );

        uint256 newCommitment = commitments[_addr].add(_commitment);
        commitments[_addr] = newCommitment;
        marketStatus.commitmentsTotal = BoringMath.to128(
            uint256(marketStatus.commitmentsTotal).add(_commitment)
        );
        emit AddedCommitment(_addr, _commitment);
    }
// Solidity 0.6.12
///--------------------------------------------------------
/// Finalize Auction
///--------------------------------------------------------
/// @notice Auction finishes successfully above the reserve
/// @dev Transfer contract funds to initialized wallet.
function finalize() public nonReentrant {
        require(
            hasAdminRole(msg.sender) ||
                wallet == msg.sender ||
                hasSmartContractRole(msg.sender) ||
                finalizeTimeExpired(),
            "BatchAuction: Sender must be admin"
        );
        require(
            !marketStatus.finalized,
            "BatchAuction: Auction has already finalized"
        );
        require(
            block.timestamp > marketInfo.endTime,
            "BatchAuction: Auction has not finished yet"
        );
        if (auctionSuccessful()) {
            /// @dev Successful auction
            /// @dev Transfer contributed tokens to wallet.
            _safeTokenPayment(
                paymentCurrency,
                wallet,
                uint256(marketStatus.commitmentsTotal)
            );
        } else {
            /// @dev Failed auction
            /// @dev Return auction tokens back to wallet.
            _safeTokenPayment(auctionToken, wallet, marketInfo.totalTokens);
        }
        marketStatus.finalized = true;
        startReleaseTime = block.timestamp;
        emit AuctionFinalized();
    }
// Solidity 0.6.12
/**
 * @notice Cancel Auction
 * @dev Admin can cancel the auction before it starts
 */
function cancelAuction() public nonReentrant {
        require(hasAdminRole(msg.sender));
        MarketStatus storage status = marketStatus;
        require(!status.finalized, "Crowdsale: already finalized");
        require(
            uint256(status.commitmentsTotal) == 0,
            "Crowdsale: Funds already raised"
        );

        _safeTokenPayment(
            auctionToken,
            wallet,
            uint256(marketInfo.totalTokens)
        );

        status.finalized = true;
        emit AuctionCancelled();
    }