Contract 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f4

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x7a338b1614669be1d497e34d35181a1448a1680b55a9ce713a476c44b7de3d5c0x6080604050047622022-01-25 3:07:09155 days 23 mins ago0xb013abd83f0bd173e9f14ce7d6e420ad711483b4 IN  Create: MasterOfCoin0 ETH0.041418470127 ETH
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xfb7b063e37de907124321c2d5e63075af80b33073cf54095aecb8f9a242eb861163428902022-06-29 3:15:4814 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0xe2bc035d8cfe07ec0f264f63b7615bcfeb9c812a035c64561999b68c79431be2163424652022-06-29 3:13:3217 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x88aa1e5218b14ffd2500d896ce97b43710455890ad2788a2cf636d40806a28ff163424302022-06-29 3:13:3217 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x9807fa0eca144853724adaec1e8246d7e5db400a216eb5a9d7591ce6aa611620163423612022-06-29 3:13:3217 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x637e5a9ae6dd4ba9ea4c16c307089e935e23b367b63d1ba8ae27f05f741158b2163423092022-06-29 3:12:1818 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0xc52517e2f07b0fb5c3c73f0c9f5b7f9d98e96e03a953666601eca582a0d2c187163422102022-06-29 3:12:1818 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0xa2a7a6ade06b93f76b6c481b76e32f98bd146082cdd5f23489a6ee87a78b4323163374122022-06-29 2:44:3846 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
0x1b94773279836736fdfc8940af8c694ae45eb8c072052eb51620f9044e71bfa3163358362022-06-29 2:33:4756 mins ago 0x3563590e19d2b9216e7879d269a04ec67ed95a87 0xf5ef1ad33d0d997a7c0c147d4d2ccb4669fec9f40 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MasterOfCoin

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 16 : MasterOfCoin.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import '@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol';
import '@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol';
import '@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol';
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import './IMasterOfCoin.sol';
import './IStream.sol';

contract MasterOfCoin is IMasterOfCoin, Initializable, AccessControlEnumerableUpgradeable {
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;
    using SafeERC20Upgradeable for IERC20Upgradeable;

    bytes32 public constant MASTER_OF_COIN_ADMIN_ROLE = keccak256("MASTER_OF_COIN_ADMIN_ROLE");

    IERC20Upgradeable public magic;

    /// @notice stream address => CoinStream
    mapping (address => CoinStream) public streamConfig;

    /// @notice stream ID => stream address
    EnumerableSetUpgradeable.AddressSet private streams;

    /// @notice stream address => bool
    mapping (address => bool) public callbackRegistry;

    modifier streamExists(address _stream) {
        require(streams.contains(_stream), "Stream does not exist");
        _;
    }

    modifier streamActive(address _stream) {
        require(streamConfig[_stream].endTimestamp > block.timestamp, "Stream ended");
        _;
    }

    modifier callbackStream(address _stream) {
        if (callbackRegistry[_stream]) IStream(_stream).preRateUpdate();
        _;
        if (callbackRegistry[_stream]) IStream(_stream).postRateUpdate();
    }

    event StreamAdded(address indexed stream, uint256 amount, uint256 startTimestamp, uint256 endTimestamp);
    event StreamTimeUpdated(address indexed stream, uint256 startTimestamp, uint256 endTimestamp);

    event StreamGrant(address indexed stream, address from, uint256 amount);
    event StreamFunded(address indexed stream, uint256 amount);
    event StreamDefunded(address indexed stream, uint256 amount);
    event StreamRemoved(address indexed stream);

    event RewardsPaid(address indexed stream, uint256 rewardsPaid, uint256 rewardsPaidInTotal);
    event Withdraw(address to, uint256 amount);
    event CallbackSet(address stream, bool value);

    function init(address _magic) external initializer {
        magic = IERC20Upgradeable(_magic);

        _setRoleAdmin(MASTER_OF_COIN_ADMIN_ROLE, MASTER_OF_COIN_ADMIN_ROLE);
        _grantRole(MASTER_OF_COIN_ADMIN_ROLE, msg.sender);

        __AccessControlEnumerable_init();
    }

    function requestRewards() public virtual returns (uint256 rewardsPaid) {
        CoinStream storage stream = streamConfig[msg.sender];

        rewardsPaid = getPendingRewards(msg.sender);

        if (rewardsPaid == 0 || magic.balanceOf(address(this)) < rewardsPaid) {
            return 0;
        }

        stream.paid += rewardsPaid;
        stream.lastRewardTimestamp = block.timestamp;

        // this should never happen but better safe than sorry
        require(stream.paid <= stream.totalRewards, "Rewards overflow");

        magic.safeTransfer(msg.sender, rewardsPaid);
        emit RewardsPaid(msg.sender, rewardsPaid, stream.paid);
    }

    function grantTokenToStream(address _stream, uint256 _amount)
        public
        virtual
        streamExists(_stream)
        streamActive(_stream)
    {
        _fundStream(_stream, _amount);

        magic.safeTransferFrom(msg.sender, address(this), _amount);
        emit StreamGrant(_stream, msg.sender, _amount);
    }

    function getStreams() external view virtual returns (address[] memory) {
        return streams.values();
    }

    function getStreamConfig(address _stream) external view virtual returns (CoinStream memory) {
        return streamConfig[_stream];
    }

    function getGlobalRatePerSecond() external view virtual returns (uint256 globalRatePerSecond) {
        uint256 len = streams.length();
        for (uint256 i = 0; i < len; i++) {
            globalRatePerSecond += getRatePerSecond(streams.at(i));
        }
    }

    function getRatePerSecond(address _stream) public view virtual returns (uint256 ratePerSecond) {
        CoinStream storage stream = streamConfig[_stream];

        if (stream.startTimestamp < block.timestamp && block.timestamp < stream.endTimestamp) {
            ratePerSecond = stream.ratePerSecond;
        }
    }

    function getPendingRewards(address _stream) public view virtual returns (uint256 pendingRewards) {
        CoinStream storage stream = streamConfig[_stream];

        uint256 paid = stream.paid;
        uint256 totalRewards = stream.totalRewards;
        uint256 lastRewardTimestamp = stream.lastRewardTimestamp;

        if (block.timestamp >= stream.endTimestamp) {
            // stream ended
            pendingRewards = totalRewards - paid;
        } else if (block.timestamp > lastRewardTimestamp) {
            // stream active
            uint256 secondsFromLastPull = block.timestamp - lastRewardTimestamp;
            pendingRewards = secondsFromLastPull * stream.ratePerSecond;

            // in case of rounding error, make sure that paid + pending rewards is never more than totalRewards
            if (paid + pendingRewards > totalRewards) {
                pendingRewards = totalRewards - paid;
            }
        }
    }

    function _fundStream(address _stream, uint256 _amount) internal virtual callbackStream(_stream) {
        CoinStream storage stream = streamConfig[_stream];

        uint256 secondsToEnd = stream.endTimestamp - stream.lastRewardTimestamp;
        uint256 rewardsLeft = secondsToEnd * stream.ratePerSecond;
        stream.ratePerSecond = (rewardsLeft + _amount) / secondsToEnd;
        stream.totalRewards += _amount;
    }

    // ADMIN

    /// @param _stream address of the contract that gets rewards
    /// @param _totalRewards amount of MAGIC that should be distributed in total
    /// @param _startTimestamp when MAGIC stream should start
    /// @param _endTimestamp when MAGIC stream should end
    /// @param _callback should callback be used (if you don't know, set false)
    function addStream(
        address _stream,
        uint256 _totalRewards,
        uint256 _startTimestamp,
        uint256 _endTimestamp,
        bool _callback
    ) external virtual onlyRole(MASTER_OF_COIN_ADMIN_ROLE) {
        require(_endTimestamp > _startTimestamp, "Rewards must last > 1 sec");
        require(!streams.contains(_stream), "Stream for address already exists");

        if (streams.add(_stream)) {
            streamConfig[_stream] = CoinStream({
                totalRewards: _totalRewards,
                startTimestamp: _startTimestamp,
                endTimestamp: _endTimestamp,
                lastRewardTimestamp: _startTimestamp,
                ratePerSecond: _totalRewards / (_endTimestamp - _startTimestamp),
                paid: 0
            });
            emit StreamAdded(_stream, _totalRewards, _startTimestamp, _endTimestamp);

            setCallback(_stream, _callback);
        }
    }

    function fundStream(address _stream, uint256 _amount)
        external
        virtual
        onlyRole(MASTER_OF_COIN_ADMIN_ROLE)
        streamExists(_stream)
        streamActive(_stream)
    {
        _fundStream(_stream, _amount);
        emit StreamFunded(_stream, _amount);
    }

    function defundStream(address _stream, uint256 _amount)
        external
        virtual
        onlyRole(MASTER_OF_COIN_ADMIN_ROLE)
        streamExists(_stream)
        streamActive(_stream)
        callbackStream(_stream)
    {
        CoinStream storage stream = streamConfig[_stream];

        uint256 secondsToEnd = stream.endTimestamp - stream.lastRewardTimestamp;
        uint256 rewardsLeft = secondsToEnd * stream.ratePerSecond;

        require(_amount <= rewardsLeft, "Reduce amount too large, rewards already paid");

        stream.ratePerSecond = (rewardsLeft - _amount) / secondsToEnd;
        stream.totalRewards -= _amount;

        emit StreamDefunded(_stream, _amount);
    }

    function updateStreamTime(address _stream, uint256 _startTimestamp, uint256 _endTimestamp)
        external
        virtual
        onlyRole(MASTER_OF_COIN_ADMIN_ROLE)
        streamExists(_stream)
        callbackStream(_stream)
    {
        CoinStream storage stream = streamConfig[_stream];

        if (_startTimestamp > 0) {
            require(_startTimestamp > block.timestamp, "startTimestamp cannot be in the past");

            stream.startTimestamp = _startTimestamp;
            stream.lastRewardTimestamp = _startTimestamp;
        }

        if (_endTimestamp > 0) {
            require(_endTimestamp > _startTimestamp, "Rewards must last > 1 sec");
            require(_endTimestamp > block.timestamp, "Cannot end rewards in the past");

            stream.endTimestamp = _endTimestamp;
        }

        stream.ratePerSecond = (stream.totalRewards - stream.paid) / (stream.endTimestamp - stream.lastRewardTimestamp);

        emit StreamTimeUpdated(_stream, _startTimestamp, _endTimestamp);
    }

    function removeStream(address _stream)
        external
        virtual
        onlyRole(MASTER_OF_COIN_ADMIN_ROLE)
        streamExists(_stream)
        callbackStream(_stream)
    {
        if (streams.remove(_stream)) {
            delete streamConfig[_stream];
            emit StreamRemoved(_stream);
        }
    }

    function setCallback(address _stream, bool _value)
        public
        virtual
        onlyRole(MASTER_OF_COIN_ADMIN_ROLE)
        streamExists(_stream)
        callbackStream(_stream)
    {
        callbackRegistry[_stream] = _value;
        emit CallbackSet(_stream, _value);
    }

    function withdrawMagic(address _to, uint256 _amount) external virtual onlyRole(MASTER_OF_COIN_ADMIN_ROLE) {
        magic.safeTransfer(_to, _amount);
        emit Withdraw(_to, _amount);
    }

    function setMagicToken(address _magic) external virtual onlyRole(MASTER_OF_COIN_ADMIN_ROLE) {
        magic = IERC20Upgradeable(_magic);
    }
}

File 2 of 16 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 3 of 16 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20Upgradeable {
    using AddressUpgradeable for address;

    function safeTransfer(
        IERC20Upgradeable token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20Upgradeable token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 4 of 16 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastvalue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastvalue;
                // Update the index for the moved value
                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        return _values(set._inner);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        assembly {
            result := store
        }

        return result;
    }
}

File 5 of 16 : AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerableUpgradeable.sol";
import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
    function __AccessControlEnumerable_init() internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
        __AccessControlEnumerable_init_unchained();
    }

    function __AccessControlEnumerable_init_unchained() internal onlyInitializing {
    }
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {_grantRole} to track enumerable memberships
     */
    function _grantRole(bytes32 role, address account) internal virtual override {
        super._grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {_revokeRole} to track enumerable memberships
     */
    function _revokeRole(bytes32 role, address account) internal virtual override {
        super._revokeRole(role, account);
        _roleMembers[role].remove(account);
    }
    uint256[49] private __gap;
}

File 6 of 16 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 7 of 16 : IMasterOfCoin.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IMasterOfCoin {
    struct CoinStream {
        uint256 totalRewards;
        uint256 startTimestamp;
        uint256 endTimestamp;
        uint256 lastRewardTimestamp;
        uint256 ratePerSecond;
        uint256 paid;
    }
    
    function requestRewards() external returns (uint256 rewardsPaid);

    function grantTokenToStream(address _stream, uint256 _amount) external;

    function getStreams() external view returns (address[] memory);

    function getStreamConfig(address _stream) external view returns (CoinStream memory);

    function getGlobalRatePerSecond() external view returns (uint256 globalRatePerSecond);

    function getRatePerSecond(address _stream) external view returns (uint256 ratePerSecond);

    function getPendingRewards(address _stream) external view returns (uint256 pendingRewards);
}

File 8 of 16 : IStream.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IStream {
    function preRateUpdate() external;
    function postRateUpdate() external;
}

File 9 of 16 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 10 of 16 : IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable {
    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

File 11 of 16 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(uint160(account), 20),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
    uint256[49] private __gap;
}

File 12 of 16 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 13 of 16 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
    uint256[50] private __gap;
}

File 14 of 16 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 15 of 16 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

File 16 of 16 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stream","type":"address"},{"indexed":false,"internalType":"bool","name":"value","type":"bool"}],"name":"CallbackSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stream","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardsPaid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardsPaidInTotal","type":"uint256"}],"name":"RewardsPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stream","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTimestamp","type":"uint256"}],"name":"StreamAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stream","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StreamDefunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stream","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StreamFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stream","type":"address"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"StreamGrant","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stream","type":"address"}],"name":"StreamRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"stream","type":"address"},{"indexed":false,"internalType":"uint256","name":"startTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTimestamp","type":"uint256"}],"name":"StreamTimeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MASTER_OF_COIN_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"},{"internalType":"uint256","name":"_totalRewards","type":"uint256"},{"internalType":"uint256","name":"_startTimestamp","type":"uint256"},{"internalType":"uint256","name":"_endTimestamp","type":"uint256"},{"internalType":"bool","name":"_callback","type":"bool"}],"name":"addStream","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"callbackRegistry","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"defundStream","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"fundStream","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getGlobalRatePerSecond","outputs":[{"internalType":"uint256","name":"globalRatePerSecond","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"}],"name":"getPendingRewards","outputs":[{"internalType":"uint256","name":"pendingRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"}],"name":"getRatePerSecond","outputs":[{"internalType":"uint256","name":"ratePerSecond","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"}],"name":"getStreamConfig","outputs":[{"components":[{"internalType":"uint256","name":"totalRewards","type":"uint256"},{"internalType":"uint256","name":"startTimestamp","type":"uint256"},{"internalType":"uint256","name":"endTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastRewardTimestamp","type":"uint256"},{"internalType":"uint256","name":"ratePerSecond","type":"uint256"},{"internalType":"uint256","name":"paid","type":"uint256"}],"internalType":"struct IMasterOfCoin.CoinStream","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStreams","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"grantTokenToStream","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_magic","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"magic","outputs":[{"internalType":"contract IERC20Upgradeable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"}],"name":"removeStream","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestRewards","outputs":[{"internalType":"uint256","name":"rewardsPaid","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"},{"internalType":"bool","name":"_value","type":"bool"}],"name":"setCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_magic","type":"address"}],"name":"setMagicToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"streamConfig","outputs":[{"internalType":"uint256","name":"totalRewards","type":"uint256"},{"internalType":"uint256","name":"startTimestamp","type":"uint256"},{"internalType":"uint256","name":"endTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastRewardTimestamp","type":"uint256"},{"internalType":"uint256","name":"ratePerSecond","type":"uint256"},{"internalType":"uint256","name":"paid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_stream","type":"address"},{"internalType":"uint256","name":"_startTimestamp","type":"uint256"},{"internalType":"uint256","name":"_endTimestamp","type":"uint256"}],"name":"updateStreamTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawMagic","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506126ef806100206000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80639010d07c11610104578063ca15c873116100a2578063df6564d411610071578063df6564d414610496578063e53c0ce8146104a9578063e92dcfbd146104be578063f6ed2017146104d157600080fd5b8063ca15c87314610448578063d04fed631461045b578063d3e6721114610470578063d547741f1461048357600080fd5b8063a217fddf116100de578063a217fddf146103b6578063ae5c9357146103be578063b2eb853f146103c6578063c95f0e92146103e957600080fd5b80639010d07c1461038857806391a2024d1461039b57806391d14854146103a357600080fd5b80632f2ff15d1161017157806359c2bb291161014b57806359c2bb291461033c5780637e11ee0d1461034f5780637fa33cbc14610362578063808a75591461037557600080fd5b80632f2ff15d1461030357806336568abe146103165780634744d1661461032957600080fd5b80630ebc4fdc116101ad5780630ebc4fdc1461029757806310af21af146102ac57806319ab453c146102bf578063248a9ca3146102d257600080fd5b806301ffc9a7146101d45780630847bf8a146101fc5780630d8546461461026c575b600080fd5b6101e76101e23660046121cb565b6104e4565b60405190151581526020015b60405180910390f35b61023f61020a366004612211565b60ca60205260009081526040902080546001820154600283015460038401546004850154600590950154939492939192909186565b604080519687526020870195909552938501929092526060840152608083015260a082015260c0016101f3565b60c95461027f906001600160a01b031681565b6040516001600160a01b0390911681526020016101f3565b6102aa6102a5366004612211565b61050f565b005b6102aa6102ba36600461223d565b6106bf565b6102aa6102cd366004612211565b610877565b6102f56102e0366004612291565b60009081526065602052604090206001015490565b6040519081526020016101f3565b6102aa6103113660046122aa565b610984565b6102aa6103243660046122aa565b6109af565b6102f5610337366004612211565b610a29565b6102aa61034a3660046122d6565b610a6a565b6102aa61035d366004612300565b610cf9565b6102aa6103703660046122d6565b610e8c565b6102aa6103833660046122d6565b610f5c565b61027f610396366004612337565b610fd3565b6102f5610ff2565b6101e76103b13660046122aa565b61103d565b6102f5600081565b6102f5611068565b6101e76103d4366004612211565b60cd6020526000908152604090205460ff1681565b6103fc6103f7366004612211565b6111de565b6040516101f39190600060c082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015292915050565b6102f5610456366004612291565b611279565b610463611290565b6040516101f39190612359565b6102aa61047e3660046123a6565b6112a1565b6102aa6104913660046122aa565b61155e565b6102aa6104a4366004612211565b611584565b6102f560008051602061269a83398151915281565b6102aa6104cc3660046122d6565b6115c0565b6102f56104df366004612211565b611691565b60006001600160e01b03198216635a05180f60e01b1480610509575061050982611722565b92915050565b60008051602061269a8339815191526105288133611757565b8161053460cb826117bb565b6105595760405162461bcd60e51b8152600401610550906123d9565b60405180910390fd5b6001600160a01b038316600090815260cd6020526040902054839060ff16156105d057806001600160a01b031663bc1f03286040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156105b757600080fd5b505af11580156105cb573d6000803e3d6000fd5b505050505b6105db60cb856117dd565b15610644576001600160a01b038416600081815260ca602052604080822082815560018101839055600281018390556003810183905560048101839055600501829055517f254bcf11eab3bff9d2632cae78df40253dd1675b019ead4d56b342124e8ed5f89190a25b6001600160a01b038116600090815260cd602052604090205460ff16156106b957806001600160a01b0316634f9845196040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156106a057600080fd5b505af11580156106b4573d6000803e3d6000fd5b505050505b50505050565b60008051602061269a8339815191526106d88133611757565b8383116107235760405162461bcd60e51b815260206004820152601960248201527852657761726473206d757374206c617374203e20312073656360381b6044820152606401610550565b61072e60cb876117bb565b156107855760405162461bcd60e51b815260206004820152602160248201527f53747265616d20666f72206164647265737320616c72656164792065786973746044820152607360f81b6064820152608401610550565b61079060cb876117f2565b1561086f576040518060c0016040528086815260200185815260200184815260200185815260200185856107c4919061241e565b6107ce9088612435565b8152600060209182018190526001600160a01b03891680825260ca83526040918290208451815584840151600182015584830151600282015560608086015160038301556080860151600483015560a0909501516005909101558151898152928301889052908201869052917f484da220470cb56a2f9c4192f61d124f2d69b205218c75f701b267e4da852bbc910160405180910390a261086f8683610cf9565b505050505050565b600054610100900460ff166108925760005460ff1615610896565b303b155b6108f95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610550565b600054610100900460ff1615801561091b576000805461ffff19166101011790555b60c980546001600160a01b0319166001600160a01b03841617905561094e60008051602061269a83398151915280611807565b61096660008051602061269a83398151915233611852565b61096e611874565b8015610980576000805461ff00191690555b5050565b6000828152606560205260409020600101546109a08133611757565b6109aa8383611852565b505050565b6001600160a01b0381163314610a1f5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610550565b61098082826118bd565b6001600160a01b038116600090815260ca60205260408120600181015442118015610a575750806002015442105b15610a6457806004015491505b50919050565b60008051602061269a833981519152610a838133611757565b82610a8f60cb826117bb565b610aab5760405162461bcd60e51b8152600401610550906123d9565b6001600160a01b038416600090815260ca602052604090206002015484904210610ae75760405162461bcd60e51b815260040161055090612457565b6001600160a01b038516600090815260cd6020526040902054859060ff1615610b5e57806001600160a01b031663bc1f03286040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610b4557600080fd5b505af1158015610b59573d6000803e3d6000fd5b505050505b6001600160a01b038616600090815260ca6020526040812060038101546002820154919291610b8d919061241e565b90506000826004015482610ba1919061247d565b905080881115610c095760405162461bcd60e51b815260206004820152602d60248201527f52656475636520616d6f756e7420746f6f206c617267652c207265776172647360448201526c08185b1c9958591e481c185a59609a1b6064820152608401610550565b81610c14898361241e565b610c1e9190612435565b6004840155825488908490600090610c3790849061241e565b90915550506040518881526001600160a01b038a16907fb66d4375eb1b962d0f2d8c3b761817076de66e3a4707e2dc664b3d0e1c16cbc29060200160405180910390a25050506001600160a01b038116600090815260cd602052604090205460ff161561086f57806001600160a01b0316634f9845196040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610cd957600080fd5b505af1158015610ced573d6000803e3d6000fd5b50505050505050505050565b60008051602061269a833981519152610d128133611757565b82610d1e60cb826117bb565b610d3a5760405162461bcd60e51b8152600401610550906123d9565b6001600160a01b038416600090815260cd6020526040902054849060ff1615610db157806001600160a01b031663bc1f03286040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610d9857600080fd5b505af1158015610dac573d6000803e3d6000fd5b505050505b6001600160a01b038516600081815260cd6020908152604091829020805460ff19168815159081179091558251938452908301527fb5541a615b23b714aea0fdeb7ca01ff9286be2c990ab585f7dc8f094701ff50f910160405180910390a16001600160a01b038116600090815260cd602052604090205460ff1615610e8557806001600160a01b0316634f9845196040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610e6c57600080fd5b505af1158015610e80573d6000803e3d6000fd5b505050505b5050505050565b81610e9860cb826117bb565b610eb45760405162461bcd60e51b8152600401610550906123d9565b6001600160a01b038316600090815260ca602052604090206002015483904210610ef05760405162461bcd60e51b815260040161055090612457565b610efa84846118df565b60c954610f12906001600160a01b0316333086611a4b565b60408051338152602081018590526001600160a01b038616917ff48b992127d9bf4383e884ca74bfce7005bb2bca01b7233463e2279f46033e1e910160405180910390a250505050565b60008051602061269a833981519152610f758133611757565b60c954610f8c906001600160a01b03168484611ab6565b604080516001600160a01b0385168152602081018490527f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364910160405180910390a1505050565b6000828152609760205260408120610feb9083611ae6565b9392505050565b600080610fff60cb611af2565b905060005b818110156110385761101a61033760cb83611ae6565b611024908461249c565b925080611030816124b4565b915050611004565b505090565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b33600081815260ca60205260408120909161108290611691565b9150811580611109575060c9546040516370a0823160e01b815230600482015283916001600160a01b0316906370a082319060240160206040518083038186803b1580156110cf57600080fd5b505afa1580156110e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061110791906124cf565b105b1561111657600091505090565b8181600501600082825461112a919061249c565b909155505042600382015580546005820154111561117d5760405162461bcd60e51b815260206004820152601060248201526f52657761726473206f766572666c6f7760801b6044820152606401610550565b60c954611194906001600160a01b03163384611ab6565b600581015460405133917f53195aae24c76f608fd5b9b6ee2da62eb3a6f4e5279d15a8ddfef43199a4b38e916111d291868252602082015260400190565b60405180910390a25090565b6112176040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001600081525090565b506001600160a01b0316600090815260ca6020908152604091829020825160c08101845281548152600182015492810192909252600281015492820192909252600382015460608201526004820154608082015260059091015460a082015290565b600081815260976020526040812061050990611af2565b606061129c60cb611afc565b905090565b60008051602061269a8339815191526112ba8133611757565b836112c660cb826117bb565b6112e25760405162461bcd60e51b8152600401610550906123d9565b6001600160a01b038516600090815260cd6020526040902054859060ff161561135957806001600160a01b031663bc1f03286040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561134057600080fd5b505af1158015611354573d6000803e3d6000fd5b505050505b6001600160a01b038616600090815260ca6020526040902085156113e1574286116113d25760405162461bcd60e51b8152602060048201526024808201527f737461727454696d657374616d702063616e6e6f7420626520696e20746865206044820152631c185cdd60e21b6064820152608401610550565b60018101869055600381018690555b8415611489578585116114325760405162461bcd60e51b815260206004820152601960248201527852657761726473206d757374206c617374203e20312073656360381b6044820152606401610550565b4285116114815760405162461bcd60e51b815260206004820152601e60248201527f43616e6e6f7420656e64207265776172647320696e20746865207061737400006044820152606401610550565b600281018590555b8060030154816002015461149d919061241e565b600582015482546114ae919061241e565b6114b89190612435565b600482015560408051878152602081018790526001600160a01b038916917f1fd81367da382670a175c21794f60c2d5c54ccdc0352f188e456f211639cd4b4910160405180910390a2506001600160a01b038116600090815260cd602052604090205460ff161561086f57806001600160a01b0316634f9845196040518163ffffffff1660e01b8152600401600060405180830381600087803b158015610cd957600080fd5b60008281526065602052604090206001015461157a8133611757565b6109aa83836118bd565b60008051602061269a83398151915261159d8133611757565b5060c980546001600160a01b0319166001600160a01b0392909216919091179055565b60008051602061269a8339815191526115d98133611757565b826115e560cb826117bb565b6116015760405162461bcd60e51b8152600401610550906123d9565b6001600160a01b038416600090815260ca60205260409020600201548490421061163d5760405162461bcd60e51b815260040161055090612457565b61164785856118df565b846001600160a01b03167f3cc66965316d63dfc547ebbc450bf2deef36b96d3436c5a3874fff04e07c54a58560405161168291815260200190565b60405180910390a25050505050565b6001600160a01b038116600090815260ca60205260408120600581015481546003830154600284015442106116d1576116ca838361241e565b9450611719565b804211156117195760006116e5824261241e565b90508460040154816116f7919061247d565b955082611704878661249c565b111561171757611714848461241e565b95505b505b50505050919050565b60006001600160e01b03198216637965db0b60e01b148061050957506301ffc9a760e01b6001600160e01b0319831614610509565b611761828261103d565b61098057611779816001600160a01b03166014611b09565b611784836020611b09565b604051602001611795929190612514565b60408051601f198184030181529082905262461bcd60e51b825261055091600401612589565b6001600160a01b03811660009081526001830160205260408120541515610feb565b6000610feb836001600160a01b038416611ca5565b6000610feb836001600160a01b038416611d98565b600082815260656020526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b61185c8282611de7565b60008281526097602052604090206109aa90826117f2565b600054610100900460ff1661189b5760405162461bcd60e51b8152600401610550906125bc565b6118a3611e6d565b6118ab611e6d565b6118b3611e6d565b6118bb611e6d565b565b6118c78282611e94565b60008281526097602052604090206109aa90826117dd565b6001600160a01b038216600090815260cd6020526040902054829060ff161561195657806001600160a01b031663bc1f03286040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561193d57600080fd5b505af1158015611951573d6000803e3d6000fd5b505050505b6001600160a01b038316600090815260ca6020526040812060038101546002820154919291611985919061241e565b90506000826004015482611999919061247d565b9050816119a6868361249c565b6119b09190612435565b60048401558254859084906000906119c990849061249c565b909155505050506001600160a01b038216600090815260cd602052604090205460ff161590506109aa57806001600160a01b0316634f9845196040518163ffffffff1660e01b8152600401600060405180830381600087803b158015611a2e57600080fd5b505af1158015611a42573d6000803e3d6000fd5b50505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526106b99085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611efb565b6040516001600160a01b0383166024820152604481018290526109aa90849063a9059cbb60e01b90606401611a7f565b6000610feb8383611fcd565b6000610509825490565b60606000610feb83611ff7565b60606000611b1883600261247d565b611b2390600261249c565b67ffffffffffffffff811115611b3b57611b3b612607565b6040519080825280601f01601f191660200182016040528015611b65576020820181803683370190505b509050600360fc1b81600081518110611b8057611b8061261d565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611baf57611baf61261d565b60200101906001600160f81b031916908160001a9053506000611bd384600261247d565b611bde90600161249c565b90505b6001811115611c56576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611c1257611c1261261d565b1a60f81b828281518110611c2857611c2861261d565b60200101906001600160f81b031916908160001a90535060049490941c93611c4f81612633565b9050611be1565b508315610feb5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610550565b60008181526001830160205260408120548015611d8e576000611cc960018361241e565b8554909150600090611cdd9060019061241e565b9050818114611d42576000866000018281548110611cfd57611cfd61261d565b9060005260206000200154905080876000018481548110611d2057611d2061261d565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611d5357611d5361264a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610509565b6000915050610509565b6000818152600183016020526040812054611ddf57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610509565b506000610509565b611df1828261103d565b6109805760008281526065602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611e293390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600054610100900460ff166118bb5760405162461bcd60e51b8152600401610550906125bc565b611e9e828261103d565b156109805760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000611f50826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166120539092919063ffffffff16565b8051909150156109aa5780806020019051810190611f6e9190612660565b6109aa5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610550565b6000826000018281548110611fe457611fe461261d565b9060005260206000200154905092915050565b60608160000180548060200260200160405190810160405280929190818152602001828054801561204757602002820191906000526020600020905b815481526020019060010190808311612033575b50505050509050919050565b6060612062848460008561206a565b949350505050565b6060824710156120cb5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610550565b843b6121195760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610550565b600080866001600160a01b03168587604051612135919061267d565b60006040518083038185875af1925050503d8060008114612172576040519150601f19603f3d011682016040523d82523d6000602084013e612177565b606091505b5091509150612187828286612192565b979650505050505050565b606083156121a1575081610feb565b8251156121b15782518084602001fd5b8160405162461bcd60e51b81526004016105509190612589565b6000602082840312156121dd57600080fd5b81356001600160e01b031981168114610feb57600080fd5b80356001600160a01b038116811461220c57600080fd5b919050565b60006020828403121561222357600080fd5b610feb826121f5565b801515811461223a57600080fd5b50565b600080600080600060a0868803121561225557600080fd5b61225e866121f5565b945060208601359350604086013592506060860135915060808601356122838161222c565b809150509295509295909350565b6000602082840312156122a357600080fd5b5035919050565b600080604083850312156122bd57600080fd5b823591506122cd602084016121f5565b90509250929050565b600080604083850312156122e957600080fd5b6122f2836121f5565b946020939093013593505050565b6000806040838503121561231357600080fd5b61231c836121f5565b9150602083013561232c8161222c565b809150509250929050565b6000806040838503121561234a57600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b8181101561239a5783516001600160a01b031683529284019291840191600101612375565b50909695505050505050565b6000806000606084860312156123bb57600080fd5b6123c4846121f5565b95602085013595506040909401359392505050565b60208082526015908201527414dd1c99585b48191bd95cc81b9bdd08195e1a5cdd605a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60008282101561243057612430612408565b500390565b60008261245257634e487b7160e01b600052601260045260246000fd5b500490565b6020808252600c908201526b14dd1c99585b48195b99195960a21b604082015260600190565b600081600019048311821515161561249757612497612408565b500290565b600082198211156124af576124af612408565b500190565b60006000198214156124c8576124c8612408565b5060010190565b6000602082840312156124e157600080fd5b5051919050565b60005b838110156125035781810151838201526020016124eb565b838111156106b95750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161254c8160178501602088016124e8565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161257d8160288401602088016124e8565b01602801949350505050565b60208152600082518060208401526125a88160408501602087016124e8565b601f01601f19169190910160400192915050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60008161264257612642612408565b506000190190565b634e487b7160e01b600052603160045260246000fd5b60006020828403121561267257600080fd5b8151610feb8161222c565b6000825161268f8184602087016124e8565b919091019291505056fe275f12656528ceae7cba2736a15cb4ce098fc404b67e9825ec13a82aaf8fabeca26469706673582212206d52641c55b3ce9805ca59b59a09b4baa49b292d230d89d9ac89b8d21354076664736f6c63430008090033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.