@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.d.mts +433 -7
- package/dist/index.d.ts +433 -7
- package/dist/index.js +383 -30
- package/dist/index.mjs +378 -36
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10,48 +10,24 @@ var environments = {
|
|
|
10
10
|
backendUrl: "https://api-dev.bitdex.xyz",
|
|
11
11
|
rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
|
|
12
12
|
protocolFetcherProxyAddress: "0x0267Fc04eE866b31907dEe123aBdCdB67d03B297",
|
|
13
|
-
paymentAddressMap: {
|
|
14
|
-
ethereum_sepolia: "0x1d8b58438D5Ccc8Fcb4b738C89078f7b4168C9c0"
|
|
15
|
-
},
|
|
16
|
-
liquidationAddressMap: {
|
|
17
|
-
ethereum_sepolia: "0x1A0a58aF331Cc792Db92CFD9fE5E3124639E2a80"
|
|
18
|
-
},
|
|
19
13
|
isTestnet: true
|
|
20
14
|
},
|
|
21
15
|
staging: {
|
|
22
16
|
backendUrl: "https://api-stg.bitdex.xyz",
|
|
23
17
|
rpcUrl: "https://rpc-bitfi-p00c4t1rul.t.conduit.xyz",
|
|
24
18
|
protocolFetcherProxyAddress: "0x7c07151ca4DFd93F352Ab9B132A95866697c38c2",
|
|
25
|
-
paymentAddressMap: {
|
|
26
|
-
ethereum_sepolia: "0x7387DcCfE2f1D5F80b4ECDF91eF58541517e90D2"
|
|
27
|
-
},
|
|
28
|
-
liquidationAddressMap: {
|
|
29
|
-
ethereum_sepolia: "0x1CcD45Be1508E70d760b11b32ccd5Ac288756b1a"
|
|
30
|
-
},
|
|
31
19
|
isTestnet: true
|
|
32
20
|
},
|
|
33
21
|
prelive: {
|
|
34
22
|
backendUrl: "https://pre-api.optimex.xyz",
|
|
35
23
|
rpcUrl: "https://rpc.optimex.xyz",
|
|
36
24
|
protocolFetcherProxyAddress: "0xFDEd4CEf9aE1E03D0BeF161262a266c1c157a32b",
|
|
37
|
-
paymentAddressMap: {
|
|
38
|
-
ethereum: "0x0A497AC4261E37FA4062762C23Cf3cB642C839b8"
|
|
39
|
-
},
|
|
40
|
-
liquidationAddressMap: {
|
|
41
|
-
ethereum_sepolia: "0x1CcD45Be1508E70d760b11b32ccd5Ac288756b1a"
|
|
42
|
-
},
|
|
43
25
|
isTestnet: false
|
|
44
26
|
},
|
|
45
27
|
production: {
|
|
46
28
|
backendUrl: "https://api.optimex.xyz",
|
|
47
29
|
rpcUrl: "https://rpc.optimex.xyz",
|
|
48
30
|
protocolFetcherProxyAddress: "0xFDEd4CEf9aE1E03D0BeF161262a266c1c157a32b",
|
|
49
|
-
paymentAddressMap: {
|
|
50
|
-
ethereum: "0x0A497AC4261E37FA4062762C23Cf3cB642C839b8"
|
|
51
|
-
},
|
|
52
|
-
liquidationAddressMap: {
|
|
53
|
-
ethereum_sepolia: "0x1CcD45Be1508E70d760b11b32ccd5Ac288756b1a"
|
|
54
|
-
},
|
|
55
31
|
isTestnet: false
|
|
56
32
|
}
|
|
57
33
|
};
|
|
@@ -104,12 +80,6 @@ var Config = class {
|
|
|
104
80
|
getRpcUrl() {
|
|
105
81
|
return this.config.rpcUrl;
|
|
106
82
|
}
|
|
107
|
-
getPaymentAddress(networkId) {
|
|
108
|
-
return this.config.paymentAddressMap[networkId];
|
|
109
|
-
}
|
|
110
|
-
getLiquidationAddress(networkId) {
|
|
111
|
-
return this.config.liquidationAddressMap[networkId];
|
|
112
|
-
}
|
|
113
83
|
getProtocolFetcherAddress() {
|
|
114
84
|
return this.config.protocolFetcherProxyAddress;
|
|
115
85
|
}
|
|
@@ -2406,6 +2376,27 @@ var _abi4 = [
|
|
|
2406
2376
|
stateMutability: "nonpayable",
|
|
2407
2377
|
type: "constructor"
|
|
2408
2378
|
},
|
|
2379
|
+
{
|
|
2380
|
+
inputs: [],
|
|
2381
|
+
name: "AccessControlBadConfirmation",
|
|
2382
|
+
type: "error"
|
|
2383
|
+
},
|
|
2384
|
+
{
|
|
2385
|
+
inputs: [
|
|
2386
|
+
{
|
|
2387
|
+
internalType: "address",
|
|
2388
|
+
name: "account",
|
|
2389
|
+
type: "address"
|
|
2390
|
+
},
|
|
2391
|
+
{
|
|
2392
|
+
internalType: "bytes32",
|
|
2393
|
+
name: "neededRole",
|
|
2394
|
+
type: "bytes32"
|
|
2395
|
+
}
|
|
2396
|
+
],
|
|
2397
|
+
name: "AccessControlUnauthorizedAccount",
|
|
2398
|
+
type: "error"
|
|
2399
|
+
},
|
|
2409
2400
|
{
|
|
2410
2401
|
inputs: [],
|
|
2411
2402
|
name: "AddressZero",
|
|
@@ -2416,6 +2407,94 @@ var _abi4 = [
|
|
|
2416
2407
|
name: "Unauthorized",
|
|
2417
2408
|
type: "error"
|
|
2418
2409
|
},
|
|
2410
|
+
{
|
|
2411
|
+
anonymous: false,
|
|
2412
|
+
inputs: [
|
|
2413
|
+
{
|
|
2414
|
+
indexed: true,
|
|
2415
|
+
internalType: "bytes32",
|
|
2416
|
+
name: "role",
|
|
2417
|
+
type: "bytes32"
|
|
2418
|
+
},
|
|
2419
|
+
{
|
|
2420
|
+
indexed: true,
|
|
2421
|
+
internalType: "bytes32",
|
|
2422
|
+
name: "previousAdminRole",
|
|
2423
|
+
type: "bytes32"
|
|
2424
|
+
},
|
|
2425
|
+
{
|
|
2426
|
+
indexed: true,
|
|
2427
|
+
internalType: "bytes32",
|
|
2428
|
+
name: "newAdminRole",
|
|
2429
|
+
type: "bytes32"
|
|
2430
|
+
}
|
|
2431
|
+
],
|
|
2432
|
+
name: "RoleAdminChanged",
|
|
2433
|
+
type: "event"
|
|
2434
|
+
},
|
|
2435
|
+
{
|
|
2436
|
+
anonymous: false,
|
|
2437
|
+
inputs: [
|
|
2438
|
+
{
|
|
2439
|
+
indexed: true,
|
|
2440
|
+
internalType: "bytes32",
|
|
2441
|
+
name: "role",
|
|
2442
|
+
type: "bytes32"
|
|
2443
|
+
},
|
|
2444
|
+
{
|
|
2445
|
+
indexed: true,
|
|
2446
|
+
internalType: "address",
|
|
2447
|
+
name: "account",
|
|
2448
|
+
type: "address"
|
|
2449
|
+
},
|
|
2450
|
+
{
|
|
2451
|
+
indexed: true,
|
|
2452
|
+
internalType: "address",
|
|
2453
|
+
name: "sender",
|
|
2454
|
+
type: "address"
|
|
2455
|
+
}
|
|
2456
|
+
],
|
|
2457
|
+
name: "RoleGranted",
|
|
2458
|
+
type: "event"
|
|
2459
|
+
},
|
|
2460
|
+
{
|
|
2461
|
+
anonymous: false,
|
|
2462
|
+
inputs: [
|
|
2463
|
+
{
|
|
2464
|
+
indexed: true,
|
|
2465
|
+
internalType: "bytes32",
|
|
2466
|
+
name: "role",
|
|
2467
|
+
type: "bytes32"
|
|
2468
|
+
},
|
|
2469
|
+
{
|
|
2470
|
+
indexed: true,
|
|
2471
|
+
internalType: "address",
|
|
2472
|
+
name: "account",
|
|
2473
|
+
type: "address"
|
|
2474
|
+
},
|
|
2475
|
+
{
|
|
2476
|
+
indexed: true,
|
|
2477
|
+
internalType: "address",
|
|
2478
|
+
name: "sender",
|
|
2479
|
+
type: "address"
|
|
2480
|
+
}
|
|
2481
|
+
],
|
|
2482
|
+
name: "RoleRevoked",
|
|
2483
|
+
type: "event"
|
|
2484
|
+
},
|
|
2485
|
+
{
|
|
2486
|
+
inputs: [],
|
|
2487
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
2488
|
+
outputs: [
|
|
2489
|
+
{
|
|
2490
|
+
internalType: "bytes32",
|
|
2491
|
+
name: "",
|
|
2492
|
+
type: "bytes32"
|
|
2493
|
+
}
|
|
2494
|
+
],
|
|
2495
|
+
stateMutability: "view",
|
|
2496
|
+
type: "function"
|
|
2497
|
+
},
|
|
2419
2498
|
{
|
|
2420
2499
|
inputs: [
|
|
2421
2500
|
{
|
|
@@ -2577,6 +2656,87 @@ var _abi4 = [
|
|
|
2577
2656
|
stateMutability: "view",
|
|
2578
2657
|
type: "function"
|
|
2579
2658
|
},
|
|
2659
|
+
{
|
|
2660
|
+
inputs: [
|
|
2661
|
+
{
|
|
2662
|
+
internalType: "bytes32",
|
|
2663
|
+
name: "role",
|
|
2664
|
+
type: "bytes32"
|
|
2665
|
+
}
|
|
2666
|
+
],
|
|
2667
|
+
name: "getRoleAdmin",
|
|
2668
|
+
outputs: [
|
|
2669
|
+
{
|
|
2670
|
+
internalType: "bytes32",
|
|
2671
|
+
name: "",
|
|
2672
|
+
type: "bytes32"
|
|
2673
|
+
}
|
|
2674
|
+
],
|
|
2675
|
+
stateMutability: "view",
|
|
2676
|
+
type: "function"
|
|
2677
|
+
},
|
|
2678
|
+
{
|
|
2679
|
+
inputs: [
|
|
2680
|
+
{
|
|
2681
|
+
internalType: "bytes32",
|
|
2682
|
+
name: "role",
|
|
2683
|
+
type: "bytes32"
|
|
2684
|
+
},
|
|
2685
|
+
{
|
|
2686
|
+
internalType: "uint256",
|
|
2687
|
+
name: "index",
|
|
2688
|
+
type: "uint256"
|
|
2689
|
+
}
|
|
2690
|
+
],
|
|
2691
|
+
name: "getRoleMember",
|
|
2692
|
+
outputs: [
|
|
2693
|
+
{
|
|
2694
|
+
internalType: "address",
|
|
2695
|
+
name: "",
|
|
2696
|
+
type: "address"
|
|
2697
|
+
}
|
|
2698
|
+
],
|
|
2699
|
+
stateMutability: "view",
|
|
2700
|
+
type: "function"
|
|
2701
|
+
},
|
|
2702
|
+
{
|
|
2703
|
+
inputs: [
|
|
2704
|
+
{
|
|
2705
|
+
internalType: "bytes32",
|
|
2706
|
+
name: "role",
|
|
2707
|
+
type: "bytes32"
|
|
2708
|
+
}
|
|
2709
|
+
],
|
|
2710
|
+
name: "getRoleMemberCount",
|
|
2711
|
+
outputs: [
|
|
2712
|
+
{
|
|
2713
|
+
internalType: "uint256",
|
|
2714
|
+
name: "",
|
|
2715
|
+
type: "uint256"
|
|
2716
|
+
}
|
|
2717
|
+
],
|
|
2718
|
+
stateMutability: "view",
|
|
2719
|
+
type: "function"
|
|
2720
|
+
},
|
|
2721
|
+
{
|
|
2722
|
+
inputs: [
|
|
2723
|
+
{
|
|
2724
|
+
internalType: "bytes32",
|
|
2725
|
+
name: "role",
|
|
2726
|
+
type: "bytes32"
|
|
2727
|
+
}
|
|
2728
|
+
],
|
|
2729
|
+
name: "getRoleMembers",
|
|
2730
|
+
outputs: [
|
|
2731
|
+
{
|
|
2732
|
+
internalType: "address[]",
|
|
2733
|
+
name: "",
|
|
2734
|
+
type: "address[]"
|
|
2735
|
+
}
|
|
2736
|
+
],
|
|
2737
|
+
stateMutability: "view",
|
|
2738
|
+
type: "function"
|
|
2739
|
+
},
|
|
2580
2740
|
{
|
|
2581
2741
|
inputs: [
|
|
2582
2742
|
{
|
|
@@ -2637,6 +2797,48 @@ var _abi4 = [
|
|
|
2637
2797
|
stateMutability: "view",
|
|
2638
2798
|
type: "function"
|
|
2639
2799
|
},
|
|
2800
|
+
{
|
|
2801
|
+
inputs: [
|
|
2802
|
+
{
|
|
2803
|
+
internalType: "bytes32",
|
|
2804
|
+
name: "role",
|
|
2805
|
+
type: "bytes32"
|
|
2806
|
+
},
|
|
2807
|
+
{
|
|
2808
|
+
internalType: "address",
|
|
2809
|
+
name: "account",
|
|
2810
|
+
type: "address"
|
|
2811
|
+
}
|
|
2812
|
+
],
|
|
2813
|
+
name: "grantRole",
|
|
2814
|
+
outputs: [],
|
|
2815
|
+
stateMutability: "nonpayable",
|
|
2816
|
+
type: "function"
|
|
2817
|
+
},
|
|
2818
|
+
{
|
|
2819
|
+
inputs: [
|
|
2820
|
+
{
|
|
2821
|
+
internalType: "bytes32",
|
|
2822
|
+
name: "role",
|
|
2823
|
+
type: "bytes32"
|
|
2824
|
+
},
|
|
2825
|
+
{
|
|
2826
|
+
internalType: "address",
|
|
2827
|
+
name: "account",
|
|
2828
|
+
type: "address"
|
|
2829
|
+
}
|
|
2830
|
+
],
|
|
2831
|
+
name: "hasRole",
|
|
2832
|
+
outputs: [
|
|
2833
|
+
{
|
|
2834
|
+
internalType: "bool",
|
|
2835
|
+
name: "",
|
|
2836
|
+
type: "bool"
|
|
2837
|
+
}
|
|
2838
|
+
],
|
|
2839
|
+
stateMutability: "view",
|
|
2840
|
+
type: "function"
|
|
2841
|
+
},
|
|
2640
2842
|
{
|
|
2641
2843
|
inputs: [
|
|
2642
2844
|
{
|
|
@@ -2843,6 +3045,42 @@ var _abi4 = [
|
|
|
2843
3045
|
stateMutability: "view",
|
|
2844
3046
|
type: "function"
|
|
2845
3047
|
},
|
|
3048
|
+
{
|
|
3049
|
+
inputs: [
|
|
3050
|
+
{
|
|
3051
|
+
internalType: "bytes32",
|
|
3052
|
+
name: "role",
|
|
3053
|
+
type: "bytes32"
|
|
3054
|
+
},
|
|
3055
|
+
{
|
|
3056
|
+
internalType: "address",
|
|
3057
|
+
name: "callerConfirmation",
|
|
3058
|
+
type: "address"
|
|
3059
|
+
}
|
|
3060
|
+
],
|
|
3061
|
+
name: "renounceRole",
|
|
3062
|
+
outputs: [],
|
|
3063
|
+
stateMutability: "nonpayable",
|
|
3064
|
+
type: "function"
|
|
3065
|
+
},
|
|
3066
|
+
{
|
|
3067
|
+
inputs: [
|
|
3068
|
+
{
|
|
3069
|
+
internalType: "bytes32",
|
|
3070
|
+
name: "role",
|
|
3071
|
+
type: "bytes32"
|
|
3072
|
+
},
|
|
3073
|
+
{
|
|
3074
|
+
internalType: "address",
|
|
3075
|
+
name: "account",
|
|
3076
|
+
type: "address"
|
|
3077
|
+
}
|
|
3078
|
+
],
|
|
3079
|
+
name: "revokeRole",
|
|
3080
|
+
outputs: [],
|
|
3081
|
+
stateMutability: "nonpayable",
|
|
3082
|
+
type: "function"
|
|
3083
|
+
},
|
|
2846
3084
|
{
|
|
2847
3085
|
inputs: [],
|
|
2848
3086
|
name: "router",
|
|
@@ -2920,6 +3158,25 @@ var _abi4 = [
|
|
|
2920
3158
|
],
|
|
2921
3159
|
stateMutability: "view",
|
|
2922
3160
|
type: "function"
|
|
3161
|
+
},
|
|
3162
|
+
{
|
|
3163
|
+
inputs: [
|
|
3164
|
+
{
|
|
3165
|
+
internalType: "bytes4",
|
|
3166
|
+
name: "interfaceId",
|
|
3167
|
+
type: "bytes4"
|
|
3168
|
+
}
|
|
3169
|
+
],
|
|
3170
|
+
name: "supportsInterface",
|
|
3171
|
+
outputs: [
|
|
3172
|
+
{
|
|
3173
|
+
internalType: "bool",
|
|
3174
|
+
name: "",
|
|
3175
|
+
type: "bool"
|
|
3176
|
+
}
|
|
3177
|
+
],
|
|
3178
|
+
stateMutability: "view",
|
|
3179
|
+
type: "function"
|
|
2923
3180
|
}
|
|
2924
3181
|
];
|
|
2925
3182
|
var ProtocolFetcherProxy__factory = class {
|
|
@@ -4784,11 +5041,76 @@ var Signer__factory = class {
|
|
|
4784
5041
|
Signer__factory.abi = _abi6;
|
|
4785
5042
|
|
|
4786
5043
|
// src/services/protocol.service.ts
|
|
4787
|
-
import { ethers, JsonRpcProvider } from "ethers";
|
|
5044
|
+
import { ethers, JsonRpcProvider, keccak256, toUtf8Bytes } from "ethers";
|
|
5045
|
+
|
|
5046
|
+
// src/shared/network.ts
|
|
5047
|
+
var OptimexEvmNetwork = /* @__PURE__ */ ((OptimexEvmNetwork3) => {
|
|
5048
|
+
OptimexEvmNetwork3["EthereumSepolia"] = "ethereum_sepolia";
|
|
5049
|
+
OptimexEvmNetwork3["EthereumMainnet"] = "ethereum";
|
|
5050
|
+
OptimexEvmNetwork3["BaseTestnet"] = "base_sepolia";
|
|
5051
|
+
OptimexEvmNetwork3["BaseMainnet"] = "base";
|
|
5052
|
+
OptimexEvmNetwork3["ArbitrumSepolia"] = "arbitrum_sepolia";
|
|
5053
|
+
OptimexEvmNetwork3["Arbitrum"] = "arbitrum";
|
|
5054
|
+
OptimexEvmNetwork3["OptimismSepolia"] = "optimism_sepolia";
|
|
5055
|
+
OptimexEvmNetwork3["Optimism"] = "optimism";
|
|
5056
|
+
OptimexEvmNetwork3["BSC"] = "bsc";
|
|
5057
|
+
return OptimexEvmNetwork3;
|
|
5058
|
+
})(OptimexEvmNetwork || {});
|
|
5059
|
+
var OptimexL2Network = /* @__PURE__ */ ((OptimexL2Network2) => {
|
|
5060
|
+
OptimexL2Network2["Testnet"] = "optimex_testnet";
|
|
5061
|
+
OptimexL2Network2["Mainnet"] = "optimex";
|
|
5062
|
+
return OptimexL2Network2;
|
|
5063
|
+
})(OptimexL2Network || {});
|
|
5064
|
+
var OptimexBtcNetwork = /* @__PURE__ */ ((OptimexBtcNetwork2) => {
|
|
5065
|
+
OptimexBtcNetwork2["BitcoinTestnet"] = "bitcoin_testnet";
|
|
5066
|
+
OptimexBtcNetwork2["BitcoinMainnet"] = "bitcoin";
|
|
5067
|
+
return OptimexBtcNetwork2;
|
|
5068
|
+
})(OptimexBtcNetwork || {});
|
|
5069
|
+
var OptimexSolanaNetwork = /* @__PURE__ */ ((OptimexSolanaNetwork2) => {
|
|
5070
|
+
OptimexSolanaNetwork2["SolanaDevnet"] = "solana_devnet";
|
|
5071
|
+
OptimexSolanaNetwork2["SolanaMainnet"] = "solana";
|
|
5072
|
+
return OptimexSolanaNetwork2;
|
|
5073
|
+
})(OptimexSolanaNetwork || {});
|
|
5074
|
+
var OptimexLendingNetwork = /* @__PURE__ */ ((OptimexLendingNetwork2) => {
|
|
5075
|
+
OptimexLendingNetwork2["Morpho"] = "MORPHO";
|
|
5076
|
+
return OptimexLendingNetwork2;
|
|
5077
|
+
})(OptimexLendingNetwork || {});
|
|
5078
|
+
var isEvmNetwork = (network) => {
|
|
5079
|
+
return Object.values(OptimexEvmNetwork).includes(network);
|
|
5080
|
+
};
|
|
5081
|
+
var isBtcNetwork = (network) => {
|
|
5082
|
+
return Object.values(OptimexBtcNetwork).includes(network);
|
|
5083
|
+
};
|
|
5084
|
+
var isSolanaNetwork = (network) => {
|
|
5085
|
+
return Object.values(OptimexSolanaNetwork).includes(network);
|
|
5086
|
+
};
|
|
5087
|
+
var isL2Network = (network) => {
|
|
5088
|
+
return Object.values(OptimexL2Network).includes(network);
|
|
5089
|
+
};
|
|
5090
|
+
|
|
5091
|
+
// src/shared/role.ts
|
|
5092
|
+
var AssetChainContractRole = /* @__PURE__ */ ((AssetChainContractRole3) => {
|
|
5093
|
+
AssetChainContractRole3["AcrossTransitVault"] = "AcrossTransitVault";
|
|
5094
|
+
AssetChainContractRole3["Payment"] = "OptimexSwapPayment";
|
|
5095
|
+
AssetChainContractRole3["OptimexManagement"] = "OptimexManagement";
|
|
5096
|
+
AssetChainContractRole3["MorphoSupplier"] = "MorphoSupplier";
|
|
5097
|
+
AssetChainContractRole3["MorphoLiquidator"] = "MorphoLiquidator";
|
|
5098
|
+
AssetChainContractRole3["MorphoManagement"] = "MorphoManagement";
|
|
5099
|
+
return AssetChainContractRole3;
|
|
5100
|
+
})(AssetChainContractRole || {});
|
|
5101
|
+
var L2ContractRole = /* @__PURE__ */ ((L2ContractRole3) => {
|
|
5102
|
+
L2ContractRole3["MorphoAdapter"] = "MorphoAdapter";
|
|
5103
|
+
L2ContractRole3["MorphoMarketRegistry"] = "MorphoMarketRegistry";
|
|
5104
|
+
L2ContractRole3["AcrossRefund"] = "AcrossRefund";
|
|
5105
|
+
return L2ContractRole3;
|
|
5106
|
+
})(L2ContractRole || {});
|
|
5107
|
+
|
|
5108
|
+
// src/services/protocol.service.ts
|
|
4788
5109
|
var ProtocolService = class {
|
|
4789
5110
|
constructor() {
|
|
4790
5111
|
this.provider = new JsonRpcProvider(config.getRpcUrl());
|
|
4791
5112
|
this.contract = ProtocolFetcherProxy__factory.connect(config.getProtocolFetcherAddress(), this.provider);
|
|
5113
|
+
this.l2Network = config.isTestnet() ? "optimex_testnet" /* Testnet */ : "optimex" /* Mainnet */;
|
|
4792
5114
|
config.registerObserver(this);
|
|
4793
5115
|
}
|
|
4794
5116
|
/**
|
|
@@ -4798,6 +5120,7 @@ var ProtocolService = class {
|
|
|
4798
5120
|
onConfigUpdate(newConfig) {
|
|
4799
5121
|
this.provider = new JsonRpcProvider(newConfig.rpcUrl);
|
|
4800
5122
|
this.contract = ProtocolFetcherProxy__factory.connect(newConfig.protocolFetcherProxyAddress, this.provider);
|
|
5123
|
+
this.l2Network = newConfig.isTestnet ? "optimex_testnet" /* Testnet */ : "optimex" /* Mainnet */;
|
|
4801
5124
|
}
|
|
4802
5125
|
async getCurrentPubkey(network) {
|
|
4803
5126
|
return this.contract.getLatestMPCInfo(ethers.toUtf8Bytes(network));
|
|
@@ -4819,6 +5142,14 @@ var ProtocolService = class {
|
|
|
4819
5142
|
async getRouter() {
|
|
4820
5143
|
return this.contract.router();
|
|
4821
5144
|
}
|
|
5145
|
+
async getAssetChainConfig(network, role) {
|
|
5146
|
+
const hashRole = keccak256(toUtf8Bytes([network, role].join(":")));
|
|
5147
|
+
return this.contract.getRoleMembers(hashRole);
|
|
5148
|
+
}
|
|
5149
|
+
async getL2Config(role) {
|
|
5150
|
+
const hashRole = keccak256(toUtf8Bytes([this.l2Network, role].join(":")));
|
|
5151
|
+
return this.contract.getRoleMembers(hashRole);
|
|
5152
|
+
}
|
|
4822
5153
|
};
|
|
4823
5154
|
var protocolService = new ProtocolService();
|
|
4824
5155
|
|
|
@@ -5240,20 +5571,20 @@ async function defaultDomain(signerHelper, provider) {
|
|
|
5240
5571
|
}
|
|
5241
5572
|
|
|
5242
5573
|
// src/signatures/getInfoHash.ts
|
|
5243
|
-
import { AbiCoder, keccak256 } from "ethers";
|
|
5574
|
+
import { AbiCoder, keccak256 as keccak2562 } from "ethers";
|
|
5244
5575
|
var abiCoder = AbiCoder.defaultAbiCoder();
|
|
5245
5576
|
function getTradeIdsHash(tradeIds) {
|
|
5246
|
-
return
|
|
5577
|
+
return keccak2562(abiCoder.encode(["bytes32[]"], [tradeIds]));
|
|
5247
5578
|
}
|
|
5248
5579
|
function getMakePaymentHash(tradeIds, signedAt, startIdx, paymentTxId) {
|
|
5249
|
-
const bundlerHash =
|
|
5250
|
-
const infoHash =
|
|
5580
|
+
const bundlerHash = keccak2562(abiCoder.encode(["bytes32[]"], [tradeIds]));
|
|
5581
|
+
const infoHash = keccak2562(
|
|
5251
5582
|
abiCoder.encode(["uint64", "uint256", "bytes32", "bytes"], [signedAt, startIdx, bundlerHash, paymentTxId])
|
|
5252
5583
|
);
|
|
5253
5584
|
return infoHash;
|
|
5254
5585
|
}
|
|
5255
5586
|
function getCommitInfoHash(pmmId, pmmRecvAddr, toChain, toToken, amountOut, expiry) {
|
|
5256
|
-
const infoHash =
|
|
5587
|
+
const infoHash = keccak2562(
|
|
5257
5588
|
abiCoder.encode(
|
|
5258
5589
|
["bytes32", "bytes", "bytes", "bytes", "uint256", "uint64"],
|
|
5259
5590
|
[pmmId, pmmRecvAddr, toChain, toToken, amountOut, expiry]
|
|
@@ -5340,8 +5671,15 @@ async function getSignature(Signer2, provider, signerHelper, tradeId, infoHash,
|
|
|
5340
5671
|
return await Signer2.signTypedData(domain ?? contractDomain, getSignatureType(type), values);
|
|
5341
5672
|
}
|
|
5342
5673
|
export {
|
|
5674
|
+
AssetChainContractRole,
|
|
5343
5675
|
ERC20__factory,
|
|
5676
|
+
L2ContractRole,
|
|
5344
5677
|
MorphoLiquidator__factory,
|
|
5678
|
+
OptimexBtcNetwork,
|
|
5679
|
+
OptimexEvmNetwork,
|
|
5680
|
+
OptimexL2Network,
|
|
5681
|
+
OptimexLendingNetwork,
|
|
5682
|
+
OptimexSolanaNetwork,
|
|
5345
5683
|
Payment__factory,
|
|
5346
5684
|
ProtocolFetcherProxy__factory,
|
|
5347
5685
|
ProtocolService,
|
|
@@ -5368,6 +5706,10 @@ export {
|
|
|
5368
5706
|
getSignature,
|
|
5369
5707
|
getSigner,
|
|
5370
5708
|
getTradeIdsHash,
|
|
5709
|
+
isBtcNetwork,
|
|
5710
|
+
isEvmNetwork,
|
|
5711
|
+
isL2Network,
|
|
5712
|
+
isSolanaNetwork,
|
|
5371
5713
|
makePaymentType,
|
|
5372
5714
|
presignType,
|
|
5373
5715
|
protocolService,
|