@atomiqlabs/sdk 4.0.1 → 5.0.0-dev.1
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/LICENSE +201 -201
- package/README.md +1098 -1074
- package/dist/SmartChainAssets.d.ts +93 -83
- package/dist/SmartChainAssets.js +95 -85
- package/dist/SwapperFactory.d.ts +50 -50
- package/dist/SwapperFactory.js +105 -105
- package/dist/Utils.d.ts +11 -11
- package/dist/Utils.js +37 -37
- package/dist/fs-storage/FileSystemStorageManager.d.ts +15 -15
- package/dist/fs-storage/FileSystemStorageManager.js +60 -60
- package/dist/fs-storage/index.d.ts +1 -1
- package/dist/fs-storage/index.js +17 -17
- package/dist/index.d.ts +5 -5
- package/dist/index.js +21 -21
- package/dist/storage/LocalStorageManager.d.ts +24 -24
- package/dist/storage/LocalStorageManager.js +68 -68
- package/package.json +31 -31
- package/src/SmartChainAssets.js +75 -75
- package/src/SmartChainAssets.ts +96 -86
- package/src/SwapperFactory.js +120 -120
- package/src/SwapperFactory.ts +195 -195
- package/src/Utils.js +37 -37
- package/src/Utils.ts +31 -31
- package/src/fs-storage/FileSystemStorageManager.ts +71 -71
- package/src/fs-storage/index.ts +1 -1
- package/src/index.js +21 -21
- package/src/index.ts +5 -5
- package/src/storage/LocalStorageManager.js +72 -72
- package/src/storage/LocalStorageManager.ts +81 -81
|
@@ -1,83 +1,93 @@
|
|
|
1
|
-
export declare const SmartChainAssets: {
|
|
2
|
-
readonly WBTC: {
|
|
3
|
-
readonly pricing: {
|
|
4
|
-
readonly binancePair: "WBTCBTC";
|
|
5
|
-
readonly okxPair: "WBTC-BTC";
|
|
6
|
-
readonly coinGeckoCoinId: "wrapped-bitcoin";
|
|
7
|
-
readonly coinPaprikaCoinId: "wbtc-wrapped-bitcoin";
|
|
8
|
-
readonly krakenPair: "WBTCXBT";
|
|
9
|
-
};
|
|
10
|
-
readonly name: "Wrapped BTC (WBTC)";
|
|
11
|
-
};
|
|
12
|
-
readonly
|
|
13
|
-
readonly pricing: {
|
|
14
|
-
readonly binancePair:
|
|
15
|
-
readonly okxPair:
|
|
16
|
-
readonly coinGeckoCoinId: "
|
|
17
|
-
readonly coinPaprikaCoinId: "
|
|
18
|
-
readonly krakenPair:
|
|
19
|
-
};
|
|
20
|
-
readonly name: "
|
|
21
|
-
};
|
|
22
|
-
readonly
|
|
23
|
-
readonly pricing: {
|
|
24
|
-
readonly binancePair: "!
|
|
25
|
-
readonly okxPair: "!BTC-
|
|
26
|
-
readonly coinGeckoCoinId: "
|
|
27
|
-
readonly coinPaprikaCoinId: "
|
|
28
|
-
readonly krakenPair: "!
|
|
29
|
-
};
|
|
30
|
-
readonly name: "USD
|
|
31
|
-
};
|
|
32
|
-
readonly
|
|
33
|
-
readonly pricing: {
|
|
34
|
-
readonly binancePair: "
|
|
35
|
-
readonly okxPair: "
|
|
36
|
-
readonly coinGeckoCoinId: "
|
|
37
|
-
readonly coinPaprikaCoinId: "
|
|
38
|
-
readonly krakenPair: "
|
|
39
|
-
};
|
|
40
|
-
readonly name: "
|
|
41
|
-
};
|
|
42
|
-
readonly
|
|
43
|
-
readonly pricing: {
|
|
44
|
-
readonly binancePair: "
|
|
45
|
-
readonly okxPair: "
|
|
46
|
-
readonly coinGeckoCoinId: "
|
|
47
|
-
readonly coinPaprikaCoinId: "
|
|
48
|
-
readonly krakenPair: "
|
|
49
|
-
};
|
|
50
|
-
readonly name: "
|
|
51
|
-
};
|
|
52
|
-
readonly
|
|
53
|
-
readonly pricing: {
|
|
54
|
-
readonly binancePair: "
|
|
55
|
-
readonly okxPair: "
|
|
56
|
-
readonly coinGeckoCoinId: "
|
|
57
|
-
readonly coinPaprikaCoinId: "
|
|
58
|
-
readonly krakenPair: "
|
|
59
|
-
};
|
|
60
|
-
readonly name: "
|
|
61
|
-
};
|
|
62
|
-
readonly
|
|
63
|
-
readonly pricing: {
|
|
64
|
-
readonly binancePair: "
|
|
65
|
-
readonly okxPair: "
|
|
66
|
-
readonly coinGeckoCoinId: "
|
|
67
|
-
readonly coinPaprikaCoinId: "
|
|
68
|
-
readonly krakenPair: "
|
|
69
|
-
};
|
|
70
|
-
readonly name: "
|
|
71
|
-
};
|
|
72
|
-
readonly
|
|
73
|
-
readonly pricing: {
|
|
74
|
-
readonly binancePair: "
|
|
75
|
-
readonly okxPair: "
|
|
76
|
-
readonly coinGeckoCoinId: "
|
|
77
|
-
readonly coinPaprikaCoinId: "
|
|
78
|
-
readonly krakenPair: "
|
|
79
|
-
};
|
|
80
|
-
readonly name: "
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
|
|
1
|
+
export declare const SmartChainAssets: {
|
|
2
|
+
readonly WBTC: {
|
|
3
|
+
readonly pricing: {
|
|
4
|
+
readonly binancePair: "WBTCBTC";
|
|
5
|
+
readonly okxPair: "WBTC-BTC";
|
|
6
|
+
readonly coinGeckoCoinId: "wrapped-bitcoin";
|
|
7
|
+
readonly coinPaprikaCoinId: "wbtc-wrapped-bitcoin";
|
|
8
|
+
readonly krakenPair: "WBTCXBT";
|
|
9
|
+
};
|
|
10
|
+
readonly name: "Wrapped BTC (WBTC)";
|
|
11
|
+
};
|
|
12
|
+
readonly USDC: {
|
|
13
|
+
readonly pricing: {
|
|
14
|
+
readonly binancePair: "!BTCUSDC";
|
|
15
|
+
readonly okxPair: "!BTC-USDC";
|
|
16
|
+
readonly coinGeckoCoinId: "usd-coin";
|
|
17
|
+
readonly coinPaprikaCoinId: "usdc-usd-coin";
|
|
18
|
+
readonly krakenPair: "!XBTUSDC";
|
|
19
|
+
};
|
|
20
|
+
readonly name: "USD Circle";
|
|
21
|
+
};
|
|
22
|
+
readonly USDT: {
|
|
23
|
+
readonly pricing: {
|
|
24
|
+
readonly binancePair: "!BTCUSDT";
|
|
25
|
+
readonly okxPair: "!BTC-USDT";
|
|
26
|
+
readonly coinGeckoCoinId: "tether";
|
|
27
|
+
readonly coinPaprikaCoinId: "usdt-tether";
|
|
28
|
+
readonly krakenPair: "!XBTUSDT";
|
|
29
|
+
};
|
|
30
|
+
readonly name: "Tether USD";
|
|
31
|
+
};
|
|
32
|
+
readonly SOL: {
|
|
33
|
+
readonly pricing: {
|
|
34
|
+
readonly binancePair: "SOLBTC";
|
|
35
|
+
readonly okxPair: "SOL-BTC";
|
|
36
|
+
readonly coinGeckoCoinId: "solana";
|
|
37
|
+
readonly coinPaprikaCoinId: "sol-solana";
|
|
38
|
+
readonly krakenPair: "SOLXBT";
|
|
39
|
+
};
|
|
40
|
+
readonly name: "Solana";
|
|
41
|
+
};
|
|
42
|
+
readonly BONK: {
|
|
43
|
+
readonly pricing: {
|
|
44
|
+
readonly binancePair: "BONKUSDC;!BTCUSDC";
|
|
45
|
+
readonly okxPair: "BONK-USDT;!BTC-USDT";
|
|
46
|
+
readonly coinGeckoCoinId: "bonk";
|
|
47
|
+
readonly coinPaprikaCoinId: "bonk-bonk";
|
|
48
|
+
readonly krakenPair: "BONKUSD;!XXBTZUSD";
|
|
49
|
+
};
|
|
50
|
+
readonly name: "Bonk";
|
|
51
|
+
};
|
|
52
|
+
readonly ETH: {
|
|
53
|
+
readonly pricing: {
|
|
54
|
+
readonly binancePair: "ETHBTC";
|
|
55
|
+
readonly okxPair: "ETH-BTC";
|
|
56
|
+
readonly coinGeckoCoinId: "ethereum";
|
|
57
|
+
readonly coinPaprikaCoinId: "eth-ethereum";
|
|
58
|
+
readonly krakenPair: "XETHXXBT";
|
|
59
|
+
};
|
|
60
|
+
readonly name: "Ether";
|
|
61
|
+
};
|
|
62
|
+
readonly STRK: {
|
|
63
|
+
readonly pricing: {
|
|
64
|
+
readonly binancePair: "STRKUSDT;!BTCUSDT";
|
|
65
|
+
readonly okxPair: "STRK-USDT;!BTC-USDT";
|
|
66
|
+
readonly coinGeckoCoinId: "starknet";
|
|
67
|
+
readonly coinPaprikaCoinId: "strk-starknet";
|
|
68
|
+
readonly krakenPair: "STRKUSD;!XXBTZUSD";
|
|
69
|
+
};
|
|
70
|
+
readonly name: "Starknet";
|
|
71
|
+
};
|
|
72
|
+
readonly CBTC: {
|
|
73
|
+
readonly pricing: {
|
|
74
|
+
readonly binancePair: "$fixed-100000000";
|
|
75
|
+
readonly okxPair: "$fixed-100000000";
|
|
76
|
+
readonly coinGeckoCoinId: "$fixed-100000000";
|
|
77
|
+
readonly coinPaprikaCoinId: "$fixed-100000000";
|
|
78
|
+
readonly krakenPair: "$fixed-100000000";
|
|
79
|
+
};
|
|
80
|
+
readonly name: "Citrea BTC";
|
|
81
|
+
};
|
|
82
|
+
readonly BBTC: {
|
|
83
|
+
readonly pricing: {
|
|
84
|
+
readonly binancePair: "$fixed-100000000";
|
|
85
|
+
readonly okxPair: "$fixed-100000000";
|
|
86
|
+
readonly coinGeckoCoinId: "$fixed-100000000";
|
|
87
|
+
readonly coinPaprikaCoinId: "$fixed-100000000";
|
|
88
|
+
readonly krakenPair: "$fixed-100000000";
|
|
89
|
+
};
|
|
90
|
+
readonly name: "Botanix BTC";
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export type SmartChainAssetTickers = keyof typeof SmartChainAssets;
|
package/dist/SmartChainAssets.js
CHANGED
|
@@ -1,85 +1,95 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SmartChainAssets = void 0;
|
|
4
|
-
exports.SmartChainAssets = {
|
|
5
|
-
WBTC: {
|
|
6
|
-
pricing: {
|
|
7
|
-
binancePair: "WBTCBTC",
|
|
8
|
-
okxPair: "WBTC-BTC",
|
|
9
|
-
coinGeckoCoinId: "wrapped-bitcoin",
|
|
10
|
-
coinPaprikaCoinId: "wbtc-wrapped-bitcoin",
|
|
11
|
-
krakenPair: "WBTCXBT"
|
|
12
|
-
},
|
|
13
|
-
name: "Wrapped BTC (WBTC)"
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
pricing: {
|
|
17
|
-
binancePair:
|
|
18
|
-
okxPair:
|
|
19
|
-
coinGeckoCoinId: "
|
|
20
|
-
coinPaprikaCoinId: "
|
|
21
|
-
krakenPair:
|
|
22
|
-
},
|
|
23
|
-
name: "
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
pricing: {
|
|
27
|
-
binancePair: "!
|
|
28
|
-
okxPair: "!BTC-
|
|
29
|
-
coinGeckoCoinId: "
|
|
30
|
-
coinPaprikaCoinId: "
|
|
31
|
-
krakenPair: "!
|
|
32
|
-
},
|
|
33
|
-
name: "USD
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
pricing: {
|
|
37
|
-
binancePair: "
|
|
38
|
-
okxPair: "
|
|
39
|
-
coinGeckoCoinId: "
|
|
40
|
-
coinPaprikaCoinId: "
|
|
41
|
-
krakenPair: "
|
|
42
|
-
},
|
|
43
|
-
name: "
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
pricing: {
|
|
47
|
-
binancePair: "
|
|
48
|
-
okxPair: "
|
|
49
|
-
coinGeckoCoinId: "
|
|
50
|
-
coinPaprikaCoinId: "
|
|
51
|
-
krakenPair: "
|
|
52
|
-
},
|
|
53
|
-
name: "
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
pricing: {
|
|
57
|
-
binancePair: "
|
|
58
|
-
okxPair: "
|
|
59
|
-
coinGeckoCoinId: "
|
|
60
|
-
coinPaprikaCoinId: "
|
|
61
|
-
krakenPair: "
|
|
62
|
-
},
|
|
63
|
-
name: "
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
pricing: {
|
|
67
|
-
binancePair: "
|
|
68
|
-
okxPair: "
|
|
69
|
-
coinGeckoCoinId: "
|
|
70
|
-
coinPaprikaCoinId: "
|
|
71
|
-
krakenPair: "
|
|
72
|
-
},
|
|
73
|
-
name: "
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
pricing: {
|
|
77
|
-
binancePair: "
|
|
78
|
-
okxPair: "
|
|
79
|
-
coinGeckoCoinId: "
|
|
80
|
-
coinPaprikaCoinId: "
|
|
81
|
-
krakenPair: "
|
|
82
|
-
},
|
|
83
|
-
name: "
|
|
84
|
-
}
|
|
85
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SmartChainAssets = void 0;
|
|
4
|
+
exports.SmartChainAssets = {
|
|
5
|
+
WBTC: {
|
|
6
|
+
pricing: {
|
|
7
|
+
binancePair: "WBTCBTC",
|
|
8
|
+
okxPair: "WBTC-BTC",
|
|
9
|
+
coinGeckoCoinId: "wrapped-bitcoin",
|
|
10
|
+
coinPaprikaCoinId: "wbtc-wrapped-bitcoin",
|
|
11
|
+
krakenPair: "WBTCXBT"
|
|
12
|
+
},
|
|
13
|
+
name: "Wrapped BTC (WBTC)"
|
|
14
|
+
},
|
|
15
|
+
USDC: {
|
|
16
|
+
pricing: {
|
|
17
|
+
binancePair: "!BTCUSDC",
|
|
18
|
+
okxPair: "!BTC-USDC",
|
|
19
|
+
coinGeckoCoinId: "usd-coin",
|
|
20
|
+
coinPaprikaCoinId: "usdc-usd-coin",
|
|
21
|
+
krakenPair: "!XBTUSDC"
|
|
22
|
+
},
|
|
23
|
+
name: "USD Circle"
|
|
24
|
+
},
|
|
25
|
+
USDT: {
|
|
26
|
+
pricing: {
|
|
27
|
+
binancePair: "!BTCUSDT",
|
|
28
|
+
okxPair: "!BTC-USDT",
|
|
29
|
+
coinGeckoCoinId: "tether",
|
|
30
|
+
coinPaprikaCoinId: "usdt-tether",
|
|
31
|
+
krakenPair: "!XBTUSDT"
|
|
32
|
+
},
|
|
33
|
+
name: "Tether USD"
|
|
34
|
+
},
|
|
35
|
+
SOL: {
|
|
36
|
+
pricing: {
|
|
37
|
+
binancePair: "SOLBTC",
|
|
38
|
+
okxPair: "SOL-BTC",
|
|
39
|
+
coinGeckoCoinId: "solana",
|
|
40
|
+
coinPaprikaCoinId: "sol-solana",
|
|
41
|
+
krakenPair: "SOLXBT"
|
|
42
|
+
},
|
|
43
|
+
name: "Solana"
|
|
44
|
+
},
|
|
45
|
+
BONK: {
|
|
46
|
+
pricing: {
|
|
47
|
+
binancePair: "BONKUSDC;!BTCUSDC",
|
|
48
|
+
okxPair: "BONK-USDT;!BTC-USDT",
|
|
49
|
+
coinGeckoCoinId: "bonk",
|
|
50
|
+
coinPaprikaCoinId: "bonk-bonk",
|
|
51
|
+
krakenPair: "BONKUSD;!XXBTZUSD"
|
|
52
|
+
},
|
|
53
|
+
name: "Bonk"
|
|
54
|
+
},
|
|
55
|
+
ETH: {
|
|
56
|
+
pricing: {
|
|
57
|
+
binancePair: "ETHBTC",
|
|
58
|
+
okxPair: "ETH-BTC",
|
|
59
|
+
coinGeckoCoinId: "ethereum",
|
|
60
|
+
coinPaprikaCoinId: "eth-ethereum",
|
|
61
|
+
krakenPair: "XETHXXBT"
|
|
62
|
+
},
|
|
63
|
+
name: "Ether"
|
|
64
|
+
},
|
|
65
|
+
STRK: {
|
|
66
|
+
pricing: {
|
|
67
|
+
binancePair: "STRKUSDT;!BTCUSDT",
|
|
68
|
+
okxPair: "STRK-USDT;!BTC-USDT",
|
|
69
|
+
coinGeckoCoinId: "starknet",
|
|
70
|
+
coinPaprikaCoinId: "strk-starknet",
|
|
71
|
+
krakenPair: "STRKUSD;!XXBTZUSD"
|
|
72
|
+
},
|
|
73
|
+
name: "Starknet"
|
|
74
|
+
},
|
|
75
|
+
CBTC: {
|
|
76
|
+
pricing: {
|
|
77
|
+
binancePair: "$fixed-100000000",
|
|
78
|
+
okxPair: "$fixed-100000000",
|
|
79
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
80
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
81
|
+
krakenPair: "$fixed-100000000"
|
|
82
|
+
},
|
|
83
|
+
name: "Citrea BTC"
|
|
84
|
+
},
|
|
85
|
+
BBTC: {
|
|
86
|
+
pricing: {
|
|
87
|
+
binancePair: "$fixed-100000000",
|
|
88
|
+
okxPair: "$fixed-100000000",
|
|
89
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
90
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
91
|
+
krakenPair: "$fixed-100000000"
|
|
92
|
+
},
|
|
93
|
+
name: "Botanix BTC"
|
|
94
|
+
}
|
|
95
|
+
};
|
package/dist/SwapperFactory.d.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { ChainData, BitcoinNetwork, BitcoinRpc, BaseTokenType, ChainType, StorageObject, IStorageManager } from "@atomiqlabs/base";
|
|
2
|
-
import { BtcToken, CustomPriceFunction, MempoolApi, MempoolBitcoinRpc, SCToken, Swapper, SwapperOptions } from "@atomiqlabs/sdk-lib";
|
|
3
|
-
type ChainInitializer<O, C extends ChainType, T extends BaseTokenType> = {
|
|
4
|
-
chainId: ChainType["ChainId"];
|
|
5
|
-
chainType: ChainType;
|
|
6
|
-
initializer: (options: O, bitcoinRelay: BitcoinRpc<any>, network: BitcoinNetwork, storageCtor: <T extends StorageObject>(name: string) => IStorageManager<T>) => ChainData<C>;
|
|
7
|
-
tokens: T;
|
|
8
|
-
options: O;
|
|
9
|
-
};
|
|
10
|
-
type TokensDict<T extends ChainInitializer<any, any, any>> = {
|
|
11
|
-
[K in T["chainId"]]: {
|
|
12
|
-
[val in keyof T["tokens"]]: SCToken<K>;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
type GetAllTokens<T extends readonly ChainInitializer<any, any, any>[]> = (T extends readonly [infer First extends ChainInitializer<any, any, any>, ...infer Rest extends ChainInitializer<any, any, any>[]] ? TokensDict<First> & GetAllTokens<Rest> : unknown);
|
|
16
|
-
export type TokenResolverDict<T extends ChainInitializer<any, any, any>> = {
|
|
17
|
-
[K in T["chainId"]]: {
|
|
18
|
-
getToken: (address: string) => SCToken<K>;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
type GetAllTokenResolvers<T extends readonly ChainInitializer<any, any, any>[]> = (T extends readonly [infer First extends ChainInitializer<any, any, any>, ...infer Rest extends ChainInitializer<any, any, any>[]] ? TokenResolverDict<First> & GetAllTokenResolvers<Rest> : unknown);
|
|
22
|
-
type OptionsDict<T extends ChainInitializer<any, any, any>> = {
|
|
23
|
-
[K in T["chainId"]]: T["options"];
|
|
24
|
-
};
|
|
25
|
-
type GetAllOptions<T extends readonly ChainInitializer<any, any, any>[]> = (T extends readonly [infer First extends ChainInitializer<any, any, any>, ...infer Rest extends ChainInitializer<any, any, any>[]] ? OptionsDict<First> & GetAllOptions<Rest> : unknown);
|
|
26
|
-
type ChainTypeDict<T extends ChainInitializer<any, any, any>> = {
|
|
27
|
-
[K in T["chainId"]]: T["chainType"];
|
|
28
|
-
};
|
|
29
|
-
type ToMultichain<T extends readonly ChainInitializer<any, any, any>[]> = (T extends readonly [infer First extends ChainInitializer<any, any, any>, ...infer Rest extends ChainInitializer<any, any, any>[]] ? ChainTypeDict<First> & ToMultichain<Rest> : {});
|
|
30
|
-
export type MultichainSwapperOptions<T extends readonly ChainInitializer<any, any, any>[]> = SwapperOptions & {
|
|
31
|
-
chains: GetAllOptions<T>;
|
|
32
|
-
} & {
|
|
33
|
-
chainStorageCtor?: <T extends StorageObject>(name: string) => IStorageManager<T>;
|
|
34
|
-
pricingFeeDifferencePPM?: bigint;
|
|
35
|
-
mempoolApi?: MempoolApi | MempoolBitcoinRpc | string | string[];
|
|
36
|
-
getPriceFn?: CustomPriceFunction;
|
|
37
|
-
};
|
|
38
|
-
export declare class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
|
39
|
-
readonly initializers: T;
|
|
40
|
-
Tokens: GetAllTokens<T> & {
|
|
41
|
-
BITCOIN: {
|
|
42
|
-
BTC: BtcToken<false>;
|
|
43
|
-
BTCLN: BtcToken<true>;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
TokenResolver: GetAllTokenResolvers<T>;
|
|
47
|
-
constructor(initializers: T);
|
|
48
|
-
newSwapper(options: MultichainSwapperOptions<T>): Swapper<ToMultichain<T>>;
|
|
49
|
-
}
|
|
50
|
-
export {};
|
|
1
|
+
import { ChainData, BitcoinNetwork, BitcoinRpc, BaseTokenType, ChainType, StorageObject, IStorageManager } from "@atomiqlabs/base";
|
|
2
|
+
import { BtcToken, CustomPriceFunction, MempoolApi, MempoolBitcoinRpc, SCToken, Swapper, SwapperOptions } from "@atomiqlabs/sdk-lib";
|
|
3
|
+
type ChainInitializer<O, C extends ChainType, T extends BaseTokenType> = {
|
|
4
|
+
chainId: ChainType["ChainId"];
|
|
5
|
+
chainType: ChainType;
|
|
6
|
+
initializer: (options: O, bitcoinRelay: BitcoinRpc<any>, network: BitcoinNetwork, storageCtor: <T extends StorageObject>(name: string) => IStorageManager<T>) => ChainData<C>;
|
|
7
|
+
tokens: T;
|
|
8
|
+
options: O;
|
|
9
|
+
};
|
|
10
|
+
type TokensDict<T extends ChainInitializer<any, any, any>> = {
|
|
11
|
+
[K in T["chainId"]]: {
|
|
12
|
+
[val in keyof T["tokens"]]: SCToken<K>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
type GetAllTokens<T extends readonly ChainInitializer<any, any, any>[]> = (T extends readonly [infer First extends ChainInitializer<any, any, any>, ...infer Rest extends ChainInitializer<any, any, any>[]] ? TokensDict<First> & GetAllTokens<Rest> : unknown);
|
|
16
|
+
export type TokenResolverDict<T extends ChainInitializer<any, any, any>> = {
|
|
17
|
+
[K in T["chainId"]]: {
|
|
18
|
+
getToken: (address: string) => SCToken<K>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type GetAllTokenResolvers<T extends readonly ChainInitializer<any, any, any>[]> = (T extends readonly [infer First extends ChainInitializer<any, any, any>, ...infer Rest extends ChainInitializer<any, any, any>[]] ? TokenResolverDict<First> & GetAllTokenResolvers<Rest> : unknown);
|
|
22
|
+
type OptionsDict<T extends ChainInitializer<any, any, any>> = {
|
|
23
|
+
[K in T["chainId"]]: T["options"];
|
|
24
|
+
};
|
|
25
|
+
type GetAllOptions<T extends readonly ChainInitializer<any, any, any>[]> = (T extends readonly [infer First extends ChainInitializer<any, any, any>, ...infer Rest extends ChainInitializer<any, any, any>[]] ? OptionsDict<First> & GetAllOptions<Rest> : unknown);
|
|
26
|
+
type ChainTypeDict<T extends ChainInitializer<any, any, any>> = {
|
|
27
|
+
[K in T["chainId"]]: T["chainType"];
|
|
28
|
+
};
|
|
29
|
+
type ToMultichain<T extends readonly ChainInitializer<any, any, any>[]> = (T extends readonly [infer First extends ChainInitializer<any, any, any>, ...infer Rest extends ChainInitializer<any, any, any>[]] ? ChainTypeDict<First> & ToMultichain<Rest> : {});
|
|
30
|
+
export type MultichainSwapperOptions<T extends readonly ChainInitializer<any, any, any>[]> = SwapperOptions & {
|
|
31
|
+
chains: GetAllOptions<T>;
|
|
32
|
+
} & {
|
|
33
|
+
chainStorageCtor?: <T extends StorageObject>(name: string) => IStorageManager<T>;
|
|
34
|
+
pricingFeeDifferencePPM?: bigint;
|
|
35
|
+
mempoolApi?: MempoolApi | MempoolBitcoinRpc | string | string[];
|
|
36
|
+
getPriceFn?: CustomPriceFunction;
|
|
37
|
+
};
|
|
38
|
+
export declare class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
|
39
|
+
readonly initializers: T;
|
|
40
|
+
Tokens: GetAllTokens<T> & {
|
|
41
|
+
BITCOIN: {
|
|
42
|
+
BTC: BtcToken<false>;
|
|
43
|
+
BTCLN: BtcToken<true>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
TokenResolver: GetAllTokenResolvers<T>;
|
|
47
|
+
constructor(initializers: T);
|
|
48
|
+
newSwapper(options: MultichainSwapperOptions<T>): Swapper<ToMultichain<T>>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|