@atomiqlabs/sdk 6.0.1 → 7.0.0
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 +818 -274
- package/dist/SmartChainAssets.d.ts +30 -0
- package/dist/SmartChainAssets.js +30 -0
- package/dist/SwapperFactory.d.ts +3 -1
- package/dist/SwapperFactory.js +12 -2
- package/package.json +4 -3
- package/src/SmartChainAssets.ts +30 -0
- package/src/SwapperFactory.ts +16 -2
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
export declare const SmartChainAssets: {
|
|
2
|
+
readonly _TESTNET_WBTC_VESU: {
|
|
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
|
+
};
|
|
2
12
|
readonly WBTC: {
|
|
3
13
|
readonly pricing: {
|
|
4
14
|
readonly binancePair: "WBTCBTC";
|
|
@@ -79,5 +89,25 @@ export declare const SmartChainAssets: {
|
|
|
79
89
|
};
|
|
80
90
|
readonly name: "Starknet";
|
|
81
91
|
};
|
|
92
|
+
readonly CBTC: {
|
|
93
|
+
readonly pricing: {
|
|
94
|
+
readonly binancePair: "$fixed-100000000";
|
|
95
|
+
readonly okxPair: "$fixed-100000000";
|
|
96
|
+
readonly coinGeckoCoinId: "$fixed-100000000";
|
|
97
|
+
readonly coinPaprikaCoinId: "$fixed-100000000";
|
|
98
|
+
readonly krakenPair: "$fixed-100000000";
|
|
99
|
+
};
|
|
100
|
+
readonly name: "Citrea BTC";
|
|
101
|
+
};
|
|
102
|
+
readonly BBTC: {
|
|
103
|
+
readonly pricing: {
|
|
104
|
+
readonly binancePair: "$fixed-100000000";
|
|
105
|
+
readonly okxPair: "$fixed-100000000";
|
|
106
|
+
readonly coinGeckoCoinId: "$fixed-100000000";
|
|
107
|
+
readonly coinPaprikaCoinId: "$fixed-100000000";
|
|
108
|
+
readonly krakenPair: "$fixed-100000000";
|
|
109
|
+
};
|
|
110
|
+
readonly name: "Botanix BTC";
|
|
111
|
+
};
|
|
82
112
|
};
|
|
83
113
|
export type SmartChainAssetTickers = keyof typeof SmartChainAssets;
|
package/dist/SmartChainAssets.js
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SmartChainAssets = void 0;
|
|
4
4
|
exports.SmartChainAssets = {
|
|
5
|
+
_TESTNET_WBTC_VESU: {
|
|
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
|
+
},
|
|
5
15
|
WBTC: {
|
|
6
16
|
pricing: {
|
|
7
17
|
binancePair: "WBTCBTC",
|
|
@@ -81,5 +91,25 @@ exports.SmartChainAssets = {
|
|
|
81
91
|
krakenPair: "STRKUSD;!XXBTZUSD"
|
|
82
92
|
},
|
|
83
93
|
name: "Starknet"
|
|
94
|
+
},
|
|
95
|
+
CBTC: {
|
|
96
|
+
pricing: {
|
|
97
|
+
binancePair: "$fixed-100000000",
|
|
98
|
+
okxPair: "$fixed-100000000",
|
|
99
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
100
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
101
|
+
krakenPair: "$fixed-100000000"
|
|
102
|
+
},
|
|
103
|
+
name: "Citrea BTC"
|
|
104
|
+
},
|
|
105
|
+
BBTC: {
|
|
106
|
+
pricing: {
|
|
107
|
+
binancePair: "$fixed-100000000",
|
|
108
|
+
okxPair: "$fixed-100000000",
|
|
109
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
110
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
111
|
+
krakenPair: "$fixed-100000000"
|
|
112
|
+
},
|
|
113
|
+
name: "Botanix BTC"
|
|
84
114
|
}
|
|
85
115
|
};
|
package/dist/SwapperFactory.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChainData, BitcoinNetwork, BitcoinRpc, BaseTokenType, ChainType, StorageObject, IStorageManager } from "@atomiqlabs/base";
|
|
1
|
+
import { ChainData, BitcoinNetwork, BitcoinRpc, BaseTokenType, ChainType, StorageObject, IStorageManager, Messenger } from "@atomiqlabs/base";
|
|
2
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"];
|
|
@@ -33,6 +33,7 @@ export type MultichainSwapperOptions<T extends readonly ChainInitializer<any, an
|
|
|
33
33
|
chainStorageCtor?: <T extends StorageObject>(name: string) => IStorageManager<T>;
|
|
34
34
|
pricingFeeDifferencePPM?: bigint;
|
|
35
35
|
mempoolApi?: MempoolApi | MempoolBitcoinRpc | string | string[];
|
|
36
|
+
messenger?: Messenger;
|
|
36
37
|
getPriceFn?: CustomPriceFunction;
|
|
37
38
|
};
|
|
38
39
|
export declare class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
|
@@ -46,5 +47,6 @@ export declare class SwapperFactory<T extends readonly ChainInitializer<any, any
|
|
|
46
47
|
TokenResolver: GetAllTokenResolvers<T>;
|
|
47
48
|
constructor(initializers: T);
|
|
48
49
|
newSwapper(options: MultichainSwapperOptions<T>): Swapper<ToMultichain<T>>;
|
|
50
|
+
newSwapperInitialized(options: MultichainSwapperOptions<T>): Promise<Swapper<ToMultichain<T>>>;
|
|
49
51
|
}
|
|
50
52
|
export {};
|
package/dist/SwapperFactory.js
CHANGED
|
@@ -5,6 +5,7 @@ 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 messenger_nostr_1 = require("@atomiqlabs/messenger-nostr");
|
|
8
9
|
const registries = {
|
|
9
10
|
[base_1.BitcoinNetwork.MAINNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry-mainnet.json?ref=main",
|
|
10
11
|
[base_1.BitcoinNetwork.TESTNET]: "https://api.github.com/repos/adambor/SolLightning-registry/contents/registry.json?ref=main",
|
|
@@ -37,6 +38,9 @@ const mempoolUrls = {
|
|
|
37
38
|
"https://mempool.tk7.mempool.space/testnet4/api/"
|
|
38
39
|
]
|
|
39
40
|
};
|
|
41
|
+
const nostrUrls = [
|
|
42
|
+
"wss://relay.damus.io", "wss://nostr.einundzwanzig.space", "wss://nostr.mutinywallet.com"
|
|
43
|
+
];
|
|
40
44
|
class SwapperFactory {
|
|
41
45
|
constructor(initializers) {
|
|
42
46
|
this.initializers = initializers;
|
|
@@ -54,7 +58,7 @@ class SwapperFactory {
|
|
|
54
58
|
chain: "SC",
|
|
55
59
|
chainId: initializer.chainId,
|
|
56
60
|
address: assetData.address,
|
|
57
|
-
name: SmartChainAssets_1.SmartChainAssets[ticker]
|
|
61
|
+
name: SmartChainAssets_1.SmartChainAssets[ticker]?.name ?? ticker,
|
|
58
62
|
decimals: assetData.decimals,
|
|
59
63
|
displayDecimals: assetData.displayDecimals,
|
|
60
64
|
ticker
|
|
@@ -68,6 +72,7 @@ class SwapperFactory {
|
|
|
68
72
|
newSwapper(options) {
|
|
69
73
|
options.bitcoinNetwork ?? (options.bitcoinNetwork = base_1.BitcoinNetwork.MAINNET);
|
|
70
74
|
options.storagePrefix ?? (options.storagePrefix = "atomiqsdk-" + options.bitcoinNetwork + "-");
|
|
75
|
+
options.messenger ?? (options.messenger = new messenger_nostr_1.NostrMessenger(options.bitcoinNetwork, nostrUrls));
|
|
71
76
|
options.defaultTrustedIntermediaryUrl ?? (options.defaultTrustedIntermediaryUrl = trustedIntermediaries[options.bitcoinNetwork]);
|
|
72
77
|
options.registryUrl ?? (options.registryUrl = registries[options.bitcoinNetwork]);
|
|
73
78
|
const mempoolApi = options.mempoolApi ?? new sdk_lib_1.MempoolBitcoinRpc(mempoolUrls[options.bitcoinNetwork]);
|
|
@@ -102,7 +107,12 @@ class SwapperFactory {
|
|
|
102
107
|
};
|
|
103
108
|
}), options.getPriceFn)) :
|
|
104
109
|
sdk_lib_1.RedundantSwapPrice.createFromTokenMap(options.pricingFeeDifferencePPM ?? 10000n, pricingAssets);
|
|
105
|
-
return new sdk_lib_1.Swapper(bitcoinRpc, chains, swapPricing, pricingAssets, options);
|
|
110
|
+
return new sdk_lib_1.Swapper(bitcoinRpc, chains, swapPricing, pricingAssets, options.messenger, options);
|
|
111
|
+
}
|
|
112
|
+
async newSwapperInitialized(options) {
|
|
113
|
+
const swapper = this.newSwapper(options);
|
|
114
|
+
await swapper.init();
|
|
115
|
+
return swapper;
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
118
|
exports.SwapperFactory = SwapperFactory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomiqlabs/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
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,9 @@
|
|
|
21
21
|
"author": "adambor",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atomiqlabs/base": "^
|
|
25
|
-
"@atomiqlabs/
|
|
24
|
+
"@atomiqlabs/base": "^12.0.0",
|
|
25
|
+
"@atomiqlabs/messenger-nostr": "^1.0.0",
|
|
26
|
+
"@atomiqlabs/sdk-lib": "^16.0.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@types/node": "22.13.5",
|
package/src/SmartChainAssets.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
export const SmartChainAssets = {
|
|
3
|
+
_TESTNET_WBTC_VESU: {
|
|
4
|
+
pricing: {
|
|
5
|
+
binancePair: "WBTCBTC",
|
|
6
|
+
okxPair: "WBTC-BTC",
|
|
7
|
+
coinGeckoCoinId: "wrapped-bitcoin",
|
|
8
|
+
coinPaprikaCoinId: "wbtc-wrapped-bitcoin",
|
|
9
|
+
krakenPair: "WBTCXBT"
|
|
10
|
+
},
|
|
11
|
+
name: "Wrapped BTC (WBTC)"
|
|
12
|
+
},
|
|
3
13
|
WBTC: {
|
|
4
14
|
pricing: {
|
|
5
15
|
binancePair: "WBTCBTC",
|
|
@@ -80,6 +90,26 @@ export const SmartChainAssets = {
|
|
|
80
90
|
krakenPair: "STRKUSD;!XXBTZUSD"
|
|
81
91
|
},
|
|
82
92
|
name: "Starknet"
|
|
93
|
+
},
|
|
94
|
+
CBTC: {
|
|
95
|
+
pricing: {
|
|
96
|
+
binancePair: "$fixed-100000000",
|
|
97
|
+
okxPair: "$fixed-100000000",
|
|
98
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
99
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
100
|
+
krakenPair: "$fixed-100000000"
|
|
101
|
+
},
|
|
102
|
+
name: "Citrea BTC"
|
|
103
|
+
},
|
|
104
|
+
BBTC: {
|
|
105
|
+
pricing: {
|
|
106
|
+
binancePair: "$fixed-100000000",
|
|
107
|
+
okxPair: "$fixed-100000000",
|
|
108
|
+
coinGeckoCoinId: "$fixed-100000000",
|
|
109
|
+
coinPaprikaCoinId: "$fixed-100000000",
|
|
110
|
+
krakenPair: "$fixed-100000000"
|
|
111
|
+
},
|
|
112
|
+
name: "Botanix BTC"
|
|
83
113
|
}
|
|
84
114
|
} as const;
|
|
85
115
|
|
package/src/SwapperFactory.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
BaseTokenType,
|
|
6
6
|
ChainType,
|
|
7
7
|
StorageObject,
|
|
8
|
-
IStorageManager
|
|
8
|
+
IStorageManager, Messenger
|
|
9
9
|
} from "@atomiqlabs/base";
|
|
10
10
|
import {
|
|
11
11
|
BitcoinTokens,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "@atomiqlabs/sdk-lib";
|
|
18
18
|
import {SmartChainAssets} from "./SmartChainAssets";
|
|
19
19
|
import {LocalStorageManager} from "./storage/LocalStorageManager";
|
|
20
|
+
import {NostrMessenger} from "@atomiqlabs/messenger-nostr";
|
|
20
21
|
|
|
21
22
|
type ChainInitializer<O, C extends ChainType, T extends BaseTokenType> = {
|
|
22
23
|
chainId: ChainType["ChainId"],
|
|
@@ -67,6 +68,7 @@ export type MultichainSwapperOptions<T extends readonly ChainInitializer<any, an
|
|
|
67
68
|
chainStorageCtor?: <T extends StorageObject>(name: string) => IStorageManager<T>,
|
|
68
69
|
pricingFeeDifferencePPM?: bigint,
|
|
69
70
|
mempoolApi?: MempoolApi | MempoolBitcoinRpc | string | string[],
|
|
71
|
+
messenger?: Messenger,
|
|
70
72
|
getPriceFn?: CustomPriceFunction
|
|
71
73
|
};
|
|
72
74
|
|
|
@@ -105,6 +107,10 @@ const mempoolUrls = {
|
|
|
105
107
|
]
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
const nostrUrls: string[] = [
|
|
111
|
+
"wss://relay.damus.io", "wss://nostr.einundzwanzig.space", "wss://nostr.mutinywallet.com"
|
|
112
|
+
];
|
|
113
|
+
|
|
108
114
|
export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
|
109
115
|
|
|
110
116
|
Tokens: GetAllTokens<T> & {
|
|
@@ -130,7 +136,7 @@ export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]
|
|
|
130
136
|
chain: "SC",
|
|
131
137
|
chainId: initializer.chainId,
|
|
132
138
|
address: assetData.address,
|
|
133
|
-
name: SmartChainAssets[ticker]
|
|
139
|
+
name: SmartChainAssets[ticker]?.name ?? ticker,
|
|
134
140
|
decimals: assetData.decimals,
|
|
135
141
|
displayDecimals: assetData.displayDecimals,
|
|
136
142
|
ticker
|
|
@@ -146,6 +152,7 @@ export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]
|
|
|
146
152
|
newSwapper(options: MultichainSwapperOptions<T>) {
|
|
147
153
|
options.bitcoinNetwork ??= BitcoinNetwork.MAINNET as any;
|
|
148
154
|
options.storagePrefix ??= "atomiqsdk-"+options.bitcoinNetwork+"-";
|
|
155
|
+
options.messenger ??= new NostrMessenger(options.bitcoinNetwork, nostrUrls);
|
|
149
156
|
|
|
150
157
|
options.defaultTrustedIntermediaryUrl ??= trustedIntermediaries[options.bitcoinNetwork];
|
|
151
158
|
|
|
@@ -191,8 +198,15 @@ export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]
|
|
|
191
198
|
chains as any,
|
|
192
199
|
swapPricing,
|
|
193
200
|
pricingAssets,
|
|
201
|
+
options.messenger,
|
|
194
202
|
options
|
|
195
203
|
);
|
|
196
204
|
}
|
|
197
205
|
|
|
206
|
+
async newSwapperInitialized(options: MultichainSwapperOptions<T>) {
|
|
207
|
+
const swapper = this.newSwapper(options);
|
|
208
|
+
await swapper.init();
|
|
209
|
+
return swapper;
|
|
210
|
+
}
|
|
211
|
+
|
|
198
212
|
}
|