@atomiqlabs/sdk 4.0.0-beta.2 → 4.0.0-beta.4
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/README.md +1 -1
- package/dist/SwapperFactory.d.ts +2 -2
- package/dist/SwapperFactory.js +33 -20
- package/package.json +3 -3
- package/src/SmartChainAssets.js +1 -1
- package/src/SwapperFactory.js +35 -19
- package/src/SwapperFactory.ts +39 -25
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ const swapper = Factory.newSwapper({
|
|
|
48
48
|
rpcUrl: starknetRpc //You can also pass Provider object here
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
bitcoinNetwork: BitcoinNetwork.TESTNET //or BitcoinNetwork.MAINNET - this also sets the network to use for Solana (solana devnet for bitcoin testnet) & Starknet (sepolia for bitcoin testnet)
|
|
51
|
+
bitcoinNetwork: BitcoinNetwork.TESTNET //or BitcoinNetwork.MAINNET, BitcoinNetwork.TESTNET4 - this also sets the network to use for Solana (solana devnet for bitcoin testnet) & Starknet (sepolia for bitcoin testnet)
|
|
52
52
|
});
|
|
53
53
|
```
|
|
54
54
|
|
package/dist/SwapperFactory.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChainData, BitcoinNetwork, BitcoinRpc, BaseTokenType, ChainType, StorageObject, IStorageManager } from "@atomiqlabs/base";
|
|
2
|
-
import { BtcToken, CustomPriceFunction, MempoolApi, SCToken, Swapper, SwapperOptions } from "@atomiqlabs/sdk-lib";
|
|
2
|
+
import { BtcToken, CustomPriceFunction, MempoolApi, MempoolBitcoinRpc, SCToken, Swapper, SwapperOptions } from "@atomiqlabs/sdk-lib";
|
|
3
3
|
type ChainInitializer<O, C extends ChainType, T extends BaseTokenType> = {
|
|
4
4
|
chainId: ChainType["ChainId"];
|
|
5
5
|
chainType: ChainType;
|
|
@@ -32,7 +32,7 @@ export type MultichainSwapperOptions<T extends readonly ChainInitializer<any, an
|
|
|
32
32
|
} & {
|
|
33
33
|
chainStorageCtor?: <T extends StorageObject>(name: string) => IStorageManager<T>;
|
|
34
34
|
pricingFeeDifferencePPM?: bigint;
|
|
35
|
-
mempoolApi?: MempoolApi;
|
|
35
|
+
mempoolApi?: MempoolApi | MempoolBitcoinRpc | string | string[];
|
|
36
36
|
getPriceFn?: CustomPriceFunction;
|
|
37
37
|
};
|
|
38
38
|
export declare class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
package/dist/SwapperFactory.js
CHANGED
|
@@ -5,6 +5,35 @@ const base_1 = require("@atomiqlabs/base");
|
|
|
5
5
|
const sdk_lib_1 = require("@atomiqlabs/sdk-lib");
|
|
6
6
|
const SmartChainAssets_1 = require("./SmartChainAssets");
|
|
7
7
|
const LocalStorageManager_1 = require("./storage/LocalStorageManager");
|
|
8
|
+
const registries = {
|
|
9
|
+
[base_1.BitcoinNetwork.MAINNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main",
|
|
10
|
+
[base_1.BitcoinNetwork.TESTNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main",
|
|
11
|
+
[base_1.BitcoinNetwork.TESTNET4]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-testnet4.json?ref=main"
|
|
12
|
+
};
|
|
13
|
+
const trustedIntermediaries = {
|
|
14
|
+
[base_1.BitcoinNetwork.MAINNET]: "https://node3.gethopa.com:34100",
|
|
15
|
+
[base_1.BitcoinNetwork.TESTNET]: "https://node3.gethopa.com:24100"
|
|
16
|
+
};
|
|
17
|
+
const mempoolUrls = {
|
|
18
|
+
[base_1.BitcoinNetwork.MAINNET]: [
|
|
19
|
+
"https://mempool.space/api/",
|
|
20
|
+
"https://mempool.fra.mempool.space/api/",
|
|
21
|
+
"https://mempool.va1.mempool.space/api/",
|
|
22
|
+
"https://mempool.tk7.mempool.space/api/"
|
|
23
|
+
],
|
|
24
|
+
[base_1.BitcoinNetwork.TESTNET]: [
|
|
25
|
+
"https://mempool.space/testnet/api/",
|
|
26
|
+
"https://mempool.fra.mempool.space/testnet/api/",
|
|
27
|
+
"https://mempool.va1.mempool.space/testnet/api/",
|
|
28
|
+
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
29
|
+
],
|
|
30
|
+
[base_1.BitcoinNetwork.TESTNET4]: [
|
|
31
|
+
"https://mempool.space/testnet4/api/",
|
|
32
|
+
"https://mempool.fra.mempool.space/testnet4/api/",
|
|
33
|
+
"https://mempool.va1.mempool.space/testnet4/api/",
|
|
34
|
+
"https://mempool.tk7.mempool.space/testnet4/api/"
|
|
35
|
+
]
|
|
36
|
+
};
|
|
8
37
|
class SwapperFactory {
|
|
9
38
|
constructor(initializers) {
|
|
10
39
|
this.initializers = initializers;
|
|
@@ -36,26 +65,10 @@ class SwapperFactory {
|
|
|
36
65
|
newSwapper(options) {
|
|
37
66
|
options.bitcoinNetwork ?? (options.bitcoinNetwork = base_1.BitcoinNetwork.MAINNET);
|
|
38
67
|
options.storagePrefix ?? (options.storagePrefix = "atomiqsdk-" + options.bitcoinNetwork + "-");
|
|
39
|
-
options.defaultTrustedIntermediaryUrl ?? (options.defaultTrustedIntermediaryUrl = options.bitcoinNetwork
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main" :
|
|
44
|
-
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main");
|
|
45
|
-
const mempoolApi = options.mempoolApi ?? new sdk_lib_1.MempoolApi(options.bitcoinNetwork === base_1.BitcoinNetwork.TESTNET ?
|
|
46
|
-
[
|
|
47
|
-
"https://mempool.space/testnet/api/",
|
|
48
|
-
"https://mempool.fra.mempool.space/testnet/api/",
|
|
49
|
-
"https://mempool.va1.mempool.space/testnet/api/",
|
|
50
|
-
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
51
|
-
] :
|
|
52
|
-
[
|
|
53
|
-
"https://mempool.space/api/",
|
|
54
|
-
"https://mempool.fra.mempool.space/api/",
|
|
55
|
-
"https://mempool.va1.mempool.space/api/",
|
|
56
|
-
"https://mempool.tk7.mempool.space/api/"
|
|
57
|
-
]);
|
|
58
|
-
const bitcoinRpc = new sdk_lib_1.MempoolBitcoinRpc(mempoolApi);
|
|
68
|
+
options.defaultTrustedIntermediaryUrl ?? (options.defaultTrustedIntermediaryUrl = trustedIntermediaries[options.bitcoinNetwork]);
|
|
69
|
+
options.registryUrl ?? (options.registryUrl = registries[options.bitcoinNetwork]);
|
|
70
|
+
const mempoolApi = options.mempoolApi ?? new sdk_lib_1.MempoolBitcoinRpc(mempoolUrls[options.bitcoinNetwork]);
|
|
71
|
+
const bitcoinRpc = mempoolApi instanceof sdk_lib_1.MempoolBitcoinRpc ? mempoolApi : new sdk_lib_1.MempoolBitcoinRpc(mempoolApi);
|
|
59
72
|
const pricingAssets = [];
|
|
60
73
|
Object.keys(SmartChainAssets_1.SmartChainAssets).forEach((ticker) => {
|
|
61
74
|
const chains = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomiqlabs/sdk",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.4",
|
|
4
4
|
"description": "atomiq labs SDK for cross-chain swaps between smart chains and bitcoin",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types:": "./dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"author": "adambor",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atomiqlabs/base": "^9.0.0-beta.
|
|
25
|
-
"@atomiqlabs/sdk-lib": "^13.0.0-beta.
|
|
24
|
+
"@atomiqlabs/base": "^9.0.0-beta.2",
|
|
25
|
+
"@atomiqlabs/sdk-lib": "^13.0.0-beta.41"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "22.13.5",
|
package/src/SmartChainAssets.js
CHANGED
package/src/SwapperFactory.js
CHANGED
|
@@ -10,12 +10,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var _a, _b, _c;
|
|
13
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
15
|
exports.SwapperFactory = void 0;
|
|
15
16
|
var base_1 = require("@atomiqlabs/base");
|
|
16
17
|
var sdk_lib_1 = require("@atomiqlabs/sdk-lib");
|
|
17
18
|
var SmartChainAssets_1 = require("./SmartChainAssets");
|
|
18
19
|
var LocalStorageManager_1 = require("./storage/LocalStorageManager");
|
|
20
|
+
var registries = (_a = {},
|
|
21
|
+
_a[base_1.BitcoinNetwork.MAINNET] = "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main",
|
|
22
|
+
_a[base_1.BitcoinNetwork.TESTNET] = "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main",
|
|
23
|
+
_a[base_1.BitcoinNetwork.TESTNET4] = "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-testnet4.json?ref=main",
|
|
24
|
+
_a);
|
|
25
|
+
var trustedIntermediaries = (_b = {},
|
|
26
|
+
_b[base_1.BitcoinNetwork.MAINNET] = "https://node3.gethopa.com:34100",
|
|
27
|
+
_b[base_1.BitcoinNetwork.TESTNET] = "https://node3.gethopa.com:24100",
|
|
28
|
+
_b);
|
|
29
|
+
var mempoolUrls = (_c = {},
|
|
30
|
+
_c[base_1.BitcoinNetwork.MAINNET] = [
|
|
31
|
+
"https://mempool.space/api/",
|
|
32
|
+
"https://mempool.fra.mempool.space/api/",
|
|
33
|
+
"https://mempool.va1.mempool.space/api/",
|
|
34
|
+
"https://mempool.tk7.mempool.space/api/"
|
|
35
|
+
],
|
|
36
|
+
_c[base_1.BitcoinNetwork.TESTNET] = [
|
|
37
|
+
"https://mempool.space/testnet/api/",
|
|
38
|
+
"https://mempool.fra.mempool.space/testnet/api/",
|
|
39
|
+
"https://mempool.va1.mempool.space/testnet/api/",
|
|
40
|
+
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
41
|
+
],
|
|
42
|
+
_c[base_1.BitcoinNetwork.TESTNET4] = [
|
|
43
|
+
"https://mempool.space/testnet4/api/",
|
|
44
|
+
"https://mempool.fra.mempool.space/testnet4/api/",
|
|
45
|
+
"https://mempool.va1.mempool.space/testnet4/api/",
|
|
46
|
+
"https://mempool.tk7.mempool.space/testnet4/api/"
|
|
47
|
+
],
|
|
48
|
+
_c);
|
|
19
49
|
var SwapperFactory = /** @class */ (function () {
|
|
20
50
|
function SwapperFactory(initializers) {
|
|
21
51
|
var _this = this;
|
|
@@ -50,25 +80,11 @@ var SwapperFactory = /** @class */ (function () {
|
|
|
50
80
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
51
81
|
(_a = options.bitcoinNetwork) !== null && _a !== void 0 ? _a : (options.bitcoinNetwork = base_1.BitcoinNetwork.MAINNET);
|
|
52
82
|
(_b = options.storagePrefix) !== null && _b !== void 0 ? _b : (options.storagePrefix = "atomiqsdk-" + options.bitcoinNetwork + "-");
|
|
53
|
-
(_c = options.defaultTrustedIntermediaryUrl) !== null && _c !== void 0 ? _c : (options.defaultTrustedIntermediaryUrl = options.bitcoinNetwork
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main");
|
|
59
|
-
var mempoolApi = (_e = options.mempoolApi) !== null && _e !== void 0 ? _e : new sdk_lib_1.MempoolApi(options.bitcoinNetwork === base_1.BitcoinNetwork.TESTNET ?
|
|
60
|
-
[
|
|
61
|
-
"https://mempool.space/testnet/api/",
|
|
62
|
-
"https://mempool.fra.mempool.space/testnet/api/",
|
|
63
|
-
"https://mempool.va1.mempool.space/testnet/api/",
|
|
64
|
-
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
65
|
-
] :
|
|
66
|
-
[
|
|
67
|
-
"https://mempool.space/api/",
|
|
68
|
-
"https://mempool.fra.mempool.space/api/",
|
|
69
|
-
"https://mempool.va1.mempool.space/api/",
|
|
70
|
-
"https://mempool.tk7.mempool.space/api/"
|
|
71
|
-
]);
|
|
83
|
+
(_c = options.defaultTrustedIntermediaryUrl) !== null && _c !== void 0 ? _c : (options.defaultTrustedIntermediaryUrl = trustedIntermediaries[options.bitcoinNetwork]);
|
|
84
|
+
(_d = options.registryUrl) !== null && _d !== void 0 ? _d : (options.registryUrl = registries[options.bitcoinNetwork]);
|
|
85
|
+
var b;
|
|
86
|
+
if (options.mempoolApi instanceof sdk_lib_1.MempoolApi)
|
|
87
|
+
var mempoolApi = (_e = options.mempoolApi) !== null && _e !== void 0 ? _e : new sdk_lib_1.MempoolApi(mempoolUrls[options.bitcoinNetwork]);
|
|
72
88
|
var bitcoinRpc = new sdk_lib_1.MempoolBitcoinRpc(mempoolApi);
|
|
73
89
|
var pricingAssets = [];
|
|
74
90
|
Object.keys(SmartChainAssets_1.SmartChainAssets).forEach(function (ticker) {
|
package/src/SwapperFactory.ts
CHANGED
|
@@ -66,10 +66,42 @@ export type MultichainSwapperOptions<T extends readonly ChainInitializer<any, an
|
|
|
66
66
|
} & {
|
|
67
67
|
chainStorageCtor?: <T extends StorageObject>(name: string) => IStorageManager<T>,
|
|
68
68
|
pricingFeeDifferencePPM?: bigint,
|
|
69
|
-
mempoolApi?: MempoolApi,
|
|
69
|
+
mempoolApi?: MempoolApi | MempoolBitcoinRpc | string | string[],
|
|
70
70
|
getPriceFn?: CustomPriceFunction
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
const registries = {
|
|
74
|
+
[BitcoinNetwork.MAINNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main",
|
|
75
|
+
[BitcoinNetwork.TESTNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main",
|
|
76
|
+
[BitcoinNetwork.TESTNET4]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-testnet4.json?ref=main"
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const trustedIntermediaries = {
|
|
80
|
+
[BitcoinNetwork.MAINNET]: "https://node3.gethopa.com:34100",
|
|
81
|
+
[BitcoinNetwork.TESTNET]: "https://node3.gethopa.com:24100"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const mempoolUrls = {
|
|
85
|
+
[BitcoinNetwork.MAINNET]: [
|
|
86
|
+
"https://mempool.space/api/",
|
|
87
|
+
"https://mempool.fra.mempool.space/api/",
|
|
88
|
+
"https://mempool.va1.mempool.space/api/",
|
|
89
|
+
"https://mempool.tk7.mempool.space/api/"
|
|
90
|
+
],
|
|
91
|
+
[BitcoinNetwork.TESTNET]: [
|
|
92
|
+
"https://mempool.space/testnet/api/",
|
|
93
|
+
"https://mempool.fra.mempool.space/testnet/api/",
|
|
94
|
+
"https://mempool.va1.mempool.space/testnet/api/",
|
|
95
|
+
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
96
|
+
],
|
|
97
|
+
[BitcoinNetwork.TESTNET4]: [
|
|
98
|
+
"https://mempool.space/testnet4/api/",
|
|
99
|
+
"https://mempool.fra.mempool.space/testnet4/api/",
|
|
100
|
+
"https://mempool.va1.mempool.space/testnet4/api/",
|
|
101
|
+
"https://mempool.tk7.mempool.space/testnet4/api/"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
|
|
73
105
|
export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
|
74
106
|
|
|
75
107
|
Tokens: GetAllTokens<T> & {
|
|
@@ -112,30 +144,12 @@ export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]
|
|
|
112
144
|
options.bitcoinNetwork ??= BitcoinNetwork.MAINNET as any;
|
|
113
145
|
options.storagePrefix ??= "atomiqsdk-"+options.bitcoinNetwork+"-";
|
|
114
146
|
|
|
115
|
-
options.defaultTrustedIntermediaryUrl ??= options.bitcoinNetwork
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
options.
|
|
120
|
-
|
|
121
|
-
"https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main";
|
|
122
|
-
|
|
123
|
-
const mempoolApi = options.mempoolApi ?? new MempoolApi(
|
|
124
|
-
options.bitcoinNetwork===BitcoinNetwork.TESTNET ?
|
|
125
|
-
[
|
|
126
|
-
"https://mempool.space/testnet/api/",
|
|
127
|
-
"https://mempool.fra.mempool.space/testnet/api/",
|
|
128
|
-
"https://mempool.va1.mempool.space/testnet/api/",
|
|
129
|
-
"https://mempool.tk7.mempool.space/testnet/api/"
|
|
130
|
-
] :
|
|
131
|
-
[
|
|
132
|
-
"https://mempool.space/api/",
|
|
133
|
-
"https://mempool.fra.mempool.space/api/",
|
|
134
|
-
"https://mempool.va1.mempool.space/api/",
|
|
135
|
-
"https://mempool.tk7.mempool.space/api/"
|
|
136
|
-
]
|
|
137
|
-
);
|
|
138
|
-
const bitcoinRpc = new MempoolBitcoinRpc(mempoolApi);
|
|
147
|
+
options.defaultTrustedIntermediaryUrl ??= trustedIntermediaries[options.bitcoinNetwork];
|
|
148
|
+
|
|
149
|
+
options.registryUrl ??= registries[options.bitcoinNetwork];
|
|
150
|
+
|
|
151
|
+
const mempoolApi = options.mempoolApi ?? new MempoolBitcoinRpc(mempoolUrls[options.bitcoinNetwork]);
|
|
152
|
+
const bitcoinRpc = mempoolApi instanceof MempoolBitcoinRpc ? mempoolApi : new MempoolBitcoinRpc(mempoolApi);
|
|
139
153
|
|
|
140
154
|
const pricingAssets: (RedundantSwapPriceAssets<ToMultichain<T>>[number] & {ticker: string, name: string})[] = [];
|
|
141
155
|
Object.keys(SmartChainAssets).forEach((ticker) => {
|