// Contract: Batcher
// Target function: function batch(address[] calldata recipients, uint256[] calldata values) external payable lockCall
pragma solidity 0.7.5;

// SPDX-License-Identifier: Apache-2.0

/**
 *
 * Batcher
 * =======
 *
 * Contract that can take a batch of transfers, presented in the form of a recipients array and a values array, and
 * funnel off those funds to the correct accounts in a single transaction. This is useful for saving on gas when a
 * bunch of funds need to be transferred to different accounts.
 *
 * This contract will return any excess funds in a batch back to the sender. It should never store any ETH on it.
 * If any tokens are accidentally transferred to this account, contact the contract owner in order to recover them.
 *
 *
 */

contract Batcher {
    event BatchTransfer(address sender, address recipient, uint256 value);
    event OwnerChange(address prevOwner, address newOwner);
    event TransferGasLimitChange(uint256 prevTransferGasLimit, uint256 newTransferGasLimit);

    address public owner;
    uint256 public lockCounter;
    uint256 public transferGasLimit;

    constructor() {
        lockCounter = 1;
        owner = msg.sender;
        emit OwnerChange(address(0), owner);
        transferGasLimit = 10000;
        emit TransferGasLimitChange(0, transferGasLimit);
    }

    modifier lockCall() {
        lockCounter++;
        uint256 localCounter = lockCounter;
        _;
        require(localCounter == lockCounter, "Reentrancy attempt detected");
    }

    modifier onlyOwner() {
        require(msg.sender == owner, "Not owner");
        _;
    }