File size: 8,944 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
  "language": "Solidity",
  "sources": {
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../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 * By default, the owner account will be the one that deploys the contract. This\n * can 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    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\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        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing 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        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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 v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\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"
    },
    "contracts/bases/Constants.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\n//// Do not define \"state variables\" in this contract\ncontract Constants {\n    //`constant`和`immutable`变量不占用存储槽,因此不会影响delegatecall时slot的读取\n    // market id\n    uint256 public constant SEAPORT_MARKET_ID = 0;\n    uint256 public constant DEFAULT_MARKET_ID = 1;\n\n    //market address(seaport looksrare x2y2 cryptopunk mooncat)\n    address public constant SEAPORT =\n        0x00000000006c3852cbEf3e08E8dF289169EdE581;\n\n    address public constant LOOKSRARE =\n        0x59728544B08AB483533076417FbBB2fD0B17CE3a;\n    address LOOKSRARE_REWARDS_DISTRIBUTOR =\n        0x0554f068365eD43dcC98dcd7Fd7A8208a5638C72; // 领取LOOKS代币奖励\n    address LOOKSRARE_TOKEN = 0xf4d2888d29D722226FafA5d9B24F9164c092421E; //LOOKS代币地址\n\n    address public constant X2Y2 = 0x74312363e45DCaBA76c59ec49a7Aa8A65a67EeD3; //单个购买时的market合约\n    address public constant X2Y2_REWARDS_DISTRIBUTOR =\n        0x897249FEf87Fa6D1E7FeDCB960c2A01Ec99ecC6C; // 领取X2Y2代币奖励\n    address public constant X2Y2_TOKEN =\n        0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9; //X2Y2代币地址\n    // address public constant X2Y2_BATCH =\n    //     0x56Dd5bbEDE9BFDB10a2845c4D70d4a2950163044; // 批量购买时的market合约--参考用\n\n    address public constant CRYPTOPUNK =\n        0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB;\n\n    address public constant MOONCAT =\n        0x60cd862c9C687A9dE49aecdC3A99b74A4fc54aB6;\n\n    address public constant NFTX = 0x0fc584529a2AEfA997697FAfAcbA5831faC0c22d;\n\n    address public constant FOUNDATION =\n        0xcDA72070E455bb31C7690a170224Ce43623d0B6f;\n\n    address public constant SUDOSWAP =\n        0x2B2e8cDA09bBA9660dCA5cB6233787738Ad68329;\n    address public constant NFT20 = 0xA42f6cADa809Bcf417DeefbdD69C5C5A909249C0;\n\n    address public constant BLUR = 0x000000000000Ad05Ccc4F10045630fb830B95127;\n\n    struct ERC20Detail {\n        address tokenAddr;\n        uint256 amount;\n    }\n\n    struct ERC721Detail {\n        address tokenAddr;\n        uint256 id;\n    }\n\n    struct ERC1155Detail {\n        address tokenAddr;\n        uint256 id;\n        uint256 amount;\n    }\n\n    enum ItemType {\n        INVALID,\n        NATIVE,\n        ERC20,\n        ERC721,\n        ERC1155\n    }\n    struct OrderItem {\n        ItemType itemType;\n        address tokenAddr;\n        uint256 id;\n        uint256 amount;\n    }\n\n    struct TradeInput {\n        //单次调用某一market\n        uint256 value; // 此次调用x2y2\\looksrare\\..需传递的主网币数量\n        bytes inputData; //此次调用的input data\n        OrderItem[] tokens; // 本次调用要购买的NFT信息,可能会有多个(例如捆绑销售时)\n    }\n    struct TradeDetail {\n        //批量调用同一个market\n        uint256 marketId;\n        uint256 value;\n        bytes tradeData; //包含多个TradeInput信息\n    }\n}\n"
    },
    "contracts/markets/MarketRegistry.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.13;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"../bases/Constants.sol\";\n\ncontract MarketRegistry is Ownable, Constants {\n    struct Market {\n        address proxy; //custom market proxy\n        bool isLib; //是否通过委托调用的方式,调用Market市场合约。大多数情况是true,因为Market合约中会校验msg。sender是否为接单者\n        bool isActive;\n    }\n\n    Market[] public markets;\n\n    constructor(address defaultMarektProxy) {\n        markets.push(Market(SEAPORT, false, true)); //market_id=0,call\n        markets.push(Market(defaultMarektProxy, true, true)); //market_id=1,delegatecall\n    }\n\n    function addMarket(address proxy, bool isLib) external onlyOwner {\n        markets.push(Market(proxy, isLib, true));\n    }\n\n    function addMarkets(address[] memory proxies, bool[] memory isLibs)\n        external\n        onlyOwner\n    {\n        for (uint256 i = 0; i < proxies.length; i++) {\n            markets.push(Market(proxies[i], isLibs[i], true));\n        }\n    }\n\n    function setMarketStatus(uint256 marketId, bool newStatus)\n        external\n        onlyOwner\n    {\n        Market storage market = markets[marketId];\n        market.isActive = newStatus;\n    }\n\n    function setMarketProxy(\n        uint256 marketId,\n        address newProxy,\n        bool isLib\n    ) external onlyOwner {\n        Market storage market = markets[marketId];\n        market.proxy = newProxy;\n        market.isLib = isLib;\n    }\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 1000
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    },
    "metadata": {
      "useLiteralContent": true
    },
    "libraries": {}
  }
}