@optimex-xyz/market-maker-sdk 0.9.0-dev-896c690 → 0.9.0-dev-d2e92dd

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
+ ContractRole: () => ContractRole,
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: "0x2AEDAF2470EfFD35B295D710fB2e5FDAdE642B0A"
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,71 @@ 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 ContractRole = /* @__PURE__ */ ((ContractRole3) => {
5173
+ ContractRole3["AcrossTransitVault"] = "AcrossTransitVault";
5174
+ ContractRole3["Payment"] = "OptimexSwapPayment";
5175
+ return ContractRole3;
5176
+ })(ContractRole || {});
5177
+ var L2ContractRole = /* @__PURE__ */ ((L2ContractRole3) => {
5178
+ L2ContractRole3["MorphoAdapter"] = "MorphoAdapter";
5179
+ L2ContractRole3["MorphoMarketRegistry"] = "MorphoMarketRegistry";
5180
+ L2ContractRole3["AcrossRefund"] = "AcrossRefund";
5181
+ return L2ContractRole3;
5182
+ })(L2ContractRole || {});
5183
+
5184
+ // src/services/protocol.service.ts
4857
5185
  var ProtocolService = class {
4858
5186
  constructor() {
4859
5187
  this.provider = new import_ethers7.JsonRpcProvider(config.getRpcUrl());
4860
5188
  this.contract = ProtocolFetcherProxy__factory.connect(config.getProtocolFetcherAddress(), this.provider);
5189
+ this.l2Network = config.isTestnet() ? "optimex_testnet" /* Testnet */ : "optimex" /* Mainnet */;
4861
5190
  config.registerObserver(this);
4862
5191
  }
4863
5192
  /**
@@ -4867,6 +5196,7 @@ var ProtocolService = class {
4867
5196
  onConfigUpdate(newConfig) {
4868
5197
  this.provider = new import_ethers7.JsonRpcProvider(newConfig.rpcUrl);
4869
5198
  this.contract = ProtocolFetcherProxy__factory.connect(newConfig.protocolFetcherProxyAddress, this.provider);
5199
+ this.l2Network = newConfig.isTestnet ? "optimex_testnet" /* Testnet */ : "optimex" /* Mainnet */;
4870
5200
  }
4871
5201
  async getCurrentPubkey(network) {
4872
5202
  return this.contract.getLatestMPCInfo(import_ethers7.ethers.toUtf8Bytes(network));
@@ -4888,6 +5218,14 @@ var ProtocolService = class {
4888
5218
  async getRouter() {
4889
5219
  return this.contract.router();
4890
5220
  }
5221
+ async getAssetChainConfig(network, role) {
5222
+ const hashRole = (0, import_ethers7.keccak256)((0, import_ethers7.toUtf8Bytes)([network, role].join(":")));
5223
+ return this.contract.getRoleMembers(hashRole);
5224
+ }
5225
+ async getL2Config(role) {
5226
+ const hashRole = (0, import_ethers7.keccak256)((0, import_ethers7.toUtf8Bytes)([this.l2Network, role].join(":")));
5227
+ return this.contract.getRoleMembers(hashRole);
5228
+ }
4891
5229
  };
4892
5230
  var protocolService = new ProtocolService();
4893
5231
 
@@ -5410,8 +5748,15 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
5410
5748
  }
5411
5749
  // Annotate the CommonJS export names for ESM import in node:
5412
5750
  0 && (module.exports = {
5751
+ ContractRole,
5413
5752
  ERC20__factory,
5753
+ L2ContractRole,
5414
5754
  MorphoLiquidator__factory,
5755
+ OptimexBtcNetwork,
5756
+ OptimexEvmNetwork,
5757
+ OptimexL2Network,
5758
+ OptimexLendingNetwork,
5759
+ OptimexSolanaNetwork,
5415
5760
  Payment__factory,
5416
5761
  ProtocolFetcherProxy__factory,
5417
5762
  ProtocolService,
@@ -5438,6 +5783,10 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
5438
5783
  getSignature,
5439
5784
  getSigner,
5440
5785
  getTradeIdsHash,
5786
+ isBtcNetwork,
5787
+ isEvmNetwork,
5788
+ isL2Network,
5789
+ isSolanaNetwork,
5441
5790
  makePaymentType,
5442
5791
  presignType,
5443
5792
  protocolService,