@atomiqlabs/sdk 1.3.12 → 1.3.14
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BtcToken, SCToken, Swapper, SwapperOptions } from "@atomiqlabs/sdk-lib";
|
|
1
|
+
import { BtcToken, MempoolApi, SCToken, Swapper, SwapperOptions } from "@atomiqlabs/sdk-lib";
|
|
2
2
|
import { SdkSolanaType } from "./chains/solana/SolanaChainInitializer";
|
|
3
3
|
import { SdkChain } from "./chains/ChainInitializer";
|
|
4
4
|
import * as BN from "bn.js";
|
|
@@ -21,6 +21,7 @@ export type MultichainSwapperOptions = SwapperOptions & {
|
|
|
21
21
|
} & {
|
|
22
22
|
storageCtor?: <T extends StorageObject>(name: string) => IStorageManager<T>;
|
|
23
23
|
pricingFeeDifferencePPM?: BN;
|
|
24
|
+
mempoolApi?: MempoolApi;
|
|
24
25
|
};
|
|
25
26
|
export declare class MultichainSwapper extends Swapper<SdkMultichain> {
|
|
26
27
|
constructor(options: MultichainSwapperOptions);
|
|
@@ -11,7 +11,7 @@ const Chains = {
|
|
|
11
11
|
};
|
|
12
12
|
class MultichainSwapper extends sdk_lib_1.Swapper {
|
|
13
13
|
constructor(options) {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
15
15
|
(_a = options.bitcoinNetwork) !== null && _a !== void 0 ? _a : (options.bitcoinNetwork = sdk_lib_1.BitcoinNetwork.MAINNET);
|
|
16
16
|
(_b = options.storagePrefix) !== null && _b !== void 0 ? _b : (options.storagePrefix = "atomiqsdk-" + options.bitcoinNetwork);
|
|
17
17
|
(_c = options.storageCtor) !== null && _c !== void 0 ? _c : (options.storageCtor = (name) => new sdk_lib_1.IndexedDBStorageManager(name));
|
|
@@ -21,9 +21,19 @@ class MultichainSwapper extends sdk_lib_1.Swapper {
|
|
|
21
21
|
(_e = options.registryUrl) !== null && _e !== void 0 ? _e : (options.registryUrl = options.bitcoinNetwork === sdk_lib_1.BitcoinNetwork.MAINNET ?
|
|
22
22
|
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main" :
|
|
23
23
|
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main");
|
|
24
|
-
const mempoolApi = new sdk_lib_1.MempoolApi(options.bitcoinNetwork === sdk_lib_1.BitcoinNetwork.TESTNET ?
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
const mempoolApi = (_f = options.mempoolApi) !== null && _f !== void 0 ? _f : new sdk_lib_1.MempoolApi(options.bitcoinNetwork === sdk_lib_1.BitcoinNetwork.TESTNET ?
|
|
25
|
+
[
|
|
26
|
+
"https://mempool.space/testnet/api/",
|
|
27
|
+
"https://mempool.fra.mempool.space/testnet/api/",
|
|
28
|
+
"https://mempool.va1.mempool.space/testnet/api/",
|
|
29
|
+
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
30
|
+
] :
|
|
31
|
+
[
|
|
32
|
+
"https://mempool.space/api/",
|
|
33
|
+
"https://mempool.fra.mempool.space/api/",
|
|
34
|
+
"https://mempool.va1.mempool.space/api/",
|
|
35
|
+
"https://mempool.tk7.mempool.space/api/"
|
|
36
|
+
]);
|
|
27
37
|
const bitcoinRpc = new sdk_lib_1.MempoolBitcoinRpc(mempoolApi);
|
|
28
38
|
const pricingAssets = [];
|
|
29
39
|
Object.keys(SmartChainAssets_1.SmartChainAssets).forEach((ticker) => {
|
|
@@ -39,7 +49,7 @@ class MultichainSwapper extends sdk_lib_1.Swapper {
|
|
|
39
49
|
const ctorChainData = (0, Utils_1.objectMap)(Chains, (value, key) => {
|
|
40
50
|
return value.getCtorData(options, bitcoinRpc, options.bitcoinNetwork);
|
|
41
51
|
});
|
|
42
|
-
super(bitcoinRpc, ctorChainData, sdk_lib_1.RedundantSwapPrice.createFromTokenMap((
|
|
52
|
+
super(bitcoinRpc, ctorChainData, sdk_lib_1.RedundantSwapPrice.createFromTokenMap((_g = options.pricingFeeDifferencePPM) !== null && _g !== void 0 ? _g : new BN(10000), pricingAssets), pricingAssets, options);
|
|
43
53
|
}
|
|
44
54
|
}
|
|
45
55
|
exports.MultichainSwapper = MultichainSwapper;
|
package/package.json
CHANGED
package/src/MultichainSwapper.ts
CHANGED
|
@@ -38,7 +38,8 @@ export type MultichainSwapperOptions = SwapperOptions & {
|
|
|
38
38
|
}
|
|
39
39
|
} & {
|
|
40
40
|
storageCtor?: <T extends StorageObject>(name: string) => IStorageManager<T>,
|
|
41
|
-
pricingFeeDifferencePPM?: BN
|
|
41
|
+
pricingFeeDifferencePPM?: BN,
|
|
42
|
+
mempoolApi?: MempoolApi
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
export class MultichainSwapper extends Swapper<SdkMultichain> {
|
|
@@ -56,10 +57,20 @@ export class MultichainSwapper extends Swapper<SdkMultichain> {
|
|
|
56
57
|
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main" :
|
|
57
58
|
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main";
|
|
58
59
|
|
|
59
|
-
const mempoolApi = new MempoolApi(
|
|
60
|
+
const mempoolApi = options.mempoolApi ?? new MempoolApi(
|
|
60
61
|
options.bitcoinNetwork===BitcoinNetwork.TESTNET ?
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
[
|
|
63
|
+
"https://mempool.space/testnet/api/",
|
|
64
|
+
"https://mempool.fra.mempool.space/testnet/api/",
|
|
65
|
+
"https://mempool.va1.mempool.space/testnet/api/",
|
|
66
|
+
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
67
|
+
] :
|
|
68
|
+
[
|
|
69
|
+
"https://mempool.space/api/",
|
|
70
|
+
"https://mempool.fra.mempool.space/api/",
|
|
71
|
+
"https://mempool.va1.mempool.space/api/",
|
|
72
|
+
"https://mempool.tk7.mempool.space/api/"
|
|
73
|
+
]
|
|
63
74
|
);
|
|
64
75
|
const bitcoinRpc = new MempoolBitcoinRpc(mempoolApi);
|
|
65
76
|
|