@atomiqlabs/sdk 6.0.2 → 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.
@@ -89,5 +89,25 @@ export declare const SmartChainAssets: {
89
89
  };
90
90
  readonly name: "Starknet";
91
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
+ };
92
112
  };
93
113
  export type SmartChainAssetTickers = keyof typeof SmartChainAssets;
@@ -91,5 +91,25 @@ exports.SmartChainAssets = {
91
91
  krakenPair: "STRKUSD;!XXBTZUSD"
92
92
  },
93
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"
94
114
  }
95
115
  };
@@ -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 {};
@@ -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;
@@ -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": "6.0.2",
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": "^11.0.0",
25
- "@atomiqlabs/sdk-lib": "^15.0.0"
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",
@@ -90,6 +90,26 @@ export const SmartChainAssets = {
90
90
  krakenPair: "STRKUSD;!XXBTZUSD"
91
91
  },
92
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"
93
113
  }
94
114
  } as const;
95
115
 
@@ -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> & {
@@ -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
  }