@optimex-xyz/market-maker-sdk 0.9.0-dev-f1b970c → 0.9.0-dev-b026721

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -30,8 +30,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ AssetChainContractRole: () => AssetChainContractRole,
33
34
  ERC20__factory: () => ERC20__factory,
35
+ L2ContractRole: () => L2ContractRole,
34
36
  MorphoLiquidator__factory: () => MorphoLiquidator__factory,
37
+ OptimexBtcNetwork: () => OptimexBtcNetwork,
38
+ OptimexEvmNetwork: () => OptimexEvmNetwork,
39
+ OptimexL2Network: () => OptimexL2Network,
40
+ OptimexLendingNetwork: () => OptimexLendingNetwork,
41
+ OptimexSolanaNetwork: () => OptimexSolanaNetwork,
35
42
  Payment__factory: () => Payment__factory,
36
43
  ProtocolFetcherProxy__factory: () => ProtocolFetcherProxy__factory,
37
44
  ProtocolService: () => ProtocolService,
@@ -58,6 +65,10 @@ __export(index_exports, {
58
65
  getSignature: () => getSignature,
59
66
  getSigner: () => getSigner,
60
67
  getTradeIdsHash: () => getTradeIdsHash,
68
+ isBtcNetwork: () => isBtcNetwork,
69
+ isEvmNetwork: () => isEvmNetwork,
70
+ isL2Network: () => isL2Network,
71
+ isSolanaNetwork: () => isSolanaNetwork,
61
72
  makePaymentType: () => makePaymentType,
62
73
  presignType: () => presignType,
63
74
  protocolService: () => protocolService,
@@ -79,48 +90,24 @@ var environments = {
79
90
  backendUrl: "https://api-dev.bitdex.xyz",
80
91
  rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
81
92
  protocolFetcherProxyAddress: "0x0267Fc04eE866b31907dEe123aBdCdB67d03B297",
82
- paymentAddressMap: {
83
- ethereum_sepolia: "0x1d8b58438D5Ccc8Fcb4b738C89078f7b4168C9c0"
84
- },
85
- liquidationAddressMap: {
86
- ethereum_sepolia: "0x1A0a58aF331Cc792Db92CFD9fE5E3124639E2a80"
87
- },
88
93
  isTestnet: true
89
94
  },
90
95
  staging: {
91
96
  backendUrl: "https://api-stg.bitdex.xyz",
92
97
  rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
93
98
  protocolFetcherProxyAddress: "0x7c07151ca4DFd93F352Ab9B132A95866697c38c2",
94
- paymentAddressMap: {
95
- ethereum_sepolia: "0x7387DcCfE2f1D5F80b4ECDF91eF58541517e90D2"
96
- },
97
- liquidationAddressMap: {
98
- ethereum_sepolia: "0x1CcD45Be1508E70d760b11b32ccd5Ac288756b1a"
99
- },
100
99
  isTestnet: true
101
100
  },
102
101
  prelive: {
103
102
  backendUrl: "https://pre-api.optimex.xyz",
104
103
  rpcUrl: "https://rpc.optimex.xyz",
105
104
  protocolFetcherProxyAddress: "0xFDEd4CEf9aE1E03D0BeF161262a266c1c157a32b",
106
- paymentAddressMap: {
107
- ethereum: "0x0A497AC4261E37FA4062762C23Cf3cB642C839b8"
108
- },
109
- liquidationAddressMap: {
110
- ethereum_sepolia: "0x1CcD45Be1508E70d760b11b32ccd5Ac288756b1a"
111
- },
112
105
  isTestnet: false
113
106
  },
114
107
  production: {
115
108
  backendUrl: "https://api.optimex.xyz",
116
109
  rpcUrl: "https://rpc.optimex.xyz",
117
110
  protocolFetcherProxyAddress: "0xFDEd4CEf9aE1E03D0BeF161262a266c1c157a32b",
118
- paymentAddressMap: {
119
- ethereum: "0x0A497AC4261E37FA4062762C23Cf3cB642C839b8"
120
- },
121
- liquidationAddressMap: {
122
- ethereum_sepolia: "0x1CcD45Be1508E70d760b11b32ccd5Ac288756b1a"
123
- },
124
111
  isTestnet: false
125
112
  }
126
113
  };
@@ -173,12 +160,6 @@ var Config = class {
173
160
  getRpcUrl() {
174
161
  return this.config.rpcUrl;
175
162
  }
176
- getPaymentAddress(networkId) {
177
- return this.config.paymentAddressMap[networkId];
178
- }
179
- getLiquidationAddress(networkId) {
180
- return this.config.liquidationAddressMap[networkId];
181
- }
182
163
  getProtocolFetcherAddress() {
183
164
  return this.config.protocolFetcherProxyAddress;
184
165
  }
@@ -2475,6 +2456,27 @@ var _abi4 = [
2475
2456
  stateMutability: "nonpayable",
2476
2457
  type: "constructor"
2477
2458
  },
2459
+ {
2460
+ inputs: [],
2461
+ name: "AccessControlBadConfirmation",
2462
+ type: "error"
2463
+ },
2464
+ {
2465
+ inputs: [
2466
+ {
2467
+ internalType: "address",
2468
+ name: "account",
2469
+ type: "address"
2470
+ },
2471
+ {
2472
+ internalType: "bytes32",
2473
+ name: "neededRole",
2474
+ type: "bytes32"
2475
+ }
2476
+ ],
2477
+ name: "AccessControlUnauthorizedAccount",
2478
+ type: "error"
2479
+ },
2478
2480
  {
2479
2481
  inputs: [],
2480
2482
  name: "AddressZero",
@@ -2485,6 +2487,94 @@ var _abi4 = [
2485
2487
  name: "Unauthorized",
2486
2488
  type: "error"
2487
2489
  },
2490
+ {
2491
+ anonymous: false,
2492
+ inputs: [
2493
+ {
2494
+ indexed: true,
2495
+ internalType: "bytes32",
2496
+ name: "role",
2497
+ type: "bytes32"
2498
+ },
2499
+ {
2500
+ indexed: true,
2501
+ internalType: "bytes32",
2502
+ name: "previousAdminRole",
2503
+ type: "bytes32"
2504
+ },
2505
+ {
2506
+ indexed: true,
2507
+ internalType: "bytes32",
2508
+ name: "newAdminRole",
2509
+ type: "bytes32"
2510
+ }
2511
+ ],
2512
+ name: "RoleAdminChanged",
2513
+ type: "event"
2514
+ },
2515
+ {
2516
+ anonymous: false,
2517
+ inputs: [
2518
+ {
2519
+ indexed: true,
2520
+ internalType: "bytes32",
2521
+ name: "role",
2522
+ type: "bytes32"
2523
+ },
2524
+ {
2525
+ indexed: true,
2526
+ internalType: "address",
2527
+ name: "account",
2528
+ type: "address"
2529
+ },
2530
+ {
2531
+ indexed: true,
2532
+ internalType: "address",
2533
+ name: "sender",
2534
+ type: "address"
2535
+ }
2536
+ ],
2537
+ name: "RoleGranted",
2538
+ type: "event"
2539
+ },
2540
+ {
2541
+ anonymous: false,
2542
+ inputs: [
2543
+ {
2544
+ indexed: true,
2545
+ internalType: "bytes32",
2546
+ name: "role",
2547
+ type: "bytes32"
2548
+ },
2549
+ {
2550
+ indexed: true,
2551
+ internalType: "address",
2552
+ name: "account",
2553
+ type: "address"
2554
+ },
2555
+ {
2556
+ indexed: true,
2557
+ internalType: "address",
2558
+ name: "sender",
2559
+ type: "address"
2560
+ }
2561
+ ],
2562
+ name: "RoleRevoked",
2563
+ type: "event"
2564
+ },
2565
+ {
2566
+ inputs: [],
2567
+ name: "DEFAULT_ADMIN_ROLE",
2568
+ outputs: [
2569
+ {
2570
+ internalType: "bytes32",
2571
+ name: "",
2572
+ type: "bytes32"
2573
+ }
2574
+ ],
2575
+ stateMutability: "view",
2576
+ type: "function"
2577
+ },
2488
2578
  {
2489
2579
  inputs: [
2490
2580
  {
@@ -2646,6 +2736,87 @@ var _abi4 = [
2646
2736
  stateMutability: "view",
2647
2737
  type: "function"
2648
2738
  },
2739
+ {
2740
+ inputs: [
2741
+ {
2742
+ internalType: "bytes32",
2743
+ name: "role",
2744
+ type: "bytes32"
2745
+ }
2746
+ ],
2747
+ name: "getRoleAdmin",
2748
+ outputs: [
2749
+ {
2750
+ internalType: "bytes32",
2751
+ name: "",
2752
+ type: "bytes32"
2753
+ }
2754
+ ],
2755
+ stateMutability: "view",
2756
+ type: "function"
2757
+ },
2758
+ {
2759
+ inputs: [
2760
+ {
2761
+ internalType: "bytes32",
2762
+ name: "role",
2763
+ type: "bytes32"
2764
+ },
2765
+ {
2766
+ internalType: "uint256",
2767
+ name: "index",
2768
+ type: "uint256"
2769
+ }
2770
+ ],
2771
+ name: "getRoleMember",
2772
+ outputs: [
2773
+ {
2774
+ internalType: "address",
2775
+ name: "",
2776
+ type: "address"
2777
+ }
2778
+ ],
2779
+ stateMutability: "view",
2780
+ type: "function"
2781
+ },
2782
+ {
2783
+ inputs: [
2784
+ {
2785
+ internalType: "bytes32",
2786
+ name: "role",
2787
+ type: "bytes32"
2788
+ }
2789
+ ],
2790
+ name: "getRoleMemberCount",
2791
+ outputs: [
2792
+ {
2793
+ internalType: "uint256",
2794
+ name: "",
2795
+ type: "uint256"
2796
+ }
2797
+ ],
2798
+ stateMutability: "view",
2799
+ type: "function"
2800
+ },
2801
+ {
2802
+ inputs: [
2803
+ {
2804
+ internalType: "bytes32",
2805
+ name: "role",
2806
+ type: "bytes32"
2807
+ }
2808
+ ],
2809
+ name: "getRoleMembers",
2810
+ outputs: [
2811
+ {
2812
+ internalType: "address[]",
2813
+ name: "",
2814
+ type: "address[]"
2815
+ }
2816
+ ],
2817
+ stateMutability: "view",
2818
+ type: "function"
2819
+ },
2649
2820
  {
2650
2821
  inputs: [
2651
2822
  {
@@ -2706,6 +2877,48 @@ var _abi4 = [
2706
2877
  stateMutability: "view",
2707
2878
  type: "function"
2708
2879
  },
2880
+ {
2881
+ inputs: [
2882
+ {
2883
+ internalType: "bytes32",
2884
+ name: "role",
2885
+ type: "bytes32"
2886
+ },
2887
+ {
2888
+ internalType: "address",
2889
+ name: "account",
2890
+ type: "address"
2891
+ }
2892
+ ],
2893
+ name: "grantRole",
2894
+ outputs: [],
2895
+ stateMutability: "nonpayable",
2896
+ type: "function"
2897
+ },
2898
+ {
2899
+ inputs: [
2900
+ {
2901
+ internalType: "bytes32",
2902
+ name: "role",
2903
+ type: "bytes32"
2904
+ },
2905
+ {
2906
+ internalType: "address",
2907
+ name: "account",
2908
+ type: "address"
2909
+ }
2910
+ ],
2911
+ name: "hasRole",
2912
+ outputs: [
2913
+ {
2914
+ internalType: "bool",
2915
+ name: "",
2916
+ type: "bool"
2917
+ }
2918
+ ],
2919
+ stateMutability: "view",
2920
+ type: "function"
2921
+ },
2709
2922
  {
2710
2923
  inputs: [
2711
2924
  {
@@ -2912,6 +3125,42 @@ var _abi4 = [
2912
3125
  stateMutability: "view",
2913
3126
  type: "function"
2914
3127
  },
3128
+ {
3129
+ inputs: [
3130
+ {
3131
+ internalType: "bytes32",
3132
+ name: "role",
3133
+ type: "bytes32"
3134
+ },
3135
+ {
3136
+ internalType: "address",
3137
+ name: "callerConfirmation",
3138
+ type: "address"
3139
+ }
3140
+ ],
3141
+ name: "renounceRole",
3142
+ outputs: [],
3143
+ stateMutability: "nonpayable",
3144
+ type: "function"
3145
+ },
3146
+ {
3147
+ inputs: [
3148
+ {
3149
+ internalType: "bytes32",
3150
+ name: "role",
3151
+ type: "bytes32"
3152
+ },
3153
+ {
3154
+ internalType: "address",
3155
+ name: "account",
3156
+ type: "address"
3157
+ }
3158
+ ],
3159
+ name: "revokeRole",
3160
+ outputs: [],
3161
+ stateMutability: "nonpayable",
3162
+ type: "function"
3163
+ },
2915
3164
  {
2916
3165
  inputs: [],
2917
3166
  name: "router",
@@ -2989,6 +3238,25 @@ var _abi4 = [
2989
3238
  ],
2990
3239
  stateMutability: "view",
2991
3240
  type: "function"
3241
+ },
3242
+ {
3243
+ inputs: [
3244
+ {
3245
+ internalType: "bytes4",
3246
+ name: "interfaceId",
3247
+ type: "bytes4"
3248
+ }
3249
+ ],
3250
+ name: "supportsInterface",
3251
+ outputs: [
3252
+ {
3253
+ internalType: "bool",
3254
+ name: "",
3255
+ type: "bool"
3256
+ }
3257
+ ],
3258
+ stateMutability: "view",
3259
+ type: "function"
2992
3260
  }
2993
3261
  ];
2994
3262
  var ProtocolFetcherProxy__factory = class {
@@ -4854,10 +5122,75 @@ Signer__factory.abi = _abi6;
4854
5122
 
4855
5123
  // src/services/protocol.service.ts
4856
5124
  var import_ethers7 = require("ethers");
5125
+
5126
+ // src/shared/network.ts
5127
+ var OptimexEvmNetwork = /* @__PURE__ */ ((OptimexEvmNetwork3) => {
5128
+ OptimexEvmNetwork3["EthereumSepolia"] = "ethereum_sepolia";
5129
+ OptimexEvmNetwork3["EthereumMainnet"] = "ethereum";
5130
+ OptimexEvmNetwork3["BaseTestnet"] = "base_sepolia";
5131
+ OptimexEvmNetwork3["BaseMainnet"] = "base";
5132
+ OptimexEvmNetwork3["ArbitrumSepolia"] = "arbitrum_sepolia";
5133
+ OptimexEvmNetwork3["Arbitrum"] = "arbitrum";
5134
+ OptimexEvmNetwork3["OptimismSepolia"] = "optimism_sepolia";
5135
+ OptimexEvmNetwork3["Optimism"] = "optimism";
5136
+ OptimexEvmNetwork3["BSC"] = "bsc";
5137
+ return OptimexEvmNetwork3;
5138
+ })(OptimexEvmNetwork || {});
5139
+ var OptimexL2Network = /* @__PURE__ */ ((OptimexL2Network2) => {
5140
+ OptimexL2Network2["Testnet"] = "optimex_testnet";
5141
+ OptimexL2Network2["Mainnet"] = "optimex";
5142
+ return OptimexL2Network2;
5143
+ })(OptimexL2Network || {});
5144
+ var OptimexBtcNetwork = /* @__PURE__ */ ((OptimexBtcNetwork2) => {
5145
+ OptimexBtcNetwork2["BitcoinTestnet"] = "bitcoin_testnet";
5146
+ OptimexBtcNetwork2["BitcoinMainnet"] = "bitcoin";
5147
+ return OptimexBtcNetwork2;
5148
+ })(OptimexBtcNetwork || {});
5149
+ var OptimexSolanaNetwork = /* @__PURE__ */ ((OptimexSolanaNetwork2) => {
5150
+ OptimexSolanaNetwork2["SolanaDevnet"] = "solana_devnet";
5151
+ OptimexSolanaNetwork2["SolanaMainnet"] = "solana";
5152
+ return OptimexSolanaNetwork2;
5153
+ })(OptimexSolanaNetwork || {});
5154
+ var OptimexLendingNetwork = /* @__PURE__ */ ((OptimexLendingNetwork2) => {
5155
+ OptimexLendingNetwork2["Morpho"] = "MORPHO";
5156
+ return OptimexLendingNetwork2;
5157
+ })(OptimexLendingNetwork || {});
5158
+ var isEvmNetwork = (network) => {
5159
+ return Object.values(OptimexEvmNetwork).includes(network);
5160
+ };
5161
+ var isBtcNetwork = (network) => {
5162
+ return Object.values(OptimexBtcNetwork).includes(network);
5163
+ };
5164
+ var isSolanaNetwork = (network) => {
5165
+ return Object.values(OptimexSolanaNetwork).includes(network);
5166
+ };
5167
+ var isL2Network = (network) => {
5168
+ return Object.values(OptimexL2Network).includes(network);
5169
+ };
5170
+
5171
+ // src/shared/role.ts
5172
+ var AssetChainContractRole = /* @__PURE__ */ ((AssetChainContractRole3) => {
5173
+ AssetChainContractRole3["AcrossTransitVault"] = "AcrossTransitVault";
5174
+ AssetChainContractRole3["Payment"] = "OptimexSwapPayment";
5175
+ AssetChainContractRole3["OptimexManagement"] = "OptimexManagement";
5176
+ AssetChainContractRole3["MorphoSupplier"] = "MorphoSupplier";
5177
+ AssetChainContractRole3["MorphoLiquidator"] = "MorphoLiquidator";
5178
+ AssetChainContractRole3["MorphoManagement"] = "MorphoManagement";
5179
+ return AssetChainContractRole3;
5180
+ })(AssetChainContractRole || {});
5181
+ var L2ContractRole = /* @__PURE__ */ ((L2ContractRole3) => {
5182
+ L2ContractRole3["MorphoAdapter"] = "MorphoAdapter";
5183
+ L2ContractRole3["MorphoMarketRegistry"] = "MorphoMarketRegistry";
5184
+ L2ContractRole3["AcrossRefund"] = "AcrossRefund";
5185
+ return L2ContractRole3;
5186
+ })(L2ContractRole || {});
5187
+
5188
+ // src/services/protocol.service.ts
4857
5189
  var ProtocolService = class {
4858
5190
  constructor() {
4859
5191
  this.provider = new import_ethers7.JsonRpcProvider(config.getRpcUrl());
4860
5192
  this.contract = ProtocolFetcherProxy__factory.connect(config.getProtocolFetcherAddress(), this.provider);
5193
+ this.l2Network = config.isTestnet() ? "optimex_testnet" /* Testnet */ : "optimex" /* Mainnet */;
4861
5194
  config.registerObserver(this);
4862
5195
  }
4863
5196
  /**
@@ -4867,6 +5200,7 @@ var ProtocolService = class {
4867
5200
  onConfigUpdate(newConfig) {
4868
5201
  this.provider = new import_ethers7.JsonRpcProvider(newConfig.rpcUrl);
4869
5202
  this.contract = ProtocolFetcherProxy__factory.connect(newConfig.protocolFetcherProxyAddress, this.provider);
5203
+ this.l2Network = newConfig.isTestnet ? "optimex_testnet" /* Testnet */ : "optimex" /* Mainnet */;
4870
5204
  }
4871
5205
  async getCurrentPubkey(network) {
4872
5206
  return this.contract.getLatestMPCInfo(import_ethers7.ethers.toUtf8Bytes(network));
@@ -4888,6 +5222,14 @@ var ProtocolService = class {
4888
5222
  async getRouter() {
4889
5223
  return this.contract.router();
4890
5224
  }
5225
+ async getAssetChainConfig(network, role) {
5226
+ const hashRole = (0, import_ethers7.keccak256)((0, import_ethers7.toUtf8Bytes)([network, role].join(":")));
5227
+ return this.contract.getRoleMembers(hashRole);
5228
+ }
5229
+ async getL2Config(role) {
5230
+ const hashRole = (0, import_ethers7.keccak256)((0, import_ethers7.toUtf8Bytes)([this.l2Network, role].join(":")));
5231
+ return this.contract.getRoleMembers(hashRole);
5232
+ }
4891
5233
  };
4892
5234
  var protocolService = new ProtocolService();
4893
5235
 
@@ -5410,8 +5752,15 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
5410
5752
  }
5411
5753
  // Annotate the CommonJS export names for ESM import in node:
5412
5754
  0 && (module.exports = {
5755
+ AssetChainContractRole,
5413
5756
  ERC20__factory,
5757
+ L2ContractRole,
5414
5758
  MorphoLiquidator__factory,
5759
+ OptimexBtcNetwork,
5760
+ OptimexEvmNetwork,
5761
+ OptimexL2Network,
5762
+ OptimexLendingNetwork,
5763
+ OptimexSolanaNetwork,
5415
5764
  Payment__factory,
5416
5765
  ProtocolFetcherProxy__factory,
5417
5766
  ProtocolService,
@@ -5438,6 +5787,10 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
5438
5787
  getSignature,
5439
5788
  getSigner,
5440
5789
  getTradeIdsHash,
5790
+ isBtcNetwork,
5791
+ isEvmNetwork,
5792
+ isL2Network,
5793
+ isSolanaNetwork,
5441
5794
  makePaymentType,
5442
5795
  presignType,
5443
5796
  protocolService,