creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@openzeppelin/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "contracts/ExchangePrice.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\r\npragma solidity ^0.8.24;\r\n\r\ncontract ExchangePrice {\r\n  struct Price {\r\n    uint48 ts; \r\n    string q;\r\n    address qAddr;\r\n    string b;\r\n    address bAddr;\r\n    uint256 price;\r\n  }\r\n}\r\n"
      },
      "contracts/MaxExchangeOracle.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\r\npragma solidity ^0.8.24;\r\n\r\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport \"./ExchangePrice.sol\";\r\n\r\ncontract MaxExchangeOracle is Ownable {\r\n  uint private contentSize;\r\n  mapping(uint => bytes32) public keyTbl;\r\n  mapping(bytes32 => ExchangePrice.Price) _priceInfo;\r\n\r\n  event onUpdatePriceInfo();\r\n\r\n  constructor(address ownerAddr) Ownable(ownerAddr) {\r\n  }\r\n\r\n  function size() public view returns (uint) {\r\n      return contentSize;\r\n  }\r\n\r\n  function hash(address basic, address quote)\r\n        public pure returns (bytes32) {\r\n      return keccak256(abi.encode(basic, quote));\r\n  }\r\n\r\n  function updateInfo(ExchangePrice.Price[] memory info) \r\n    onlyOwner() \r\n    public {\r\n    for (uint i = 0; i < info.length; i++) {\r\n      ExchangePrice.Price memory p = info[i];\r\n      bytes32 key = hash(p.bAddr, p.qAddr);\r\n      keyTbl[i] = key;\r\n      _priceInfo[key] = info[i];\r\n    }\r\n    contentSize = info.length;\r\n    emit onUpdatePriceInfo();\r\n  }\r\n\r\n  function viewPriceInfo() public view \r\n    returns (ExchangePrice.Price[] memory) {\r\n    uint _size = size();\r\n    ExchangePrice.Price[] memory outputL = new ExchangePrice.Price[](_size);\r\n    for (uint i = 0; i < _size; i++) {\r\n      bytes32 key = keyTbl[i];\r\n      ExchangePrice.Price memory data = _priceInfo[key];\r\n      outputL[i] = data;\r\n    }\r\n    return outputL;\r\n  }\r\n\r\n  function checkExists(address targetAddr, address inAddress) \r\n    public view returns (address, address) {\r\n    if (size() == 0) {\r\n      return (address(0), address(0));\r\n    }\r\n    bytes32 key = hash(targetAddr, inAddress);\r\n    ExchangePrice.Price memory p = _priceInfo[key];\r\n    if(p.bAddr == address(0)) {\r\n      bytes32 key1 = hash(inAddress, targetAddr);\r\n      ExchangePrice.Price memory p1 = _priceInfo[key1];\r\n      return (p1.qAddr, p1.bAddr);\r\n    }\r\n    return (p.qAddr, p.bAddr);\r\n  }\r\n\r\n  function getPrice(address quote, address basic) public view\r\n    returns (ExchangePrice.Price memory) {\r\n    bytes32 key = hash(basic, quote);\r\n    ExchangePrice.Price memory data = _priceInfo[key];\r\n    require(data.bAddr != address(0), \"NOT_PRICE\");\r\n    return data;\r\n  }\r\n}"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": false,
        "runs": 800
      },
      "metadata": {
        "bytecodeHash": "none"
      },
      "evmVersion": "paris",
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "libraries": {}
    }
  }}