lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.16
/**
 * @notice Send the fees to claiming address.
 * @param account The address to send the fees to.
 * @param sUSDAmount The amount of fees priced in sUSD.
 */
function _payFees(address account, uint sUSDAmount) internal notFeeAddress(account) {
        // Grab the sUSD Synth
        ISynth sUSDSynth = issuer().synths(sUSD);

        // NOTE: we do not control the FEE_ADDRESS so it is not possible to do an
        // ERC20.approve() transaction to allow this feePool to call ERC20.transferFrom
        // to the accounts address

        // Burn the source amount
        sUSDSynth.burn(FEE_ADDRESS, sUSDAmount);

        // Mint their new synths
        sUSDSynth.issue(account, sUSDAmount);
    }
// Solidity 0.5.16
/**
 * @notice The total fees available in the system to be withdrawnn in sUSD
 */
function totalFeesAvailable() external view returns (uint) {
        uint totalFees = 0;

        // Fees in fee period [0] are not yet available for withdrawal
        for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) {
            totalFees = totalFees.add(_recentFeePeriodsStorage(i).feesToDistribute);
            totalFees = totalFees.sub(_recentFeePeriodsStorage(i).feesClaimed);
        }

        return totalFees;
    }
// Solidity 0.5.16
/**
 * @notice The fees available to be withdrawn by a specific account, priced in sUSD
 * @dev Returns two amounts, one for fees and one for SNX rewards
 */
function feesAvailable(address account) public view returns (uint, uint) {
        // Add up the fees
        uint[2][FEE_PERIOD_LENGTH] memory userFees = feesByPeriod(account);

        uint totalFees = 0;
        uint totalRewards = 0;

        // Fees & Rewards in fee period [0] are not yet available for withdrawal
        for (uint i = 1; i < FEE_PERIOD_LENGTH; i++) {
            totalFees = totalFees.add(userFees[i][0]);
            totalRewards = totalRewards.add(userFees[i][1]);
        }

        // And convert totalFees to sUSD
        // Return totalRewards as is in SNX amount
        return (totalFees, totalRewards);
    }
// Solidity 0.8.9
/**
 * @dev Sets the initial {converter} and {vest} contract addresses. Additionally, mints
 * the Vader amount available for conversion as well as the team allocation that is meant
 * to be vested to each respective contract.
 *
 * Emits a {ProtocolInitialized} event indicating all the supplied values of the function.
 *
 * Requirements:
 *
 * - the caller must be the deployer of the contract
 * - the contract must not have already been initialized
 */
function setComponents(
        IConverter _converter,
        ILinearVesting _vest,
        address[] calldata vesters,
        uint192[] calldata amounts
    ) external onlyOwner {
        require(
            _converter != IConverter(_ZERO_ADDRESS) &&
                _vest != ILinearVesting(_ZERO_ADDRESS),
            "Vader::setComponents: Incorrect Arguments"
        );
        require(
            converter == IConverter(_ZERO_ADDRESS),
            "Vader::setComponents: Already Set"
        );

        converter = _converter;
        vest = _vest;

        _mint(address(_converter), _VETH_ALLOCATION);
        _mint(address(_vest), _TEAM_ALLOCATION);

        _vest.begin(vesters, amounts);

        emit ProtocolInitialized(
            address(_converter),
            address(_vest)
        );
    }
// Solidity 0.8.1
//pay in - just send ETH to contract address
receive() external payable {
        require(!collectEnd, "Collect ended");
        uint256 amount = msg.value + balances[msg.sender];
        //if you want pay in more than 9 ETH - contact staff to KYC/AML
        //and pay directly to owner address
        //not KYC/AML-ed payments will be treated as a donation
        require(amount <= noAmlMax, "Need KYC/AML");
        balances[msg.sender] = amount;
        //fail in case that somethig* happend and collection not closed in 6 months
        if (block.timestamp > failsafe) {
            collectEnd = true;
            failed = true;
        }
        //*ie you-know-who dies
    }
// Solidity 0.8.1
//end collecting - take ETH or fail and allow to withdraw
function end() external {
        require(!collectEnd, "Collect ended");
        collectEnd = true;
        require(msg.sender == owner, "Only for owner");
        if (totalCollected() < minETH) {
            failed = true;
        } else {
            send(owner, address(this).balance);
        }
    }
// Solidity 0.6.12
/** Sets the status of a given DAO. */
function setDAOStatus(address daoAddress, uint256 index, uint256 status) external {
        // Reentrancy guard.
        require(_status == RE_NOT_ENTERED || _status == RE_FROZEN);
        require(msg.sender == _manager, "Not manager");

        // Validate the index as well.
        require(_daoAddresses[index] == daoAddress, "Non-matching DAO index");

        // Validate the status.
        require(status == VALID_DAO || status == INVALID_DAO, "Invalid status");
        uint256 currentStatus = _isValidDAO[daoAddress];
        require(currentStatus != status && (currentStatus == VALID_DAO || currentStatus == INVALID_DAO), "Invalid current status");

        // Update the status.
        _isValidDAO[daoAddress] = status;

        // Hello world!
        emit DAOStatusChanged(daoAddress, status);
    }
// Solidity 0.6.12
/** Upgrades to the new DAO version. Can only be done when frozen. */
function upgradeDAO(address daoAddress) external {
        // Reentrancy guard.
        require(_status == RE_FROZEN);
        _status = RE_ENTERED;

        // It must be a contract.
        uint256 codeSize;
        assembly { codeSize := extcodesize(daoAddress) }
        require(codeSize > 0, "Not a contract");

        // Make sure it hasn't been tracked yet.
        require(_isValidDAO[daoAddress] == UNTRACKED_DAO, "DAO already tracked");

        // Upgrade the DAO.
        _daoAddresses.push(daoAddress);
        _isValidDAO[daoAddress] = VALID_DAO;

        // Enable the DAO.
        IGoaldDAO(daoAddress).makeReady(_governanceStage, _goaldCount);

        // Hello world!
        emit DAOUpgraded(daoAddress);

        // By storing the original amount once again, a refund is triggered (see https://eips.ethereum.org/EIPS/eip-2200).
        _status = RE_FROZEN;
    }
// Solidity 0.6.12
/** Returns the address of the DAO which deployed the Goald. */
function getGoaldDAO(uint256 id) external view returns (address) {
        require(id < _goaldCount, "ID too large");

        uint256 addressesCount = _daoAddresses.length;
        uint256 index;
        uint256 goaldCount;
        address goaldAddress;

        for (; index < addressesCount; index ++) {
            goaldAddress = _daoAddresses[index];
            goaldCount += IGoaldDAO(goaldAddress).getGoaldCount();
            if (id <= goaldCount) {
                return goaldAddress;
            }
        }

        revert("Unknown DAO");
    }
// Solidity 0.6.12
/** Releases management to the DAO. */
function initializeDAO() external {
        // Reentrancy guard.
        require(_status == RE_NOT_ENTERED);
        _status = RE_ENTERED;

        require(msg.sender == _manager,                     "Not manager");
        require(_governanceStage == STAGE_ISSUANCE_CLAIMED, "Issuance unclaimed");

        // Burn the tokens.
        uint256 startingBalance = balanceOf(_manager);
        require(startingBalance >= 110000 * REWARD_THRESHOLD, "Not enough tokens");
        _burn(_manager, 110000 * REWARD_THRESHOLD);

        // Update the stage.
        _governanceStage = STAGE_DAO_INITIATED;

        uint256 count = _daoAddresses.length;

        // If the manager no longer is a holder we need to tell the latest DAO.
        if (count > 0 && startingBalance - (110000 * REWARD_THRESHOLD) < REWARD_THRESHOLD) {
            IGoaldDAO(_daoAddresses[count - 1]).initializeDecreasesHolders();
        }

        // Tell the DAOs so they can create rewards.
        uint256 index;
        for (; index < count; index++) {
            IGoaldDAO(_daoAddresses[index]).updateGovernanceStage();
        }

        // By storing the original amount once again, a refund is triggered (see https://eips.ethereum.org/EIPS/eip-2200).
        _status = RE_NOT_ENTERED;
    }
// Solidity 0.6.12
/**
 * Executes a function on the DAO. Only the manager can call this function. This DOES NOT guard against reentrancy. Do not use
 * this unless reentrancy is needed or the call is made to an invlaid contract. Otherwise use `safeCallDAO()`. This code is
 * duplicated in place of having an internal `_callDAO()` since reentrancy guarding is not guaranteed.
 *
 * @param daoAddress Which DAO is being called.
 * @param encodedData The non-packed, abi encoded calldata that will be included with the function call.
 */
function unsafeCallDAO(address daoAddress, bytes calldata encodedData) external returns (bytes memory) {
        // Reentrancy guard. We check against both normal reentrancy and DAO call reentrancy.
        require(_daoStatus == RE_NOT_ENTERED);
        _daoStatus = RE_ENTERED;

        require(msg.sender == _manager, "Not manager");
        // `_isValidDAO` since DAOs can be disabled.
        require(_isValidDAO[daoAddress] != UNTRACKED_DAO, "DAO not tracked");

        // Call the function, bubbling on errors.
        (bool success, bytes memory returnData) = daoAddress.call(encodedData);

        // By storing the original amount once again, a refund is triggered (see https://eips.ethereum.org/EIPS/eip-2200).
        _daoStatus = RE_NOT_ENTERED;
        
        // See @OpenZeppelin.Address._functionCallWithValue()
        if (success) {
            return returnData;
        } else {
            // Look for revert reason and bubble it up if present
            if (returnData.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returnData_size := mload(returnData)
                    revert(add(32, returnData), returnData_size)
                }
            } else {
                revert();
            }
        }
    }
// Solidity 0.6.12
/** This is overridden so we can update the reward balancees prior to the transfer completing. */
function transfer(address recipient, uint256 amount) public override returns (bool) {
        // Reentrancy guard.
        require(_status == RE_NOT_ENTERED);
        _status = RE_ENTERED;

        // Preserve the original balances so we know if we need to change `_rewardHolders`. We need to call `pre()` and `post()` on
        // every DAO version to make sure that the reward balances are updated correctly.
        uint256 senderBefore = balanceOf(msg.sender);
        uint256 recipientBefore = balanceOf(recipient);

        // Update reward balances.
        uint256 count = _daoAddresses.length;
        uint256 index;
        for (; index < count; index ++) {
            IGoaldDAO(_daoAddresses[index]).preTransfer(msg.sender, recipient);
        }
        
        // Transfer the tokens.
        super.transfer(recipient, amount);
        
        // Update holder counts.
        index = 0;
        for (; index < count; index ++) {
            IGoaldDAO(_daoAddresses[index]).postTransfer(msg.sender, senderBefore, balanceOf(msg.sender), recipientBefore, balanceOf(recipient));
        }

        // By storing the original amount once again, a refund is triggered (see https://eips.ethereum.org/EIPS/eip-2200).
        _status = RE_NOT_ENTERED;

        return true;
    }
// Solidity 0.8.1
/// @notice Create a token without setting uri
/// @dev It emits `NewAdapter` if `_erc20` is true
/// @param _supply The amount of token to create
/// @param _receiver Address that receives minted token
/// @param _settingOperator Address that can perform setTimeInterval
///  and set ERC20 Attribute
/// @param _needTime Set to `true` if need to query holding time for token
/// @param _erc20 Set to `true` to create a erc20 adapter for token
/// @return Token ID
function createToken(
        uint256 _supply,
        address _receiver,
        address _settingOperator,
        bool _needTime,
        bool _erc20
    )
        public 
        override
        returns (uint256)
    {
        uint256 tokenId = _mint(_supply, _receiver, _settingOperator, _needTime, "");
        if (_erc20)
            _createAdapter(tokenId);
        return tokenId;
    }
// Solidity 0.8.1
/// @notice Create a token with uri
/// @param _supply The amount of token to create
/// @param _receiver Address that receives minted token
/// @param _settingOperator Address that can perform setTimeInterval
///  and set ERC20 Attribute
/// @param _needTime Set to `true` if need to query holding time for token
/// @param _uri URI that points to token metadata
/// @param _erc20 Set to `true` to create a erc20 adapter for token
/// @return Token ID
function createToken(
        uint256 _supply,
        address _receiver,
        address _settingOperator,
        bool _needTime,
        string calldata _uri,
        bool _erc20
    )
        external
        override
        returns (uint256)
    {
        uint256 tokenId = createToken(_supply, _receiver, _settingOperator, _needTime, _erc20);
        _setTokenURI(tokenId, _uri);
        return tokenId;
    }
// Solidity 0.8.1
/// @notice Create both normal token and recording token without setting uri
/// @dev Recording token shares the same token ID with normal token
/// @param _supply The amount of token to create
/// @param _supplyOfRecording The amount of recording token to create
/// @param _receiver Address that receives minted token
/// @param _settingOperator Address that can perform setTimeInterval
///  and set ERC20 Attribute
/// @param _needTime Set to `true` if need to query holding time for token
/// @param _recordingOperator Address that can manage recording token
/// @param _erc20 Set to `true` to create a erc20 adapter for token
/// @return Token ID
function createTokenWithRecording(
        uint256 _supply,
        uint256 _supplyOfRecording,
        address _receiver,
        address _settingOperator,
        bool _needTime,
        address _recordingOperator,
        bool _erc20
    )
        public
        override
        returns (uint256)
    {
        uint256 tokenId = createToken(_supply, _receiver, _settingOperator, _needTime, _erc20);
        _mintCopy(tokenId, _supplyOfRecording, _recordingOperator);
        return tokenId;
    }
// Solidity 0.8.1
/// @notice Set starting time and ending time for token holding time calculation
/// @dev Starting time must be greater than time at the moment
/// @dev To save gas cost, here use uint128 to store time
/// @param _startTime Starting time in unix time format
/// @param _endTime Ending time in unix time format
function setTimeInterval(
        uint256 _tokenId,
        uint128 _startTime,
        uint128 _endTime
    )
        external
        override
    {
        require(_msgSender() == _settingOperators[_tokenId], "Not authorized");
        require(_startTime >= block.timestamp, "Time smaller than now");
        require(_endTime > _startTime, "End greater than start");
        require(_timeInterval[_tokenId] == 0, "Already set");

        _setTime(_tokenId, _startTime, _endTime);
    }
// Solidity 0.8.1
/// @notice Set erc20 token attribute
/// @dev Throws if `msg.sender` is not authorized setting operator
/// @param _tokenId Corresponding token ID with erc20 adapter
/// @param _name Name of the token
/// @param _symbol Symbol of the token
/// @param _decimals Number of decimals to use
function setERC20Attribute(
        uint256 _tokenId,
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    )
        external
        override
    {
        require(_msgSender() == _settingOperators[_tokenId], "Not authorized");
        require(_adapters[_tokenId] != address(0), "No adapter found");

        _setERC20Attribute(_tokenId, _name, _symbol, _decimals);
    }
// Solidity 0.4.21
/**
 @dev upgrade an old converter to the latest version
 will throw if ownership wasn't transferred to the upgrader before calling this function.
 ownership of the new converter will be transferred back to the original owner.
 fires the ConverterUpgrade event upon success.
 
 @param _oldConverter   old converter contract address
 @param _version        old converter version
 */
function upgrade(IBancorConverterExtended _oldConverter, bytes32 _version) public {
        bool formerVersions = false;
        if (_version == "0.4")
            formerVersions = true;
        acceptConverterOwnership(_oldConverter);
        IBancorConverterExtended newConverter = createConverter(_oldConverter);
        copyConnectors(_oldConverter, newConverter, formerVersions);
        copyConversionFee(_oldConverter, newConverter);
        copyQuickBuyPath(_oldConverter, newConverter);
        transferConnectorsBalances(_oldConverter, newConverter, formerVersions);                
        ISmartToken token = _oldConverter.token();

        if (token.owner() == address(_oldConverter)) {
            _oldConverter.transferTokenOwnership(newConverter);
            newConverter.acceptTokenOwnership();
        }

        _oldConverter.transferOwnership(msg.sender);
        newConverter.transferOwnership(msg.sender);
        newConverter.transferManagement(msg.sender);

        emit ConverterUpgrade(address(_oldConverter), address(newConverter));
    }
// Solidity 0.4.21
/**
 @dev creates a new converter with same basic data as the original old converter
 the newly created converter will have no connectors at this step.
 
 @param _oldConverter    old converter contract address
 
 @return the new converter  new converter contract address
 */
function createConverter(IBancorConverterExtended _oldConverter) private returns(IBancorConverterExtended) {
        IWhitelist whitelist;
        ISmartToken token = _oldConverter.token();
        uint32 maxConversionFee = _oldConverter.maxConversionFee();

        address converterAdderess  = bancorConverterFactory.createConverter(
            token,
            registry,
            maxConversionFee,
            IERC20Token(address(0)),
            0
        );

        IBancorConverterExtended converter = IBancorConverterExtended(converterAdderess);
        converter.acceptOwnership();
        converter.acceptManagement();

        // get the contract features address from the registry
        IContractFeatures features = IContractFeatures(registry.getAddress(ContractIds.CONTRACT_FEATURES));

        if (features.isSupported(_oldConverter, FeatureIds.CONVERTER_CONVERSION_WHITELIST)) {
            whitelist = _oldConverter.conversionWhitelist();
            if (whitelist != address(0))
                converter.setConversionWhitelist(whitelist);
        }

        return converter;
    }
// Solidity 0.4.21
/**
 @dev copies the connectors from the old converter to the new one.
 note that this will not work for an unlimited number of connectors due to block gas limit constraints.
 
 @param _oldConverter    old converter contract address
 @param _newConverter    new converter contract address
 @param _isLegacyVersion true if the converter version is under 0.5
 */
function copyConnectors(IBancorConverterExtended _oldConverter, IBancorConverterExtended _newConverter, bool _isLegacyVersion)
        private
    {
        uint256 virtualBalance;
        uint32 weight;
        bool isVirtualBalanceEnabled;
        bool isPurchaseEnabled;
        bool isSet;
        uint16 connectorTokenCount = _isLegacyVersion ? _oldConverter.reserveTokenCount() : _oldConverter.connectorTokenCount();

        for (uint16 i = 0; i < connectorTokenCount; i++) {
            address connectorAddress = _isLegacyVersion ? _oldConverter.reserveTokens(i) : _oldConverter.connectorTokens(i);
            (virtualBalance, weight, isVirtualBalanceEnabled, isPurchaseEnabled, isSet) = readConnector(
                _oldConverter,
                connectorAddress,
                _isLegacyVersion
            );

            IERC20Token connectorToken = IERC20Token(connectorAddress);
            _newConverter.addConnector(connectorToken, weight, isVirtualBalanceEnabled);

            if (isVirtualBalanceEnabled)
                _newConverter.updateConnector(connectorToken, weight, isVirtualBalanceEnabled, virtualBalance);
        }
    }
// Solidity 0.4.21
/**
 @dev copies the quick buy path from the old converter to the new one
 
 @param _oldConverter    old converter contract address
 @param _newConverter    new converter contract address
 */
function copyQuickBuyPath(IBancorConverterExtended _oldConverter, IBancorConverterExtended _newConverter) private {
        uint256 quickBuyPathLength = _oldConverter.getQuickBuyPathLength();
        if (quickBuyPathLength <= 0)
            return;

        IERC20Token[] memory path = new IERC20Token[](quickBuyPathLength);
        for (uint256 i = 0; i < quickBuyPathLength; i++) {
            path[i] = _oldConverter.quickBuyPath(i);
        }

        _newConverter.setQuickBuyPath(path);
    }
// Solidity 0.4.21
/**
 @dev transfers the balance of each connector in the old converter to the new one.
 note that the function assumes that the new converter already has the exact same number of
 also, this will not work for an unlimited number of connectors due to block gas limit constraints.
 
 @param _oldConverter    old converter contract address
 @param _newConverter    new converter contract address
 @param _isLegacyVersion true if the converter version is under 0.5
 */
function transferConnectorsBalances(IBancorConverterExtended _oldConverter, IBancorConverterExtended _newConverter, bool _isLegacyVersion)
        private
    {
        uint256 connectorBalance;
        uint16 connectorTokenCount = _isLegacyVersion ? _oldConverter.reserveTokenCount() : _oldConverter.connectorTokenCount();

        for (uint16 i = 0; i < connectorTokenCount; i++) {
            address connectorAddress = _isLegacyVersion ? _oldConverter.reserveTokens(i) : _oldConverter.connectorTokens(i);
            IERC20Token connector = IERC20Token(connectorAddress);
            connectorBalance = connector.balanceOf(_oldConverter);
            _oldConverter.withdrawTokens(connector, address(_newConverter), connectorBalance);
        }
    }
// Solidity 0.6.12
/// @notice Serves as the constructor for clones, as clones can't have a regular constructor
/// @dev `data` is abi encoded in the format: (IERC20 collateral, IERC20 asset, IOracle oracle, bytes oracleData)
function init(bytes calldata data) public payable override {
        require(address(collateral) == address(0), "Cauldron: already initialized");
        (collateral, oracle, oracleData, accrueInfo.INTEREST_PER_SECOND, LIQUIDATION_MULTIPLIER, COLLATERIZATION_RATE, BORROW_OPENING_FEE) = abi.decode(data, (IERC20, IOracle, bytes, uint64, uint256, uint256, uint256));
        require(address(collateral) != address(0), "Cauldron: bad pair");
    }