ETH Price: $3,203.90 (+1.47%)
Gas: 1 Gwei

Contract

0xBF7D92AfdF01C8370e0b164338FDEf105a7c8dbb
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Update Data Feed...189897882024-01-12 9:01:11184 days ago1705050071IN
0xBF7D92Af...05a7c8dbb
0 ETH0.0017601819.14454624
0x60806040189897582024-01-12 8:55:11184 days ago1705049711IN
 Create: MergedAdapterWithoutRoundsOsethethV2
0 ETH0.0365892718.40917804

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MergedAdapterWithoutRoundsOsethethV2

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
File 1 of 26 : MergedAdapterWithoutRoundsOsethethV2.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;

import {MergedPriceFeedAdapterWithoutRoundsPrimaryProd} from "@redstone-finance/on-chain-relayer/contracts/price-feeds/data-services/MergedPriceFeedAdapterWithoutRoundsPrimaryProd.sol";
import {OldGelatoAddress, GelatoAddress} from "../__addresses/Addresses.sol";

contract MergedAdapterWithoutRoundsOsethethV2 is MergedPriceFeedAdapterWithoutRoundsPrimaryProd {

  address internal constant MAIN_UPDATER_ADDRESS = 0xcd1435F09c411FCBc44DA4A51f5C1a2e1b32fF47;
  address internal constant FALLBACK_UPDATER_ADDRESS = 0x9Abfefd388ae17E0B8a9F865EB1cCb137bf436cF;
  address internal constant MANUAL_UPDATER_ADDRESS = 0xc1c090658937107675cBFe4494E6b63519538B62;

  error UpdaterNotAuthorised(address signer);

  function getDataFeedId() public pure virtual override returns (bytes32) {
    return bytes32("osETH/ETH");
  }

  function requireAuthorisedUpdater(address updater) public view override virtual {
    if (
      updater != MAIN_UPDATER_ADDRESS &&
      updater != FALLBACK_UPDATER_ADDRESS &&
      updater != MANUAL_UPDATER_ADDRESS &&
      updater != GelatoAddress.ADDR &&
      updater != OldGelatoAddress.ADDR
    ) {
      revert UpdaterNotAuthorised(updater);
    }
  }
}

File 2 of 26 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
}

File 3 of 26 : 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;
    }
}

File 4 of 26 : 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);
        }
    }
}

File 5 of 26 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.2._
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v2.5._
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.2._
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v2.5._
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v2.5._
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v2.5._
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v2.5._
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     *
     * _Available since v3.0._
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.7._
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.7._
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     *
     * _Available since v3.0._
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 6 of 26 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 7 of 26 : CalldataExtractor.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/math/SafeMath.sol";

import "./RedstoneConstants.sol";

/**
 * @title The base contract with the main logic of data extraction from calldata
 * @author The Redstone Oracles team
 * @dev This contract was created to reuse the same logic in the RedstoneConsumerBase
 * and the ProxyConnector contracts
 */
contract CalldataExtractor is RedstoneConstants {
  using SafeMath for uint256;

  error DataPackageTimestampMustNotBeZero();
  error DataPackageTimestampsMustBeEqual();
  error RedstonePayloadMustHaveAtLeastOneDataPackage();

  function extractTimestampsAndAssertAllAreEqual() public pure returns (uint256 extractedTimestamp) {
    uint256 calldataNegativeOffset = _extractByteSizeOfUnsignedMetadata();
    uint256 dataPackagesCount = _extractDataPackagesCountFromCalldata(calldataNegativeOffset);

    if (dataPackagesCount == 0) {
      revert RedstonePayloadMustHaveAtLeastOneDataPackage();
    }

    calldataNegativeOffset += DATA_PACKAGES_COUNT_BS;
    for (uint256 dataPackageIndex = 0; dataPackageIndex < dataPackagesCount; dataPackageIndex++) {
      uint256 dataPackageByteSize = _getDataPackageByteSize(calldataNegativeOffset);

      // Extracting timestamp for the current data package
      uint48 dataPackageTimestamp; // uint48, because timestamp uses 6 bytes
      uint256 timestampNegativeOffset = (calldataNegativeOffset + TIMESTAMP_NEGATIVE_OFFSET_IN_DATA_PACKAGE_WITH_STANDARD_SLOT_BS);
      uint256 timestampOffset = msg.data.length - timestampNegativeOffset;
      assembly {
        dataPackageTimestamp := calldataload(timestampOffset)
      }

      if (dataPackageTimestamp == 0) {
        revert DataPackageTimestampMustNotBeZero();
      }

      if (extractedTimestamp == 0) {
        extractedTimestamp = dataPackageTimestamp;
      } else if (dataPackageTimestamp != extractedTimestamp) {
        revert DataPackageTimestampsMustBeEqual();
      }

      calldataNegativeOffset += dataPackageByteSize;
    }
  }

  function _getDataPackageByteSize(uint256 calldataNegativeOffset) internal pure returns (uint256) {
    (
      uint256 dataPointsCount,
      uint256 eachDataPointValueByteSize
    ) = _extractDataPointsDetailsForDataPackage(calldataNegativeOffset);

    return
      dataPointsCount *
      (DATA_POINT_SYMBOL_BS + eachDataPointValueByteSize) +
      DATA_PACKAGE_WITHOUT_DATA_POINTS_BS;
  }

  function _extractByteSizeOfUnsignedMetadata() internal pure returns (uint256) {
    // Checking if the calldata ends with the RedStone marker
    bool hasValidRedstoneMarker;
    assembly {
      let calldataLast32Bytes := calldataload(sub(calldatasize(), STANDARD_SLOT_BS))
      hasValidRedstoneMarker := eq(
        REDSTONE_MARKER_MASK,
        and(calldataLast32Bytes, REDSTONE_MARKER_MASK)
      )
    }
    if (!hasValidRedstoneMarker) {
      revert CalldataMustHaveValidPayload();
    }

    // Using uint24, because unsigned metadata byte size number has 3 bytes
    uint24 unsignedMetadataByteSize;
    if (REDSTONE_MARKER_BS_PLUS_STANDARD_SLOT_BS > msg.data.length) {
      revert CalldataOverOrUnderFlow();
    }
    assembly {
      unsignedMetadataByteSize := calldataload(
        sub(calldatasize(), REDSTONE_MARKER_BS_PLUS_STANDARD_SLOT_BS)
      )
    }
    uint256 calldataNegativeOffset = unsignedMetadataByteSize
      + UNSIGNED_METADATA_BYTE_SIZE_BS
      + REDSTONE_MARKER_BS;
    if (calldataNegativeOffset + DATA_PACKAGES_COUNT_BS > msg.data.length) {
      revert IncorrectUnsignedMetadataSize();
    }
    return calldataNegativeOffset;
  }

  // We return uint16, because unsigned metadata byte size number has 2 bytes
  function _extractDataPackagesCountFromCalldata(uint256 calldataNegativeOffset)
    internal
    pure
    returns (uint16 dataPackagesCount)
  {
    uint256 calldataNegativeOffsetWithStandardSlot = calldataNegativeOffset + STANDARD_SLOT_BS;
    if (calldataNegativeOffsetWithStandardSlot > msg.data.length) {
      revert CalldataOverOrUnderFlow();
    }
    assembly {
      dataPackagesCount := calldataload(
        sub(calldatasize(), calldataNegativeOffsetWithStandardSlot)
      )
    }
    return dataPackagesCount;
  }

  function _extractDataPointValueAndDataFeedId(
    uint256 calldataNegativeOffsetForDataPackage,
    uint256 defaultDataPointValueByteSize,
    uint256 dataPointIndex
  ) internal pure virtual returns (bytes32 dataPointDataFeedId, uint256 dataPointValue) {
    uint256 negativeOffsetToDataPoints = calldataNegativeOffsetForDataPackage + DATA_PACKAGE_WITHOUT_DATA_POINTS_BS;
    uint256 dataPointNegativeOffset = negativeOffsetToDataPoints.add(
      (1 + dataPointIndex).mul((defaultDataPointValueByteSize + DATA_POINT_SYMBOL_BS))
    );
    uint256 dataPointCalldataOffset = msg.data.length.sub(dataPointNegativeOffset);
    assembly {
      dataPointDataFeedId := calldataload(dataPointCalldataOffset)
      dataPointValue := calldataload(add(dataPointCalldataOffset, DATA_POINT_SYMBOL_BS))
    }
  }

  function _extractDataPointsDetailsForDataPackage(uint256 calldataNegativeOffsetForDataPackage)
    internal
    pure
    returns (uint256 dataPointsCount, uint256 eachDataPointValueByteSize)
  {
    // Using uint24, because data points count byte size number has 3 bytes
    uint24 dataPointsCount_;

    // Using uint32, because data point value byte size has 4 bytes
    uint32 eachDataPointValueByteSize_;

    // Extract data points count
    uint256 negativeCalldataOffset = calldataNegativeOffsetForDataPackage + SIG_BS;
    uint256 calldataOffset = msg.data.length.sub(negativeCalldataOffset + STANDARD_SLOT_BS);
    assembly {
      dataPointsCount_ := calldataload(calldataOffset)
    }

    // Extract each data point value size
    calldataOffset = calldataOffset.sub(DATA_POINTS_COUNT_BS);
    assembly {
      eachDataPointValueByteSize_ := calldataload(calldataOffset)
    }

    // Prepare returned values
    dataPointsCount = dataPointsCount_;
    eachDataPointValueByteSize = eachDataPointValueByteSize_;
  }
}

File 8 of 26 : RedstoneConstants.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;

/**
 * @title The base contract with helpful constants
 * @author The Redstone Oracles team
 * @dev It mainly contains redstone-related values, which improve readability
 * of other contracts (e.g. CalldataExtractor and RedstoneConsumerBase)
 */
contract RedstoneConstants {
  // === Abbreviations ===
  // BS - Bytes size
  // PTR - Pointer (memory location)
  // SIG - Signature

  // Solidity and YUL constants
  uint256 internal constant STANDARD_SLOT_BS = 32;
  uint256 internal constant FREE_MEMORY_PTR = 0x40;
  uint256 internal constant BYTES_ARR_LEN_VAR_BS = 32;
  uint256 internal constant FUNCTION_SIGNATURE_BS = 4;
  uint256 internal constant REVERT_MSG_OFFSET = 68; // Revert message structure described here: https://ethereum.stackexchange.com/a/66173/106364
  uint256 internal constant STRING_ERR_MESSAGE_MASK = 0x08c379a000000000000000000000000000000000000000000000000000000000;

  // RedStone protocol consts
  uint256 internal constant SIG_BS = 65;
  uint256 internal constant TIMESTAMP_BS = 6;
  uint256 internal constant DATA_PACKAGES_COUNT_BS = 2;
  uint256 internal constant DATA_POINTS_COUNT_BS = 3;
  uint256 internal constant DATA_POINT_VALUE_BYTE_SIZE_BS = 4;
  uint256 internal constant DATA_POINT_SYMBOL_BS = 32;
  uint256 internal constant DEFAULT_DATA_POINT_VALUE_BS = 32;
  uint256 internal constant UNSIGNED_METADATA_BYTE_SIZE_BS = 3;
  uint256 internal constant REDSTONE_MARKER_BS = 9; // byte size of 0x000002ed57011e0000
  uint256 internal constant REDSTONE_MARKER_MASK = 0x0000000000000000000000000000000000000000000000000002ed57011e0000;

  // Derived values (based on consts)
  uint256 internal constant TIMESTAMP_NEGATIVE_OFFSET_IN_DATA_PACKAGE_WITH_STANDARD_SLOT_BS = 104; // SIG_BS + DATA_POINTS_COUNT_BS + DATA_POINT_VALUE_BYTE_SIZE_BS + STANDARD_SLOT_BS
  uint256 internal constant DATA_PACKAGE_WITHOUT_DATA_POINTS_BS = 78; // DATA_POINT_VALUE_BYTE_SIZE_BS + TIMESTAMP_BS + DATA_POINTS_COUNT_BS + SIG_BS
  uint256 internal constant DATA_PACKAGE_WITHOUT_DATA_POINTS_AND_SIG_BS = 13; // DATA_POINT_VALUE_BYTE_SIZE_BS + TIMESTAMP_BS + DATA_POINTS_COUNT_BS
  uint256 internal constant REDSTONE_MARKER_BS_PLUS_STANDARD_SLOT_BS = 41; // REDSTONE_MARKER_BS + STANDARD_SLOT_BS

  // Error messages
  error CalldataOverOrUnderFlow();
  error IncorrectUnsignedMetadataSize();
  error InsufficientNumberOfUniqueSigners(uint256 receivedSignersCount, uint256 requiredSignersCount);
  error EachSignerMustProvideTheSameValue();
  error EmptyCalldataPointersArr();
  error InvalidCalldataPointer();
  error CalldataMustHaveValidPayload();
  error SignerNotAuthorised(address receivedSigner);
}

File 9 of 26 : RedstoneConsumerBase.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/math/SafeMath.sol";

import "./RedstoneConstants.sol";
import "./RedstoneDefaultsLib.sol";
import "./CalldataExtractor.sol";
import "../libs/BitmapLib.sol";
import "../libs/SignatureLib.sol";

/**
 * @title The base contract with the main Redstone logic
 * @author The Redstone Oracles team
 * @dev Do not use this contract directly in consumer contracts, take a
 * look at `RedstoneConsumerNumericBase` and `RedstoneConsumerBytesBase` instead
 */
abstract contract RedstoneConsumerBase is CalldataExtractor {
  using SafeMath for uint256;

  error GetDataServiceIdNotImplemented();

  /* ========== VIRTUAL FUNCTIONS (MAY BE OVERRIDDEN IN CHILD CONTRACTS) ========== */

  /**
   * @dev This function must be implemented by the child consumer contract.
   * It should return dataServiceId which DataServiceWrapper will use if not provided explicitly .
   * If not overridden, value will always have to be provided explicitly in DataServiceWrapper.
   * @return dataServiceId being consumed by contract
   */
  function getDataServiceId() public view virtual returns (string memory) {
    revert GetDataServiceIdNotImplemented();
  }

  /**
   * @dev This function must be implemented by the child consumer contract.
   * It should return a unique index for a given signer address if the signer
   * is authorised, otherwise it should revert
   * @param receivedSigner The address of a signer, recovered from ECDSA signature
   * @return Unique index for a signer in the range [0..255]
   */
  function getAuthorisedSignerIndex(address receivedSigner) public view virtual returns (uint8);

  /**
   * @dev This function may be overridden by the child consumer contract.
   * It should validate the timestamp against the current time (block.timestamp)
   * It should revert with a helpful message if the timestamp is not valid
   * @param receivedTimestampMilliseconds Timestamp extracted from calldata
   */
  function validateTimestamp(uint256 receivedTimestampMilliseconds) public view virtual {
    RedstoneDefaultsLib.validateTimestamp(receivedTimestampMilliseconds);
  }

  /**
   * @dev This function should be overridden by the child consumer contract.
   * @return The minimum required value of unique authorised signers
   */
  function getUniqueSignersThreshold() public view virtual returns (uint8) {
    return 1;
  }

  /**
   * @dev This function may be overridden by the child consumer contract.
   * It should aggregate values from different signers to a single uint value.
   * By default, it calculates the median value
   * @param values An array of uint256 values from different signers
   * @return Result of the aggregation in the form of a single number
   */
  function aggregateValues(uint256[] memory values) public view virtual returns (uint256) {
    return RedstoneDefaultsLib.aggregateValues(values);
  }

  /* ========== FUNCTIONS WITH IMPLEMENTATION (CAN NOT BE OVERRIDDEN) ========== */

  /**
   * @dev This is an internal helpful function for secure extraction oracle values
   * from the tx calldata. Security is achieved by signatures verification, timestamp
   * validation, and aggregating values from different authorised signers into a
   * single numeric value. If any of the required conditions (e.g. too old timestamp or
   * insufficient number of authorised signers) do not match, the function will revert.
   *
   * Note! You should not call this function in a consumer contract. You can use
   * `getOracleNumericValuesFromTxMsg` or `getOracleNumericValueFromTxMsg` instead.
   *
   * @param dataFeedIds An array of unique data feed identifiers
   * @return An array of the extracted and verified oracle values in the same order
   * as they are requested in dataFeedIds array
   */
  function _securelyExtractOracleValuesFromTxMsg(bytes32[] memory dataFeedIds)
    internal
    view
    returns (uint256[] memory)
  {
    // Initializing helpful variables and allocating memory
    uint256[] memory uniqueSignerCountForDataFeedIds = new uint256[](dataFeedIds.length);
    uint256[] memory signersBitmapForDataFeedIds = new uint256[](dataFeedIds.length);
    uint256[][] memory valuesForDataFeeds = new uint256[][](dataFeedIds.length);
    for (uint256 i = 0; i < dataFeedIds.length; i++) {
      // The line below is commented because newly allocated arrays are filled with zeros
      // But we left it for better readability
      // signersBitmapForDataFeedIds[i] = 0; // <- setting to an empty bitmap
      valuesForDataFeeds[i] = new uint256[](getUniqueSignersThreshold());
    }

    // Extracting the number of data packages from calldata
    uint256 calldataNegativeOffset = _extractByteSizeOfUnsignedMetadata();
    uint256 dataPackagesCount = _extractDataPackagesCountFromCalldata(calldataNegativeOffset);
    calldataNegativeOffset += DATA_PACKAGES_COUNT_BS;

    // Saving current free memory pointer
    uint256 freeMemPtr;
    assembly {
      freeMemPtr := mload(FREE_MEMORY_PTR)
    }

    // Data packages extraction in a loop
    for (uint256 dataPackageIndex = 0; dataPackageIndex < dataPackagesCount; dataPackageIndex++) {
      // Extract data package details and update calldata offset
      uint256 dataPackageByteSize = _extractDataPackage(
        dataFeedIds,
        uniqueSignerCountForDataFeedIds,
        signersBitmapForDataFeedIds,
        valuesForDataFeeds,
        calldataNegativeOffset
      );
      calldataNegativeOffset += dataPackageByteSize;

      // Shifting memory pointer back to the "safe" value
      assembly {
        mstore(FREE_MEMORY_PTR, freeMemPtr)
      }
    }

    // Validating numbers of unique signers and calculating aggregated values for each dataFeedId
    return _getAggregatedValues(valuesForDataFeeds, uniqueSignerCountForDataFeedIds);
  }

  /**
   * @dev This is a private helpful function, which extracts data for a data package based
   * on the given negative calldata offset, verifies them, and in the case of successful
   * verification updates the corresponding data package values in memory
   *
   * @param dataFeedIds an array of unique data feed identifiers
   * @param uniqueSignerCountForDataFeedIds an array with the numbers of unique signers
   * for each data feed
   * @param signersBitmapForDataFeedIds an array of signer bitmaps for data feeds
   * @param valuesForDataFeeds 2-dimensional array, valuesForDataFeeds[i][j] contains
   * j-th value for the i-th data feed
   * @param calldataNegativeOffset negative calldata offset for the given data package
   *
   * @return An array of the aggregated values
   */
  function _extractDataPackage(
    bytes32[] memory dataFeedIds,
    uint256[] memory uniqueSignerCountForDataFeedIds,
    uint256[] memory signersBitmapForDataFeedIds,
    uint256[][] memory valuesForDataFeeds,
    uint256 calldataNegativeOffset
  ) private view returns (uint256) {
    uint256 signerIndex;

    (
      uint256 dataPointsCount,
      uint256 eachDataPointValueByteSize
    ) = _extractDataPointsDetailsForDataPackage(calldataNegativeOffset);

    // We use scopes to resolve problem with too deep stack
    {
      uint48 extractedTimestamp;
      address signerAddress;
      bytes32 signedHash;
      bytes memory signedMessage;
      uint256 signedMessageBytesCount;

      signedMessageBytesCount = dataPointsCount.mul(eachDataPointValueByteSize + DATA_POINT_SYMBOL_BS)
        + DATA_PACKAGE_WITHOUT_DATA_POINTS_AND_SIG_BS; //DATA_POINT_VALUE_BYTE_SIZE_BS + TIMESTAMP_BS + DATA_POINTS_COUNT_BS

      uint256 timestampCalldataOffset = msg.data.length.sub(
        calldataNegativeOffset + TIMESTAMP_NEGATIVE_OFFSET_IN_DATA_PACKAGE_WITH_STANDARD_SLOT_BS);

      uint256 signedMessageCalldataOffset = msg.data.length.sub(
        calldataNegativeOffset + SIG_BS + signedMessageBytesCount);

      assembly {
        // Extracting the signed message
        signedMessage := extractBytesFromCalldata(
          signedMessageCalldataOffset,
          signedMessageBytesCount
        )

        // Hashing the signed message
        signedHash := keccak256(add(signedMessage, BYTES_ARR_LEN_VAR_BS), signedMessageBytesCount)

        // Extracting timestamp
        extractedTimestamp := calldataload(timestampCalldataOffset)

        function initByteArray(bytesCount) -> ptr {
          ptr := mload(FREE_MEMORY_PTR)
          mstore(ptr, bytesCount)
          ptr := add(ptr, BYTES_ARR_LEN_VAR_BS)
          mstore(FREE_MEMORY_PTR, add(ptr, bytesCount))
        }

        function extractBytesFromCalldata(offset, bytesCount) -> extractedBytes {
          let extractedBytesStartPtr := initByteArray(bytesCount)
          calldatacopy(
            extractedBytesStartPtr,
            offset,
            bytesCount
          )
          extractedBytes := sub(extractedBytesStartPtr, BYTES_ARR_LEN_VAR_BS)
        }
      }

      // Validating timestamp
      validateTimestamp(extractedTimestamp);

      // Verifying the off-chain signature against on-chain hashed data
      signerAddress = SignatureLib.recoverSignerAddress(
        signedHash,
        calldataNegativeOffset + SIG_BS
      );
      signerIndex = getAuthorisedSignerIndex(signerAddress);
    }

    // Updating helpful arrays
    {
      bytes32 dataPointDataFeedId;
      uint256 dataPointValue;
      for (uint256 dataPointIndex = 0; dataPointIndex < dataPointsCount; dataPointIndex++) {
        // Extracting data feed id and value for the current data point
        (dataPointDataFeedId, dataPointValue) = _extractDataPointValueAndDataFeedId(
          calldataNegativeOffset,
          eachDataPointValueByteSize,
          dataPointIndex
        );

        for (
          uint256 dataFeedIdIndex = 0;
          dataFeedIdIndex < dataFeedIds.length;
          dataFeedIdIndex++
        ) {
          if (dataPointDataFeedId == dataFeedIds[dataFeedIdIndex]) {
            uint256 bitmapSignersForDataFeedId = signersBitmapForDataFeedIds[dataFeedIdIndex];

            if (
              !BitmapLib.getBitFromBitmap(bitmapSignersForDataFeedId, signerIndex) && /* current signer was not counted for current dataFeedId */
              uniqueSignerCountForDataFeedIds[dataFeedIdIndex] < getUniqueSignersThreshold()
            ) {
              // Increase unique signer counter
              uniqueSignerCountForDataFeedIds[dataFeedIdIndex]++;

              // Add new value
              valuesForDataFeeds[dataFeedIdIndex][
                uniqueSignerCountForDataFeedIds[dataFeedIdIndex] - 1
              ] = dataPointValue;

              // Update signers bitmap
              signersBitmapForDataFeedIds[dataFeedIdIndex] = BitmapLib.setBitInBitmap(
                bitmapSignersForDataFeedId,
                signerIndex
              );
            }

            // Breaking, as there couldn't be several indexes for the same feed ID
            break;
          }
        }
      }
    }

    // Return total data package byte size
    return
      DATA_PACKAGE_WITHOUT_DATA_POINTS_BS +
      (eachDataPointValueByteSize + DATA_POINT_SYMBOL_BS) *
      dataPointsCount;
  }

  /**
   * @dev This is a private helpful function, which aggregates values from different
   * authorised signers for the given arrays of values for each data feed
   *
   * @param valuesForDataFeeds 2-dimensional array, valuesForDataFeeds[i][j] contains
   * j-th value for the i-th data feed
   * @param uniqueSignerCountForDataFeedIds an array with the numbers of unique signers
   * for each data feed
   *
   * @return An array of the aggregated values
   */
  function _getAggregatedValues(
    uint256[][] memory valuesForDataFeeds,
    uint256[] memory uniqueSignerCountForDataFeedIds
  ) private view returns (uint256[] memory) {
    uint256[] memory aggregatedValues = new uint256[](valuesForDataFeeds.length);
    uint256 uniqueSignersThreshold = getUniqueSignersThreshold();

    for (uint256 dataFeedIndex = 0; dataFeedIndex < valuesForDataFeeds.length; dataFeedIndex++) {
      if (uniqueSignerCountForDataFeedIds[dataFeedIndex] < uniqueSignersThreshold) {
        revert InsufficientNumberOfUniqueSigners(
          uniqueSignerCountForDataFeedIds[dataFeedIndex],
          uniqueSignersThreshold);
      }
      uint256 aggregatedValueForDataFeedId = aggregateValues(valuesForDataFeeds[dataFeedIndex]);
      aggregatedValues[dataFeedIndex] = aggregatedValueForDataFeedId;
    }

    return aggregatedValues;
  }
}

File 10 of 26 : RedstoneConsumerNumericBase.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;

import "./RedstoneConsumerBase.sol";

/**
 * @title The base contract for Redstone consumers' contracts that allows to
 * securely calculate numeric redstone oracle values
 * @author The Redstone Oracles team
 * @dev This contract can extend other contracts to allow them
 * securely fetch Redstone oracle data from transactions calldata
 */
abstract contract RedstoneConsumerNumericBase is RedstoneConsumerBase {
  /**
   * @dev This function can be used in a consumer contract to securely extract an
   * oracle value for a given data feed id. Security is achieved by
   * signatures verification, timestamp validation, and aggregating values
   * from different authorised signers into a single numeric value. If any of the
   * required conditions do not match, the function will revert.
   * Note! This function expects that tx calldata contains redstone payload in the end
   * Learn more about redstone payload here: https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/evm-connector#readme
   * @param dataFeedId bytes32 value that uniquely identifies the data feed
   * @return Extracted and verified numeric oracle value for the given data feed id
   */
  function getOracleNumericValueFromTxMsg(bytes32 dataFeedId)
    internal
    view
    virtual
    returns (uint256)
  {
    bytes32[] memory dataFeedIds = new bytes32[](1);
    dataFeedIds[0] = dataFeedId;
    return getOracleNumericValuesFromTxMsg(dataFeedIds)[0];
  }

  /**
   * @dev This function can be used in a consumer contract to securely extract several
   * numeric oracle values for a given array of data feed ids. Security is achieved by
   * signatures verification, timestamp validation, and aggregating values
   * from different authorised signers into a single numeric value. If any of the
   * required conditions do not match, the function will revert.
   * Note! This function expects that tx calldata contains redstone payload in the end
   * Learn more about redstone payload here: https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/evm-connector#readme
   * @param dataFeedIds An array of unique data feed identifiers
   * @return An array of the extracted and verified oracle values in the same order
   * as they are requested in the dataFeedIds array
   */
  function getOracleNumericValuesFromTxMsg(bytes32[] memory dataFeedIds)
    internal
    view
    virtual
    returns (uint256[] memory)
  {
    return _securelyExtractOracleValuesFromTxMsg(dataFeedIds);
  }

  /**
   * @dev This function works similarly to the `getOracleNumericValuesFromTxMsg` with the
   * only difference that it allows to request oracle data for an array of data feeds
   * that may contain duplicates
   * 
   * @param dataFeedIdsWithDuplicates An array of data feed identifiers (duplicates are allowed)
   * @return An array of the extracted and verified oracle values in the same order
   * as they are requested in the dataFeedIdsWithDuplicates array
   */
  function getOracleNumericValuesWithDuplicatesFromTxMsg(bytes32[] memory dataFeedIdsWithDuplicates) internal view returns (uint256[] memory) {
    // Building an array without duplicates
    bytes32[] memory dataFeedIdsWithoutDuplicates = new bytes32[](dataFeedIdsWithDuplicates.length);
    bool alreadyIncluded;
    uint256 uniqueDataFeedIdsCount = 0;

    for (uint256 indexWithDup = 0; indexWithDup < dataFeedIdsWithDuplicates.length; indexWithDup++) {
      // Checking if current element is already included in `dataFeedIdsWithoutDuplicates`
      alreadyIncluded = false;
      for (uint256 indexWithoutDup = 0; indexWithoutDup < uniqueDataFeedIdsCount; indexWithoutDup++) {
        if (dataFeedIdsWithoutDuplicates[indexWithoutDup] == dataFeedIdsWithDuplicates[indexWithDup]) {
          alreadyIncluded = true;
          break;
        }
      }

      // Adding if not included
      if (!alreadyIncluded) {
        dataFeedIdsWithoutDuplicates[uniqueDataFeedIdsCount] = dataFeedIdsWithDuplicates[indexWithDup];
        uniqueDataFeedIdsCount++;
      }
    }

    // Overriding dataFeedIdsWithoutDuplicates.length
    // Equivalent to: dataFeedIdsWithoutDuplicates.length = uniqueDataFeedIdsCount;
    assembly {
      mstore(dataFeedIdsWithoutDuplicates, uniqueDataFeedIdsCount)
    }

    // Requesting oracle values (without duplicates)
    uint256[] memory valuesWithoutDuplicates = getOracleNumericValuesFromTxMsg(dataFeedIdsWithoutDuplicates);

    // Preparing result values array
    uint256[] memory valuesWithDuplicates = new uint256[](dataFeedIdsWithDuplicates.length);
    for (uint256 indexWithDup = 0; indexWithDup < dataFeedIdsWithDuplicates.length; indexWithDup++) {
      for (uint256 indexWithoutDup = 0; indexWithoutDup < dataFeedIdsWithoutDuplicates.length; indexWithoutDup++) {
        if (dataFeedIdsWithDuplicates[indexWithDup] == dataFeedIdsWithoutDuplicates[indexWithoutDup]) {
          valuesWithDuplicates[indexWithDup] = valuesWithoutDuplicates[indexWithoutDup];
          break;
        }
      }
    }

    return valuesWithDuplicates;
  }
}

File 11 of 26 : RedstoneDefaultsLib.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;

import "../libs/NumericArrayLib.sol";

/**
 * @title Default implementations of virtual redstone consumer base functions
 * @author The Redstone Oracles team
 */
library RedstoneDefaultsLib {
  uint256 constant DEFAULT_MAX_DATA_TIMESTAMP_DELAY_SECONDS = 3 minutes;
  uint256 constant DEFAULT_MAX_DATA_TIMESTAMP_AHEAD_SECONDS = 1 minutes;

  error TimestampFromTooLongFuture(uint256 receivedTimestampSeconds, uint256 blockTimestamp);
  error TimestampIsTooOld(uint256 receivedTimestampSeconds, uint256 blockTimestamp);

  function validateTimestamp(uint256 receivedTimestampMilliseconds) internal view {
    // Getting data timestamp from future seems quite unlikely
    // But we've already spent too much time with different cases
    // Where block.timestamp was less than dataPackage.timestamp.
    // Some blockchains may case this problem as well.
    // That's why we add MAX_BLOCK_TIMESTAMP_DELAY
    // and allow data "from future" but with a small delay
    uint256 receivedTimestampSeconds = receivedTimestampMilliseconds / 1000;

    if (block.timestamp < receivedTimestampSeconds) {
      if ((receivedTimestampSeconds - block.timestamp) > DEFAULT_MAX_DATA_TIMESTAMP_AHEAD_SECONDS) {
        revert TimestampFromTooLongFuture(receivedTimestampSeconds, block.timestamp);
      }
    } else if ((block.timestamp - receivedTimestampSeconds) > DEFAULT_MAX_DATA_TIMESTAMP_DELAY_SECONDS) {
      revert TimestampIsTooOld(receivedTimestampSeconds, block.timestamp);
    }
  }

  function aggregateValues(uint256[] memory values) internal pure returns (uint256) {
    return NumericArrayLib.pickMedian(values);
  }
}

File 12 of 26 : BitmapLib.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

library BitmapLib {
  function setBitInBitmap(uint256 bitmap, uint256 bitIndex) internal pure returns (uint256) {
    return bitmap | (1 << bitIndex);
  }

  function getBitFromBitmap(uint256 bitmap, uint256 bitIndex) internal pure returns (bool) {
    uint256 bitAtIndex = bitmap & (1 << bitIndex);
    return bitAtIndex > 0;
  }
}

File 13 of 26 : NumericArrayLib.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/math/SafeMath.sol";

library NumericArrayLib {
  // This function sort array in memory using bubble sort algorithm,
  // which performs even better than quick sort for small arrays

  uint256 constant BYTES_ARR_LEN_VAR_BS = 32;
  uint256 constant UINT256_VALUE_BS = 32;

  error CanNotPickMedianOfEmptyArray();

  // This function modifies the array
  function pickMedian(uint256[] memory arr) internal pure returns (uint256) {
    if (arr.length == 0) {
      revert CanNotPickMedianOfEmptyArray();
    }
    sort(arr);
    uint256 middleIndex = arr.length / 2;
    if (arr.length % 2 == 0) {
      uint256 sum = SafeMath.add(arr[middleIndex - 1], arr[middleIndex]);
      return sum / 2;
    } else {
      return arr[middleIndex];
    }
  }

  function sort(uint256[] memory arr) internal pure {
    assembly {
      let arrLength := mload(arr)
      let valuesPtr := add(arr, BYTES_ARR_LEN_VAR_BS)
      let endPtr := add(valuesPtr, mul(arrLength, UINT256_VALUE_BS))
      for {
        let arrIPtr := valuesPtr
      } lt(arrIPtr, endPtr) {
        arrIPtr := add(arrIPtr, UINT256_VALUE_BS) // arrIPtr += 32
      } {
        for {
          let arrJPtr := valuesPtr
        } lt(arrJPtr, arrIPtr) {
          arrJPtr := add(arrJPtr, UINT256_VALUE_BS) // arrJPtr += 32
        } {
          let arrI := mload(arrIPtr)
          let arrJ := mload(arrJPtr)
          if lt(arrI, arrJ) {
            mstore(arrIPtr, arrJ)
            mstore(arrJPtr, arrI)
          }
        }
      }
    }
  }
}

File 14 of 26 : SignatureLib.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

library SignatureLib {
  uint256 constant ECDSA_SIG_R_BS = 32;
  uint256 constant ECDSA_SIG_S_BS = 32;

  function recoverSignerAddress(bytes32 signedHash, uint256 signatureCalldataNegativeOffset)
    internal
    pure
    returns (address)
  {
    bytes32 r;
    bytes32 s;
    uint8 v;
    assembly {
      let signatureCalldataStartPos := sub(calldatasize(), signatureCalldataNegativeOffset)
      r := calldataload(signatureCalldataStartPos)
      signatureCalldataStartPos := add(signatureCalldataStartPos, ECDSA_SIG_R_BS)
      s := calldataload(signatureCalldataStartPos)
      signatureCalldataStartPos := add(signatureCalldataStartPos, ECDSA_SIG_S_BS)
      v := byte(0, calldataload(signatureCalldataStartPos)) // last byte of the signature memory array
    }
    return ecrecover(signedHash, v, r, s);
  }
}

File 15 of 26 : IRedstoneAdapter.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.14;

/**
 * @title Interface of RedStone adapter
 * @author The Redstone Oracles team
 */
interface IRedstoneAdapter {

  /**
   * @notice Updates values of all data feeds supported by the Adapter contract
   * @dev This function requires an attached redstone payload to the transaction calldata.
   * It also requires each data package to have exactly the same timestamp
   * @param dataPackagesTimestamp Timestamp of each signed data package in the redstone payload
   */
  function updateDataFeedsValues(uint256 dataPackagesTimestamp) external;


  /**
   * @notice Returns the latest properly reported value of the data feed
   * @param dataFeedId The identifier of the requested data feed
   * @return value The latest value of the given data feed
   */
  function getValueForDataFeed(bytes32 dataFeedId) external view returns (uint256);

  /**
   * @notice Returns the latest properly reported values for several data feeds
   * @param requestedDataFeedIds The array of identifiers for the requested feeds
   * @return values Values of the requested data feeds in the corresponding order
   */
  function getValuesForDataFeeds(bytes32[] memory requestedDataFeedIds) external view returns (uint256[] memory);

  /**
   * @notice Returns data timestamp from the latest update
   * @dev It's virtual, because its implementation can sometimes be different
   * (e.g. SinglePriceFeedAdapterWithClearing)
   * @return lastDataTimestamp Timestamp of the latest reported data packages
   */
  function getDataTimestampFromLatestUpdate() external view returns (uint256 lastDataTimestamp);

  /**
   * @notice Returns block timestamp of the latest successful update
   * @return blockTimestamp The block timestamp of the latest successful update
   */
  function getBlockTimestampFromLatestUpdate() external view returns (uint256 blockTimestamp);


  /**
   * @notice Returns timestamps of the latest successful update
   * @return dataTimestamp timestamp (usually in milliseconds) from the signed data packages
   * @return blockTimestamp timestamp of the block when the update has happened
   */
  function getTimestampsFromLatestUpdate() external view returns (uint128 dataTimestamp, uint128 blockTimestamp);

  /**
   * @notice Returns identifiers of all data feeds supported by the Adapter contract
   * @return An array of data feed identifiers
   */
  function getDataFeedIds() external view returns (bytes32[] memory);

  /**
   * @notice Returns the unique index of the given data feed
   * @param dataFeedId The data feed identifier
   * @return index The index of the data feed
   */
  function getDataFeedIndex(bytes32 dataFeedId) external view returns (uint256);

  /**
   * @notice Returns minimal required interval (usually in seconds) between subsequent updates
   * @return interval The required interval between updates
   */
  function getMinIntervalBetweenUpdates() external view returns (uint256);

  /**
   * @notice Reverts if the proposed timestamp of data packages it too old or too new
   * comparing to the block.timestamp. It also ensures that the proposed timestamp is newer
   * Then the one from the previous update
   * @param dataPackagesTimestamp The proposed timestamp (usually in milliseconds)
   */
  function validateProposedDataPackagesTimestamp(uint256 dataPackagesTimestamp) external view;

  /**
   * @notice Reverts if the updater is not authorised
   * @dev This function should revert if msg.sender is not allowed to update data feed values
   * @param updater The address of the proposed updater
   */
  function requireAuthorisedUpdater(address updater) external view;
}

File 16 of 26 : RedstoneAdapterBase.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.14;

import {RedstoneConsumerNumericBase, RedstoneDefaultsLib} from "@redstone-finance/evm-connector/contracts/core/RedstoneConsumerNumericBase.sol";
import {IRedstoneAdapter} from "./IRedstoneAdapter.sol";

/**
 * @title Core logic of Redstone Adapter Contract
 * @author The Redstone Oracles team
 * @dev This contract is used to repeatedly push Redstone data to blockchain storage
 * More details here: https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-classic
 *
 * Key details about the contract:
 * - Values for data feeds can be updated using the `updateDataFeedsValues` function
 * - All data feeds must be updated within a single call, partial updates are not allowed
 * - There is a configurable minimum interval between updates
 * - Updaters can be restricted by overriding `requireAuthorisedUpdater` function
 * - The contract is designed to force values validation, by default it prevents returning zero values
 * - All data packages in redstone payload must have the same timestamp,
 *    equal to `dataPackagesTimestamp` argument of the `updateDataFeedsValues` function
 * - Block timestamp abstraction - even though we call it blockTimestamp in many places,
 *    it's possible to have a custom logic here, e.g. use block number instead of a timestamp
 */
abstract contract RedstoneAdapterBase is RedstoneConsumerNumericBase, IRedstoneAdapter {
  // We don't use storage variables to avoid potential problems with upgradable contracts
  bytes32 internal constant LATEST_UPDATE_TIMESTAMPS_STORAGE_LOCATION = 0x3d01e4d77237ea0f771f1786da4d4ff757fcba6a92933aa53b1dcef2d6bd6fe2; // keccak256("RedStone.lastUpdateTimestamp");
  uint256 internal constant MIN_INTERVAL_BETWEEN_UPDATES = 3 seconds;
  uint256 internal constant BITS_COUNT_IN_16_BYTES = 128;
  uint256 internal constant MAX_NUMBER_FOR_128_BITS = 0x00000000000000000000000000000000ffffffffffffffffffffffffffffffff;

  error DataTimestampShouldBeNewerThanBefore(
    uint256 receivedDataTimestampMilliseconds,
    uint256 lastDataTimestampMilliseconds
  );

  error MinIntervalBetweenUpdatesHasNotPassedYet(
    uint256 currentBlockTimestamp,
    uint256 lastUpdateTimestamp,
    uint256 minIntervalBetweenUpdates
  );

  error DataPackageTimestampMismatch(uint256 expectedDataTimestamp, uint256 dataPackageTimestamp);

  error DataFeedValueCannotBeZero(bytes32 dataFeedId);

  error DataFeedIdNotFound(bytes32 dataFeedId);

  error DataTimestampIsTooBig(uint256 dataTimestamp);

  error BlockTimestampIsTooBig(uint256 blockTimestamp);

  /**
   * @notice Reverts if the updater is not authorised
   * @dev This function should revert if msg.sender is not allowed to update data feed values
   * @param updater The address of the proposed updater
   */
  function requireAuthorisedUpdater(address updater) public view virtual {
    // By default, anyone can update data feed values, but it can be overridden
  }

  /**
   * @notice Returns identifiers of all data feeds supported by the Adapter contract
   * @dev this function must be implemented in derived contracts
   * @return An array of data feed identifiers
   */
  function getDataFeedIds() public view virtual returns (bytes32[] memory);

  /**
   * @notice Returns the unique index of the given data feed
   * @dev This function can (and should) be overriden to reduce gas
   * costs of other functions
   * @param dataFeedId The data feed identifier
   * @return index The index of the data feed
   */
  function getDataFeedIndex(bytes32 dataFeedId) public view virtual returns (uint256) {
    bytes32[] memory dataFeedIds = getDataFeedIds();
    for (uint256 i = 0; i < dataFeedIds.length;) {
      if (dataFeedIds[i] == dataFeedId) {
        return i;
      }
      unchecked { i++; } // reduces gas costs
    }
    revert DataFeedIdNotFound(dataFeedId);
  }

  /**
   * @notice Updates values of all data feeds supported by the Adapter contract
   * @dev This function requires an attached redstone payload to the transaction calldata.
   * It also requires each data package to have exactly the same timestamp
   * @param dataPackagesTimestamp Timestamp of each signed data package in the redstone payload
   */
  function updateDataFeedsValues(uint256 dataPackagesTimestamp) public {
    requireAuthorisedUpdater(msg.sender);
    _assertMinIntervalBetweenUpdatesPassed();
    validateProposedDataPackagesTimestamp(dataPackagesTimestamp);
    _saveTimestampsOfCurrentUpdate(dataPackagesTimestamp);

    bytes32[] memory dataFeedsIdsArray = getDataFeedIds();

    // It will trigger timestamp validation for each data package
    uint256[] memory oracleValues = getOracleNumericValuesFromTxMsg(dataFeedsIdsArray);

    _validateAndUpdateDataFeedsValues(dataFeedsIdsArray, oracleValues);
  }

  /**
   * @dev Note! This function is not called directly, it's called for each data package    .
   * in redstone payload and just verifies if each data package has the same timestamp
   * as the one that was saved in the storage
   * @param receivedTimestampMilliseconds Timestamp from a data package
   */
  function validateTimestamp(uint256 receivedTimestampMilliseconds) public view virtual override {
    // It means that we are in the special view context and we can skip validation of the
    // timestamp. It can be useful for calling view functions, as they can not modify the contract
    // state to pass the timestamp validation below
    if (msg.sender == address(0)) {
      return;
    }

    uint256 expectedDataPackageTimestamp = getDataTimestampFromLatestUpdate();
    if (receivedTimestampMilliseconds != expectedDataPackageTimestamp) {
      revert DataPackageTimestampMismatch(
        expectedDataPackageTimestamp,
        receivedTimestampMilliseconds
      );
    }
  }

  /**
   * @dev This function should be implemented by the actual contract
   * and should contain the logic of values validation and reporting.
   * Usually, values reporting is based on saving them to the contract storage,
   * e.g. in PriceFeedsAdapter, but some custom implementations (e.g. GMX keeper adapter
   * or Mento Sorted Oracles adapter) may handle values updating in a different way
   * @param dataFeedIdsArray Array of the data feeds identifiers (it will always be all data feed ids)
   * @param values The reported values that should be validated and reported
   */
  function _validateAndUpdateDataFeedsValues(bytes32[] memory dataFeedIdsArray, uint256[] memory values) internal virtual;

  /**
   * @dev This function reverts if not enough time passed since the latest update
   */
  function _assertMinIntervalBetweenUpdatesPassed() private view {
    uint256 currentBlockTimestamp = getBlockTimestamp();
    uint256 blockTimestampFromLatestUpdate = getBlockTimestampFromLatestUpdate();
    uint256 minIntervalBetweenUpdates = getMinIntervalBetweenUpdates();
    if (currentBlockTimestamp < blockTimestampFromLatestUpdate + minIntervalBetweenUpdates) {
      revert MinIntervalBetweenUpdatesHasNotPassedYet(
        currentBlockTimestamp,
        blockTimestampFromLatestUpdate,
        minIntervalBetweenUpdates
      );
    }
  }

  /**
   * @notice Returns minimal required interval (usually in seconds) between subsequent updates
   * @dev You can override this function to change the required interval between udpates.
   * Please do not set it to 0, as it may open many attack vectors
   * @return interval The required interval between updates
   */
  function getMinIntervalBetweenUpdates() public view virtual returns (uint256) {
    return MIN_INTERVAL_BETWEEN_UPDATES;
  }

  /**
   * @notice Reverts if the proposed timestamp of data packages it too old or too new
   * comparing to the block.timestamp. It also ensures that the proposed timestamp is newer
   * Then the one from the previous update
   * @param dataPackagesTimestamp The proposed timestamp (usually in milliseconds)
   */
  function validateProposedDataPackagesTimestamp(uint256 dataPackagesTimestamp) public view {
    _preventUpdateWithOlderDataPackages(dataPackagesTimestamp);
    validateDataPackagesTimestampOnce(dataPackagesTimestamp);
  }


  /**
   * @notice Reverts if the proposed timestamp of data packages it too old or too new
   * comparing to the current block timestamp
   * @param dataPackagesTimestamp The proposed timestamp (usually in milliseconds)
   */
  function validateDataPackagesTimestampOnce(uint256 dataPackagesTimestamp) public view virtual {
    uint256 receivedTimestampSeconds = dataPackagesTimestamp / 1000;

    (uint256 maxDataAheadSeconds, uint256 maxDataDelaySeconds) = getAllowedTimestampDiffsInSeconds();

    uint256 blockTimestamp = getBlockTimestamp();

    if (blockTimestamp < receivedTimestampSeconds) {
      if ((receivedTimestampSeconds - blockTimestamp) > maxDataAheadSeconds) {
        revert RedstoneDefaultsLib.TimestampFromTooLongFuture(receivedTimestampSeconds, blockTimestamp);
      }
    } else if ((blockTimestamp - receivedTimestampSeconds) > maxDataDelaySeconds) {
      revert RedstoneDefaultsLib.TimestampIsTooOld(receivedTimestampSeconds, blockTimestamp);
    }
  }

  /**
   * @dev This function can be overriden, e.g. to use block.number instead of block.timestamp
   * It can be useful in some L2 chains, as sometimes their different blocks can have the same timestamp
   * @return timestamp Timestamp or Block number or any other number that can identify time in the context
   * of the given blockchain
   */
  function getBlockTimestamp() public view virtual returns (uint256) {
    return block.timestamp;
  }

  /**
   * @dev Helpful function for getting values for timestamp validation
   * @return  maxDataAheadSeconds Max allowed number of seconds ahead of block.timrstamp
   * @return  maxDataDelaySeconds Max allowed number of seconds for data delay
   */
  function getAllowedTimestampDiffsInSeconds() public view virtual returns (uint256 maxDataAheadSeconds, uint256 maxDataDelaySeconds) {
    maxDataAheadSeconds = RedstoneDefaultsLib.DEFAULT_MAX_DATA_TIMESTAMP_AHEAD_SECONDS;
    maxDataDelaySeconds = RedstoneDefaultsLib.DEFAULT_MAX_DATA_TIMESTAMP_DELAY_SECONDS;
  }

  /**
   * @dev Reverts if proposed data packages are not newer than the ones used previously
   * @param dataPackagesTimestamp Timestamp od the data packages (usually in milliseconds)
   */
  function _preventUpdateWithOlderDataPackages(uint256 dataPackagesTimestamp) internal view {
    uint256 dataTimestampFromLatestUpdate = getDataTimestampFromLatestUpdate();

    if (dataPackagesTimestamp <= dataTimestampFromLatestUpdate) {
      revert DataTimestampShouldBeNewerThanBefore(
        dataPackagesTimestamp,
        dataTimestampFromLatestUpdate
      );
    }
  }

  /**
   * @notice Returns data timestamp from the latest update
   * @dev It's virtual, because its implementation can sometimes be different
   * (e.g. SinglePriceFeedAdapterWithClearing)
   * @return lastDataTimestamp Timestamp of the latest reported data packages
   */
  function getDataTimestampFromLatestUpdate() public view virtual returns (uint256 lastDataTimestamp) {
    (lastDataTimestamp, ) = getTimestampsFromLatestUpdate();
  }

  /**
   * @notice Returns block timestamp of the latest successful update
   * @return blockTimestamp The block timestamp of the latest successful update
   */
  function getBlockTimestampFromLatestUpdate() public view returns (uint256 blockTimestamp) {
    (, blockTimestamp) = getTimestampsFromLatestUpdate();
  }

  /**
   * @dev Returns 2 timestamps packed into a single uint256 number
   * @return packedTimestamps a single uin256 number with 2 timestamps
   */
  function getPackedTimestampsFromLatestUpdate() public view returns (uint256 packedTimestamps) {
    assembly {
      packedTimestamps := sload(LATEST_UPDATE_TIMESTAMPS_STORAGE_LOCATION)
    }
  }

  /**
   * @notice Returns timestamps of the latest successful update
   * @return dataTimestamp timestamp (usually in milliseconds) from the signed data packages
   * @return blockTimestamp timestamp of the block when the update has happened
   */
  function getTimestampsFromLatestUpdate() public view virtual returns (uint128 dataTimestamp, uint128 blockTimestamp) {
    return _unpackTimestamps(getPackedTimestampsFromLatestUpdate());
  }


  /**
   * @dev A helpful function to unpack 2 timestamps from one uin256 number
   * @param packedTimestamps a single uin256 number
   * @return dataTimestamp fetched from left 128 bits
   * @return blockTimestamp fetched from right 128 bits
   */
  function _unpackTimestamps(uint256 packedTimestamps) internal pure returns (uint128 dataTimestamp, uint128 blockTimestamp) {
    dataTimestamp = uint128(packedTimestamps >> 128); // left 128 bits
    blockTimestamp = uint128(packedTimestamps); // right 128 bits
  }


  /**
   * @dev Logic of saving timestamps of the current update
   * By default, it stores packed timestamps in one storage slot (32 bytes)
   * to minimise gas costs
   * But it can be overriden (e.g. in SinglePriceFeedAdapter)
   * @param   dataPackagesTimestamp  .
   */
  function _saveTimestampsOfCurrentUpdate(uint256 dataPackagesTimestamp) internal virtual {
    uint256 blockTimestamp = getBlockTimestamp();

    if (blockTimestamp > MAX_NUMBER_FOR_128_BITS) {
      revert BlockTimestampIsTooBig(blockTimestamp);
    }

    if (dataPackagesTimestamp > MAX_NUMBER_FOR_128_BITS) {
      revert DataTimestampIsTooBig(dataPackagesTimestamp);
    }

    assembly {
      let timestamps := or(shl(BITS_COUNT_IN_16_BYTES, dataPackagesTimestamp), blockTimestamp)
      sstore(LATEST_UPDATE_TIMESTAMPS_STORAGE_LOCATION, timestamps)
    }
  }

  /**
   * @notice Returns the latest properly reported value of the data feed
   * @param dataFeedId The identifier of the requested data feed
   * @return value The latest value of the given data feed
   */
  function getValueForDataFeed(bytes32 dataFeedId) public view returns (uint256) {
    getDataFeedIndex(dataFeedId); // will revert if data feed id is not supported

    // "unsafe" here means "without validation"
    uint256 valueForDataFeed = getValueForDataFeedUnsafe(dataFeedId);

    validateDataFeedValue(dataFeedId, valueForDataFeed);
    return valueForDataFeed;
  }

  /**
   * @notice Returns the latest properly reported values for several data feeds
   * @param dataFeedIds The array of identifiers for the requested feeds
   * @return values Values of the requested data feeds in the corresponding order
   */
  function getValuesForDataFeeds(bytes32[] memory dataFeedIds) public view returns (uint256[] memory) {
    uint256[] memory values = getValuesForDataFeedsUnsafe(dataFeedIds);
    for (uint256 i = 0; i < dataFeedIds.length;) {
      bytes32 dataFeedId = dataFeedIds[i];
      getDataFeedIndex(dataFeedId); // will revert if data feed id is not supported
      validateDataFeedValue(dataFeedId, values[i]);
      unchecked { i++; } // reduces gas costs
    }
    return values;
  }


  /**
   * @dev Reverts if proposed value for the proposed data feed id is invalid
   * By default, it just checks if the value is not equal to 0, but it can be extended
   * @param dataFeedId The data feed identifier
   * @param valueForDataFeed Proposed value for the data feed
   */
  function validateDataFeedValue(bytes32 dataFeedId, uint256 valueForDataFeed) public pure virtual {
    if (valueForDataFeed == 0) {
      revert DataFeedValueCannotBeZero(dataFeedId);
    }
  }

  /**
   * @dev [HIGH RISK] Returns the latest value for a given data feed without validation
   * Important! Using this function instead of `getValueForDataFeed` may cause
   * significant risk for your smart contracts
   * @param dataFeedId The data feed identifier
   * @return dataFeedValue Unvalidated value of the latest successful update
   */
  function getValueForDataFeedUnsafe(bytes32 dataFeedId) public view virtual returns (uint256);

  /**
   * @notice [HIGH RISK] Returns the latest properly reported values for several data feeds without validation
   * Important! Using this function instead of `getValuesForDataFeeds` may cause
   * significant risk for your smart contracts
   * @param requestedDataFeedIds The array of identifiers for the requested feeds
   * @return values Unvalidated values of the requested data feeds in the corresponding order
   */
  function getValuesForDataFeedsUnsafe(bytes32[] memory requestedDataFeedIds) public view virtual returns (uint256[] memory values) {
    values = new uint256[](requestedDataFeedIds.length);
    for (uint256 i = 0; i < requestedDataFeedIds.length;) {
      values[i] = getValueForDataFeedUnsafe(requestedDataFeedIds[i]);
      unchecked { i++; } // reduces gas costs
    }
    return values;
  }
}

File 17 of 26 : MergedPriceFeedAdapterWithoutRoundsPrimaryProd.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.14;

import {MergedPriceFeedAdapterWithoutRounds} from "../without-rounds/MergedPriceFeedAdapterWithoutRounds.sol";

abstract contract MergedPriceFeedAdapterWithoutRoundsPrimaryProd is MergedPriceFeedAdapterWithoutRounds {
  function getUniqueSignersThreshold() public view virtual override returns (uint8) {
    return 2;
  }

  function getAuthorisedSignerIndex(
    address signerAddress
  ) public view virtual override returns (uint8) {
    if (signerAddress == 0x8BB8F32Df04c8b654987DAaeD53D6B6091e3B774) { return 0; }
    else if (signerAddress == 0xdEB22f54738d54976C4c0fe5ce6d408E40d88499) { return 1; }
    else if (signerAddress == 0x51Ce04Be4b3E32572C4Ec9135221d0691Ba7d202) { return 2; }
    else if (signerAddress == 0xDD682daEC5A90dD295d14DA4b0bec9281017b5bE) { return 3; }
    else if (signerAddress == 0x9c5AE89C4Af6aA32cE58588DBaF90d18a855B6de) { return 4; }
    else {
      revert SignerNotAuthorised(signerAddress);
    }
  }
}

File 18 of 26 : IPriceFeed.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.14;

import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import {IPriceFeedLegacy} from "./IPriceFeedLegacy.sol";

/**
 * @title Complete price feed interface
 * @author The Redstone Oracles team
 * @dev All required public functions that must be implemented
 * by each Redstone PriceFeed contract
 */
interface IPriceFeed is IPriceFeedLegacy, AggregatorV3Interface {
  /**
   * @notice Returns data feed identifier for the PriceFeed contract
   * @return dataFeedId The identifier of the data feed
   */
  function getDataFeedId() external view returns (bytes32);
}

File 19 of 26 : IPriceFeedLegacy.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.14;

/**
 * @title Interface with the old Chainlink Price Feed functions
 * @author The Redstone Oracles team
 * @dev There are some projects (e.g. gmx-contracts) that still
 * rely on some legacy functions
 */
interface IPriceFeedLegacy {
  /**
   * @notice Old Chainlink function for getting the number of latest round
   * @return latestRound The number of the latest update round
   */
  function latestRound() external view returns (uint80);

  
  /**
   * @notice Old Chainlink function for getting the latest successfully reported value
   * @return latestAnswer The latest successfully reported value
   */
  function latestAnswer() external view returns (int256);
}

File 20 of 26 : MergedPriceFeedAdapterCommon.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.14;
import {IRedstoneAdapter} from "../core/IRedstoneAdapter.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

abstract contract MergedPriceFeedAdapterCommon {
  event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);

  error CannotUpdateMoreThanOneDataFeed();

  function getPriceFeedAdapter() public view virtual returns (IRedstoneAdapter) {
    return IRedstoneAdapter(address(this));
  }

  function aggregator() public view virtual returns (address) {
    return address(getPriceFeedAdapter());
  }
}

File 21 of 26 : PriceFeedBase.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.14;

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {IRedstoneAdapter} from "../core/IRedstoneAdapter.sol";
import {IPriceFeed} from "./interfaces/IPriceFeed.sol";

/**
 * @title Main logic of the price feed contract
 * @author The Redstone Oracles team
 * @dev Implementation of common functions for the PriceFeed contract
 * that queries data from the specified PriceFeedAdapter
 * 
 * It can be used by projects that have already implemented with Chainlink-like
 * price feeds and would like to minimise changes in their existing codebase.
 * 
 * If you are flexible, it's much better (and cheaper in terms of gas) to query
 * the PriceFeedAdapter contract directly
 */
abstract contract PriceFeedBase is IPriceFeed, Initializable {
  uint256 internal constant INT256_MAX = uint256(type(int256).max);

  error UnsafeUintToIntConversion(uint256 value);

  /**
   * @dev Helpful function for upgradable contracts
   */
  function initialize() public virtual initializer {
    // We don't have storage variables, but we keep this function
    // Because it is used for contract setup in upgradable contracts
  }

  /**
   * @notice Returns data feed identifier for the PriceFeed contract
   * @return dataFeedId The identifier of the data feed
   */
  function getDataFeedId() public view virtual returns (bytes32);

  /**
   * @notice Returns the address of the price feed adapter
   * @return address The address of the price feed adapter
   */
  function getPriceFeedAdapter() public view virtual returns (IRedstoneAdapter);


  /**
   * @notice Returns the number of decimals for the price feed
   * @dev By default, RedStone uses 8 decimals for data feeds
   * @return decimals The number of decimals in the price feed values
   */
  function decimals() public virtual pure override returns (uint8) {
    return 8;
  }


  /**
   * @notice Description of the Price Feed
   * @return description
   */
  function description() public view virtual override returns (string memory) {
    return "Redstone Price Feed";
  }

  /**
   * @notice Version of the Price Feed
   * @dev Currently it has no specific motivation and was added
   * only to be compatible with the Chainlink interface
   * @return version
   */
  function version() public virtual pure override returns (uint256) {
    return 1;
  }


  /**
   * @notice Returns details of the latest successful update round
   * @dev It uses few helpful functions to abstract logic of getting
   * latest round id and value
   * @return roundId The number of the latest round
   * @return answer The latest reported value
   * @return startedAt Block timestamp when the latest successful round started
   * @return updatedAt Block timestamp of the latest successful round
   * @return answeredInRound The number of the latest round
   */
  function latestRoundData()
    public
    view
    override
    virtual
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    )
  {
    roundId = latestRound();
    answer = latestAnswer();

    uint256 blockTimestamp = getPriceFeedAdapter().getBlockTimestampFromLatestUpdate();

    // These values are equal after chainlink’s OCR update
    startedAt = blockTimestamp;
    updatedAt = blockTimestamp;

    // We want to be compatible with Chainlink's interface
    // And in our case the roundId is always equal to answeredInRound
    answeredInRound = roundId;
  }

  /**
   * @notice Old Chainlink function for getting the latest successfully reported value
   * @return latestAnswer The latest successfully reported value
   */
  function latestAnswer() public virtual view returns (int256) {
    bytes32 dataFeedId = getDataFeedId();

    uint256 uintAnswer = getPriceFeedAdapter().getValueForDataFeed(dataFeedId);

    if (uintAnswer > INT256_MAX) {
      revert UnsafeUintToIntConversion(uintAnswer);
    }

    return int256(uintAnswer);
  }

  /**
   * @notice Old Chainlink function for getting the number of latest round
   * @return latestRound The number of the latest update round
   */
  function latestRound() public view virtual returns (uint80);
}

File 22 of 26 : PriceFeedsAdapterBase.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.14;

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {RedstoneAdapterBase} from "../core/RedstoneAdapterBase.sol";

/**
 * @title Common logic of the price feeds adapter contracts
 * @author The Redstone Oracles team
 */
abstract contract PriceFeedsAdapterBase is RedstoneAdapterBase, Initializable {

  /**
   * @dev Helpful function for upgradable contracts
   */
  function initialize() public virtual initializer {
    // We don't have storage variables, but we keep this function
    // Because it is used for contract setup in upgradable contracts
  }

  /**
   * @dev This function is virtual and may contain additional logic in the derived contract
   * E.g. it can check if the updating conditions are met (e.g. if at least one
   * value is deviated enough)
   * @param dataFeedIdsArray Array of all data feeds identifiers
   * @param values The reported values that are validated and reported
   */
  function _validateAndUpdateDataFeedsValues(
    bytes32[] memory dataFeedIdsArray,
    uint256[] memory values
  ) internal virtual override {
    for (uint256 i = 0; i < dataFeedIdsArray.length;) {
      _validateAndUpdateDataFeedValue(dataFeedIdsArray[i], values[i]);
      unchecked { i++; } // reduces gas costs
    }
  }

  /**
   * @dev Helpful virtual function for handling value validation and saving in derived
   * Price Feed Adapters contracts 
   * @param dataFeedId The data feed identifier
   * @param dataFeedValue Proposed value for the data feed
   */
  function _validateAndUpdateDataFeedValue(bytes32 dataFeedId, uint256 dataFeedValue) internal virtual;
}

File 23 of 26 : MergedPriceFeedAdapterWithoutRounds.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.14;

import {PriceFeedsAdapterBase, PriceFeedsAdapterWithoutRounds} from "./PriceFeedsAdapterWithoutRounds.sol";
import {PriceFeedBase, PriceFeedWithoutRounds} from "./PriceFeedWithoutRounds.sol";
import {IRedstoneAdapter} from "../../core/IRedstoneAdapter.sol";
import {MergedPriceFeedAdapterCommon} from "../MergedPriceFeedAdapterCommon.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

abstract contract MergedPriceFeedAdapterWithoutRounds is
  MergedPriceFeedAdapterCommon,
  PriceFeedsAdapterWithoutRounds,
  PriceFeedWithoutRounds
{

  function initialize() public override(PriceFeedBase, PriceFeedsAdapterBase) initializer {
    // We don't have storage variables, but we keep this function
    // Because it is used for contract setup in upgradable contracts
  }

  function getPriceFeedAdapter() public view virtual override(MergedPriceFeedAdapterCommon, PriceFeedBase) returns (IRedstoneAdapter) {
    return super.getPriceFeedAdapter();
  }

  function getDataFeedIds() public view virtual override returns (bytes32[] memory dataFeedIds) {
    dataFeedIds = new bytes32[](1);
    dataFeedIds[0] = getDataFeedId();
  }

  function getDataFeedIndex(bytes32 dataFeedId) public view virtual override returns (uint256) {
    if (dataFeedId == getDataFeedId()) {
      return 0;
    } else {
      revert DataFeedIdNotFound(dataFeedId);
    }
  }

  function _emitEventAfterSingleValueUpdate(uint256 newValue) internal virtual {
    emit AnswerUpdated(SafeCast.toInt256(newValue), latestRound(), block.timestamp);
  }

  function _validateAndUpdateDataFeedsValues(
    bytes32[] memory dataFeedIdsArray,
    uint256[] memory values
  ) internal virtual override {
    if (dataFeedIdsArray.length != 1 || values.length != 1) {
      revert CannotUpdateMoreThanOneDataFeed();
    }
    _validateAndUpdateDataFeedValue(dataFeedIdsArray[0], values[0]);
    _emitEventAfterSingleValueUpdate(values[0]);
  }
}

File 24 of 26 : PriceFeedsAdapterWithoutRounds.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.14;

import {PriceFeedsAdapterBase} from "../PriceFeedsAdapterBase.sol";

/**
 * @title Implementation of a price feeds adapter without rounds support
 * @author The Redstone Oracles team
 * @dev This contract is abstract, the following functions should be
 * implemented in the actual contract before deployment:
 * - getDataFeedIds
 * - getUniqueSignersThreshold
 * - getAuthorisedSignerIndex
 * 
 * We also recommend to override `getDataFeedIndex` function with hardcoded
 * values, as it can significantly reduce gas usage
 */
abstract contract PriceFeedsAdapterWithoutRounds is PriceFeedsAdapterBase {
  bytes32 constant VALUES_MAPPING_STORAGE_LOCATION = 0x4dd0c77efa6f6d590c97573d8c70b714546e7311202ff7c11c484cc841d91bfc; // keccak256("RedStone.oracleValuesMapping");

  /**
   * @dev Helpful virtual function for handling value validation and saving
   * @param dataFeedId The data feed identifier
   * @param dataFeedValue Proposed value for the data feed
   */
  function _validateAndUpdateDataFeedValue(bytes32 dataFeedId, uint256 dataFeedValue) internal override virtual {
    validateDataFeedValue(dataFeedId, dataFeedValue);
    bytes32 locationInStorage = _getValueLocationInStorage(dataFeedId);
    assembly {
      sstore(locationInStorage, dataFeedValue)
    }
  }

  /**
   * @dev [HIGH RISK] Returns the latest value for a given data feed without validation
   * Important! Using this function instead of `getValueForDataFeed` may cause
   * significant risk for your smart contracts
   * @param dataFeedId The data feed identifier
   * @return dataFeedValue Unvalidated value of the latest successful update
   */
  function getValueForDataFeedUnsafe(bytes32 dataFeedId) public view  virtual override returns (uint256 dataFeedValue) {
    bytes32 locationInStorage = _getValueLocationInStorage(dataFeedId);
    assembly {
      dataFeedValue := sload(locationInStorage)
    }
  }

  /**
   * @dev Helpful function for getting storage location for the requested data feed
   * @param dataFeedId Requested data feed identifier
   * @return locationInStorage
   */
  function _getValueLocationInStorage(bytes32 dataFeedId) private pure returns (bytes32) {
    return keccak256(abi.encode(dataFeedId, VALUES_MAPPING_STORAGE_LOCATION));
  }
}

File 25 of 26 : PriceFeedWithoutRounds.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.14;

import {PriceFeedBase} from "../PriceFeedBase.sol";

/**
 * @title Implementation of a price feed contract without rounds support
 * @author The Redstone Oracles team
 * @dev This contract is abstract. The actual contract instance
 * must implement the following functions:
 * - getDataFeedId
 * - getPriceFeedAdapter
 */
abstract contract PriceFeedWithoutRounds is PriceFeedBase {
  uint80 constant DEFAULT_ROUND = 1;

  error GetRoundDataCanBeOnlyCalledWithLatestRound(uint80 requestedRoundId);

  /**
   * @dev We always return 1, since we do not support rounds in this contract
   */
  function latestRound() public pure override returns (uint80) {
    return DEFAULT_ROUND;
  }
  
  /**
   * @dev There are possible use cases that some contracts don't need values from old rounds
   * but still rely on `getRoundData` or `latestRounud` functions
   */
  function getRoundData(uint80 requestedRoundId) public view override returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) {
    if (requestedRoundId != latestRound()) {
      revert GetRoundDataCanBeOnlyCalledWithLatestRound(requestedRoundId);
    }
    return latestRoundData();
  }
}

File 26 of 26 : Addresses.sol
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.4;

library OldGelatoAddress {
  address constant public ADDR = 0xc4D1AE5E796E6d7561cdc8335F85e6B57a36e097;
}

library GelatoAddress {
  address constant public ADDR = 0xCD6BfDA4D95d5C0f3f2882dC221D792392c99714;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"blockTimestamp","type":"uint256"}],"name":"BlockTimestampIsTooBig","type":"error"},{"inputs":[],"name":"CalldataMustHaveValidPayload","type":"error"},{"inputs":[],"name":"CalldataOverOrUnderFlow","type":"error"},{"inputs":[],"name":"CanNotPickMedianOfEmptyArray","type":"error"},{"inputs":[],"name":"CannotUpdateMoreThanOneDataFeed","type":"error"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"DataFeedIdNotFound","type":"error"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"DataFeedValueCannotBeZero","type":"error"},{"inputs":[{"internalType":"uint256","name":"expectedDataTimestamp","type":"uint256"},{"internalType":"uint256","name":"dataPackageTimestamp","type":"uint256"}],"name":"DataPackageTimestampMismatch","type":"error"},{"inputs":[],"name":"DataPackageTimestampMustNotBeZero","type":"error"},{"inputs":[],"name":"DataPackageTimestampsMustBeEqual","type":"error"},{"inputs":[{"internalType":"uint256","name":"dataTimestamp","type":"uint256"}],"name":"DataTimestampIsTooBig","type":"error"},{"inputs":[{"internalType":"uint256","name":"receivedDataTimestampMilliseconds","type":"uint256"},{"internalType":"uint256","name":"lastDataTimestampMilliseconds","type":"uint256"}],"name":"DataTimestampShouldBeNewerThanBefore","type":"error"},{"inputs":[],"name":"EachSignerMustProvideTheSameValue","type":"error"},{"inputs":[],"name":"EmptyCalldataPointersArr","type":"error"},{"inputs":[],"name":"GetDataServiceIdNotImplemented","type":"error"},{"inputs":[{"internalType":"uint80","name":"requestedRoundId","type":"uint80"}],"name":"GetRoundDataCanBeOnlyCalledWithLatestRound","type":"error"},{"inputs":[],"name":"IncorrectUnsignedMetadataSize","type":"error"},{"inputs":[{"internalType":"uint256","name":"receivedSignersCount","type":"uint256"},{"internalType":"uint256","name":"requiredSignersCount","type":"uint256"}],"name":"InsufficientNumberOfUniqueSigners","type":"error"},{"inputs":[],"name":"InvalidCalldataPointer","type":"error"},{"inputs":[{"internalType":"uint256","name":"currentBlockTimestamp","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTimestamp","type":"uint256"},{"internalType":"uint256","name":"minIntervalBetweenUpdates","type":"uint256"}],"name":"MinIntervalBetweenUpdatesHasNotPassedYet","type":"error"},{"inputs":[],"name":"RedstonePayloadMustHaveAtLeastOneDataPackage","type":"error"},{"inputs":[{"internalType":"address","name":"receivedSigner","type":"address"}],"name":"SignerNotAuthorised","type":"error"},{"inputs":[{"internalType":"uint256","name":"receivedTimestampSeconds","type":"uint256"},{"internalType":"uint256","name":"blockTimestamp","type":"uint256"}],"name":"TimestampFromTooLongFuture","type":"error"},{"inputs":[{"internalType":"uint256","name":"receivedTimestampSeconds","type":"uint256"},{"internalType":"uint256","name":"blockTimestamp","type":"uint256"}],"name":"TimestampIsTooOld","type":"error"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"UnsafeUintToIntConversion","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"UpdaterNotAuthorised","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"int256","name":"current","type":"int256"},{"indexed":true,"internalType":"uint256","name":"roundId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"updatedAt","type":"uint256"}],"name":"AnswerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"inputs":[{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"aggregateValues","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"aggregator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"description","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"extractTimestampsAndAssertAllAreEqual","outputs":[{"internalType":"uint256","name":"extractedTimestamp","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getAllowedTimestampDiffsInSeconds","outputs":[{"internalType":"uint256","name":"maxDataAheadSeconds","type":"uint256"},{"internalType":"uint256","name":"maxDataDelaySeconds","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"signerAddress","type":"address"}],"name":"getAuthorisedSignerIndex","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockTimestampFromLatestUpdate","outputs":[{"internalType":"uint256","name":"blockTimestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDataFeedId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getDataFeedIds","outputs":[{"internalType":"bytes32[]","name":"dataFeedIds","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"getDataFeedIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDataServiceId","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDataTimestampFromLatestUpdate","outputs":[{"internalType":"uint256","name":"lastDataTimestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMinIntervalBetweenUpdates","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPackedTimestampsFromLatestUpdate","outputs":[{"internalType":"uint256","name":"packedTimestamps","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPriceFeedAdapter","outputs":[{"internalType":"contract IRedstoneAdapter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint80","name":"requestedRoundId","type":"uint80"}],"name":"getRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimestampsFromLatestUpdate","outputs":[{"internalType":"uint128","name":"dataTimestamp","type":"uint128"},{"internalType":"uint128","name":"blockTimestamp","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getUniqueSignersThreshold","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"getValueForDataFeed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"}],"name":"getValueForDataFeedUnsafe","outputs":[{"internalType":"uint256","name":"dataFeedValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"dataFeedIds","type":"bytes32[]"}],"name":"getValuesForDataFeeds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"requestedDataFeedIds","type":"bytes32[]"}],"name":"getValuesForDataFeedsUnsafe","outputs":[{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"latestAnswer","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"latestRound","outputs":[{"internalType":"uint80","name":"","type":"uint80"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"latestRoundData","outputs":[{"internalType":"uint80","name":"roundId","type":"uint80"},{"internalType":"int256","name":"answer","type":"int256"},{"internalType":"uint256","name":"startedAt","type":"uint256"},{"internalType":"uint256","name":"updatedAt","type":"uint256"},{"internalType":"uint80","name":"answeredInRound","type":"uint80"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"updater","type":"address"}],"name":"requireAuthorisedUpdater","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dataPackagesTimestamp","type":"uint256"}],"name":"updateDataFeedsValues","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataFeedId","type":"bytes32"},{"internalType":"uint256","name":"valueForDataFeed","type":"uint256"}],"name":"validateDataFeedValue","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"dataPackagesTimestamp","type":"uint256"}],"name":"validateDataPackagesTimestampOnce","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"dataPackagesTimestamp","type":"uint256"}],"name":"validateProposedDataPackagesTimestamp","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"receivedTimestampMilliseconds","type":"uint256"}],"name":"validateTimestamp","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]

608060405234801561001057600080fd5b50612330806100206000396000f3fe608060405234801561001057600080fd5b50600436106102415760003560e01c8063971b9c0311610145578063c14c9204116100bd578063f50b2efe1161008c578063fba0315811610071578063fba03158146104f3578063fd1f4bef146104fb578063feaf968c1461052257600080fd5b8063f50b2efe146104d9578063f90c4924146104ec57600080fd5b8063c14c920414610491578063c274583a146104a4578063c8337760146104ac578063d149c0d7146104d257600080fd5b8063aef2f16511610114578063b1fcc5cf116100f9578063b1fcc5cf14610458578063b24ebfcc1461046b578063bb1f29b71461047e57600080fd5b8063aef2f16514610412578063b0f106b01461042757600080fd5b8063971b9c031461038f5780639a6fc8f5146103a2578063a8b940e6146103ec578063ada11457146103ff57600080fd5b806355a547d5116101d85780636dafaf6a116101a7578063796b89b91161018c578063796b89b9146103775780637a02bdf11461037d5780638129fc1c1461038557600080fd5b80636dafaf6a146103225780637284e4161461033557600080fd5b806355a547d5146102d857806355d12458146102e05780636668316a14610300578063668a0f021461031357600080fd5b806344e029821161021457806344e02982146102b057806347043b00146102c357806350d25bcd146102c957806354fd4d50146102d157600080fd5b80631b2758ee14610246578063245a7bfc14610261578063313ce567146102885780633ce142f51461029d575b600080fd5b61024e61052a565b6040519081526020015b60405180910390f35b305b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610258565b60085b60405160ff9091168152602001610258565b61028b6102ab366004611f32565b61054c565b61024e6102be366004611f68565b6106ba565b30610263565b61024e6106e3565b600161024e565b61024e6107e1565b6102f36102ee366004612023565b610944565b60405161025891906120b9565b61024e61030e366004611f68565b6109e5565b60405160018152602001610258565b61024e610330366004611f68565b6109f9565b60408051808201909152601381527f52656473746f6e6520507269636520466565640000000000000000000000000060208201525b60405161025891906120fd565b4261024e565b61024e610a5f565b61038d610a81565b005b6102f361039d366004612023565b610c0b565b6103b56103b0366004612169565b610c81565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a001610258565b61038d6103fa366004611f32565b610cf5565b61038d61040d366004611f68565b610e4a565b60408051603c815260b4602082015201610258565b61042f610e5c565b604080516fffffffffffffffffffffffffffffffff938416815292909116602083015201610258565b61038d610466366004612195565b610e9a565b61024e610479366004612023565b610edb565b61038d61048c366004611f68565b610ee6565b61038d61049f366004611f68565b610fa9565b61036a610ff4565b7f6f734554482f455448000000000000000000000000000000000000000000000061024e565b600361024e565b61038d6104e7366004611f68565b611028565b600261028b565b6102f361107f565b7f3d01e4d77237ea0f771f1786da4d4ff757fcba6a92933aa53b1dcef2d6bd6fe25461024e565b6103b56110e4565b6000610534610e5c565b6fffffffffffffffffffffffffffffffff1692915050565b600073ffffffffffffffffffffffffffffffffffffffff8216738bb8f32df04c8b654987daaed53d6b6091e3b7740361058757506000919050565b73ffffffffffffffffffffffffffffffffffffffff821673deb22f54738d54976c4c0fe5ce6d408e40d88499036105c057506001919050565b73ffffffffffffffffffffffffffffffffffffffff82167351ce04be4b3e32572c4ec9135221d0691ba7d202036105f957506002919050565b73ffffffffffffffffffffffffffffffffffffffff821673dd682daec5a90dd295d14da4b0bec9281017b5be0361063257506003919050565b73ffffffffffffffffffffffffffffffffffffffff8216739c5ae89c4af6aa32ce58588dbaf90d18a855b6de0361066b57506004919050565b6040517fec459bc000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024015b60405180910390fd5b60006106c5826109f9565b5060006106d1836109e5565b90506106dd8382610e9a565b92915050565b6040517f44e029820000000000000000000000000000000000000000000000000000000081527f6f734554482f455448000000000000000000000000000000000000000000000060048201819052600091829030906344e0298290602401602060405180830381865afa15801561075e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078291906121b7565b90507f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8111156106dd576040517feccac09b000000000000000000000000000000000000000000000000000000008152600481018290526024016106b1565b6000806107ec611176565b905060006107f9826112ab565b61ffff16905080600003610839576040517f8552ff3c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108446002836121ff565b915060005b8181101561093e57600061085c846112fe565b905060008061086c6068876121ff565b9050600061087a8236612212565b9050803592508265ffffffffffff166000036108c2576040517f336dc9d000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b876000036108da578265ffffffffffff16975061091b565b878365ffffffffffff161461091b576040517fd9d1f46500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61092584886121ff565b965050505050808061093690612225565b915050610849565b50505090565b6060815167ffffffffffffffff81111561096057610960611f81565b604051908082528060200260200182016040528015610989578160200160208202803683370190505b50905060005b82518110156109df576109ba8382815181106109ad576109ad61225d565b60200260200101516109e5565b8282815181106109cc576109cc61225d565b602090810291909101015260010161098f565b50919050565b6000806109f18361133a565b549392505050565b60007f6f734554482f45544800000000000000000000000000000000000000000000008203610a2a57506000919050565b6040517f93829403000000000000000000000000000000000000000000000000000000008152600481018390526024016106b1565b6000610a69610e5c565b506fffffffffffffffffffffffffffffffff16919050565b600054610100900460ff1615808015610aa15750600054600160ff909116105b80610abb5750303b158015610abb575060005460ff166001145b610b47576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016106b1565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015610ba557600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b8015610c0857600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b60606000610c1883610944565b905060005b8351811015610c7a576000848281518110610c3a57610c3a61225d565b60200260200101519050610c4d816109f9565b50610c7181848481518110610c6457610c6461225d565b6020026020010151610e9a565b50600101610c1d565b5092915050565b60008080808069ffffffffffffffffffff8616600114610cdb576040517f22bfd6df00000000000000000000000000000000000000000000000000000000815269ffffffffffffffffffff871660048201526024016106b1565b610ce36110e4565b939a9299509097509550909350915050565b73ffffffffffffffffffffffffffffffffffffffff811673cd1435f09c411fcbc44da4a51f5c1a2e1b32ff4714801590610d59575073ffffffffffffffffffffffffffffffffffffffff8116739abfefd388ae17e0b8a9f865eb1ccb137bf436cf14155b8015610d8f575073ffffffffffffffffffffffffffffffffffffffff811673c1c090658937107675cbfe4494e6b63519538b6214155b8015610dc5575073ffffffffffffffffffffffffffffffffffffffff811673cd6bfda4d95d5c0f3f2882dc221d792392c9971414155b8015610dfb575073ffffffffffffffffffffffffffffffffffffffff811673c4d1ae5e796e6d7561cdc8335f85e6b57a36e09714155b15610c08576040517f63328d3d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016106b1565b610e5381611396565b610c0881610ee6565b600080610e92610e8a7f3d01e4d77237ea0f771f1786da4d4ff757fcba6a92933aa53b1dcef2d6bd6fe25490565b608081901c91565b915091509091565b80600003610ed7576040517f0565ce2a000000000000000000000000000000000000000000000000000000008152600481018390526024016106b1565b5050565b60006106dd826113e5565b6000610ef46103e8836122bb565b9050603c60b44283811015610f555782610f0e8286612212565b1115610f50576040517fb6b0916d00000000000000000000000000000000000000000000000000000000815260048101859052602481018290526044016106b1565b610fa2565b81610f608583612212565b1115610fa2576040517f0321d0b500000000000000000000000000000000000000000000000000000000815260048101859052602481018290526044016106b1565b5050505050565b610fb233610cf5565b610fba6113f0565b610fc381610e4a565b610fcc81611453565b6000610fd661107f565b90506000610fe382611519565b9050610fef8282611524565b505050565b60606040517f608b530700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336110305750565b600061103a610a5f565b9050808214610ed7576040517f6bc11ec500000000000000000000000000000000000000000000000000000000815260048101829052602481018390526044016106b1565b604080516001808252818301909252606091602080830190803683370190505090507f6f734554482f4554480000000000000000000000000000000000000000000000816000815181106110d5576110d561225d565b60200260200101818152505090565b600160008080806110f36106e3565b935060003073ffffffffffffffffffffffffffffffffffffffff16631b2758ee6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611142573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116691906121b7565b9596949594859450879350915050565b60006602ed57011e00007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0360135811614806111de576040517fe7764c9e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000366029111561121b576040517f5796f78a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd736013560006009611254600362ffffff85166121ff565b61125e91906121ff565b90503661126c6002836121ff565b11156112a4576040517fc30a7bd700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9392505050565b6000806112b96020846121ff565b9050368111156112f5576040517f5796f78a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b36033592915050565b600080600061130c846115cf565b9092509050604e61131e8260206121ff565b61132890846122cf565b61133291906121ff565b949350505050565b6040516000906113799083907f4dd0c77efa6f6d590c97573d8c70b714546e7311202ff7c11c484cc841d91bfc90602001918252602082015260400190565b604051602081830303815290604052805190602001209050919050565b60006113a0610a5f565b9050808211610ed7576040517fef05deba00000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016106b1565b60006106dd82611626565b4260006113fb61052a565b9050600361140981836121ff565b831015610fef576040517f83b3f5c40000000000000000000000000000000000000000000000000000000081526004810184905260248101839052604481018290526064016106b1565b426fffffffffffffffffffffffffffffffff8111156114a1576040517f70db678f000000000000000000000000000000000000000000000000000000008152600481018290526024016106b1565b6fffffffffffffffffffffffffffffffff8211156114ee576040517f5cbfa8a1000000000000000000000000000000000000000000000000000000008152600481018390526024016106b1565b60809190911b177f3d01e4d77237ea0f771f1786da4d4ff757fcba6a92933aa53b1dcef2d6bd6fe255565b60606106dd8261170a565b8151600114158061153757508051600114155b1561156e576040517fbed42bab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115ac826000815181106115845761158461225d565b60200260200101518260008151811061159f5761159f61225d565b60200260200101516118ce565b610ed7816000815181106115c2576115c261225d565b60200260200101516118eb565b6000808080806115e06041876121ff565b905060006115f96115f26020846121ff565b369061192c565b80359450905061160a81600361192c565b62ffffff9490941697933563ffffffff16965092945050505050565b60008151600003611663576040517f9e198af900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61166c82611938565b60006002835161167c91906122bb565b90506002835161168c91906122e6565b6000036116e85760006116db846116a4600185612212565b815181106116b4576116b461225d565b60200260200101518584815181106116ce576116ce61225d565b6020026020010151611986565b90506113326002826122bb565b8281815181106116fa576116fa61225d565b6020026020010151915050919050565b60606000825167ffffffffffffffff81111561172857611728611f81565b604051908082528060200260200182016040528015611751578160200160208202803683370190505b5090506000835167ffffffffffffffff81111561177057611770611f81565b604051908082528060200260200182016040528015611799578160200160208202803683370190505b5090506000845167ffffffffffffffff8111156117b8576117b8611f81565b6040519080825280602002602001820160405280156117eb57816020015b60608152602001906001900390816117d65790505b50905060005b85518110156118485760408051600280825260608201835290916020830190803683370190505082828151811061182a5761182a61225d565b6020026020010181905250808061184090612225565b9150506117f1565b506000611853611176565b90506000611860826112ab565b61ffff1690506118716002836121ff565b60405190925060005b828110156118b75760006118918a89898989611992565b905061189d81866121ff565b9450826040525080806118af90612225565b91505061187a565b506118c28487611c49565b98975050505050505050565b6118d88282610e9a565b60006118e38361133a565b919091555050565b60016118f682611d7b565b6040514281527f0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f9060200160405180910390a350565b60006112a48284612212565b8051602082016020820281019150805b8281101561198057815b8181101561197757815181518082101561196d578084528183525b5050602001611952565b50602001611948565b50505050565b60006112a482846121ff565b6000806000806119a1856115cf565b909250905060008080606081600d6119c46119bd6020896121ff565b8990611e31565b6119ce91906121ff565b905060006119e06115f260688d6121ff565b905060006119fd836119f360418f6121ff565b6115f291906121ff565b9050611a098382611a1c565b9350826020850120945081359650611a5e565b604080518381526020818501810190925260009101838382377fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0019392505050565b611a6f8765ffffffffffff16611028565b611a8385611a7e60418f6121ff565b611e3d565b9550611a8e8661054c565b60ff1699505050505050505060008060005b84811015611c1657611ab3888583611ed3565b909350915060005b8c51811015611c03578c8181518110611ad657611ad661225d565b60200260200101518403611bf15760008b8281518110611af857611af861225d565b60200260200101519050611b1181896001901b16151590565b158015611b3a5750600260ff168d8381518110611b3057611b3061225d565b6020026020010151105b15611beb578c8281518110611b5157611b5161225d565b602002602001018051809190611b6690612225565b81525050838b8381518110611b7d57611b7d61225d565b602002602001015160018f8581518110611b9957611b9961225d565b6020026020010151611bab9190612212565b81518110611bbb57611bbb61225d565b60209081029190910101526001881b81178c8381518110611bde57611bde61225d565b6020026020010181815250505b50611c03565b80611bfb81612225565b915050611abb565b5080611c0e81612225565b915050611aa0565b50505081602082611c2791906121ff565b611c3191906122cf565b611c3c90604e6121ff565b9998505050505050505050565b60606000835167ffffffffffffffff811115611c6757611c67611f81565b604051908082528060200260200182016040528015611c90578160200160208202803683370190505b509050600260005b8551811015611d715781858281518110611cb457611cb461225d565b60200260200101511015611d1a57848181518110611cd457611cd461225d565b6020026020010151826040517f2b13aef50000000000000000000000000000000000000000000000000000000081526004016106b1929190918252602082015260400190565b6000611d3e878381518110611d3157611d3161225d565b6020026020010151610edb565b905080848381518110611d5357611d5361225d565b60209081029190910101525080611d6981612225565b915050611c98565b5090949350505050565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821115611e2d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e206160448201527f6e20696e7432353600000000000000000000000000000000000000000000000060648201526084016106b1565b5090565b60006112a482846122cf565b60408051600080825260208083018085528690523685900380850135831a948401859052803560608501819052910135608084018190529193909260019060a0016020604051602081039080840390855afa158015611ea0573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00151979650505050505050565b60008080611ee2604e876121ff565b90506000611f0f611f08611ef76020896121ff565b611f028860016121ff565b90611e31565b8390611986565b90506000611f1d368361192c565b80359960209091013598509650505050505050565b600060208284031215611f4457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146112a457600080fd5b600060208284031215611f7a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611ff757611ff7611f81565b604052919050565b600067ffffffffffffffff82111561201957612019611f81565b5060051b60200190565b6000602080838503121561203657600080fd5b823567ffffffffffffffff81111561204d57600080fd5b8301601f8101851361205e57600080fd5b803561207161206c82611fff565b611fb0565b81815260059190911b8201830190838101908783111561209057600080fd5b928401925b828410156120ae57833582529284019290840190612095565b979650505050505050565b6020808252825182820181905260009190848201906040850190845b818110156120f1578351835292840192918401916001016120d5565b50909695505050505050565b600060208083528351808285015260005b8181101561212a5785810183015185820160400152820161210e565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60006020828403121561217b57600080fd5b813569ffffffffffffffffffff811681146112a457600080fd5b600080604083850312156121a857600080fd5b50508035926020909101359150565b6000602082840312156121c957600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156106dd576106dd6121d0565b818103818111156106dd576106dd6121d0565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612256576122566121d0565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000826122ca576122ca61228c565b500490565b80820281158282048414176106dd576106dd6121d0565b6000826122f5576122f561228c565b50069056fea2646970667358221220e11cfe8423fa2ee98c2adf065251be7cfd5865a47aac440f9392cc6f2b82452464736f6c63430008110033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102415760003560e01c8063971b9c0311610145578063c14c9204116100bd578063f50b2efe1161008c578063fba0315811610071578063fba03158146104f3578063fd1f4bef146104fb578063feaf968c1461052257600080fd5b8063f50b2efe146104d9578063f90c4924146104ec57600080fd5b8063c14c920414610491578063c274583a146104a4578063c8337760146104ac578063d149c0d7146104d257600080fd5b8063aef2f16511610114578063b1fcc5cf116100f9578063b1fcc5cf14610458578063b24ebfcc1461046b578063bb1f29b71461047e57600080fd5b8063aef2f16514610412578063b0f106b01461042757600080fd5b8063971b9c031461038f5780639a6fc8f5146103a2578063a8b940e6146103ec578063ada11457146103ff57600080fd5b806355a547d5116101d85780636dafaf6a116101a7578063796b89b91161018c578063796b89b9146103775780637a02bdf11461037d5780638129fc1c1461038557600080fd5b80636dafaf6a146103225780637284e4161461033557600080fd5b806355a547d5146102d857806355d12458146102e05780636668316a14610300578063668a0f021461031357600080fd5b806344e029821161021457806344e02982146102b057806347043b00146102c357806350d25bcd146102c957806354fd4d50146102d157600080fd5b80631b2758ee14610246578063245a7bfc14610261578063313ce567146102885780633ce142f51461029d575b600080fd5b61024e61052a565b6040519081526020015b60405180910390f35b305b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610258565b60085b60405160ff9091168152602001610258565b61028b6102ab366004611f32565b61054c565b61024e6102be366004611f68565b6106ba565b30610263565b61024e6106e3565b600161024e565b61024e6107e1565b6102f36102ee366004612023565b610944565b60405161025891906120b9565b61024e61030e366004611f68565b6109e5565b60405160018152602001610258565b61024e610330366004611f68565b6109f9565b60408051808201909152601381527f52656473746f6e6520507269636520466565640000000000000000000000000060208201525b60405161025891906120fd565b4261024e565b61024e610a5f565b61038d610a81565b005b6102f361039d366004612023565b610c0b565b6103b56103b0366004612169565b610c81565b6040805169ffffffffffffffffffff968716815260208101959095528401929092526060830152909116608082015260a001610258565b61038d6103fa366004611f32565b610cf5565b61038d61040d366004611f68565b610e4a565b60408051603c815260b4602082015201610258565b61042f610e5c565b604080516fffffffffffffffffffffffffffffffff938416815292909116602083015201610258565b61038d610466366004612195565b610e9a565b61024e610479366004612023565b610edb565b61038d61048c366004611f68565b610ee6565b61038d61049f366004611f68565b610fa9565b61036a610ff4565b7f6f734554482f455448000000000000000000000000000000000000000000000061024e565b600361024e565b61038d6104e7366004611f68565b611028565b600261028b565b6102f361107f565b7f3d01e4d77237ea0f771f1786da4d4ff757fcba6a92933aa53b1dcef2d6bd6fe25461024e565b6103b56110e4565b6000610534610e5c565b6fffffffffffffffffffffffffffffffff1692915050565b600073ffffffffffffffffffffffffffffffffffffffff8216738bb8f32df04c8b654987daaed53d6b6091e3b7740361058757506000919050565b73ffffffffffffffffffffffffffffffffffffffff821673deb22f54738d54976c4c0fe5ce6d408e40d88499036105c057506001919050565b73ffffffffffffffffffffffffffffffffffffffff82167351ce04be4b3e32572c4ec9135221d0691ba7d202036105f957506002919050565b73ffffffffffffffffffffffffffffffffffffffff821673dd682daec5a90dd295d14da4b0bec9281017b5be0361063257506003919050565b73ffffffffffffffffffffffffffffffffffffffff8216739c5ae89c4af6aa32ce58588dbaf90d18a855b6de0361066b57506004919050565b6040517fec459bc000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff831660048201526024015b60405180910390fd5b60006106c5826109f9565b5060006106d1836109e5565b90506106dd8382610e9a565b92915050565b6040517f44e029820000000000000000000000000000000000000000000000000000000081527f6f734554482f455448000000000000000000000000000000000000000000000060048201819052600091829030906344e0298290602401602060405180830381865afa15801561075e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078291906121b7565b90507f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8111156106dd576040517feccac09b000000000000000000000000000000000000000000000000000000008152600481018290526024016106b1565b6000806107ec611176565b905060006107f9826112ab565b61ffff16905080600003610839576040517f8552ff3c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108446002836121ff565b915060005b8181101561093e57600061085c846112fe565b905060008061086c6068876121ff565b9050600061087a8236612212565b9050803592508265ffffffffffff166000036108c2576040517f336dc9d000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b876000036108da578265ffffffffffff16975061091b565b878365ffffffffffff161461091b576040517fd9d1f46500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61092584886121ff565b965050505050808061093690612225565b915050610849565b50505090565b6060815167ffffffffffffffff81111561096057610960611f81565b604051908082528060200260200182016040528015610989578160200160208202803683370190505b50905060005b82518110156109df576109ba8382815181106109ad576109ad61225d565b60200260200101516109e5565b8282815181106109cc576109cc61225d565b602090810291909101015260010161098f565b50919050565b6000806109f18361133a565b549392505050565b60007f6f734554482f45544800000000000000000000000000000000000000000000008203610a2a57506000919050565b6040517f93829403000000000000000000000000000000000000000000000000000000008152600481018390526024016106b1565b6000610a69610e5c565b506fffffffffffffffffffffffffffffffff16919050565b600054610100900460ff1615808015610aa15750600054600160ff909116105b80610abb5750303b158015610abb575060005460ff166001145b610b47576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016106b1565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015610ba557600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b8015610c0857600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b60606000610c1883610944565b905060005b8351811015610c7a576000848281518110610c3a57610c3a61225d565b60200260200101519050610c4d816109f9565b50610c7181848481518110610c6457610c6461225d565b6020026020010151610e9a565b50600101610c1d565b5092915050565b60008080808069ffffffffffffffffffff8616600114610cdb576040517f22bfd6df00000000000000000000000000000000000000000000000000000000815269ffffffffffffffffffff871660048201526024016106b1565b610ce36110e4565b939a9299509097509550909350915050565b73ffffffffffffffffffffffffffffffffffffffff811673cd1435f09c411fcbc44da4a51f5c1a2e1b32ff4714801590610d59575073ffffffffffffffffffffffffffffffffffffffff8116739abfefd388ae17e0b8a9f865eb1ccb137bf436cf14155b8015610d8f575073ffffffffffffffffffffffffffffffffffffffff811673c1c090658937107675cbfe4494e6b63519538b6214155b8015610dc5575073ffffffffffffffffffffffffffffffffffffffff811673cd6bfda4d95d5c0f3f2882dc221d792392c9971414155b8015610dfb575073ffffffffffffffffffffffffffffffffffffffff811673c4d1ae5e796e6d7561cdc8335f85e6b57a36e09714155b15610c08576040517f63328d3d00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff821660048201526024016106b1565b610e5381611396565b610c0881610ee6565b600080610e92610e8a7f3d01e4d77237ea0f771f1786da4d4ff757fcba6a92933aa53b1dcef2d6bd6fe25490565b608081901c91565b915091509091565b80600003610ed7576040517f0565ce2a000000000000000000000000000000000000000000000000000000008152600481018390526024016106b1565b5050565b60006106dd826113e5565b6000610ef46103e8836122bb565b9050603c60b44283811015610f555782610f0e8286612212565b1115610f50576040517fb6b0916d00000000000000000000000000000000000000000000000000000000815260048101859052602481018290526044016106b1565b610fa2565b81610f608583612212565b1115610fa2576040517f0321d0b500000000000000000000000000000000000000000000000000000000815260048101859052602481018290526044016106b1565b5050505050565b610fb233610cf5565b610fba6113f0565b610fc381610e4a565b610fcc81611453565b6000610fd661107f565b90506000610fe382611519565b9050610fef8282611524565b505050565b60606040517f608b530700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336110305750565b600061103a610a5f565b9050808214610ed7576040517f6bc11ec500000000000000000000000000000000000000000000000000000000815260048101829052602481018390526044016106b1565b604080516001808252818301909252606091602080830190803683370190505090507f6f734554482f4554480000000000000000000000000000000000000000000000816000815181106110d5576110d561225d565b60200260200101818152505090565b600160008080806110f36106e3565b935060003073ffffffffffffffffffffffffffffffffffffffff16631b2758ee6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611142573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116691906121b7565b9596949594859450879350915050565b60006602ed57011e00007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0360135811614806111de576040517fe7764c9e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000366029111561121b576040517f5796f78a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd736013560006009611254600362ffffff85166121ff565b61125e91906121ff565b90503661126c6002836121ff565b11156112a4576040517fc30a7bd700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9392505050565b6000806112b96020846121ff565b9050368111156112f5576040517f5796f78a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b36033592915050565b600080600061130c846115cf565b9092509050604e61131e8260206121ff565b61132890846122cf565b61133291906121ff565b949350505050565b6040516000906113799083907f4dd0c77efa6f6d590c97573d8c70b714546e7311202ff7c11c484cc841d91bfc90602001918252602082015260400190565b604051602081830303815290604052805190602001209050919050565b60006113a0610a5f565b9050808211610ed7576040517fef05deba00000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016106b1565b60006106dd82611626565b4260006113fb61052a565b9050600361140981836121ff565b831015610fef576040517f83b3f5c40000000000000000000000000000000000000000000000000000000081526004810184905260248101839052604481018290526064016106b1565b426fffffffffffffffffffffffffffffffff8111156114a1576040517f70db678f000000000000000000000000000000000000000000000000000000008152600481018290526024016106b1565b6fffffffffffffffffffffffffffffffff8211156114ee576040517f5cbfa8a1000000000000000000000000000000000000000000000000000000008152600481018390526024016106b1565b60809190911b177f3d01e4d77237ea0f771f1786da4d4ff757fcba6a92933aa53b1dcef2d6bd6fe255565b60606106dd8261170a565b8151600114158061153757508051600114155b1561156e576040517fbed42bab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115ac826000815181106115845761158461225d565b60200260200101518260008151811061159f5761159f61225d565b60200260200101516118ce565b610ed7816000815181106115c2576115c261225d565b60200260200101516118eb565b6000808080806115e06041876121ff565b905060006115f96115f26020846121ff565b369061192c565b80359450905061160a81600361192c565b62ffffff9490941697933563ffffffff16965092945050505050565b60008151600003611663576040517f9e198af900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61166c82611938565b60006002835161167c91906122bb565b90506002835161168c91906122e6565b6000036116e85760006116db846116a4600185612212565b815181106116b4576116b461225d565b60200260200101518584815181106116ce576116ce61225d565b6020026020010151611986565b90506113326002826122bb565b8281815181106116fa576116fa61225d565b6020026020010151915050919050565b60606000825167ffffffffffffffff81111561172857611728611f81565b604051908082528060200260200182016040528015611751578160200160208202803683370190505b5090506000835167ffffffffffffffff81111561177057611770611f81565b604051908082528060200260200182016040528015611799578160200160208202803683370190505b5090506000845167ffffffffffffffff8111156117b8576117b8611f81565b6040519080825280602002602001820160405280156117eb57816020015b60608152602001906001900390816117d65790505b50905060005b85518110156118485760408051600280825260608201835290916020830190803683370190505082828151811061182a5761182a61225d565b6020026020010181905250808061184090612225565b9150506117f1565b506000611853611176565b90506000611860826112ab565b61ffff1690506118716002836121ff565b60405190925060005b828110156118b75760006118918a89898989611992565b905061189d81866121ff565b9450826040525080806118af90612225565b91505061187a565b506118c28487611c49565b98975050505050505050565b6118d88282610e9a565b60006118e38361133a565b919091555050565b60016118f682611d7b565b6040514281527f0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f9060200160405180910390a350565b60006112a48284612212565b8051602082016020820281019150805b8281101561198057815b8181101561197757815181518082101561196d578084528183525b5050602001611952565b50602001611948565b50505050565b60006112a482846121ff565b6000806000806119a1856115cf565b909250905060008080606081600d6119c46119bd6020896121ff565b8990611e31565b6119ce91906121ff565b905060006119e06115f260688d6121ff565b905060006119fd836119f360418f6121ff565b6115f291906121ff565b9050611a098382611a1c565b9350826020850120945081359650611a5e565b604080518381526020818501810190925260009101838382377fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0019392505050565b611a6f8765ffffffffffff16611028565b611a8385611a7e60418f6121ff565b611e3d565b9550611a8e8661054c565b60ff1699505050505050505060008060005b84811015611c1657611ab3888583611ed3565b909350915060005b8c51811015611c03578c8181518110611ad657611ad661225d565b60200260200101518403611bf15760008b8281518110611af857611af861225d565b60200260200101519050611b1181896001901b16151590565b158015611b3a5750600260ff168d8381518110611b3057611b3061225d565b6020026020010151105b15611beb578c8281518110611b5157611b5161225d565b602002602001018051809190611b6690612225565b81525050838b8381518110611b7d57611b7d61225d565b602002602001015160018f8581518110611b9957611b9961225d565b6020026020010151611bab9190612212565b81518110611bbb57611bbb61225d565b60209081029190910101526001881b81178c8381518110611bde57611bde61225d565b6020026020010181815250505b50611c03565b80611bfb81612225565b915050611abb565b5080611c0e81612225565b915050611aa0565b50505081602082611c2791906121ff565b611c3191906122cf565b611c3c90604e6121ff565b9998505050505050505050565b60606000835167ffffffffffffffff811115611c6757611c67611f81565b604051908082528060200260200182016040528015611c90578160200160208202803683370190505b509050600260005b8551811015611d715781858281518110611cb457611cb461225d565b60200260200101511015611d1a57848181518110611cd457611cd461225d565b6020026020010151826040517f2b13aef50000000000000000000000000000000000000000000000000000000081526004016106b1929190918252602082015260400190565b6000611d3e878381518110611d3157611d3161225d565b6020026020010151610edb565b905080848381518110611d5357611d5361225d565b60209081029190910101525080611d6981612225565b915050611c98565b5090949350505050565b60007f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821115611e2d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f53616665436173743a2076616c756520646f65736e27742066697420696e206160448201527f6e20696e7432353600000000000000000000000000000000000000000000000060648201526084016106b1565b5090565b60006112a482846122cf565b60408051600080825260208083018085528690523685900380850135831a948401859052803560608501819052910135608084018190529193909260019060a0016020604051602081039080840390855afa158015611ea0573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe00151979650505050505050565b60008080611ee2604e876121ff565b90506000611f0f611f08611ef76020896121ff565b611f028860016121ff565b90611e31565b8390611986565b90506000611f1d368361192c565b80359960209091013598509650505050505050565b600060208284031215611f4457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff811681146112a457600080fd5b600060208284031215611f7a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611ff757611ff7611f81565b604052919050565b600067ffffffffffffffff82111561201957612019611f81565b5060051b60200190565b6000602080838503121561203657600080fd5b823567ffffffffffffffff81111561204d57600080fd5b8301601f8101851361205e57600080fd5b803561207161206c82611fff565b611fb0565b81815260059190911b8201830190838101908783111561209057600080fd5b928401925b828410156120ae57833582529284019290840190612095565b979650505050505050565b6020808252825182820181905260009190848201906040850190845b818110156120f1578351835292840192918401916001016120d5565b50909695505050505050565b600060208083528351808285015260005b8181101561212a5785810183015185820160400152820161210e565b5060006040828601015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8301168501019250505092915050565b60006020828403121561217b57600080fd5b813569ffffffffffffffffffff811681146112a457600080fd5b600080604083850312156121a857600080fd5b50508035926020909101359150565b6000602082840312156121c957600080fd5b5051919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808201808211156106dd576106dd6121d0565b818103818111156106dd576106dd6121d0565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612256576122566121d0565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000826122ca576122ca61228c565b500490565b80820281158282048414176106dd576106dd6121d0565b6000826122f5576122f561228c565b50069056fea2646970667358221220e11cfe8423fa2ee98c2adf065251be7cfd5865a47aac440f9392cc6f2b82452464736f6c63430008110033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.