lohoz/Smart-Contract-MultiTask-Dataset huggingface dataset:
// Solidity 0.5.2
/// @dev Internal function to deposit token to the DutchX
/// @param token The token address that is being deposited.
/// @param amount The amount of token to deposit.
function _depositToken(address token, uint amount) internal {

        uint allowance = ITokenMinimal(token).allowance(address(this), address(dutchXProxy));
        if (allowance < amount) {
            SafeERC20.safeApprove(token, address(dutchXProxy), max);
        }

        // Confirm that the balance of the token on the DutchX is at least how much was deposited
        uint newBalance = dutchXProxy.deposit(token, amount);
        require(newBalance >= amount, "deposit didn't work");
    }
// Solidity 0.4.18
/// @dev Constructor function sets contract owner
/// @param _receiver Receiver of vested tokens
/// @param _disbursementPeriod Vesting period in seconds
/// @param _startDate Start date of disbursement period (cliff)
function Disbursement(address _receiver, uint _disbursementPeriod, uint _startDate)
        public
    {
        if (_receiver == 0 || _disbursementPeriod == 0)
            // Arguments are null
            revert();
        owner = msg.sender;
        receiver = _receiver;
        disbursementPeriod = _disbursementPeriod;
        startDate = _startDate;
        if (startDate == 0)
            startDate = now;
    }
// Solidity 0.4.18
/// @dev Calculates the maximum amount of vested tokens
/// @return Number of vested tokens to withdraw
function calcMaxWithdraw()
        public
        constant
        returns (uint)
    {
        uint maxTokens = (token.balanceOf(this) + withdrawnTokens) * (now - startDate) / disbursementPeriod;
        if (withdrawnTokens >= maxTokens || startDate > now)
            return 0;
        return maxTokens - withdrawnTokens;
    }
// Solidity 0.8.7
/**
 * @dev See {IERC1155-balanceOfBatch}.
 *
 * Requirements:
 *
 * - `accounts` and `ids` must have the same length.
 */
function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }
// Solidity 0.8.7
/**
 * @dev See {IERC1155-safeTransferFrom}.
 */
function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }
// Solidity 0.8.7
/**
 * @dev See {IERC1155-safeBatchTransferFrom}.
 */
function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: transfer caller is not owner nor approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }
// Solidity 0.8.7
/**
 * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
 *
 * Emits a {TransferSingle} event.
 *
 * Requirements:
 *
 * - `to` cannot be the zero address.
 * - `from` must have a balance of tokens of type `id` of at least `amount`.
 * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
 * acceptance magic value.
 */
function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }
// Solidity 0.8.7
/**
 * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
 *
 * Emits a {TransferBatch} event.
 *
 * Requirements:
 *
 * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
 * acceptance magic value.
 */
function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }
// Solidity 0.8.7
/**
 * @dev Creates `amount` tokens of token type `id`, and assigns them to `account`.
 *
 * Emits a {TransferSingle} event.
 *
 * Requirements:
 *
 * - `account` cannot be the zero address.
 * - If `account` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
 * acceptance magic value.
 */
function _mint(
        address account,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(account != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), account, _asSingletonArray(id), _asSingletonArray(amount), data);

        _balances[id][account] += amount;
        emit TransferSingle(operator, address(0), account, id, amount);

        _doSafeTransferAcceptanceCheck(operator, address(0), account, id, amount, data);
    }
// Solidity 0.8.7
/**
 * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
 *
 * Requirements:
 *
 * - `ids` and `amounts` must have the same length.
 * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
 * acceptance magic value.
 */
function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }
// Solidity 0.8.7
/**
 * @dev Destroys `amount` tokens of token type `id` from `account`
 *
 * Requirements:
 *
 * - `account` cannot be the zero address.
 * - `account` must have at least `amount` tokens of token type `id`.
 */
function _burn(
        address account,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(account != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, account, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");

        uint256 accountBalance = _balances[id][account];
        require(accountBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][account] = accountBalance - amount;
        }

        emit TransferSingle(operator, account, address(0), id, amount);
    }
// Solidity 0.8.7
/**
 * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
 *
 * Requirements:
 *
 * - `ids` and `amounts` must have the same length.
 */
function _burnBatch(
        address account,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(account != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, account, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 accountBalance = _balances[id][account];
            require(accountBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][account] = accountBalance - amount;
            }
        }

        emit TransferBatch(operator, account, address(0), ids, amounts);
    }
// Solidity 0.8.7
/**
 * @dev See {ERC1155-_mintBatch}.
 */
function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual override {
        super._mintBatch(to, ids, amounts, data);
        for (uint256 i = 0; i < ids.length; ++i) {
            _totalSupply[ids[i]] += amounts[i];
        }
    }
// Solidity 0.8.7
/**
 * @dev See {ERC1155-_burnBatch}.
 */
function _burnBatch(
        address account,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual override {
        super._burnBatch(account, ids, amounts);
        for (uint256 i = 0; i < ids.length; ++i) {
            _totalSupply[ids[i]] -= amounts[i];
        }
    }
// Solidity 0.5.8
/// @notice Transfers an amount out of balance to a specified address
///
/// @param _darknode The address of the darknode
/// @param _token Which token to transfer
/// @param _amount The amount to transfer
/// @param _recipient The address to withdraw it to
function transfer(address _darknode, address _token, uint256 _amount, address payable _recipient) external onlyOwner {
        require(darknodeBalances[_darknode][_token] >= _amount, "insufficient darknode balance");
        darknodeBalances[_darknode][_token] = darknodeBalances[_darknode][_token].sub(_amount);
        lockedBalances[_token] = lockedBalances[_token].sub(_amount);

        if (_token == ETHEREUM) {
            _recipient.transfer(_amount);
        } else {
            ERC20(_token).safeTransfer(_recipient, _amount);
        }
    }
// Solidity 0.8.7
// Buy GetValues
function _getValuesBuy(uint256 tAmount, Fee memory currentFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
        BuyBreakdown memory buyFees;
        (buyFees.tTransferAmount, buyFees.tLP, buyFees.tMarketing, buyFees.tReflection) = _getTValues(tAmount, currentFee.buyLPFee, currentFee.buyMarketingFee, currentFee.buyReflectionFee);
        uint256 currentRate = _getRate();
        (uint256 rAmount, uint256 rTransferAmount, uint256 rReflection) = _getRValues(tAmount, buyFees.tLP, buyFees.tMarketing, buyFees.tReflection, currentRate);
        return (rAmount, rTransferAmount, rReflection, buyFees.tTransferAmount, buyFees.tLP, buyFees.tMarketing);
    }
// Solidity 0.8.7
// Sell GetValues
function _getValuesSell(uint256 tAmount, Fee memory currentFee) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
        SellBreakdown memory sellFees;
        (sellFees.tTransferAmount, sellFees.tLP, sellFees.tMarketing, sellFees.tReflection) = _getTValues(tAmount, currentFee.sellLPFee, currentFee.sellMarketingFee, currentFee.sellReflectionFee);
        uint256 currentRate = _getRate();
        (uint256 rAmount, uint256 rTransferAmount, uint256 rReflection) = _getRValues(tAmount, sellFees.tLP, sellFees.tMarketing, sellFees.tReflection, currentRate);
        return (rAmount, rTransferAmount, rReflection, sellFees.tTransferAmount, sellFees.tLP, sellFees.tMarketing);
    }
// Solidity 0.8.4
/**
 * @dev to decrease the allowance of `spender` over the `owner` account.
 *
 * Requirements
 * `spender` allowance shoule be greater than the `reducedValue`
 * `spender` cannot be a zero address
 */
function decreaseAllowance(address spender, uint256 reducedValue)
        public
        virtual
        returns (bool)
    {
        uint256 currentAllowance = allowances[msgSender()][spender];
        require(
            currentAllowance >= reducedValue,
            "ERC20: ReducedValue greater than allowance"
        );

        _approve(msgSender(), spender, currentAllowance - reducedValue);
        return true;
    }
// Solidity 0.8.4
/**
 * @dev sets the amount as the allowance of `spender` over the `owner` address
 *
 * Requirements:
 * `owner` cannot be zero address
 * `spender` cannot be zero address
 */
function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from zero address");
        require(spender != address(0), "ERC20: approve to zero address");

        allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }
// Solidity 0.8.4
/**
 * @dev transfers the 'amount` from the `sender` to the `recipient`
 * on behalf of the `sender`.
 *
 * Requirements
 * `sender` and `recipient` should be non zero addresses
 * `sender` should have balance of more than `amount`
 * `caller` must have allowance greater than `amount`
 */
function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        require(validateTransfer(sender),"ERC20: Transfer reverted");
        
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = allowances[sender][msgSender()];
        require(currentAllowance >= amount, "ERC20: amount exceeds allowance");
        _approve(sender, msgSender(), currentAllowance - amount);
      
        emit Transfer(sender, recipient, amount);

        return true;
    }
// Solidity 0.8.4
/**
 * @dev mints the amount of tokens to the `recipient` wallet.
 *
 * Requirements :
 *
 * The caller must be the `governor` of the contract.
 * Governor can be an DAO smart contract.
 */
function mint(address recipient, uint256 amount)
        public
        virtual
        onlyGovernor
        returns (bool)
    {
        require(recipient != address(0), "ERC20: mint to a zero address");

 
        _totalSupply += amount;
        balances[recipient] += amount;

        emit Transfer(address(0), recipient, amount);
        return true;
    }
// Solidity 0.8.4
/**
 * @dev burns the `amount` tokens from `supply`.
 *
 * Requirements
 * `caller` address balance should be greater than `amount`
 */
function burn(uint256 amount) public virtual onlyGovernor returns (bool) {
        uint256 currentBalance = balances[msgSender()];
        require(
            currentBalance >= amount,
            "ERC20: burning amount exceeds balance"
        );

        balances[msgSender()] = currentBalance - amount;
        _totalSupply -= amount;

        return true;
    }
// Solidity 0.8.4
/**
 * @dev transfers the `amount` of tokens from `sender` to `recipient`.
 *
 * Requirements:
 * `sender` is not a zero address
 * `recipient` is also not a zero address
 * `amount` is less than or equal to balance of the sender.
 */
function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from zero address");
        require(recipient != address(0), "ERC20: transfer to zero address");

        uint256 senderBalance = balances[sender];
        require(
            senderBalance >= amount,
            "ERC20: transfer amount exceeds balance"
        );

     
        balances[sender] = senderBalance - amount;
        
        // Transfer the spread to the admin
        uint256 fee = amount * feeFraction / 10**4;

        uint256 receiverAmount = amount - fee;

        balances[recipient] += receiverAmount;
        balances[_governor] +=fee;

        emit Transfer(sender, recipient, amount);
    }
// Solidity 0.5.17
/// @notice excludes an assimilator from the component
/// @param _derivative the address of the assimilator to exclude
function excludeDerivative (
        address _derivative
    ) external onlyOwner {

        for (uint i = 0; i < numeraires.length; i++) {

            if (_derivative == numeraires[i]) revert("Component/cannot-delete-numeraire");
            if (_derivative == reserves[i]) revert("Component/cannot-delete-reserve");

        }

        delete component.assimilators[_derivative];

    }
// Solidity 0.5.17
/// @author james foley http://github.com/realisation
/// @notice swap a dynamic origin amount for a fixed target amount
/// @param _origin the address of the origin
/// @param _target the address of the target
/// @param _originAmount the origin amount
/// @param _minTargetAmount the minimum target amount
/// @param _deadline deadline in block number after which the trade will not execute
/// @return targetAmount_ the amount of target that has been swapped for the origin amount
function originSwap (
        address _origin,
        address _target,
        uint _originAmount,
        uint _minTargetAmount,
        uint _deadline
    ) external deadline(_deadline) transactable nonReentrant returns (
        uint targetAmount_
    ) {

        targetAmount_ = Swaps.originSwap(component, _origin, _target, _originAmount, msg.sender);

        require(targetAmount_ > _minTargetAmount, "Component/below-min-target-amount");

    }
// Solidity 0.8.6
/// @notice PolygonCommunityVault initializer
/// @dev Needs to be called after deployment. Get addresses from https://github.com/maticnetwork/static/tree/master/network
/// @param _token The address of the ERC20 that the vault will manipulate/own
/// @param _rootChainManager Polygon root network chain manager. Zero address for child deployment
/// @param _erc20Predicate Polygon ERC20 Predicate. Zero address for child deployment
function initialize(address _token, address _rootChainManager, address _erc20Predicate) public initializer {
        require(_token != address(0), "Vault: a valid token address must be provided");

        __Ownable_init();

        token = _token;

        if (_rootChainManager != address(0)) {
            require(_erc20Predicate != address(0), "Vault: erc20Predicate must not be 0x0");

            erc20Predicate = _erc20Predicate;
            rootChainManager = IRootChainManager(_rootChainManager);
        }
    }
// Solidity 0.5.17
/// @author james foley http://github.com/realisation
/// @notice selectively deposit any supported stablecoin flavor into the contract in return for corresponding amount of component tokens
/// @param _derivatives an array containing the addresses of the flavors being deposited into
/// @param _amounts an array containing the values of the flavors you wish to deposit into the contract. each amount should have the same index as the flavor it is meant to deposit
/// @param _minComponents minimum acceptable amount of components
/// @param _deadline deadline for tx
/// @return componentsToMint_ the amount of components to mint for the deposited stablecoin flavors
function selectiveDeposit (
        address[] calldata _derivatives,
        uint[] calldata _amounts,
        uint _minComponents,
        uint _deadline
    ) external deadline(_deadline) transactable nonReentrant returns (
        uint componentsMinted_
    ) {

        componentsMinted_ = SelectiveLiquidity.selectiveDeposit(component, _derivatives, _amounts, _minComponents);

    }
// Solidity 0.5.17
/// @author james foley http://github.com/realisation
/// @notice selectively withdrawal any supported stablecoin flavor from the contract by burning a corresponding amount of component tokens
/// @param _derivatives an array of flavors to withdraw from the reserves
/// @param _amounts an array of amounts to withdraw that maps to _flavors
/// @param _maxComponents the maximum amount of components you want to burn
/// @param _deadline timestamp after which the transaction is no longer valid
/// @return componentsBurned_ the corresponding amount of component tokens to withdraw the specified amount of specified flavors
function selectiveWithdraw (
        address[] calldata _derivatives,
        uint[] calldata _amounts,
        uint _maxComponents,
        uint _deadline
    ) external deadline(_deadline) transactable nonReentrant returns (
        uint componentsBurned_
    ) {

        componentsBurned_ = SelectiveLiquidity.selectiveWithdraw(component, _derivatives, _amounts, _maxComponents);

    }
// Solidity 0.8.6
/// @notice Transfers full balance of managed token through the Polygon Bridge
/// @dev Emits TransferToChild on funds being sucessfuly deposited
function transferToChild() public { // onlyOnRoot , maybe onlyOwner
        require(erc20Predicate != address(0), "Vault: transfer to child chain is disabled");

        IERC20 erc20 = IERC20(token);

        uint256 amount = erc20.balanceOf(address(this));
        erc20.approve(erc20Predicate, amount);
        rootChainManager.depositFor(address(this), token, abi.encode(amount));

        emit TransferToChild(msg.sender, token, amount);
    }
// Solidity 0.4.19
// Constructor
// @notice RAOToken Contract
// @return the transaction address
function RAOToken(address _multisig) public {
        require(_multisig != 0x0);
        multisig = _multisig;
        RATE = initialPrice;
        startTime = now;

        // the balances will be sealed for 6 months
        sealdate = startTime + 180 days;

        // for now the token sale will run for 30 days
        endTime = startTime + 60 days;
        balances[multisig] = _totalSupply;

        owner = msg.sender;
    }
// Solidity 0.8.4
/**
 * @dev Add time lock, only locker can add
 */
function _addTimeLock(
        address account,
        uint256 amount,
        uint256 expiresAt
    ) internal {
        require(amount > 0, "Time Lock: lock amount must be greater than 0");
        require(expiresAt > block.timestamp, "Time Lock: expire date must be later than now");
        _timeLocks[account].push(TimeLock(amount, expiresAt));
        emit TimeLocked(account);
    }