false
true
0

Contract Address Details

0x7cBb92E2e73c7431303d6F54E9E7cD6E35aFD667

Contract Name
Autopay
Creator
0xdf24bc–bc15fb at 0xe6b1a8–164979
Balance
0 tPLS
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
26048724
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
Autopay




Optimization enabled
true
Compiler version
v0.8.20+commit.a1b79de6




Optimization runs
300
EVM Version
paris




Verified at
2025-03-10T07:36:47.850437Z

contracts/Autopay.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

//TODO fix import paths
import {UsingFetchUpgradeReady} from "./usingfetch/UsingFetchUpgradeReady.sol";
import {IERC20} from "./interfaces/IERC20.sol";
import "./interfaces/IQueryDataStorage.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

/**
 @author Fetch Inc.
 @title Autopay
 @dev This is a contract for automatically paying for Fetch oracle data at
 * specific time intervals, as well as one time tips.
*/
contract Autopay is UsingFetchUpgradeReady, Initializable, OwnableUpgradeable, UUPSUpgradeable {
    // Storage
    IERC20 public token; // FETCH token address
    IQueryDataStorage public queryDataStorage; // Query data storage contract

    mapping(bytes32 => bytes32[]) currentFeeds; // mapping queryId to dataFeedIds array
    mapping(bytes32 => mapping(bytes32 => Feed)) dataFeed; // mapping queryId to dataFeedId to details
    mapping(bytes32 => bytes32) public queryIdFromDataFeedId; // mapping dataFeedId to queryId
    mapping(bytes32 => uint256) public queryIdsWithFundingIndex; // mapping queryId to queryIdsWithFunding index plus one (0 if not in array)
    mapping(bytes32 => Tip[]) public tips; // mapping queryId to tips
    mapping(address => uint256) public userTipsTotal; // track user tip total per user

    bytes32[] public feedsWithFunding; // array of dataFeedIds that have funding
    bytes32[] public queryIdsWithFunding; // array of queryIds that have funding

    // Structs
    struct Feed {
        FeedDetails details;
        mapping(uint256 => bool) rewardClaimed; // tracks which tips were already paid out
    }

    struct FeedDetails {
        uint256 reward; // amount paid for each eligible data submission
        uint256 balance; // account remaining balance
        uint256 startTime; // time of first payment window
        uint256 interval; // time between pay periods
        uint256 window; // amount of time data can be submitted per interval
        uint256 priceThreshold; //change in price necessitating an update 100 = 1%
        uint256 rewardIncreasePerSecond; // amount reward increases per second within window (0 for flat rewards)
        uint256 feedsWithFundingIndex; // index plus one of dataFeedID in feedsWithFunding array (0 if not in array)
    }

    struct FeedDetailsWithQueryData {
        FeedDetails details; // feed details for feed id with funding
        bytes queryData; // query data for requested data
    }

    struct SingleTipsWithQueryData {
        bytes queryData; // query data with single tip for requested data
        uint256 tip; // reward amount for request
    }

    struct Tip {
        uint256 amount; // amount tipped
        uint256 timestamp; // time tipped
        uint256 cumulativeTips; // cumulative tips for query ID
    }

    // Events
    event DataFeedFunded(
        bytes32 indexed _queryId,
        bytes32 indexed _feedId,
        uint256 indexed _amount,
        address _feedFunder,
        FeedDetails _feedDetails
    );
    event NewDataFeed(
        bytes32 indexed _queryId,
        bytes32 indexed _feedId,
        bytes _queryData,
        address _feedCreator
    );
    event OneTimeTipClaimed(
        bytes32 indexed _queryId,
        uint256 indexed _amount,
        address indexed _reporter
    );
    event TipAdded(
        bytes32 indexed _queryId,
        uint256 indexed _amount,
        bytes _queryData,
        address _tipper
    );
    event TipClaimed(
        bytes32 indexed _feedId,
        bytes32 indexed _queryId,
        uint256 indexed _amount,
        address _reporter
    );

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    function initialize(address payable _fetch, address _queryDataStorage) public initializer {
        __Ownable_init();
        setFetchAddress(_fetch);
        token = IERC20(fetch.token());
        queryDataStorage = IQueryDataStorage(_queryDataStorage);
    }

    function _authorizeUpgrade(address _newImplementation) internal virtual override onlyOwner {
    }

    /**
     * @dev Function to claim singular tip
     * @param _queryId id of reported data
     * @param _timestamps[] batch of timestamps array of reported data eligible for reward
     */
    function claimOneTimeTip(
        bytes32 _queryId,
        uint256[] calldata _timestamps
    ) external {
        require(
            tips[_queryId].length > 0,
            "no tips submitted for this queryId"
        );
        uint256 _cumulativeReward;
        for (uint256 _i = 0; _i < _timestamps.length; _i++) {
            _cumulativeReward += _getOneTimeTipAmount(
                _queryId,
                _timestamps[_i]
            );
        }
        require(
            token.transfer(
                msg.sender,
                _cumulativeReward
            )
        );
        if (getCurrentTip(_queryId) == 0) {
            if (queryIdsWithFundingIndex[_queryId] != 0) {
                uint256 _idx = queryIdsWithFundingIndex[_queryId] - 1;
                // Replace unfunded feed in array with last element
                queryIdsWithFunding[_idx] = queryIdsWithFunding[
                    queryIdsWithFunding.length - 1
                ];
                bytes32 _queryIdLastFunded = queryIdsWithFunding[_idx];
                queryIdsWithFundingIndex[_queryIdLastFunded] = _idx + 1;
                queryIdsWithFundingIndex[_queryId] = 0;
                queryIdsWithFunding.pop();
            }
        }
        emit OneTimeTipClaimed(_queryId, _cumulativeReward, msg.sender);
    }

    /**
     * @dev Allows Fetch reporters to claim their tips in batches
     * @param _feedId unique feed identifier
     * @param _queryId ID of reported data
     * @param _timestamps batch of timestamps array of reported data eligible for reward
     */
    function claimTip(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256[] calldata _timestamps
    ) external {
        Feed storage _feed = dataFeed[_queryId][_feedId];
        uint256 _balance = _feed.details.balance;
        require(_balance > 0, "no funds available for this feed");
        uint256 _cumulativeReward;
        for (uint256 _i = 0; _i < _timestamps.length; _i++) {
            require(
                block.timestamp - _timestamps[_i] > 12 hours,
                "buffer time has not passed"
            );
            require(
                getReporterByTimestamp(_queryId, _timestamps[_i]) == msg.sender,
                "message sender not reporter for given queryId and timestamp"
            );
            _cumulativeReward += _getRewardAmount(
                _feedId,
                _queryId,
                _timestamps[_i]
            );
            if (_cumulativeReward >= _balance) {
                // Balance runs out
                require(
                    _i == _timestamps.length - 1,
                    "insufficient balance for all submitted timestamps"
                );
                _cumulativeReward = _balance;
                // Adjust currently funded feeds
                if (feedsWithFunding.length > 1) {
                    uint256 _idx = _feed.details.feedsWithFundingIndex - 1;
                    // Replace unfunded feed in array with last element
                    feedsWithFunding[_idx] = feedsWithFunding[
                        feedsWithFunding.length - 1
                    ];
                    bytes32 _feedIdLastFunded = feedsWithFunding[_idx];
                    bytes32 _queryIdLastFunded = queryIdFromDataFeedId[
                        _feedIdLastFunded
                    ];
                    dataFeed[_queryIdLastFunded][_feedIdLastFunded]
                        .details
                        .feedsWithFundingIndex = _idx + 1;
                }
                feedsWithFunding.pop();
                _feed.details.feedsWithFundingIndex = 0;
            }
            _feed.rewardClaimed[_timestamps[_i]] = true;
        }
        _feed.details.balance -= _cumulativeReward;
        require(
            token.transfer(
                msg.sender,
                _cumulativeReward
            )
        );
        emit TipClaimed(_feedId, _queryId, _cumulativeReward, msg.sender);
    }

    /**
     * @dev Allows dataFeed account to be filled with tokens
     * @param _feedId unique feed identifier
     * @param _queryId identifier of reported data type associated with feed
     * @param _amount quantity of tokens to fund feed
     */
    function fundFeed(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256 _amount
    ) public {
        FeedDetails storage _feed = dataFeed[_queryId][_feedId].details;
        require(_feed.reward > 0, "feed not set up");
        require(_amount > 0, "must be sending an amount");
        _feed.balance += _amount;
        require(
            token.transferFrom(msg.sender, address(this), _amount),
            "ERC20: transfer amount exceeds balance"
        );
        // Add to array of feeds with funding
        if (_feed.feedsWithFundingIndex == 0 && _feed.balance > 0) {
            feedsWithFunding.push(_feedId);
            _feed.feedsWithFundingIndex = feedsWithFunding.length;
        }
        userTipsTotal[msg.sender] += _amount;
        emit DataFeedFunded(_feedId, _queryId, _amount, msg.sender, _feed);
    }

    /**
     * @dev Initializes dataFeed parameters.
     * @param _queryId unique identifier of desired data feed
     * @param _reward tip amount per eligible data submission
     * @param _startTime timestamp of first autopay window
     * @param _interval amount of time between autopay windows
     * @param _window amount of time after each new interval when reports are eligible for tips
     * @param _priceThreshold amount price must change to automate update regardless of time (negated if 0, 100 = 1%)
     * @param _rewardIncreasePerSecond amount reward increases per second within a window (0 for flat reward)
     * @param _queryData the data used by reporters to fulfill the query
     * @param _amount optional initial amount to fund it with
     */
    function setupDataFeed(
        bytes32 _queryId,
        uint256 _reward,
        uint256 _startTime,
        uint256 _interval,
        uint256 _window,
        uint256 _priceThreshold,
        uint256 _rewardIncreasePerSecond,
        bytes calldata _queryData,
        uint256 _amount
    ) external returns (bytes32 _feedId) {
        require(
            _queryId == keccak256(_queryData),
            "id must be hash of bytes data"
        );
        _feedId = keccak256(
            abi.encode(
                _queryId,
                _reward,
                _startTime,
                _interval,
                _window,
                _priceThreshold,
                _rewardIncreasePerSecond
            )
        );
        FeedDetails storage _feed = dataFeed[_queryId][_feedId].details;
        require(_feed.reward == 0, "feed must not be set up already");
        require(_reward > 0, "reward must be greater than zero");
        require(_interval > 0, "interval must be greater than zero");
        require(
            _window < _interval,
            "window must be less than interval length"
        );
        _feed.reward = _reward;
        _feed.startTime = _startTime;
        _feed.interval = _interval;
        _feed.window = _window;
        _feed.priceThreshold = _priceThreshold;
        _feed.rewardIncreasePerSecond = _rewardIncreasePerSecond;
        currentFeeds[_queryId].push(_feedId);
        queryIdFromDataFeedId[_feedId] = _queryId;
        queryDataStorage.storeData(_queryData);
        emit NewDataFeed(_queryId, _feedId, _queryData, msg.sender);
        if (_amount > 0) {
            fundFeed(_feedId, _queryId, _amount);
        }
        return _feedId;
    }

    /**
     * @dev Function to run a single tip
     * @param _queryId ID of tipped data
     * @param _amount amount to tip
     * @param _queryData the data used by reporters to fulfill the query
     */
    function tip(
        bytes32 _queryId,
        uint256 _amount,
        bytes calldata _queryData
    ) external {
        require(
            _queryId == keccak256(_queryData),
            "id must be hash of bytes data"
        );
        require(_amount > 0, "tip must be greater than zero");
        Tip[] storage _tips = tips[_queryId];
        if (_tips.length == 0) {
            _tips.push(Tip(_amount, block.timestamp + 1, _amount));
            queryDataStorage.storeData(_queryData);
        } else {
            (, uint256 _timestampRetrieved) = _getCurrentValue(_queryId);
            if (_timestampRetrieved < _tips[_tips.length - 1].timestamp) {
                _tips[_tips.length - 1].timestamp = block.timestamp + 1;
                _tips[_tips.length - 1].amount += _amount;
                _tips[_tips.length - 1].cumulativeTips += _amount;
            } else {
                _tips.push(
                    Tip(
                        _amount,
                        block.timestamp + 1,
                        _tips[_tips.length - 1].cumulativeTips + _amount
                    )
                );
            }
        }
        if (
            queryIdsWithFundingIndex[_queryId] == 0 &&
            getCurrentTip(_queryId) > 0
        ) {
            queryIdsWithFunding.push(_queryId);
            queryIdsWithFundingIndex[_queryId] = queryIdsWithFunding.length;
        }
        require(
            token.transferFrom(msg.sender, address(this), _amount),
            "ERC20: transfer amount exceeds balance"
        );
        userTipsTotal[msg.sender] += _amount;
        emit TipAdded(_queryId, _amount, _queryData, msg.sender);
    }

    // Getters
    /**
     * @dev Getter function to read current data feeds
     * @param _queryId id of reported data
     * @return feedIds array for queryId
     */
    function getCurrentFeeds(
        bytes32 _queryId
    ) external view returns (bytes32[] memory) {
        return currentFeeds[_queryId];
    }

    /**
     * @dev Getter function to current oneTime tip by queryId
     * @param _queryId id of reported data
     * @return amount of tip
     */
    function getCurrentTip(bytes32 _queryId) public view returns (uint256) {
        // if no tips, return 0
        if (tips[_queryId].length == 0) {
            return 0;
        }
        (, uint256 _timestampRetrieved) = _getCurrentValue(_queryId);
        Tip memory _lastTip = tips[_queryId][tips[_queryId].length - 1];
        if (_timestampRetrieved < _lastTip.timestamp) {
            return _lastTip.amount;
        } else {
            return 0;
        }
    }

    /**
     * @dev Getter function to read a specific dataFeed
     * @param _feedId unique feedId of parameters
     * @return FeedDetails details of specified feed
     */
    function getDataFeed(
        bytes32 _feedId
    ) external view returns (FeedDetails memory) {
        return (dataFeed[queryIdFromDataFeedId[_feedId]][_feedId].details);
    }

    /**
     * @dev Getter function for currently funded feed details
     * @return FeedDetailsWithQueryData[] array of details for funded feeds
     */
    function getFundedFeedDetails()
        external
        view
        returns (FeedDetailsWithQueryData[] memory)
    {
        bytes32[] memory _feeds = this.getFundedFeeds();
        FeedDetailsWithQueryData[]
            memory _details = new FeedDetailsWithQueryData[](_feeds.length);
        for (uint256 i = 0; i < _feeds.length; i++) {
            FeedDetails memory _feedDetail = this.getDataFeed(_feeds[i]);
            bytes32 _queryId = this.getQueryIdFromFeedId(_feeds[i]);
            bytes memory _queryData = queryDataStorage.getQueryData(_queryId);
            _details[i].details = _feedDetail;
            _details[i].queryData = _queryData;
        }
        return _details;
    }

    /**
     * @dev Getter function for currently funded feeds
     */
    function getFundedFeeds() external view returns (bytes32[] memory) {
        return feedsWithFunding;
    }

    /**
     * @dev Getter function for queryIds with current one time tips
     */
    function getFundedQueryIds() external view returns (bytes32[] memory) {
        return queryIdsWithFunding;
    }

    /**
     * @dev Getter function for currently funded single tips with queryData
     * @return SingleTipsWithQueryData[] array of current tips
     */
    function getFundedSingleTipsInfo()
        external
        view
        returns (SingleTipsWithQueryData[] memory)
    {
        bytes32[] memory _fundedQueryIds = this.getFundedQueryIds();
        SingleTipsWithQueryData[] memory _query = new SingleTipsWithQueryData[](
            _fundedQueryIds.length
        );
        for (uint256 i = 0; i < _fundedQueryIds.length; i++) {
            bytes memory _data = queryDataStorage.getQueryData(
                _fundedQueryIds[i]
            );
            uint256 _reward = this.getCurrentTip(_fundedQueryIds[i]);
            _query[i].queryData = _data;
            _query[i].tip = _reward;
        }
        return _query;
    }

    /**
     * @dev Getter function to get number of past tips
     * @param _queryId id of reported data
     * @return count of tips available
     */
    function getPastTipCount(bytes32 _queryId) external view returns (uint256) {
        return tips[_queryId].length;
    }

    /**
     * @dev Getter function for past tips
     * @param _queryId id of reported data
     * @return Tip struct (amount/timestamp) of all past tips
     */
    function getPastTips(
        bytes32 _queryId
    ) external view returns (Tip[] memory) {
        return tips[_queryId];
    }

    /**
     * @dev Getter function for past tips by index
     * @param _queryId id of reported data
     * @param _index uint index in the Tip array
     * @return amount/timestamp of specific tip
     */
    function getPastTipByIndex(
        bytes32 _queryId,
        uint256 _index
    ) external view returns (Tip memory) {
        return tips[_queryId][_index];
    }

    /**
     * @dev Getter function to lookup query IDs from dataFeed IDs
     * @param _feedId dataFeed unique identifier
     * @return bytes32 corresponding query ID
     */
    function getQueryIdFromFeedId(
        bytes32 _feedId
    ) external view returns (bytes32) {
        return queryIdFromDataFeedId[_feedId];
    }

    /**
     * @dev Getter function to read potential rewards for a set of oracle submissions
     * NOTE: Does not consider reporter address, 12-hour dispute buffer period, or duplicate timestamps
     * @param _feedId dataFeed unique identifier
     * @param _queryId unique identifier of reported data
     * @param _timestamps array of timestamps of oracle submissions
     * @return _cumulativeReward total potential reward for the set of oracle submissions
     */
    function getRewardAmount(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256[] calldata _timestamps
    ) external view returns (uint256 _cumulativeReward) {
        FeedDetails storage _feed = dataFeed[_queryId][_feedId].details;
        for (uint256 _i = 0; _i < _timestamps.length; _i++) {
            _cumulativeReward += _getRewardAmount(
                _feedId,
                _queryId,
                _timestamps[_i]
            );
        }
        if (_cumulativeReward > _feed.balance) {
            _cumulativeReward = _feed.balance;
        }
    }

    /**
     * @dev Getter function for reading whether a reward has been claimed
     * @param _feedId feedId of dataFeed
     * @param _queryId id of reported data
     * @param _timestamp id or reported data
     * @return bool rewardClaimed
     */
    function getRewardClaimedStatus(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256 _timestamp
    ) external view returns (bool) {
        return dataFeed[_queryId][_feedId].rewardClaimed[_timestamp];
    }

    /**
     * @dev Getter function for reading whether a reward has been claimed
     * @param _feedId feedId of dataFeed
     * @param _queryId queryId of reported data
     * @param _timestamp[] list of report timestamps
     * @return bool[] list of rewardClaim status
     */
    function getRewardClaimStatusList(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256[] calldata _timestamp
    ) external view returns (bool[] memory) {
        bool[] memory _status = new bool[](_timestamp.length);
        for (uint256 i = 0; i < _timestamp.length; i++) {
            _status[i] = dataFeed[_queryId][_feedId].rewardClaimed[
                _timestamp[i]
            ];
        }
        return _status;
    }

    /**
     * @dev Getter function for retrieving the total amount of tips paid by a given address
     * @param _user address of user to query
     * @return uint256 total amount of tips paid by user
     */
    function getTipsByAddress(address _user) external view returns (uint256) {
        return userTipsTotal[_user];
    }

    // Internal functions
    /**
     * @dev Internal function to read if a reward has been claimed
     * @param _b bytes value to convert to uint256
     * @return _number uint256 converted from bytes
     */
    function _bytesToUint(
        bytes memory _b
    ) internal pure returns (uint256 _number) {
        for (uint256 _i = 0; _i < _b.length; _i++) {
            _number = _number * 256 + uint8(_b[_i]);
        }
    }

    /**
     ** @dev Internal function which determines tip eligibility for a given oracle submission
     * @param _queryId id of reported data
     * @param _timestamp timestamp of one time tip
     * @return _tipAmount of tip
     */
    function _getOneTimeTipAmount(
        bytes32 _queryId,
        uint256 _timestamp
    ) internal returns (uint256 _tipAmount) {
        require(
            block.timestamp - _timestamp > 12 hours,
            "buffer time has not passed"
        );
        require(!isInDispute(_queryId, _timestamp), "value disputed");
        require(
            msg.sender == getReporterByTimestamp(_queryId, _timestamp),
            "msg sender must be reporter address"
        );
        Tip[] storage _tips = tips[_queryId];
        uint256 _min = 0;
        uint256 _max = _tips.length;
        uint256 _mid;
        while (_max - _min > 1) {
            _mid = (_max + _min) / 2;
            if (_tips[_mid].timestamp > _timestamp) {
                _max = _mid;
            } else {
                _min = _mid;
            }
        }
        (, uint256 _timestampBefore) = getDataBefore(_queryId, _timestamp);
        require(
            _timestampBefore < _tips[_min].timestamp,
            "tip earned by previous submission"
        );
        require(
            _timestamp >= _tips[_min].timestamp,
            "timestamp not eligible for tip"
        );
        require(_tips[_min].amount > 0, "tip already claimed");
        _tipAmount = _tips[_min].amount;
        _tips[_min].amount = 0;
        uint256 _minBackup = _min;
        // check whether eligible for previous tips in array due to disputes
        (, uint256 _indexNow) = getIndexForDataBefore(_queryId, _timestamp + 1);
        (bool _found, uint256 _indexBefore) = getIndexForDataBefore(
            _queryId,
            _timestampBefore + 1
        );
        if (_indexNow - _indexBefore > 1 || !_found) {
            if (!_found) {
                _tipAmount = _tips[_minBackup].cumulativeTips;
            } else {
                _max = _min;
                _min = 0;
                _mid;
                while (_max - _min > 1) {
                    _mid = (_max + _min) / 2;
                    if (_tips[_mid].timestamp > _timestampBefore) {
                        _max = _mid;
                    } else {
                        _min = _mid;
                    }
                }
                _min++;
                if (_min < _minBackup) {
                    _tipAmount =
                        _tips[_minBackup].cumulativeTips -
                        _tips[_min].cumulativeTips +
                        _tips[_min].amount;
                }
            }
        }
    }

    /**
     * @dev Allows the user to get the latest value for the queryId specified
     * @param _queryId is the id to look up the value for
     * @return _value the value retrieved
     * @return _timestampRetrieved the retrieved value's timestamp
     */

    function _getCurrentValue(
        bytes32 _queryId
    ) internal view returns (bytes memory _value, uint256 _timestampRetrieved) {
        uint256 _count = getNewValueCountbyQueryId(_queryId);
        if (_count == 0) {
            return (bytes(""), 0);
        }
        uint256 _time;
        //loop handles for dispute (value = "" if disputed)
        while (_count > 0) {
            _count--;
            _time = getTimestampbyQueryIdandIndex(_queryId, _count);
            _value = retrieveData(_queryId, _time);
            if (_value.length > 0) {
                return (_value, _time);
            }
        }
        return (bytes(""), _time);
    }

    /**
     * @dev Internal function which determines the reward amount for a given oracle submission
     * @param _feedId id of dataFeed
     * @param _queryId id of reported data
     * @param _timestamp timestamp of reported data eligible for reward
     * @return _rewardAmount potential reward amount for the given oracle submission
     */
    function _getRewardAmount(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256 _timestamp
    ) internal view returns (uint256 _rewardAmount) {
        require(
            block.timestamp - _timestamp < 4 weeks,
            "timestamp too old to claim tip"
        );
        Feed storage _feed = dataFeed[_queryId][_feedId];
        require(!_feed.rewardClaimed[_timestamp], "reward already claimed");
        uint256 _n = (_timestamp - _feed.details.startTime) /
            _feed.details.interval; // finds closest interval _n to timestamp
        uint256 _c = _feed.details.startTime + _feed.details.interval * _n; // finds start timestamp _c of interval _n
        bytes memory _valueRetrieved = retrieveData(_queryId, _timestamp);
        require(_valueRetrieved.length != 0, "no value exists at timestamp");
        (
            bytes memory _valueRetrievedBefore,
            uint256 _timestampBefore
        ) = getDataBefore(_queryId, _timestamp);
        uint256 _priceChange = 0; // price change from last value to current value
        if (_feed.details.priceThreshold != 0) {
            uint256 _v1 = _bytesToUint(_valueRetrieved);
            uint256 _v2 = _bytesToUint(_valueRetrievedBefore);
            if (_v2 == 0) {
                _priceChange = 10000;
            } else if (_v1 >= _v2) {
                _priceChange = (10000 * (_v1 - _v2)) / _v2;
            } else {
                _priceChange = (10000 * (_v2 - _v1)) / _v2;
            }
        }
        _rewardAmount = _feed.details.reward;
        uint256 _timeDiff = _timestamp - _c; // time difference between report timestamp and start of interval
        // ensure either report is first within a valid window, or price change threshold is met
        if (_timeDiff < _feed.details.window && _timestampBefore < _c) {
            // add time based rewards if applicable
            _rewardAmount += _feed.details.rewardIncreasePerSecond * _timeDiff;
        } else {
            require(
                _priceChange > _feed.details.priceThreshold,
                "price threshold not met"
            );
        }

        if (_feed.details.balance < _rewardAmount) {
            _rewardAmount = _feed.details.balance;
        }
    }
}
        

@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}
          

@openzeppelin/contracts-upgradeable/interfaces/IERC1967Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
 *
 * _Available since v4.8.3._
 */
interface IERC1967Upgradeable {
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Emitted when the beacon is changed.
     */
    event BeaconUpgraded(address indexed beacon);
}
          

@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}
          

@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import {Initializable} from "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            AddressUpgradeable.functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}
          

@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}
          

@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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 proxied contracts do not make use of 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.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * 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 prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

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

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}
          

@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import {Initializable} from "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeTo(address newImplementation) public virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}
          

@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}
          

@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;
import {Initializable} from "../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 {
    }

    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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}
          

@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
 * _Available since v4.9 for `string`, `bytes`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}
          

contracts/interfaces/IERC20.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

interface IERC20 {
    function balanceOf(address account) external view returns (uint256);

    function transfer(address recipient, uint256 amount)
        external
        returns (bool);

    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external returns (bool);
}
          

contracts/interfaces/IERC2362.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

/**
    * @dev EIP2362 Interface for pull oracles
    * https://github.com/fetchoracle/EIP-2362
*/
interface IERC2362
{
	/**
	 * @dev Exposed function pertaining to EIP standards
	 * @param _id bytes32 ID of the query
	 * @return int,uint,uint returns the value, timestamp, and status code of query
	 */
	function valueFor(bytes32 _id) external view returns(int256,uint256,uint256);
}
          

contracts/interfaces/IFetch.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

interface IFetch {
    //Controller
    function addresses(bytes32) external view returns (address);

    function uints(bytes32) external view returns (uint256);

    function burn(uint256 _amount) external;

    function changeDeity(address _newDeity) external;

    function changeOwner(address _newOwner) external;
    function changeUint(bytes32 _target, uint256 _amount) external;

    function migrate() external;

    function mint(address _reciever, uint256 _amount) external;

    function init() external;

    function getAllDisputeVars(uint256 _disputeId)
        external
        view
        returns (
            bytes32,
            bool,
            bool,
            bool,
            address,
            address,
            address,
            uint256[9] memory,
            int256
        );

    function getDisputeIdByDisputeHash(bytes32 _hash)
        external
        view
        returns (uint256);

    function getDisputeUintVars(uint256 _disputeId, bytes32 _data)
        external
        view
        returns (uint256);

    function getLastNewValueById(uint256 _requestId)
        external
        view
        returns (uint256, bool);

    function retrieveData(uint256 _requestId, uint256 _timestamp)
        external
        view
        returns (uint256);

    function getNewValueCountbyRequestId(uint256 _requestId)
        external
        view
        returns (uint256);

    function getAddressVars(bytes32 _data) external view returns (address);

    function getUintVar(bytes32 _data) external view returns (uint256);

    function totalSupply() external view returns (uint256);

    function name() external pure returns (string memory);

    function symbol() external pure returns (string memory);

    function decimals() external pure returns (uint8);

    function isMigrated(address _addy) external view returns (bool);

    function allowance(address _user, address _spender)
        external
        view
        returns (uint256);

    function allowedToTrade(address _user, uint256 _amount)
        external
        view
        returns (bool);

    function approve(address _spender, uint256 _amount) external returns (bool);

    function approveAndTransferFrom(
        address _from,
        address _to,
        uint256 _amount
    ) external returns (bool);

    function balanceOf(address _user) external view returns (uint256);

    function balanceOfAt(address _user, uint256 _blockNumber)
        external
        view
        returns (uint256);

    function transfer(address _to, uint256 _amount)
        external
        returns (bool success);

    function transferFrom(
        address _from,
        address _to,
        uint256 _amount
    ) external returns (bool success);

    function depositStake() external;

    function requestStakingWithdraw() external;

    function withdrawStake() external;

    function changeStakingStatus(address _reporter, uint256 _status) external;

    function slashReporter(address _reporter, address _disputer) external;

    function getStakerInfo(address _staker)
        external
        view
        returns (uint256, uint256);

    function getTimestampbyRequestIDandIndex(uint256 _requestId, uint256 _index)
        external
        view
        returns (uint256);

    function getNewCurrentVariables()
        external
        view
        returns (
            bytes32 _c,
            uint256[5] memory _r,
            uint256 _d,
            uint256 _t
        );

    function getNewValueCountbyQueryId(bytes32 _queryId)
        external
        view
        returns (uint256);

    function getTimestampbyQueryIdandIndex(bytes32 _queryId, uint256 _index)
        external
        view
        returns (uint256);

    function retrieveData(bytes32 _queryId, uint256 _timestamp)
        external
        view
        returns (bytes memory);

    //Governance
    enum VoteResult {
        FAILED,
        PASSED,
        INVALID
    }

    function setApprovedFunction(bytes4 _func, bool _val) external;

    function beginDispute(bytes32 _queryId, uint256 _timestamp) external;

    function delegate(address _delegate) external;

    function delegateOfAt(address _user, uint256 _blockNumber)
        external
        view
        returns (address);

    function executeVote(uint256 _disputeId) external;

    function proposeVote(
        address _contract,
        bytes4 _function,
        bytes calldata _data,
        uint256 _timestamp
    ) external;

    function tallyVotes(uint256 _disputeId) external;

    function governance() external view returns (address);

    function updateMinDisputeFee() external;

    function verify() external pure returns (uint256);

    function vote(
        uint256 _disputeId,
        bool _supports,
        bool _invalidQuery
    ) external;

    function voteFor(
        address[] calldata _addys,
        uint256 _disputeId,
        bool _supports,
        bool _invalidQuery
    ) external;

    function getDelegateInfo(address _holder)
        external
        view
        returns (address, uint256);

    function isFunctionApproved(bytes4 _func) external view returns (bool);

    function isApprovedGovernanceContract(address _contract)
        external
        returns (bool);

    function getVoteRounds(bytes32 _hash)
        external
        view
        returns (uint256[] memory);

    function getVoteCount() external view returns (uint256);

    function getVoteInfo(uint256 _disputeId)
        external
        view
        returns (
            bytes32,
            uint256[9] memory,
            bool[2] memory,
            VoteResult,
            bytes memory,
            bytes4,
            address[2] memory
        );

    function getDisputeInfo(uint256 _disputeId)
        external
        view
        returns (
            uint256,
            uint256,
            bytes memory,
            address
        );

    function getOpenDisputesOnId(bytes32 _queryId)
        external
        view
        returns (uint256);

    function didVote(uint256 _disputeId, address _voter)
        external
        view
        returns (bool);

    //Oracle
    function getReportTimestampByIndex(bytes32 _queryId, uint256 _index)
        external
        view
        returns (uint256);

    function getValueByTimestamp(bytes32 _queryId, uint256 _timestamp)
        external
        view
        returns (bytes memory);

    function getBlockNumberByTimestamp(bytes32 _queryId, uint256 _timestamp)
        external
        view
        returns (uint256);

    function getReportingLock() external view returns (uint256);

    function getReporterByTimestamp(bytes32 _queryId, uint256 _timestamp)
        external
        view
        returns (address);

    function reportingLock() external view returns (uint256);

    function removeValue(bytes32 _queryId, uint256 _timestamp) external;
    function getTipsByUser(address _user) external view returns(uint256);
    function tipQuery(bytes32 _queryId, uint256 _tip, bytes memory _queryData) external;
    function submitValue(bytes32 _queryId, bytes calldata _value, uint256 _nonce, bytes memory _queryData) external;
    function burnTips() external;

    function changeReportingLock(uint256 _newReportingLock) external;
    function getReportsSubmittedByAddress(address _reporter) external view returns(uint256);
    function changeTimeBasedReward(uint256 _newTimeBasedReward) external;
    function getReporterLastTimestamp(address _reporter) external view returns(uint256);
    function getTipsById(bytes32 _queryId) external view returns(uint256);
    function getTimeBasedReward() external view returns(uint256);
    function getTimestampCountById(bytes32 _queryId) external view returns(uint256);
    function getTimestampIndexByTimestamp(bytes32 _queryId, uint256 _timestamp) external view returns(uint256);
    function getCurrentReward(bytes32 _queryId) external view returns(uint256, uint256);
    function getCurrentValue(bytes32 _queryId) external view returns(bytes memory);
    function getDataBefore(bytes32 _queryId, uint256 _timestamp) external view returns(bool _ifRetrieve, bytes memory _value, uint256 _timestampRetrieved);
    function getTimeOfLastNewValue() external view returns(uint256);
    function depositStake(uint256 _amount) external;
    function requestStakingWithdraw(uint256 _amount) external;

    //Test functions
    function changeAddressVar(bytes32 _id, address _addy) external;

    //parachute functions
    function killContract() external;

    function migrateFor(address _destination, uint256 _amount) external;

    function rescue51PercentAttack(address _tokenHolder) external;

    function rescueBrokenDataReporting() external;

    function rescueFailedUpdate() external;

    //Fetch 360
    function addStakingRewards(uint256 _amount) external;

    function _sliceUint(bytes memory _b)
        external
        pure
        returns (uint256 _number);

    function claimOneTimeTip(bytes32 _queryId, uint256[] memory _timestamps)
        external;

    function claimTip(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256[] memory _timestamps
    ) external;

    function fee() external view returns (uint256);

    function feedsWithFunding(uint256) external view returns (bytes32);

    function fundFeed(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256 _amount
    ) external;

    function getCurrentFeeds(bytes32 _queryId)
        external
        view
        returns (bytes32[] memory);

    function getCurrentTip(bytes32 _queryId) external view returns (uint256);

    function getDataAfter(bytes32 _queryId, uint256 _timestamp)
        external
        view
        returns (bytes memory _value, uint256 _timestampRetrieved);

    function getDataFeed(bytes32 _feedId)
        external
        view
        returns (Autopay.FeedDetails memory);

    function getFundedFeeds() external view returns (bytes32[] memory);

    function getFundedQueryIds() external view returns (bytes32[] memory);

    function getIndexForDataAfter(bytes32 _queryId, uint256 _timestamp)
        external
        view
        returns (bool _found, uint256 _index);

    function getIndexForDataBefore(bytes32 _queryId, uint256 _timestamp)
        external
        view
        returns (bool _found, uint256 _index);

    function getMultipleValuesBefore(
        bytes32 _queryId,
        uint256 _timestamp,
        uint256 _maxAge,
        uint256 _maxCount
    )
        external
        view
        returns (uint256[] memory _values, uint256[] memory _timestamps);

    function getPastTipByIndex(bytes32 _queryId, uint256 _index)
        external
        view
        returns (Autopay.Tip memory);

    function getPastTipCount(bytes32 _queryId) external view returns (uint256);

    function getPastTips(bytes32 _queryId)
        external
        view
        returns (Autopay.Tip[] memory);

    function getQueryIdFromFeedId(bytes32 _feedId)
        external
        view
        returns (bytes32);

    function getRewardAmount(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256[] memory _timestamps
    ) external view returns (uint256 _cumulativeReward);

    function getRewardClaimedStatus(
        bytes32 _feedId,
        bytes32 _queryId,
        uint256 _timestamp
    ) external view returns (bool);

    function getTipsByAddress(address _user) external view returns (uint256);

    function isInDispute(bytes32 _queryId, uint256 _timestamp)
        external
        view
        returns (bool);

    function queryIdFromDataFeedId(bytes32) external view returns (bytes32);

    function queryIdsWithFunding(uint256) external view returns (bytes32);

    function queryIdsWithFundingIndex(bytes32) external view returns (uint256);

    function setupDataFeed(
        bytes32 _queryId,
        uint256 _reward,
        uint256 _startTime,
        uint256 _interval,
        uint256 _window,
        uint256 _priceThreshold,
        uint256 _rewardIncreasePerSecond,
        bytes memory _queryData,
        uint256 _amount
    ) external;

    function fetch() external view returns (address);

    function tip(
        bytes32 _queryId,
        uint256 _amount,
        bytes memory _queryData
    ) external;

    function tips(bytes32, uint256)
        external
        view
        returns (uint256 amount, uint256 timestamp);

    function token() external view returns (address);

    function userTipsTotal(address) external view returns (uint256);

    function valueFor(bytes32 _id)
        external
        view
        returns (
            int256 _value,
            uint256 _timestamp,
            uint256 _statusCode
        );
}

interface Autopay {
    struct FeedDetails {
        uint256 reward;
        uint256 balance;
        uint256 startTime;
        uint256 interval;
        uint256 window;
        uint256 priceThreshold;
        uint256 rewardIncreasePerSecond;
        uint256 feedsWithFundingIndex;
    }

    struct Tip {
        uint256 amount;
        uint256 timestamp;
    }
    function getStakeAmount() external view returns(uint256);
    function stakeAmount() external view returns(uint256);
    function token() external view returns(address);
}
          

contracts/interfaces/IMappingContract.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IMappingContract{
    function getFetchID(bytes32 _id) external view returns(bytes32);
}
          

contracts/interfaces/IQueryDataStorage.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

interface IQueryDataStorage {
  function storeData(bytes memory _queryData) external; 
  function getQueryData(bytes32 _queryId) external view returns (bytes memory);
}
          

contracts/usingfetch/UsingFetchUpgradeReady.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import "../interfaces/IFetch.sol";
import "../interfaces/IERC2362.sol";
import "../interfaces/IMappingContract.sol";

/**
 @author Fetch Inc
 @title UsingFetchUpgradeReady
 @dev This contract helps smart contracts read data from Fetch
 */
contract UsingFetchUpgradeReady is IERC2362 {
    IFetch public fetch;
    IMappingContract public idMappingContract;
    uint256[50] private __gap;

    function setFetchAddress(address payable _fetch) internal {
        fetch = IFetch(_fetch);
    }

    /*Getters*/
    /**
     * @dev Retrieves the next value for the queryId after the specified timestamp
     * @param _queryId is the queryId to look up the value for
     * @param _timestamp after which to search for next value
     * @return _value the value retrieved
     * @return _timestampRetrieved the value's timestamp
     */
    function getDataAfter(bytes32 _queryId, uint256 _timestamp)
        public
        view
        returns (bytes memory _value, uint256 _timestampRetrieved)
    {
        (bool _found, uint256 _index) = getIndexForDataAfter(
            _queryId,
            _timestamp
        );
        if (!_found) {
            return ("", 0);
        }
        _timestampRetrieved = getTimestampbyQueryIdandIndex(_queryId, _index);
        _value = retrieveData(_queryId, _timestampRetrieved);
        return (_value, _timestampRetrieved);
    }

    /**
     * @dev Retrieves the latest value for the queryId before the specified timestamp
     * @param _queryId is the queryId to look up the value for
     * @param _timestamp before which to search for latest value
     * @return _value the value retrieved
     * @return _timestampRetrieved the value's timestamp
     */
    function getDataBefore(bytes32 _queryId, uint256 _timestamp)
        public
        view
        returns (bytes memory _value, uint256 _timestampRetrieved)
    {
        (, _value, _timestampRetrieved) = fetch.getDataBefore(
            _queryId,
            _timestamp
        );
    }

    /**
     * @dev Retrieves latest array index of data before the specified timestamp for the queryId
     * @param _queryId is the queryId to look up the index for
     * @param _timestamp is the timestamp before which to search for the latest index
     * @return _found whether the index was found
     * @return _index the latest index found before the specified timestamp
     */
    // slither-disable-next-line calls-loop
    function getIndexForDataAfter(bytes32 _queryId, uint256 _timestamp)
        public
        view
        returns (bool _found, uint256 _index)
    {
        uint256 _count = getNewValueCountbyQueryId(_queryId);
        if (_count == 0) return (false, 0);
        _count--;
        bool _search = true; // perform binary search
        uint256 _middle = 0;
        uint256 _start = 0;
        uint256 _end = _count;
        uint256 _timestampRetrieved;
        // checking boundaries to short-circuit the algorithm
        _timestampRetrieved = getTimestampbyQueryIdandIndex(_queryId, _end);
        if (_timestampRetrieved <= _timestamp) return (false, 0);
        _timestampRetrieved = getTimestampbyQueryIdandIndex(_queryId, _start);
        if (_timestampRetrieved > _timestamp) {
            // candidate found, check for disputes
            _search = false;
        }
        // since the value is within our boundaries, do a binary search
        while (_search) {
            _middle = (_end + _start) / 2;
            _timestampRetrieved = getTimestampbyQueryIdandIndex(
                _queryId,
                _middle
            );
            if (_timestampRetrieved > _timestamp) {
                // get immediate previous value
                uint256 _prevTime = getTimestampbyQueryIdandIndex(
                    _queryId,
                    _middle - 1
                );
                if (_prevTime <= _timestamp) {
                    // candidate found, check for disputes
                    _search = false;
                } else {
                    // look from start to middle -1(prev value)
                    _end = _middle - 1;
                }
            } else {
                // get immediate next value
                uint256 _nextTime = getTimestampbyQueryIdandIndex(
                    _queryId,
                    _middle + 1
                );
                if (_nextTime > _timestamp) {
                    // candidate found, check for disputes
                    _search = false;
                    _middle++;
                    _timestampRetrieved = _nextTime;
                } else {
                    // look from middle + 1(next value) to end
                    _start = _middle + 1;
                }
            }
        }
        // candidate found, check for disputed values
        if (!isInDispute(_queryId, _timestampRetrieved)) {
            // _timestampRetrieved is correct
            return (true, _middle);
        } else {
            // iterate forward until we find a non-disputed value
            while (
                isInDispute(_queryId, _timestampRetrieved) && _middle < _count
            ) {
                _middle++;
                _timestampRetrieved = getTimestampbyQueryIdandIndex(
                    _queryId,
                    _middle
                );
            }
            if (
                _middle == _count && isInDispute(_queryId, _timestampRetrieved)
            ) {
                return (false, 0);
            }
            // _timestampRetrieved is correct
            return (true, _middle);
        }
    }

    /**
     * @dev Retrieves latest array index of data before the specified timestamp for the queryId
     * @param _queryId is the queryId to look up the index for
     * @param _timestamp is the timestamp before which to search for the latest index
     * @return _found whether the index was found
     * @return _index the latest index found before the specified timestamp
     */
    // slither-disable-next-line calls-loop
    function getIndexForDataBefore(bytes32 _queryId, uint256 _timestamp)
        public
        view
        returns (bool _found, uint256 _index)
    {
        return fetch.getIndexForDataBefore(_queryId, _timestamp);
    }

    /**
     * @dev Retrieves multiple uint256 values before the specified timestamp
     * @param _queryId the unique id of the data query
     * @param _timestamp the timestamp before which to search for values
     * @param _maxAge the maximum number of seconds before the _timestamp to search for values
     * @param _maxCount the maximum number of values to return
     * @return _values the values retrieved, ordered from oldest to newest
     * @return _timestamps the timestamps of the values retrieved
     */
    function getMultipleValuesBefore(
        bytes32 _queryId,
        uint256 _timestamp,
        uint256 _maxAge,
        uint256 _maxCount
    )
        public
        view
        returns (bytes[] memory _values, uint256[] memory _timestamps)
    {
        // get index of first possible value
        (bool _ifRetrieve, uint256 _startIndex) = getIndexForDataAfter(
            _queryId,
            _timestamp - _maxAge
        );
        // no value within range
        if (!_ifRetrieve) {
            return (new bytes[](0), new uint256[](0));
        }
        uint256 _endIndex;
        // get index of last possible value
        (_ifRetrieve, _endIndex) = getIndexForDataBefore(_queryId, _timestamp);
        // no value before _timestamp
        if (!_ifRetrieve) {
            return (new bytes[](0), new uint256[](0));
        }
        uint256 _valCount = 0;
        uint256 _index = 0;
        uint256[] memory _timestampsArrayTemp = new uint256[](_maxCount);
        // generate array of non-disputed timestamps within range
        while (_valCount < _maxCount && _endIndex + 1 - _index > _startIndex) {
            uint256 _timestampRetrieved = getTimestampbyQueryIdandIndex(
                _queryId,
                _endIndex - _index
            );
            if (!isInDispute(_queryId, _timestampRetrieved)) {
                _timestampsArrayTemp[_valCount] = _timestampRetrieved;
                _valCount++;
            }
            _index++;
        }

        bytes[] memory _valuesArray = new bytes[](_valCount);
        uint256[] memory _timestampsArray = new uint256[](_valCount);
        // retrieve values and reverse timestamps order
        for (uint256 _i = 0; _i < _valCount; _i++) {
            _timestampsArray[_i] = _timestampsArrayTemp[_valCount - 1 - _i];
            _valuesArray[_i] = retrieveData(_queryId, _timestampsArray[_i]);
        }
        return (_valuesArray, _timestampsArray);
    }

    /**
     * @dev Counts the number of values that have been submitted for the queryId
     * @param _queryId the id to look up
     * @return uint256 count of the number of values received for the queryId
     */
    function getNewValueCountbyQueryId(bytes32 _queryId)
        public
        view
        returns (uint256)
    {
        return fetch.getNewValueCountbyQueryId(_queryId);
    }

    /**
     * @dev Returns the address of the reporter who submitted a value for a data ID at a specific time
     * @param _queryId is ID of the specific data feed
     * @param _timestamp is the timestamp to find a corresponding reporter for
     * @return address of the reporter who reported the value for the data ID at the given timestamp
     */
    function getReporterByTimestamp(bytes32 _queryId, uint256 _timestamp)
        public
        view
        returns (address)
    {
        return fetch.getReporterByTimestamp(_queryId, _timestamp);
    }

    /**
     * @dev Gets the timestamp for the value based on their index
     * @param _queryId is the id to look up
     * @param _index is the value index to look up
     * @return uint256 timestamp
     */
    function getTimestampbyQueryIdandIndex(bytes32 _queryId, uint256 _index)
        public
        view
        returns (uint256)
    {
        return fetch.getTimestampbyQueryIdandIndex(_queryId, _index);
    }

    /**
     * @dev Determines whether a value with a given queryId and timestamp has been disputed
     * @param _queryId is the value id to look up
     * @param _timestamp is the timestamp of the value to look up
     * @return bool true if queryId/timestamp is under dispute
     */
    function isInDispute(bytes32 _queryId, uint256 _timestamp)
        public
        view
        returns (bool)
    {
        return fetch.isInDispute(_queryId, _timestamp);
    }

    /**
     * @dev Retrieve value from oracle based on queryId/timestamp
     * @param _queryId being requested
     * @param _timestamp to retrieve data/value from
     * @return bytes value for query/timestamp submitted
     */
    function retrieveData(bytes32 _queryId, uint256 _timestamp)
        public
        view
        returns (bytes memory)
    {
        return fetch.retrieveData(_queryId, _timestamp);
    }

    /**
     * @dev allows dev to set mapping contract for valueFor (EIP2362)
     * @param _addy address of mapping contract
     */
    function setIdMappingContract(address _addy) external {
        require(address(idMappingContract) == address(0));
        idMappingContract = IMappingContract(_addy);
    }

    /**
     * @dev Retrieve most recent int256 value from oracle based on queryId
     * @param _id being requested
     * @return _value most recent value submitted
     * @return _timestamp timestamp of most recent value
     * @return _statusCode 200 if value found, 404 if not found
     */
    function valueFor(bytes32 _id)
        external
        view
        override
        returns (
            int256 _value,
            uint256 _timestamp,
            uint256 _statusCode
        )
    {
        bytes32 _queryId = idMappingContract.getFetchID(_id);
        bytes memory _valueBytes;
        (_valueBytes, _timestamp) = getDataBefore(
            _queryId,
            block.timestamp + 1
        );
        if (_timestamp == 0) {
            return (0, 0, 404);
        }
        uint256 _valueUint = _sliceUint(_valueBytes);
        _value = int256(_valueUint);
        return (_value, _timestamp, 200);
    }

    // Internal functions
    /**
     * @dev Convert bytes to uint256
     * @param _b bytes value to convert to uint256
     * @return _number uint256 converted from bytes
     */
    function _sliceUint(bytes memory _b)
        internal
        pure
        returns (uint256 _number)
    {
        for (uint256 _i = 0; _i < _b.length; _i++) {
            _number = _number * 256 + uint8(_b[_i]);
        }
    }
}
          

Compiler Settings

{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata","storageLayout"],"":["ast"]}},"optimizer":{"runs":300,"enabled":true},"libraries":{},"evmVersion":"paris"}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"DataFeedFunded","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"_feedId","internalType":"bytes32","indexed":true},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":true},{"type":"address","name":"_feedFunder","internalType":"address","indexed":false},{"type":"tuple","name":"_feedDetails","internalType":"struct Autopay.FeedDetails","indexed":false,"components":[{"type":"uint256","name":"reward","internalType":"uint256"},{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"startTime","internalType":"uint256"},{"type":"uint256","name":"interval","internalType":"uint256"},{"type":"uint256","name":"window","internalType":"uint256"},{"type":"uint256","name":"priceThreshold","internalType":"uint256"},{"type":"uint256","name":"rewardIncreasePerSecond","internalType":"uint256"},{"type":"uint256","name":"feedsWithFundingIndex","internalType":"uint256"}]}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"NewDataFeed","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"_feedId","internalType":"bytes32","indexed":true},{"type":"bytes","name":"_queryData","internalType":"bytes","indexed":false},{"type":"address","name":"_feedCreator","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"OneTimeTipClaimed","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32","indexed":true},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":true},{"type":"address","name":"_reporter","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"TipAdded","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32","indexed":true},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":true},{"type":"bytes","name":"_queryData","internalType":"bytes","indexed":false},{"type":"address","name":"_tipper","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"TipClaimed","inputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"_queryId","internalType":"bytes32","indexed":true},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":true},{"type":"address","name":"_reporter","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimOneTimeTip","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256[]","name":"_timestamps","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"claimTip","inputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32"},{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256[]","name":"_timestamps","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"feedsWithFunding","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IFetch"}],"name":"fetch","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"fundFeed","inputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32"},{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32[]","name":"","internalType":"bytes32[]"}],"name":"getCurrentFeeds","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getCurrentTip","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"_value","internalType":"bytes"},{"type":"uint256","name":"_timestampRetrieved","internalType":"uint256"}],"name":"getDataAfter","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"_value","internalType":"bytes"},{"type":"uint256","name":"_timestampRetrieved","internalType":"uint256"}],"name":"getDataBefore","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Autopay.FeedDetails","components":[{"type":"uint256","name":"reward","internalType":"uint256"},{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"startTime","internalType":"uint256"},{"type":"uint256","name":"interval","internalType":"uint256"},{"type":"uint256","name":"window","internalType":"uint256"},{"type":"uint256","name":"priceThreshold","internalType":"uint256"},{"type":"uint256","name":"rewardIncreasePerSecond","internalType":"uint256"},{"type":"uint256","name":"feedsWithFundingIndex","internalType":"uint256"}]}],"name":"getDataFeed","inputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct Autopay.FeedDetailsWithQueryData[]","components":[{"type":"tuple","name":"details","internalType":"struct Autopay.FeedDetails","components":[{"type":"uint256","name":"reward","internalType":"uint256"},{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"startTime","internalType":"uint256"},{"type":"uint256","name":"interval","internalType":"uint256"},{"type":"uint256","name":"window","internalType":"uint256"},{"type":"uint256","name":"priceThreshold","internalType":"uint256"},{"type":"uint256","name":"rewardIncreasePerSecond","internalType":"uint256"},{"type":"uint256","name":"feedsWithFundingIndex","internalType":"uint256"}]},{"type":"bytes","name":"queryData","internalType":"bytes"}]}],"name":"getFundedFeedDetails","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32[]","name":"","internalType":"bytes32[]"}],"name":"getFundedFeeds","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32[]","name":"","internalType":"bytes32[]"}],"name":"getFundedQueryIds","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct Autopay.SingleTipsWithQueryData[]","components":[{"type":"bytes","name":"queryData","internalType":"bytes"},{"type":"uint256","name":"tip","internalType":"uint256"}]}],"name":"getFundedSingleTipsInfo","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"_found","internalType":"bool"},{"type":"uint256","name":"_index","internalType":"uint256"}],"name":"getIndexForDataAfter","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"_found","internalType":"bool"},{"type":"uint256","name":"_index","internalType":"uint256"}],"name":"getIndexForDataBefore","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes[]","name":"_values","internalType":"bytes[]"},{"type":"uint256[]","name":"_timestamps","internalType":"uint256[]"}],"name":"getMultipleValuesBefore","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"uint256","name":"_maxAge","internalType":"uint256"},{"type":"uint256","name":"_maxCount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getNewValueCountbyQueryId","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Autopay.Tip","components":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"uint256","name":"cumulativeTips","internalType":"uint256"}]}],"name":"getPastTipByIndex","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getPastTipCount","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct Autopay.Tip[]","components":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"uint256","name":"cumulativeTips","internalType":"uint256"}]}],"name":"getPastTips","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getQueryIdFromFeedId","inputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getReporterByTimestamp","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"_cumulativeReward","internalType":"uint256"}],"name":"getRewardAmount","inputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32"},{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256[]","name":"_timestamps","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool[]","name":"","internalType":"bool[]"}],"name":"getRewardClaimStatusList","inputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32"},{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256[]","name":"_timestamp","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"getRewardClaimedStatus","inputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32"},{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTimestampbyQueryIdandIndex","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTipsByAddress","inputs":[{"type":"address","name":"_user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IMappingContract"}],"name":"idMappingContract","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_fetch","internalType":"address payable"},{"type":"address","name":"_queryDataStorage","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isInDispute","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IQueryDataStorage"}],"name":"queryDataStorage","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"queryIdFromDataFeedId","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"queryIdsWithFunding","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"queryIdsWithFundingIndex","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"retrieveData","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_timestamp","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setIdMappingContract","inputs":[{"type":"address","name":"_addy","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes32","name":"_feedId","internalType":"bytes32"}],"name":"setupDataFeed","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_reward","internalType":"uint256"},{"type":"uint256","name":"_startTime","internalType":"uint256"},{"type":"uint256","name":"_interval","internalType":"uint256"},{"type":"uint256","name":"_window","internalType":"uint256"},{"type":"uint256","name":"_priceThreshold","internalType":"uint256"},{"type":"uint256","name":"_rewardIncreasePerSecond","internalType":"uint256"},{"type":"bytes","name":"_queryData","internalType":"bytes"},{"type":"uint256","name":"_amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"tip","inputs":[{"type":"bytes32","name":"_queryId","internalType":"bytes32"},{"type":"uint256","name":"_amount","internalType":"uint256"},{"type":"bytes","name":"_queryData","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"timestamp","internalType":"uint256"},{"type":"uint256","name":"cumulativeTips","internalType":"uint256"}],"name":"tips","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IERC20"}],"name":"token","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"userTipsTotal","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"_value","internalType":"int256"},{"type":"uint256","name":"_timestamp","internalType":"uint256"},{"type":"uint256","name":"_statusCode","internalType":"uint256"}],"name":"valueFor","inputs":[{"type":"bytes32","name":"_id","internalType":"bytes32"}]}]
              

Contract Creation Code

0x60a0604052306080523480156200001557600080fd5b506200002062000026565b620000e7565b603454610100900460ff1615620000935760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60345460ff90811614620000e5576034805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b608051614fa16200011f60003960008181610ecc01528181610f150152818161161501528181611655015261170a0152614fa16000f3fe60806040526004361061031e5760003560e01c8063751c895c116101a5578063b0e5fd07116100ec578063e07c548611610095578063f78eea831161006f578063f78eea83146109e0578063fc0c546a14610a00578063fcd4a54614610a20578063fdb9d0e214610a4e57600080fd5b8063e07c548614610980578063f2fde38b146109a0578063f66f49c3146109c057600080fd5b8063c5958af9116100c6578063c5958af914610913578063c7fafff814610940578063ce5e11bf1461096057600080fd5b8063b0e5fd0714610898578063b7c9d376146108b8578063bd05a23a146108e657600080fd5b806393d539321161014e578063a792765f11610128578063a792765f1461082b578063a9352c091461084b578063a95c372d1461087857600080fd5b806393d53932146107a3578063997b7990146107c3578063a733d2db1461080b57600080fd5b80637f23d1ce1161017f5780637f23d1ce14610737578063868d8b59146107575780638da5cb5b1461078557600080fd5b8063751c895c146106bc57806377b03e0d146106dc5780637bcdfa7a146106fc57600080fd5b806345d608231161026957806352d1902d1161021257806364ee3c6d116101ec57806364ee3c6d1461064b57806366c1de5014610679578063715018a6146106a757600080fd5b806352d1902d146105e957806357806e70146105fe578063579b6d061461061e57600080fd5b80634f1ef286116102435780634f1ef286146105885780634fce1e181461059b5780634fff7099146105bb57600080fd5b806345d60823146105045780634637de0b1461053b578063485cc9551461056857600080fd5b80633659cfe6116102cb57806342505164116102a5578063425051641461049f57806344e87f91146104b457806345740ccc146104e457600080fd5b80633659cfe61461042f57806337db4faf1461044f5780633d3fc43d1461047d57600080fd5b806329449085116102fc578063294490851461039e5780632af8aae0146103d5578063353d8ac91461040d57600080fd5b806309d6e27e14610323578063193b505b1461034e5780631af4075f14610370575b600080fd5b34801561032f57600080fd5b50610338610a6e565b604051610345919061429b565b60405180910390f35b34801561035a57600080fd5b5061036e61036936600461437b565b610d2e565b005b34801561037c57600080fd5b5061039061038b3660046143e3565b610d66565b604051908152602001610345565b3480156103aa57600080fd5b506103be6103b9366004614435565b610de9565b604080519215158352602083019190915201610345565b3480156103e157600080fd5b506001546103f5906001600160a01b031681565b6040516001600160a01b039091168152602001610345565b34801561041957600080fd5b50610422610e69565b6040516103459190614457565b34801561043b57600080fd5b5061036e61044a36600461437b565b610ec2565b34801561045b57600080fd5b5061039061046a36600461449b565b6101026020526000908152604090205481565b34801561048957600080fd5b50610492610faa565b60405161034591906144b4565b3480156104ab57600080fd5b50610422611203565b3480156104c057600080fd5b506104d46104cf366004614435565b61125a565b6040519015158152602001610345565b3480156104f057600080fd5b506103906104ff36600461449b565b6112d8565b34801561051057600080fd5b5061039061051f36600461437b565b6001600160a01b03166000908152610104602052604090205490565b34801561054757600080fd5b5061055b61055636600461449b565b611384565b604051610345919061452a565b34801561057457600080fd5b5061036e610583366004614582565b61144c565b61036e610596366004614628565b61160b565b3480156105a757600080fd5b506103906105b636600461449b565b6116db565b3480156105c757600080fd5b506103906105d636600461449b565b6000908152610101602052604090205490565b3480156105f557600080fd5b506103906116fd565b34801561060a57600080fd5b5061036e6106193660046143e3565b6117b0565b34801561062a57600080fd5b5061063e61063936600461449b565b611c17565b60405161034591906146ba565b34801561065757600080fd5b5061066b610666366004614435565b611ca8565b604051610345929190614710565b34801561068557600080fd5b5061039061069436600461437b565b6101046020526000908152604090205481565b3480156106b357600080fd5b5061036e611d01565b3480156106c857600080fd5b5061036e6106d7366004614773565b611d15565b3480156106e857600080fd5b506103906106f736600461449b565b6121d2565b34801561070857600080fd5b5061071c610717366004614435565b612240565b60408051938452602084019290925290820152606001610345565b34801561074357600080fd5b5061036e6107523660046147b9565b612283565b34801561076357600080fd5b5061039061077236600461449b565b6101016020526000908152604090205481565b34801561079157600080fd5b506067546001600160a01b03166103f5565b3480156107af57600080fd5b506104226107be36600461449b565b6124e7565b3480156107cf57600080fd5b506104d46107de3660046147b9565b60009182526101006020908152604080842094845293815283832091835260089091019052205460ff1690565b34801561081757600080fd5b506103906108263660046147e5565b612549565b34801561083757600080fd5b5061066b610846366004614435565b61288c565b34801561085757600080fd5b5061086b610866366004614435565b612913565b6040516103459190614879565b34801561088457600080fd5b506000546103f5906001600160a01b031681565b3480156108a457600080fd5b5060fe546103f5906001600160a01b031681565b3480156108c457600080fd5b506103906108d336600461449b565b6000908152610103602052604090205490565b3480156108f257600080fd5b506109066109013660046143e3565b612997565b604051610345919061489a565b34801561091f57600080fd5b5061093361092e366004614435565b612a7d565b60405161034591906148d4565b34801561094c57600080fd5b5061039061095b36600461449b565b612af6565b34801561096c57600080fd5b5061039061097b366004614435565b612b07565b34801561098c57600080fd5b506103f561099b366004614435565b612b7c565b3480156109ac57600080fd5b5061036e6109bb36600461437b565b612bf1565b3480156109cc57600080fd5b506103be6109db366004614435565b612c67565b3480156109ec57600080fd5b5061071c6109fb36600461449b565b612e24565b348015610a0c57600080fd5b5060fd546103f5906001600160a01b031681565b348015610a2c57600080fd5b50610a40610a3b3660046148e7565b612ee9565b604051610345929190614919565b348015610a5a57600080fd5b5061036e610a693660046149b4565b6131d5565b60606000306001600160a01b031663353d8ac96040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ab0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ad891908101906149ff565b9050600081516001600160401b03811115610af557610af56145bb565b604051908082528060200260200182016040528015610b2e57816020015b610b1b6141eb565b815260200190600190039081610b135790505b50905060005b8251811015610d27576000306001600160a01b0316634637de0b858481518110610b6057610b60614aa4565b60200260200101516040518263ffffffff1660e01b8152600401610b8691815260200190565b61010060405180830381865afa158015610ba4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc89190614aba565b90506000306001600160a01b0316634fff7099868581518110610bed57610bed614aa4565b60200260200101516040518263ffffffff1660e01b8152600401610c1391815260200190565b602060405180830381865afa158015610c30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c549190614b49565b60fe546040516341b6849f60e11b8152600481018390529192506000916001600160a01b039091169063836d093e90602401600060405180830381865afa158015610ca3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ccb9190810190614ba7565b905082858581518110610ce057610ce0614aa4565b60200260200101516000018190525080858581518110610d0257610d02614aa4565b6020026020010151602001819052505050508080610d1f90614bf1565b915050610b34565b5092915050565b6001546001600160a01b031615610d4457600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000838152610100602090815260408083208784529091528120815b83811015610dcb57610dad8787878785818110610da157610da1614aa4565b90506020020135613445565b610db79084614c0a565b925080610dc381614bf1565b915050610d82565b508060010154821115610de057806001015491505b50949350505050565b60008054604051632944908560e01b8152600481018590526024810184905282916001600160a01b0316906329449085906044016040805180830381865afa158015610e39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5d9190614c32565b915091505b9250929050565b6060610105805480602002602001604051908101604052809291908181526020018280548015610eb857602002820191906000526020600020905b815481526020019060010190808311610ea4575b5050505050905090565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610f135760405162461bcd60e51b8152600401610f0a90614c5e565b60405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610f5c600080516020614f25833981519152546001600160a01b031690565b6001600160a01b031614610f825760405162461bcd60e51b8152600401610f0a90614caa565b610f8b81613725565b60408051600080825260208201909252610fa79183919061372d565b50565b60606000306001600160a01b031663425051646040518163ffffffff1660e01b8152600401600060405180830381865afa158015610fec573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261101491908101906149ff565b9050600081516001600160401b03811115611031576110316145bb565b60405190808252806020026020018201604052801561107757816020015b60408051808201909152606081526000602082015281526020019060019003908161104f5790505b50905060005b8251811015610d275760fe5483516000916001600160a01b03169063836d093e908690859081106110b0576110b0614aa4565b60200260200101516040518263ffffffff1660e01b81526004016110d691815260200190565b600060405180830381865afa1580156110f3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261111b9190810190614ba7565b90506000306001600160a01b03166345740ccc86858151811061114057611140614aa4565b60200260200101516040518263ffffffff1660e01b815260040161116691815260200190565b602060405180830381865afa158015611183573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a79190614b49565b9050818484815181106111bc576111bc614aa4565b602002602001015160000181905250808484815181106111de576111de614aa4565b60200260200101516020018181525050505080806111fb90614bf1565b91505061107d565b6060610106805480602002602001604051908101604052809291908181526020018280548015610eb85760200282019190600052602060002090815481526020019060010190808311610ea4575050505050905090565b600080546040516344e87f9160e01b815260048101859052602481018490526001600160a01b03909116906344e87f9190604401602060405180830381865afa1580156112ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cf9190614cf6565b90505b92915050565b6000818152610103602052604081205481036112f657506000919050565b600061130183613898565b60008581526101036020526040812080549294509092509061132590600190614d11565b8154811061133557611335614aa4565b60009182526020918290206040805160608101825260039093029091018054835260018101549383018490526002015490820152915082101561137a57519392505050565b5060009392505050565b6113cc60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b506000818152610101602090815260408083205483526101008083528184209484529382529182902082519384018352805484526001810154918401919091526002810154918301919091526003810154606083015260048101546080830152600581015460a0830152600681015460c08301526007015460e082015290565b603454610100900460ff161580801561146c5750603454600160ff909116105b806114865750303b158015611486575060345460ff166001145b6114e95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610f0a565b6034805460ff19166001179055801561150c576034805461ff0019166101001790555b611514613929565b600080546001600160a01b0319166001600160a01b03851690811790915560408051637e062a3560e11b8152905163fc0c546a916004808201926020929091908290030181865afa15801561156d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115919190614d24565b60fd80546001600160a01b03199081166001600160a01b039384161790915560fe80549091169184169190911790558015611606576034805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036116535760405162461bcd60e51b8152600401610f0a90614c5e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661169c600080516020614f25833981519152546001600160a01b031690565b6001600160a01b0316146116c25760405162461bcd60e51b8152600401610f0a90614caa565b6116cb82613725565b6116d78282600161372d565b5050565b61010581815481106116ec57600080fd5b600091825260209091200154905081565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461179d5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610f0a565b50600080516020614f2583398151915290565b600083815261010060209081526040808320878452909152902060018101548061181c5760405162461bcd60e51b815260206004820181905260248201527f6e6f2066756e647320617661696c61626c6520666f72207468697320666565646044820152606401610f0a565b6000805b84811015611b3a5761a8c086868381811061183d5761183d614aa4565b905060200201354261184f9190614d11565b1161189c5760405162461bcd60e51b815260206004820152601a60248201527f6275666665722074696d6520686173206e6f74207061737365640000000000006044820152606401610f0a565b336118bf888888858181106118b3576118b3614aa4565b90506020020135612b7c565b6001600160a01b03161461193b5760405162461bcd60e51b815260206004820152603b60248201527f6d6573736167652073656e646572206e6f74207265706f7274657220666f722060448201527f676976656e207175657279496420616e642074696d657374616d7000000000006064820152608401610f0a565b6119528888888885818110610da157610da1614aa4565b61195c9083614c0a565b9150828210611ae157611970600186614d11565b81146119d85760405162461bcd60e51b815260206004820152603160248201527f696e73756666696369656e742062616c616e636520666f7220616c6c207375626044820152706d69747465642074696d657374616d707360781b6064820152608401610f0a565b6101055483925060011015611aaf5760078401546000906119fb90600190614d11565b610105805491925090611a1090600190614d11565b81548110611a2057611a20614aa4565b90600052602060002001546101058281548110611a3f57611a3f614aa4565b906000526020600020018190555060006101058281548110611a6357611a63614aa4565b6000918252602080832090910154808352610101909152604090912054909150611a8e836001614c0a565b60009182526101006020908152604080842094845293905291902060070155505b610105805480611ac157611ac1614d41565b600082815260208120820160001990810182905590910190915560078501555b6001846008016000888885818110611afb57611afb614aa4565b90506020020135815260200190815260200160002060006101000a81548160ff0219169083151502179055508080611b3290614bf1565b915050611820565b5080836000016001016000828254611b529190614d11565b909155505060fd5460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015611ba8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcc9190614cf6565b611bd557600080fd5b6040513381528190879089907fbe397b811472239aa40c62686337c1611135342d6e238e8aa16580dcd7223adf9060200160405180910390a450505050505050565b60606101036000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611c9d5783829060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505081526020019060010190611c4d565b505050509050919050565b60606000806000611cb98686612c67565b9150915081611ce05760006040518060200160405280600081525090935093505050610e62565b611cea8682612b07565b9250611cf68684612a7d565b935050509250929050565b611d09613958565b611d1360006139b2565b565b8181604051611d25929190614d57565b60405180910390208414611d7b5760405162461bcd60e51b815260206004820152601d60248201527f6964206d7573742062652068617368206f6620627974657320646174610000006044820152606401610f0a565b60008311611dcb5760405162461bcd60e51b815260206004820152601d60248201527f746970206d7573742062652067726561746572207468616e207a65726f0000006044820152606401610f0a565b6000848152610103602052604081208054909103611eab57806040518060600160405280868152602001426001611e029190614c0a565b815260209081018790528254600181810185556000948552938290208351600390920201908155908201519281019290925560409081015160029092019190915560fe54905163ac5c853560e01b81526001600160a01b039091169063ac5c853590611e749086908690600401614d90565b600060405180830381600087803b158015611e8e57600080fd5b505af1158015611ea2573d6000803e3d6000fd5b50505050612064565b6000611eb686613898565b8354909250839150611eca90600190614d11565b81548110611eda57611eda614aa4565b906000526020600020906003020160010154811015611fc857611efe426001614c0a565b82548390611f0e90600190614d11565b81548110611f1e57611f1e614aa4565b906000526020600020906003020160010181905550848260018480549050611f469190614d11565b81548110611f5657611f56614aa4565b90600052602060002090600302016000016000828254611f769190614c0a565b9091555050815485908390611f8d90600190614d11565b81548110611f9d57611f9d614aa4565b90600052602060002090600302016002016000828254611fbd9190614c0a565b909155506120629050565b816040518060600160405280878152602001426001611fe79190614c0a565b8152602001878560018780549050611fff9190614d11565b8154811061200f5761200f614aa4565b90600052602060002090600302016002015461202b9190614c0a565b9052815460018181018455600093845260209384902083516003909302019182559282015192810192909255604001516002909101555b505b6000858152610102602052604090205415801561208957506000612087866112d8565b115b156120d05761010680546001810182557fc9ef9fceea91e87b2c84ea400a44fde78842aae8aa24cd4b502ce5fb4d91e63b0186905554600086815261010260205260409020555b60fd546040516323b872dd60e01b8152336004820152306024820152604481018690526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015612127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214b9190614cf6565b6121675760405162461bcd60e51b8152600401610f0a90614da4565b336000908152610104602052604081208054869290612187908490614c0a565b9250508190555083857ff5ab15991b2cec1142b66b2c57a205c2af5e9d8fc5056bcb33b53b193990b07e8585336040516121c393929190614dea565b60405180910390a35050505050565b600080546040516377b03e0d60e01b8152600481018490526001600160a01b03909116906377b03e0d90602401602060405180830381865afa15801561221c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d29190614b49565b610103602052816000526040600020818154811061225d57600080fd5b600091825260209091206003909102018054600182015460029092015490935090915083565b600082815261010060209081526040808320868452909152902080546122dd5760405162461bcd60e51b815260206004820152600f60248201526e066656564206e6f742073657420757608c1b6044820152606401610f0a565b6000821161232d5760405162461bcd60e51b815260206004820152601960248201527f6d7573742062652073656e64696e6720616e20616d6f756e74000000000000006044820152606401610f0a565b818160010160008282546123419190614c0a565b909155505060fd546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd906064016020604051808303816000875af115801561239d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123c19190614cf6565b6123dd5760405162461bcd60e51b8152600401610f0a90614da4565b60078101541580156123f3575060008160010154115b1561243457610105805460018101825560008290527ffc62abc8c0fc47c2d92f5aec99bf8b60f375828e14394d89345cae11a9867371018590555460078201555b336000908152610104602052604081208054849290612454908490614c0a565b909155505060408051338152825460208201526001830154818301526002830154606082015260038301546080820152600483015460a0820152600583015460c0820152600683015460e0820152600783015461010082015290518391859187917fdaf477f4ffa6a044c31632ac3040e483553fb75f8437629291046a833cc352af91908190036101200190a450505050565b600081815260ff602090815260409182902080548351818402810184019094528084526060939283018282801561253d57602002820191906000526020600020905b815481526020019060010190808311612529575b50505050509050919050565b6000838360405161255b929190614d57565b60405180910390208b146125b15760405162461bcd60e51b815260206004820152601d60248201527f6964206d7573742062652068617368206f6620627974657320646174610000006044820152606401610f0a565b60408051602081018d90529081018b9052606081018a90526080810189905260a0810188905260c0810187905260e081018690526101000160408051601f19818403018152918152815160209283012060008e815261010084528281208282529093529120805491925090156126695760405162461bcd60e51b815260206004820152601f60248201527f66656564206d757374206e6f742062652073657420757020616c7265616479006044820152606401610f0a565b60008b116126b95760405162461bcd60e51b815260206004820181905260248201527f726577617264206d7573742062652067726561746572207468616e207a65726f6044820152606401610f0a565b600089116127145760405162461bcd60e51b815260206004820152602260248201527f696e74657276616c206d7573742062652067726561746572207468616e207a65604482015261726f60f01b6064820152608401610f0a565b8888106127745760405162461bcd60e51b815260206004820152602860248201527f77696e646f77206d757374206265206c657373207468616e20696e74657276616044820152670d840d8cadccee8d60c31b6064820152608401610f0a565b8a8155600281018a9055600381018990556004808201899055600582018890556006820187905560008d815260ff60209081526040808320805460018101825590845282842001869055858352610101909152908190208e905560fe54905163ac5c853560e01b81526001600160a01b039091169163ac5c8535916127fd918991899101614d90565b600060405180830381600087803b15801561281757600080fd5b505af115801561282b573d6000803e3d6000fd5b50505050818c7f25b7a245f1298a141e9a73052d47515c64a19a5550bc21f5c896f2097e155efe87873360405161286493929190614dea565b60405180910390a3821561287d5761287d828d85612283565b509a9950505050505050505050565b6000805460405163a792765f60e01b81526004810185905260248101849052606092916001600160a01b03169063a792765f90604401600060405180830381865afa1580156128df573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526129079190810190614e17565b90969095509350505050565b61293760405180606001604052806000815260200160008152602001600081525090565b60008381526101036020526040902080548390811061295857612958614aa4565b90600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050905092915050565b60606000826001600160401b038111156129b3576129b36145bb565b6040519080825280602002602001820160405280156129dc578160200160208202803683370190505b50905060005b83811015612a71576000868152610100602090815260408083208a8452909152812060080190868684818110612a1a57612a1a614aa4565b90506020020135815260200190815260200160002060009054906101000a900460ff16828281518110612a4f57612a4f614aa4565b9115156020928302919091019091015280612a6981614bf1565b9150506129e2565b5090505b949350505050565b60005460405163c5958af960e01b815260048101849052602481018390526060916001600160a01b03169063c5958af990604401600060405180830381865afa158015612ace573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112cf9190810190614ba7565b61010681815481106116ec57600080fd5b6000805460405163ce5e11bf60e01b815260048101859052602481018490526001600160a01b039091169063ce5e11bf90604401602060405180830381865afa158015612b58573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cf9190614b49565b6000805460405163703e2a4360e11b815260048101859052602481018490526001600160a01b039091169063e07c548690604401602060405180830381865afa158015612bcd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cf9190614d24565b612bf9613958565b6001600160a01b038116612c5e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610f0a565b610fa7816139b2565b6000806000612c75856121d2565b905080600003612c8c576000809250925050610e62565b80612c9681614e6d565b9150600190506000808381612cab8a83612b07565b9050888111612cc65760008097509750505050505050610e62565b612cd08a84612b07565b905088811115612cdf57600094505b8415612d8f576002612cf18484614c0a565b612cfb9190614e84565b9350612d078a85612b07565b905088811115612d48576000612d228b61097b600188614d11565b9050898111612d345760009550612d42565b612d3f600186614d11565b92505b50612cdf565b6000612d598b61097b876001614c0a565b905089811115612d7c576000955084612d7181614bf1565b955050809150612d42565b612d87856001614c0a565b935050612cdf565b612d998a8261125a565b612daf5760018497509750505050505050610e62565b612db98a8261125a565b8015612dc457508584105b15612de75783612dd381614bf1565b945050612de08a85612b07565b9050612daf565b8584148015612dfb5750612dfb8a8261125a565b15612e125760008097509750505050505050610e62565b60018497509750505050505050610e62565b60015460405163690ebcf760e11b8152600481018390526000918291829182916001600160a01b039091169063d21d79ee90602401602060405180830381865afa158015612e76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e9a9190614b49565b90506060612ead82610846426001614c0a565b945090506000849003612ecd576000806101949450945094505050612ee2565b6000612ed882613a04565b955060c893505050505b9193909250565b606080600080612efd886109db888a614d11565b9150915081612f4e576040805160008082526020820190925290612f31565b6060815260200190600190039081612f1c5790505b5060408051600081526020810190915290945092506131cc915050565b6000612f5a8989610de9565b909350905082612fad576040805160008082526020820190925290612f8f565b6060815260200190600190039081612f7a5790505b5060408051600081526020810190915290955093506131cc92505050565b6000806000886001600160401b03811115612fca57612fca6145bb565b604051908082528060200260200182016040528015612ff3578160200160208202803683370190505b5090505b888310801561301a5750848261300e866001614c0a565b6130189190614d11565b115b1561307e57600061302f8d61097b8588614d11565b905061303b8d8261125a565b61306b578082858151811061305257613052614aa4565b60209081029190910101528361306781614bf1565b9450505b8261307581614bf1565b93505050612ff7565b6000836001600160401b03811115613098576130986145bb565b6040519080825280602002602001820160405280156130cb57816020015b60608152602001906001900390816130b65790505b5090506000846001600160401b038111156130e8576130e86145bb565b604051908082528060200260200182016040528015613111578160200160208202803683370190505b50905060005b858110156131bf57838161312c600189614d11565b6131369190614d11565b8151811061314657613146614aa4565b602002602001015182828151811061316057613160614aa4565b60200260200101818152505061318f8f83838151811061318257613182614aa4565b6020026020010151612a7d565b8382815181106131a1576131a1614aa4565b602002602001018190525080806131b790614bf1565b915050613117565b5090985096505050505050505b94509492505050565b6000838152610103602052604090205461323c5760405162461bcd60e51b815260206004820152602260248201527f6e6f2074697073207375626d697474656420666f722074686973207175657279604482015261125960f21b6064820152608401610f0a565b6000805b828110156132885761326a8585858481811061325e5761325e614aa4565b90506020020135613a5b565b6132749083614c0a565b91508061328081614bf1565b915050613240565b5060fd5460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af11580156132da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132fe9190614cf6565b61330757600080fd5b613310846112d8565b600003613410576000848152610102602052604090205415613410576000848152610102602052604081205461334890600190614d11565b61010680549192509061335d90600190614d11565b8154811061336d5761336d614aa4565b9060005260206000200154610106828154811061338c5761338c614aa4565b9060005260206000200181905550600061010682815481106133b0576133b0614aa4565b906000526020600020015490508160016133ca9190614c0a565b6000828152610102602052604080822092909255878152908120556101068054806133f7576133f7614d41565b6001900381819060005260206000200160009055905550505b6040513390829086907fdff45d500502d35c7f1150acbb404c5b2e288e31a74354c8553a283dd1e806e790600090a450505050565b60006224ea006134558342614d11565b106134a25760405162461bcd60e51b815260206004820152601e60248201527f74696d657374616d7020746f6f206f6c6420746f20636c61696d2074697000006044820152606401610f0a565b6000838152610100602090815260408083208784528252808320858452600881019092529091205460ff161561351a5760405162461bcd60e51b815260206004820152601660248201527f72657761726420616c726561647920636c61696d6564000000000000000000006044820152606401610f0a565b60038101546002820154600091906135329086614d11565b61353c9190614e84565b905060008183600001600301546135539190614ea6565b60028401546135629190614c0a565b905060006135708787612a7d565b905080516000036135c35760405162461bcd60e51b815260206004820152601c60248201527f6e6f2076616c7565206578697374732061742074696d657374616d70000000006044820152606401610f0a565b6000806135d0898961288c565b60058801549193509150600090156136645760006135ed85613f2d565b905060006135fa85613f2d565b90508060000361360e576127109250613661565b80821061363d57806136208184614d11565b61362c90612710614ea6565b6136369190614e84565b9250613661565b806136488382614d11565b61365490612710614ea6565b61365e9190614e84565b92505b50505b865497506000613674868b614d11565b60048901549091508110801561368957508583105b156136af57600688015461369e908290614ea6565b6136a8908a614c0a565b9850613702565b600588015482116137025760405162461bcd60e51b815260206004820152601760248201527f7072696365207468726573686f6c64206e6f74206d65740000000000000000006044820152606401610f0a565b600188015489111561371657600188015498505b50505050505050509392505050565b610fa7613958565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156137605761160683613f7e565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156137ba575060408051601f3d908101601f191682019092526137b791810190614b49565b60015b61381d5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610f0a565b600080516020614f25833981519152811461388c5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610f0a565b5061160683838361401a565b60606000806138a6846121d2565b9050806000036138cc576040518060200160405280600081525060009250925050915091565b60005b811561391057816138df81614e6d565b9250506138ec8583612b07565b90506138f88582612a7d565b80519094501561390b5792949293505050565b6138cf565b6040805160208101909152600081529590945092505050565b603454610100900460ff166139505760405162461bcd60e51b8152600401610f0a90614ebd565b611d13614045565b6067546001600160a01b03163314611d135760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f0a565b606780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000805b8251811015613a5557828181518110613a2357613a23614aa4565b016020015160f81c613a3783610100614ea6565b613a419190614c0a565b915080613a4d81614bf1565b915050613a08565b50919050565b600061a8c0613a6a8342614d11565b11613ab75760405162461bcd60e51b815260206004820152601a60248201527f6275666665722074696d6520686173206e6f74207061737365640000000000006044820152606401610f0a565b613ac1838361125a565b15613aff5760405162461bcd60e51b815260206004820152600e60248201526d1d985b1d5948191a5cdc1d5d195960921b6044820152606401610f0a565b613b098383612b7c565b6001600160a01b0316336001600160a01b031614613b755760405162461bcd60e51b815260206004820152602360248201527f6d73672073656e646572206d757374206265207265706f72746572206164647260448201526265737360e81b6064820152608401610f0a565b6000838152610103602052604081208054909190815b6001613b978484614d11565b1115613bf0576002613ba98484614c0a565b613bb39190614e84565b905085848281548110613bc857613bc8614aa4565b9060005260206000209060030201600101541115613be857809150613b8b565b809250613b8b565b6000613bfc888861288c565b915050848481548110613c1157613c11614aa4565b9060005260206000209060030201600101548110613c7b5760405162461bcd60e51b815260206004820152602160248201527f746970206561726e65642062792070726576696f7573207375626d697373696f6044820152603760f91b6064820152608401610f0a565b848481548110613c8d57613c8d614aa4565b906000526020600020906003020160010154871015613cee5760405162461bcd60e51b815260206004820152601e60248201527f74696d657374616d70206e6f7420656c696769626c6520666f722074697000006044820152606401610f0a565b6000858581548110613d0257613d02614aa4565b90600052602060002090600302016000015411613d575760405162461bcd60e51b81526020600482015260136024820152721d1a5c08185b1c9958591e4818db185a5b5959606a1b6044820152606401610f0a565b848481548110613d6957613d69614aa4565b90600052602060002090600302016000015495506000858581548110613d9157613d91614aa4565b600091825260208220600390910201919091558490613db58a6103b98b6001614c0a565b91506000905080613dcb8c6103b9876001614c0a565b90925090506001613ddc8285614d11565b1180613de6575081155b15613f1e5781613e1b57888481548110613e0257613e02614aa4565b9060005260206000209060030201600201549950613f1e565b60009796505b6001613e2d8989614d11565b1115613e86576002613e3f8989614c0a565b613e499190614e84565b955084898781548110613e5e57613e5e614aa4565b9060005260206000209060030201600101541115613e7e57859650613e21565b859750613e21565b87613e9081614bf1565b98505083881015613f1e57888881548110613ead57613ead614aa4565b906000526020600020906003020160000154898981548110613ed157613ed1614aa4565b9060005260206000209060030201600201548a8681548110613ef557613ef5614aa4565b906000526020600020906003020160020154613f119190614d11565b613f1b9190614c0a565b99505b50505050505050505092915050565b6000805b8251811015613a5557828181518110613f4c57613f4c614aa4565b016020015160f81c613f6083610100614ea6565b613f6a9190614c0a565b915080613f7681614bf1565b915050613f31565b6001600160a01b0381163b613feb5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610f0a565b600080516020614f2583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61402383614075565b6000825111806140305750805b156116065761403f83836140b5565b50505050565b603454610100900460ff1661406c5760405162461bcd60e51b8152600401610f0a90614ebd565b611d13336139b2565b61407e81613f7e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606112cf8383604051806060016040528060278152602001614f45602791396060600080856001600160a01b0316856040516140f29190614f08565b600060405180830381855af49150503d806000811461412d576040519150601f19603f3d011682016040523d82523d6000602084013e614132565b606091505b50915091506141438683838761414d565b9695505050505050565b606083156141bc5782516000036141b5576001600160a01b0385163b6141b55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f0a565b5081612a75565b612a7583838151156141d15781518083602001fd5b8060405162461bcd60e51b8152600401610f0a91906148d4565b604051806040016040528061423e60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001606081525090565b60005b8381101561426657818101518382015260200161424e565b50506000910152565b6000815180845261428781602086016020860161424b565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561435957603f19888603018452815161012061432c878351805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e08301525050565b878201519150806101008801526143458188018361426f565b9650505092850192908501906001016142c2565b5092979650505050505050565b6001600160a01b0381168114610fa757600080fd5b60006020828403121561438d57600080fd5b813561439881614366565b9392505050565b60008083601f8401126143b157600080fd5b5081356001600160401b038111156143c857600080fd5b6020830191508360208260051b8501011115610e6257600080fd5b600080600080606085870312156143f957600080fd5b843593506020850135925060408501356001600160401b0381111561441d57600080fd5b6144298782880161439f565b95989497509550505050565b6000806040838503121561444857600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b8181101561448f57835183529284019291840191600101614473565b50909695505050505050565b6000602082840312156144ad57600080fd5b5035919050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561451c57888303603f19018552815180518785526144ff8886018261426f565b9189015194890194909452948701949250908601906001016144db565b509098975050505050505050565b61010081016112d28284805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e08301525050565b6000806040838503121561459557600080fd5b82356145a081614366565b915060208301356145b081614366565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156145f9576145f96145bb565b604052919050565b60006001600160401b0382111561461a5761461a6145bb565b50601f01601f191660200190565b6000806040838503121561463b57600080fd5b823561464681614366565b915060208301356001600160401b0381111561466157600080fd5b8301601f8101851361467257600080fd5b803561468561468082614601565b6145d1565b81815286602083850101111561469a57600080fd5b816020840160208301376000602083830101528093505050509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561448f576146fd8385518051825260208082015190830152604090810151910152565b92840192606092909201916001016146d6565b604081526000614723604083018561426f565b90508260208301529392505050565b60008083601f84011261474457600080fd5b5081356001600160401b0381111561475b57600080fd5b602083019150836020828501011115610e6257600080fd5b6000806000806060858703121561478957600080fd5b843593506020850135925060408501356001600160401b038111156147ad57600080fd5b61442987828801614732565b6000806000606084860312156147ce57600080fd5b505081359360208301359350604090920135919050565b6000806000806000806000806000806101208b8d03121561480557600080fd5b8a35995060208b0135985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b0135935060e08b01356001600160401b0381111561484c57600080fd5b6148588d828e01614732565b915080945050809250506101008b013590509295989b9194979a5092959850565b815181526020808301519082015260408083015190820152606081016112d2565b6020808252825182820181905260009190848201906040850190845b8181101561448f5783511515835292840192918401916001016148b6565b6020815260006112cf602083018461426f565b600080600080608085870312156148fd57600080fd5b5050823594602084013594506040840135936060013592509050565b6000604082016040835280855180835260608501915060608160051b8601019250602080880160005b8381101561497057605f1988870301855261495e86835161426f565b95509382019390820190600101614942565b50508584038187015286518085528782019482019350915060005b828110156149a75784518452938101939281019260010161498b565b5091979650505050505050565b6000806000604084860312156149c957600080fd5b8335925060208401356001600160401b038111156149e657600080fd5b6149f28682870161439f565b9497909650939450505050565b60006020808385031215614a1257600080fd5b82516001600160401b0380821115614a2957600080fd5b818501915085601f830112614a3d57600080fd5b815181811115614a4f57614a4f6145bb565b8060051b9150614a608483016145d1565b8181529183018401918481019088841115614a7a57600080fd5b938501935b83851015614a9857845182529385019390850190614a7f565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b6000610100808385031215614ace57600080fd5b604051908101906001600160401b0382118183101715614af057614af06145bb565b81604052835181526020840151602082015260408401516040820152606084015160608201526080840151608082015260a084015160a082015260c084015160c082015260e084015160e0820152809250505092915050565b600060208284031215614b5b57600080fd5b5051919050565b600082601f830112614b7357600080fd5b8151614b8161468082614601565b818152846020838601011115614b9657600080fd5b612a7582602083016020870161424b565b600060208284031215614bb957600080fd5b81516001600160401b03811115614bcf57600080fd5b612a7584828501614b62565b634e487b7160e01b600052601160045260246000fd5b600060018201614c0357614c03614bdb565b5060010190565b808201808211156112d2576112d2614bdb565b80518015158114614c2d57600080fd5b919050565b60008060408385031215614c4557600080fd5b614c4e83614c1d565b9150602083015190509250929050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b600060208284031215614d0857600080fd5b6112cf82614c1d565b818103818111156112d2576112d2614bdb565b600060208284031215614d3657600080fd5b815161439881614366565b634e487b7160e01b600052603160045260246000fd5b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526000612a75602083018486614d67565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b604081526000614dfe604083018587614d67565b90506001600160a01b0383166020830152949350505050565b600080600060608486031215614e2c57600080fd5b614e3584614c1d565b925060208401516001600160401b03811115614e5057600080fd5b614e5c86828701614b62565b925050604084015190509250925092565b600081614e7c57614e7c614bdb565b506000190190565b600082614ea157634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176112d2576112d2614bdb565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251614f1a81846020870161424b565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212200513499bdd2481ac4b92f62101ff2758df5b3f7d1bde2b1b23bdd0986a985d4064736f6c63430008140033

Deployed ByteCode

0x60806040526004361061031e5760003560e01c8063751c895c116101a5578063b0e5fd07116100ec578063e07c548611610095578063f78eea831161006f578063f78eea83146109e0578063fc0c546a14610a00578063fcd4a54614610a20578063fdb9d0e214610a4e57600080fd5b8063e07c548614610980578063f2fde38b146109a0578063f66f49c3146109c057600080fd5b8063c5958af9116100c6578063c5958af914610913578063c7fafff814610940578063ce5e11bf1461096057600080fd5b8063b0e5fd0714610898578063b7c9d376146108b8578063bd05a23a146108e657600080fd5b806393d539321161014e578063a792765f11610128578063a792765f1461082b578063a9352c091461084b578063a95c372d1461087857600080fd5b806393d53932146107a3578063997b7990146107c3578063a733d2db1461080b57600080fd5b80637f23d1ce1161017f5780637f23d1ce14610737578063868d8b59146107575780638da5cb5b1461078557600080fd5b8063751c895c146106bc57806377b03e0d146106dc5780637bcdfa7a146106fc57600080fd5b806345d608231161026957806352d1902d1161021257806364ee3c6d116101ec57806364ee3c6d1461064b57806366c1de5014610679578063715018a6146106a757600080fd5b806352d1902d146105e957806357806e70146105fe578063579b6d061461061e57600080fd5b80634f1ef286116102435780634f1ef286146105885780634fce1e181461059b5780634fff7099146105bb57600080fd5b806345d60823146105045780634637de0b1461053b578063485cc9551461056857600080fd5b80633659cfe6116102cb57806342505164116102a5578063425051641461049f57806344e87f91146104b457806345740ccc146104e457600080fd5b80633659cfe61461042f57806337db4faf1461044f5780633d3fc43d1461047d57600080fd5b806329449085116102fc578063294490851461039e5780632af8aae0146103d5578063353d8ac91461040d57600080fd5b806309d6e27e14610323578063193b505b1461034e5780631af4075f14610370575b600080fd5b34801561032f57600080fd5b50610338610a6e565b604051610345919061429b565b60405180910390f35b34801561035a57600080fd5b5061036e61036936600461437b565b610d2e565b005b34801561037c57600080fd5b5061039061038b3660046143e3565b610d66565b604051908152602001610345565b3480156103aa57600080fd5b506103be6103b9366004614435565b610de9565b604080519215158352602083019190915201610345565b3480156103e157600080fd5b506001546103f5906001600160a01b031681565b6040516001600160a01b039091168152602001610345565b34801561041957600080fd5b50610422610e69565b6040516103459190614457565b34801561043b57600080fd5b5061036e61044a36600461437b565b610ec2565b34801561045b57600080fd5b5061039061046a36600461449b565b6101026020526000908152604090205481565b34801561048957600080fd5b50610492610faa565b60405161034591906144b4565b3480156104ab57600080fd5b50610422611203565b3480156104c057600080fd5b506104d46104cf366004614435565b61125a565b6040519015158152602001610345565b3480156104f057600080fd5b506103906104ff36600461449b565b6112d8565b34801561051057600080fd5b5061039061051f36600461437b565b6001600160a01b03166000908152610104602052604090205490565b34801561054757600080fd5b5061055b61055636600461449b565b611384565b604051610345919061452a565b34801561057457600080fd5b5061036e610583366004614582565b61144c565b61036e610596366004614628565b61160b565b3480156105a757600080fd5b506103906105b636600461449b565b6116db565b3480156105c757600080fd5b506103906105d636600461449b565b6000908152610101602052604090205490565b3480156105f557600080fd5b506103906116fd565b34801561060a57600080fd5b5061036e6106193660046143e3565b6117b0565b34801561062a57600080fd5b5061063e61063936600461449b565b611c17565b60405161034591906146ba565b34801561065757600080fd5b5061066b610666366004614435565b611ca8565b604051610345929190614710565b34801561068557600080fd5b5061039061069436600461437b565b6101046020526000908152604090205481565b3480156106b357600080fd5b5061036e611d01565b3480156106c857600080fd5b5061036e6106d7366004614773565b611d15565b3480156106e857600080fd5b506103906106f736600461449b565b6121d2565b34801561070857600080fd5b5061071c610717366004614435565b612240565b60408051938452602084019290925290820152606001610345565b34801561074357600080fd5b5061036e6107523660046147b9565b612283565b34801561076357600080fd5b5061039061077236600461449b565b6101016020526000908152604090205481565b34801561079157600080fd5b506067546001600160a01b03166103f5565b3480156107af57600080fd5b506104226107be36600461449b565b6124e7565b3480156107cf57600080fd5b506104d46107de3660046147b9565b60009182526101006020908152604080842094845293815283832091835260089091019052205460ff1690565b34801561081757600080fd5b506103906108263660046147e5565b612549565b34801561083757600080fd5b5061066b610846366004614435565b61288c565b34801561085757600080fd5b5061086b610866366004614435565b612913565b6040516103459190614879565b34801561088457600080fd5b506000546103f5906001600160a01b031681565b3480156108a457600080fd5b5060fe546103f5906001600160a01b031681565b3480156108c457600080fd5b506103906108d336600461449b565b6000908152610103602052604090205490565b3480156108f257600080fd5b506109066109013660046143e3565b612997565b604051610345919061489a565b34801561091f57600080fd5b5061093361092e366004614435565b612a7d565b60405161034591906148d4565b34801561094c57600080fd5b5061039061095b36600461449b565b612af6565b34801561096c57600080fd5b5061039061097b366004614435565b612b07565b34801561098c57600080fd5b506103f561099b366004614435565b612b7c565b3480156109ac57600080fd5b5061036e6109bb36600461437b565b612bf1565b3480156109cc57600080fd5b506103be6109db366004614435565b612c67565b3480156109ec57600080fd5b5061071c6109fb36600461449b565b612e24565b348015610a0c57600080fd5b5060fd546103f5906001600160a01b031681565b348015610a2c57600080fd5b50610a40610a3b3660046148e7565b612ee9565b604051610345929190614919565b348015610a5a57600080fd5b5061036e610a693660046149b4565b6131d5565b60606000306001600160a01b031663353d8ac96040518163ffffffff1660e01b8152600401600060405180830381865afa158015610ab0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ad891908101906149ff565b9050600081516001600160401b03811115610af557610af56145bb565b604051908082528060200260200182016040528015610b2e57816020015b610b1b6141eb565b815260200190600190039081610b135790505b50905060005b8251811015610d27576000306001600160a01b0316634637de0b858481518110610b6057610b60614aa4565b60200260200101516040518263ffffffff1660e01b8152600401610b8691815260200190565b61010060405180830381865afa158015610ba4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bc89190614aba565b90506000306001600160a01b0316634fff7099868581518110610bed57610bed614aa4565b60200260200101516040518263ffffffff1660e01b8152600401610c1391815260200190565b602060405180830381865afa158015610c30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c549190614b49565b60fe546040516341b6849f60e11b8152600481018390529192506000916001600160a01b039091169063836d093e90602401600060405180830381865afa158015610ca3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610ccb9190810190614ba7565b905082858581518110610ce057610ce0614aa4565b60200260200101516000018190525080858581518110610d0257610d02614aa4565b6020026020010151602001819052505050508080610d1f90614bf1565b915050610b34565b5092915050565b6001546001600160a01b031615610d4457600080fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6000838152610100602090815260408083208784529091528120815b83811015610dcb57610dad8787878785818110610da157610da1614aa4565b90506020020135613445565b610db79084614c0a565b925080610dc381614bf1565b915050610d82565b508060010154821115610de057806001015491505b50949350505050565b60008054604051632944908560e01b8152600481018590526024810184905282916001600160a01b0316906329449085906044016040805180830381865afa158015610e39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5d9190614c32565b915091505b9250929050565b6060610105805480602002602001604051908101604052809291908181526020018280548015610eb857602002820191906000526020600020905b815481526020019060010190808311610ea4575b5050505050905090565b6001600160a01b037f0000000000000000000000007cbb92e2e73c7431303d6f54e9e7cd6e35afd667163003610f135760405162461bcd60e51b8152600401610f0a90614c5e565b60405180910390fd5b7f0000000000000000000000007cbb92e2e73c7431303d6f54e9e7cd6e35afd6676001600160a01b0316610f5c600080516020614f25833981519152546001600160a01b031690565b6001600160a01b031614610f825760405162461bcd60e51b8152600401610f0a90614caa565b610f8b81613725565b60408051600080825260208201909252610fa79183919061372d565b50565b60606000306001600160a01b031663425051646040518163ffffffff1660e01b8152600401600060405180830381865afa158015610fec573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261101491908101906149ff565b9050600081516001600160401b03811115611031576110316145bb565b60405190808252806020026020018201604052801561107757816020015b60408051808201909152606081526000602082015281526020019060019003908161104f5790505b50905060005b8251811015610d275760fe5483516000916001600160a01b03169063836d093e908690859081106110b0576110b0614aa4565b60200260200101516040518263ffffffff1660e01b81526004016110d691815260200190565b600060405180830381865afa1580156110f3573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261111b9190810190614ba7565b90506000306001600160a01b03166345740ccc86858151811061114057611140614aa4565b60200260200101516040518263ffffffff1660e01b815260040161116691815260200190565b602060405180830381865afa158015611183573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a79190614b49565b9050818484815181106111bc576111bc614aa4565b602002602001015160000181905250808484815181106111de576111de614aa4565b60200260200101516020018181525050505080806111fb90614bf1565b91505061107d565b6060610106805480602002602001604051908101604052809291908181526020018280548015610eb85760200282019190600052602060002090815481526020019060010190808311610ea4575050505050905090565b600080546040516344e87f9160e01b815260048101859052602481018490526001600160a01b03909116906344e87f9190604401602060405180830381865afa1580156112ab573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cf9190614cf6565b90505b92915050565b6000818152610103602052604081205481036112f657506000919050565b600061130183613898565b60008581526101036020526040812080549294509092509061132590600190614d11565b8154811061133557611335614aa4565b60009182526020918290206040805160608101825260039093029091018054835260018101549383018490526002015490820152915082101561137a57519392505050565b5060009392505050565b6113cc60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b506000818152610101602090815260408083205483526101008083528184209484529382529182902082519384018352805484526001810154918401919091526002810154918301919091526003810154606083015260048101546080830152600581015460a0830152600681015460c08301526007015460e082015290565b603454610100900460ff161580801561146c5750603454600160ff909116105b806114865750303b158015611486575060345460ff166001145b6114e95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610f0a565b6034805460ff19166001179055801561150c576034805461ff0019166101001790555b611514613929565b600080546001600160a01b0319166001600160a01b03851690811790915560408051637e062a3560e11b8152905163fc0c546a916004808201926020929091908290030181865afa15801561156d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115919190614d24565b60fd80546001600160a01b03199081166001600160a01b039384161790915560fe80549091169184169190911790558015611606576034805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b6001600160a01b037f0000000000000000000000007cbb92e2e73c7431303d6f54e9e7cd6e35afd6671630036116535760405162461bcd60e51b8152600401610f0a90614c5e565b7f0000000000000000000000007cbb92e2e73c7431303d6f54e9e7cd6e35afd6676001600160a01b031661169c600080516020614f25833981519152546001600160a01b031690565b6001600160a01b0316146116c25760405162461bcd60e51b8152600401610f0a90614caa565b6116cb82613725565b6116d78282600161372d565b5050565b61010581815481106116ec57600080fd5b600091825260209091200154905081565b6000306001600160a01b037f0000000000000000000000007cbb92e2e73c7431303d6f54e9e7cd6e35afd667161461179d5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610f0a565b50600080516020614f2583398151915290565b600083815261010060209081526040808320878452909152902060018101548061181c5760405162461bcd60e51b815260206004820181905260248201527f6e6f2066756e647320617661696c61626c6520666f72207468697320666565646044820152606401610f0a565b6000805b84811015611b3a5761a8c086868381811061183d5761183d614aa4565b905060200201354261184f9190614d11565b1161189c5760405162461bcd60e51b815260206004820152601a60248201527f6275666665722074696d6520686173206e6f74207061737365640000000000006044820152606401610f0a565b336118bf888888858181106118b3576118b3614aa4565b90506020020135612b7c565b6001600160a01b03161461193b5760405162461bcd60e51b815260206004820152603b60248201527f6d6573736167652073656e646572206e6f74207265706f7274657220666f722060448201527f676976656e207175657279496420616e642074696d657374616d7000000000006064820152608401610f0a565b6119528888888885818110610da157610da1614aa4565b61195c9083614c0a565b9150828210611ae157611970600186614d11565b81146119d85760405162461bcd60e51b815260206004820152603160248201527f696e73756666696369656e742062616c616e636520666f7220616c6c207375626044820152706d69747465642074696d657374616d707360781b6064820152608401610f0a565b6101055483925060011015611aaf5760078401546000906119fb90600190614d11565b610105805491925090611a1090600190614d11565b81548110611a2057611a20614aa4565b90600052602060002001546101058281548110611a3f57611a3f614aa4565b906000526020600020018190555060006101058281548110611a6357611a63614aa4565b6000918252602080832090910154808352610101909152604090912054909150611a8e836001614c0a565b60009182526101006020908152604080842094845293905291902060070155505b610105805480611ac157611ac1614d41565b600082815260208120820160001990810182905590910190915560078501555b6001846008016000888885818110611afb57611afb614aa4565b90506020020135815260200190815260200160002060006101000a81548160ff0219169083151502179055508080611b3290614bf1565b915050611820565b5080836000016001016000828254611b529190614d11565b909155505060fd5460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af1158015611ba8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bcc9190614cf6565b611bd557600080fd5b6040513381528190879089907fbe397b811472239aa40c62686337c1611135342d6e238e8aa16580dcd7223adf9060200160405180910390a450505050505050565b60606101036000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b82821015611c9d5783829060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505081526020019060010190611c4d565b505050509050919050565b60606000806000611cb98686612c67565b9150915081611ce05760006040518060200160405280600081525090935093505050610e62565b611cea8682612b07565b9250611cf68684612a7d565b935050509250929050565b611d09613958565b611d1360006139b2565b565b8181604051611d25929190614d57565b60405180910390208414611d7b5760405162461bcd60e51b815260206004820152601d60248201527f6964206d7573742062652068617368206f6620627974657320646174610000006044820152606401610f0a565b60008311611dcb5760405162461bcd60e51b815260206004820152601d60248201527f746970206d7573742062652067726561746572207468616e207a65726f0000006044820152606401610f0a565b6000848152610103602052604081208054909103611eab57806040518060600160405280868152602001426001611e029190614c0a565b815260209081018790528254600181810185556000948552938290208351600390920201908155908201519281019290925560409081015160029092019190915560fe54905163ac5c853560e01b81526001600160a01b039091169063ac5c853590611e749086908690600401614d90565b600060405180830381600087803b158015611e8e57600080fd5b505af1158015611ea2573d6000803e3d6000fd5b50505050612064565b6000611eb686613898565b8354909250839150611eca90600190614d11565b81548110611eda57611eda614aa4565b906000526020600020906003020160010154811015611fc857611efe426001614c0a565b82548390611f0e90600190614d11565b81548110611f1e57611f1e614aa4565b906000526020600020906003020160010181905550848260018480549050611f469190614d11565b81548110611f5657611f56614aa4565b90600052602060002090600302016000016000828254611f769190614c0a565b9091555050815485908390611f8d90600190614d11565b81548110611f9d57611f9d614aa4565b90600052602060002090600302016002016000828254611fbd9190614c0a565b909155506120629050565b816040518060600160405280878152602001426001611fe79190614c0a565b8152602001878560018780549050611fff9190614d11565b8154811061200f5761200f614aa4565b90600052602060002090600302016002015461202b9190614c0a565b9052815460018181018455600093845260209384902083516003909302019182559282015192810192909255604001516002909101555b505b6000858152610102602052604090205415801561208957506000612087866112d8565b115b156120d05761010680546001810182557fc9ef9fceea91e87b2c84ea400a44fde78842aae8aa24cd4b502ce5fb4d91e63b0186905554600086815261010260205260409020555b60fd546040516323b872dd60e01b8152336004820152306024820152604481018690526001600160a01b03909116906323b872dd906064016020604051808303816000875af1158015612127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214b9190614cf6565b6121675760405162461bcd60e51b8152600401610f0a90614da4565b336000908152610104602052604081208054869290612187908490614c0a565b9250508190555083857ff5ab15991b2cec1142b66b2c57a205c2af5e9d8fc5056bcb33b53b193990b07e8585336040516121c393929190614dea565b60405180910390a35050505050565b600080546040516377b03e0d60e01b8152600481018490526001600160a01b03909116906377b03e0d90602401602060405180830381865afa15801561221c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112d29190614b49565b610103602052816000526040600020818154811061225d57600080fd5b600091825260209091206003909102018054600182015460029092015490935090915083565b600082815261010060209081526040808320868452909152902080546122dd5760405162461bcd60e51b815260206004820152600f60248201526e066656564206e6f742073657420757608c1b6044820152606401610f0a565b6000821161232d5760405162461bcd60e51b815260206004820152601960248201527f6d7573742062652073656e64696e6720616e20616d6f756e74000000000000006044820152606401610f0a565b818160010160008282546123419190614c0a565b909155505060fd546040516323b872dd60e01b8152336004820152306024820152604481018490526001600160a01b03909116906323b872dd906064016020604051808303816000875af115801561239d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123c19190614cf6565b6123dd5760405162461bcd60e51b8152600401610f0a90614da4565b60078101541580156123f3575060008160010154115b1561243457610105805460018101825560008290527ffc62abc8c0fc47c2d92f5aec99bf8b60f375828e14394d89345cae11a9867371018590555460078201555b336000908152610104602052604081208054849290612454908490614c0a565b909155505060408051338152825460208201526001830154818301526002830154606082015260038301546080820152600483015460a0820152600583015460c0820152600683015460e0820152600783015461010082015290518391859187917fdaf477f4ffa6a044c31632ac3040e483553fb75f8437629291046a833cc352af91908190036101200190a450505050565b600081815260ff602090815260409182902080548351818402810184019094528084526060939283018282801561253d57602002820191906000526020600020905b815481526020019060010190808311612529575b50505050509050919050565b6000838360405161255b929190614d57565b60405180910390208b146125b15760405162461bcd60e51b815260206004820152601d60248201527f6964206d7573742062652068617368206f6620627974657320646174610000006044820152606401610f0a565b60408051602081018d90529081018b9052606081018a90526080810189905260a0810188905260c0810187905260e081018690526101000160408051601f19818403018152918152815160209283012060008e815261010084528281208282529093529120805491925090156126695760405162461bcd60e51b815260206004820152601f60248201527f66656564206d757374206e6f742062652073657420757020616c7265616479006044820152606401610f0a565b60008b116126b95760405162461bcd60e51b815260206004820181905260248201527f726577617264206d7573742062652067726561746572207468616e207a65726f6044820152606401610f0a565b600089116127145760405162461bcd60e51b815260206004820152602260248201527f696e74657276616c206d7573742062652067726561746572207468616e207a65604482015261726f60f01b6064820152608401610f0a565b8888106127745760405162461bcd60e51b815260206004820152602860248201527f77696e646f77206d757374206265206c657373207468616e20696e74657276616044820152670d840d8cadccee8d60c31b6064820152608401610f0a565b8a8155600281018a9055600381018990556004808201899055600582018890556006820187905560008d815260ff60209081526040808320805460018101825590845282842001869055858352610101909152908190208e905560fe54905163ac5c853560e01b81526001600160a01b039091169163ac5c8535916127fd918991899101614d90565b600060405180830381600087803b15801561281757600080fd5b505af115801561282b573d6000803e3d6000fd5b50505050818c7f25b7a245f1298a141e9a73052d47515c64a19a5550bc21f5c896f2097e155efe87873360405161286493929190614dea565b60405180910390a3821561287d5761287d828d85612283565b509a9950505050505050505050565b6000805460405163a792765f60e01b81526004810185905260248101849052606092916001600160a01b03169063a792765f90604401600060405180830381865afa1580156128df573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526129079190810190614e17565b90969095509350505050565b61293760405180606001604052806000815260200160008152602001600081525090565b60008381526101036020526040902080548390811061295857612958614aa4565b90600052602060002090600302016040518060600160405290816000820154815260200160018201548152602001600282015481525050905092915050565b60606000826001600160401b038111156129b3576129b36145bb565b6040519080825280602002602001820160405280156129dc578160200160208202803683370190505b50905060005b83811015612a71576000868152610100602090815260408083208a8452909152812060080190868684818110612a1a57612a1a614aa4565b90506020020135815260200190815260200160002060009054906101000a900460ff16828281518110612a4f57612a4f614aa4565b9115156020928302919091019091015280612a6981614bf1565b9150506129e2565b5090505b949350505050565b60005460405163c5958af960e01b815260048101849052602481018390526060916001600160a01b03169063c5958af990604401600060405180830381865afa158015612ace573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112cf9190810190614ba7565b61010681815481106116ec57600080fd5b6000805460405163ce5e11bf60e01b815260048101859052602481018490526001600160a01b039091169063ce5e11bf90604401602060405180830381865afa158015612b58573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cf9190614b49565b6000805460405163703e2a4360e11b815260048101859052602481018490526001600160a01b039091169063e07c548690604401602060405180830381865afa158015612bcd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112cf9190614d24565b612bf9613958565b6001600160a01b038116612c5e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610f0a565b610fa7816139b2565b6000806000612c75856121d2565b905080600003612c8c576000809250925050610e62565b80612c9681614e6d565b9150600190506000808381612cab8a83612b07565b9050888111612cc65760008097509750505050505050610e62565b612cd08a84612b07565b905088811115612cdf57600094505b8415612d8f576002612cf18484614c0a565b612cfb9190614e84565b9350612d078a85612b07565b905088811115612d48576000612d228b61097b600188614d11565b9050898111612d345760009550612d42565b612d3f600186614d11565b92505b50612cdf565b6000612d598b61097b876001614c0a565b905089811115612d7c576000955084612d7181614bf1565b955050809150612d42565b612d87856001614c0a565b935050612cdf565b612d998a8261125a565b612daf5760018497509750505050505050610e62565b612db98a8261125a565b8015612dc457508584105b15612de75783612dd381614bf1565b945050612de08a85612b07565b9050612daf565b8584148015612dfb5750612dfb8a8261125a565b15612e125760008097509750505050505050610e62565b60018497509750505050505050610e62565b60015460405163690ebcf760e11b8152600481018390526000918291829182916001600160a01b039091169063d21d79ee90602401602060405180830381865afa158015612e76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e9a9190614b49565b90506060612ead82610846426001614c0a565b945090506000849003612ecd576000806101949450945094505050612ee2565b6000612ed882613a04565b955060c893505050505b9193909250565b606080600080612efd886109db888a614d11565b9150915081612f4e576040805160008082526020820190925290612f31565b6060815260200190600190039081612f1c5790505b5060408051600081526020810190915290945092506131cc915050565b6000612f5a8989610de9565b909350905082612fad576040805160008082526020820190925290612f8f565b6060815260200190600190039081612f7a5790505b5060408051600081526020810190915290955093506131cc92505050565b6000806000886001600160401b03811115612fca57612fca6145bb565b604051908082528060200260200182016040528015612ff3578160200160208202803683370190505b5090505b888310801561301a5750848261300e866001614c0a565b6130189190614d11565b115b1561307e57600061302f8d61097b8588614d11565b905061303b8d8261125a565b61306b578082858151811061305257613052614aa4565b60209081029190910101528361306781614bf1565b9450505b8261307581614bf1565b93505050612ff7565b6000836001600160401b03811115613098576130986145bb565b6040519080825280602002602001820160405280156130cb57816020015b60608152602001906001900390816130b65790505b5090506000846001600160401b038111156130e8576130e86145bb565b604051908082528060200260200182016040528015613111578160200160208202803683370190505b50905060005b858110156131bf57838161312c600189614d11565b6131369190614d11565b8151811061314657613146614aa4565b602002602001015182828151811061316057613160614aa4565b60200260200101818152505061318f8f83838151811061318257613182614aa4565b6020026020010151612a7d565b8382815181106131a1576131a1614aa4565b602002602001018190525080806131b790614bf1565b915050613117565b5090985096505050505050505b94509492505050565b6000838152610103602052604090205461323c5760405162461bcd60e51b815260206004820152602260248201527f6e6f2074697073207375626d697474656420666f722074686973207175657279604482015261125960f21b6064820152608401610f0a565b6000805b828110156132885761326a8585858481811061325e5761325e614aa4565b90506020020135613a5b565b6132749083614c0a565b91508061328081614bf1565b915050613240565b5060fd5460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af11580156132da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132fe9190614cf6565b61330757600080fd5b613310846112d8565b600003613410576000848152610102602052604090205415613410576000848152610102602052604081205461334890600190614d11565b61010680549192509061335d90600190614d11565b8154811061336d5761336d614aa4565b9060005260206000200154610106828154811061338c5761338c614aa4565b9060005260206000200181905550600061010682815481106133b0576133b0614aa4565b906000526020600020015490508160016133ca9190614c0a565b6000828152610102602052604080822092909255878152908120556101068054806133f7576133f7614d41565b6001900381819060005260206000200160009055905550505b6040513390829086907fdff45d500502d35c7f1150acbb404c5b2e288e31a74354c8553a283dd1e806e790600090a450505050565b60006224ea006134558342614d11565b106134a25760405162461bcd60e51b815260206004820152601e60248201527f74696d657374616d7020746f6f206f6c6420746f20636c61696d2074697000006044820152606401610f0a565b6000838152610100602090815260408083208784528252808320858452600881019092529091205460ff161561351a5760405162461bcd60e51b815260206004820152601660248201527f72657761726420616c726561647920636c61696d6564000000000000000000006044820152606401610f0a565b60038101546002820154600091906135329086614d11565b61353c9190614e84565b905060008183600001600301546135539190614ea6565b60028401546135629190614c0a565b905060006135708787612a7d565b905080516000036135c35760405162461bcd60e51b815260206004820152601c60248201527f6e6f2076616c7565206578697374732061742074696d657374616d70000000006044820152606401610f0a565b6000806135d0898961288c565b60058801549193509150600090156136645760006135ed85613f2d565b905060006135fa85613f2d565b90508060000361360e576127109250613661565b80821061363d57806136208184614d11565b61362c90612710614ea6565b6136369190614e84565b9250613661565b806136488382614d11565b61365490612710614ea6565b61365e9190614e84565b92505b50505b865497506000613674868b614d11565b60048901549091508110801561368957508583105b156136af57600688015461369e908290614ea6565b6136a8908a614c0a565b9850613702565b600588015482116137025760405162461bcd60e51b815260206004820152601760248201527f7072696365207468726573686f6c64206e6f74206d65740000000000000000006044820152606401610f0a565b600188015489111561371657600188015498505b50505050505050509392505050565b610fa7613958565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff16156137605761160683613f7e565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156137ba575060408051601f3d908101601f191682019092526137b791810190614b49565b60015b61381d5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610f0a565b600080516020614f25833981519152811461388c5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610f0a565b5061160683838361401a565b60606000806138a6846121d2565b9050806000036138cc576040518060200160405280600081525060009250925050915091565b60005b811561391057816138df81614e6d565b9250506138ec8583612b07565b90506138f88582612a7d565b80519094501561390b5792949293505050565b6138cf565b6040805160208101909152600081529590945092505050565b603454610100900460ff166139505760405162461bcd60e51b8152600401610f0a90614ebd565b611d13614045565b6067546001600160a01b03163314611d135760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f0a565b606780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000805b8251811015613a5557828181518110613a2357613a23614aa4565b016020015160f81c613a3783610100614ea6565b613a419190614c0a565b915080613a4d81614bf1565b915050613a08565b50919050565b600061a8c0613a6a8342614d11565b11613ab75760405162461bcd60e51b815260206004820152601a60248201527f6275666665722074696d6520686173206e6f74207061737365640000000000006044820152606401610f0a565b613ac1838361125a565b15613aff5760405162461bcd60e51b815260206004820152600e60248201526d1d985b1d5948191a5cdc1d5d195960921b6044820152606401610f0a565b613b098383612b7c565b6001600160a01b0316336001600160a01b031614613b755760405162461bcd60e51b815260206004820152602360248201527f6d73672073656e646572206d757374206265207265706f72746572206164647260448201526265737360e81b6064820152608401610f0a565b6000838152610103602052604081208054909190815b6001613b978484614d11565b1115613bf0576002613ba98484614c0a565b613bb39190614e84565b905085848281548110613bc857613bc8614aa4565b9060005260206000209060030201600101541115613be857809150613b8b565b809250613b8b565b6000613bfc888861288c565b915050848481548110613c1157613c11614aa4565b9060005260206000209060030201600101548110613c7b5760405162461bcd60e51b815260206004820152602160248201527f746970206561726e65642062792070726576696f7573207375626d697373696f6044820152603760f91b6064820152608401610f0a565b848481548110613c8d57613c8d614aa4565b906000526020600020906003020160010154871015613cee5760405162461bcd60e51b815260206004820152601e60248201527f74696d657374616d70206e6f7420656c696769626c6520666f722074697000006044820152606401610f0a565b6000858581548110613d0257613d02614aa4565b90600052602060002090600302016000015411613d575760405162461bcd60e51b81526020600482015260136024820152721d1a5c08185b1c9958591e4818db185a5b5959606a1b6044820152606401610f0a565b848481548110613d6957613d69614aa4565b90600052602060002090600302016000015495506000858581548110613d9157613d91614aa4565b600091825260208220600390910201919091558490613db58a6103b98b6001614c0a565b91506000905080613dcb8c6103b9876001614c0a565b90925090506001613ddc8285614d11565b1180613de6575081155b15613f1e5781613e1b57888481548110613e0257613e02614aa4565b9060005260206000209060030201600201549950613f1e565b60009796505b6001613e2d8989614d11565b1115613e86576002613e3f8989614c0a565b613e499190614e84565b955084898781548110613e5e57613e5e614aa4565b9060005260206000209060030201600101541115613e7e57859650613e21565b859750613e21565b87613e9081614bf1565b98505083881015613f1e57888881548110613ead57613ead614aa4565b906000526020600020906003020160000154898981548110613ed157613ed1614aa4565b9060005260206000209060030201600201548a8681548110613ef557613ef5614aa4565b906000526020600020906003020160020154613f119190614d11565b613f1b9190614c0a565b99505b50505050505050505092915050565b6000805b8251811015613a5557828181518110613f4c57613f4c614aa4565b016020015160f81c613f6083610100614ea6565b613f6a9190614c0a565b915080613f7681614bf1565b915050613f31565b6001600160a01b0381163b613feb5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610f0a565b600080516020614f2583398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61402383614075565b6000825111806140305750805b156116065761403f83836140b5565b50505050565b603454610100900460ff1661406c5760405162461bcd60e51b8152600401610f0a90614ebd565b611d13336139b2565b61407e81613f7e565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606112cf8383604051806060016040528060278152602001614f45602791396060600080856001600160a01b0316856040516140f29190614f08565b600060405180830381855af49150503d806000811461412d576040519150601f19603f3d011682016040523d82523d6000602084013e614132565b606091505b50915091506141438683838761414d565b9695505050505050565b606083156141bc5782516000036141b5576001600160a01b0385163b6141b55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f0a565b5081612a75565b612a7583838151156141d15781518083602001fd5b8060405162461bcd60e51b8152600401610f0a91906148d4565b604051806040016040528061423e60405180610100016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b8152602001606081525090565b60005b8381101561426657818101518382015260200161424e565b50506000910152565b6000815180845261428781602086016020860161424b565b601f01601f19169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561435957603f19888603018452815161012061432c878351805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e08301525050565b878201519150806101008801526143458188018361426f565b9650505092850192908501906001016142c2565b5092979650505050505050565b6001600160a01b0381168114610fa757600080fd5b60006020828403121561438d57600080fd5b813561439881614366565b9392505050565b60008083601f8401126143b157600080fd5b5081356001600160401b038111156143c857600080fd5b6020830191508360208260051b8501011115610e6257600080fd5b600080600080606085870312156143f957600080fd5b843593506020850135925060408501356001600160401b0381111561441d57600080fd5b6144298782880161439f565b95989497509550505050565b6000806040838503121561444857600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b8181101561448f57835183529284019291840191600101614473565b50909695505050505050565b6000602082840312156144ad57600080fd5b5035919050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b8381101561451c57888303603f19018552815180518785526144ff8886018261426f565b9189015194890194909452948701949250908601906001016144db565b509098975050505050505050565b61010081016112d28284805182526020810151602083015260408101516040830152606081015160608301526080810151608083015260a081015160a083015260c081015160c083015260e081015160e08301525050565b6000806040838503121561459557600080fd5b82356145a081614366565b915060208301356145b081614366565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156145f9576145f96145bb565b604052919050565b60006001600160401b0382111561461a5761461a6145bb565b50601f01601f191660200190565b6000806040838503121561463b57600080fd5b823561464681614366565b915060208301356001600160401b0381111561466157600080fd5b8301601f8101851361467257600080fd5b803561468561468082614601565b6145d1565b81815286602083850101111561469a57600080fd5b816020840160208301376000602083830101528093505050509250929050565b6020808252825182820181905260009190848201906040850190845b8181101561448f576146fd8385518051825260208082015190830152604090810151910152565b92840192606092909201916001016146d6565b604081526000614723604083018561426f565b90508260208301529392505050565b60008083601f84011261474457600080fd5b5081356001600160401b0381111561475b57600080fd5b602083019150836020828501011115610e6257600080fd5b6000806000806060858703121561478957600080fd5b843593506020850135925060408501356001600160401b038111156147ad57600080fd5b61442987828801614732565b6000806000606084860312156147ce57600080fd5b505081359360208301359350604090920135919050565b6000806000806000806000806000806101208b8d03121561480557600080fd5b8a35995060208b0135985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b0135935060e08b01356001600160401b0381111561484c57600080fd5b6148588d828e01614732565b915080945050809250506101008b013590509295989b9194979a5092959850565b815181526020808301519082015260408083015190820152606081016112d2565b6020808252825182820181905260009190848201906040850190845b8181101561448f5783511515835292840192918401916001016148b6565b6020815260006112cf602083018461426f565b600080600080608085870312156148fd57600080fd5b5050823594602084013594506040840135936060013592509050565b6000604082016040835280855180835260608501915060608160051b8601019250602080880160005b8381101561497057605f1988870301855261495e86835161426f565b95509382019390820190600101614942565b50508584038187015286518085528782019482019350915060005b828110156149a75784518452938101939281019260010161498b565b5091979650505050505050565b6000806000604084860312156149c957600080fd5b8335925060208401356001600160401b038111156149e657600080fd5b6149f28682870161439f565b9497909650939450505050565b60006020808385031215614a1257600080fd5b82516001600160401b0380821115614a2957600080fd5b818501915085601f830112614a3d57600080fd5b815181811115614a4f57614a4f6145bb565b8060051b9150614a608483016145d1565b8181529183018401918481019088841115614a7a57600080fd5b938501935b83851015614a9857845182529385019390850190614a7f565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b6000610100808385031215614ace57600080fd5b604051908101906001600160401b0382118183101715614af057614af06145bb565b81604052835181526020840151602082015260408401516040820152606084015160608201526080840151608082015260a084015160a082015260c084015160c082015260e084015160e0820152809250505092915050565b600060208284031215614b5b57600080fd5b5051919050565b600082601f830112614b7357600080fd5b8151614b8161468082614601565b818152846020838601011115614b9657600080fd5b612a7582602083016020870161424b565b600060208284031215614bb957600080fd5b81516001600160401b03811115614bcf57600080fd5b612a7584828501614b62565b634e487b7160e01b600052601160045260246000fd5b600060018201614c0357614c03614bdb565b5060010190565b808201808211156112d2576112d2614bdb565b80518015158114614c2d57600080fd5b919050565b60008060408385031215614c4557600080fd5b614c4e83614c1d565b9150602083015190509250929050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b600060208284031215614d0857600080fd5b6112cf82614c1d565b818103818111156112d2576112d2614bdb565b600060208284031215614d3657600080fd5b815161439881614366565b634e487b7160e01b600052603160045260246000fd5b8183823760009101908152919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b602081526000612a75602083018486614d67565b60208082526026908201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604082015265616c616e636560d01b606082015260800190565b604081526000614dfe604083018587614d67565b90506001600160a01b0383166020830152949350505050565b600080600060608486031215614e2c57600080fd5b614e3584614c1d565b925060208401516001600160401b03811115614e5057600080fd5b614e5c86828701614b62565b925050604084015190509250925092565b600081614e7c57614e7c614bdb565b506000190190565b600082614ea157634e487b7160e01b600052601260045260246000fd5b500490565b80820281158282048414176112d2576112d2614bdb565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251614f1a81846020870161424b565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212200513499bdd2481ac4b92f62101ff2758df5b3f7d1bde2b1b23bdd0986a985d4064736f6c63430008140033