@atomiqlabs/sdk 3.0.2 → 3.0.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/dist/SwapperFactory.d.ts +2 -1
- package/dist/SwapperFactory.js +9 -1
- package/package.json +2 -2
- package/src/SwapperFactory.ts +14 -4
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, MempoolApi, SCToken, Swapper, SwapperOptions } from "@atomiqlabs/sdk-lib";
|
|
2
|
+
import { BtcToken, CustomPriceFunction, MempoolApi, 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;
|
|
@@ -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;
|
|
36
|
+
getPriceFn?: CustomPriceFunction;
|
|
36
37
|
};
|
|
37
38
|
export declare class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
|
38
39
|
readonly initializers: T;
|
package/dist/SwapperFactory.js
CHANGED
|
@@ -78,7 +78,15 @@ class SwapperFactory {
|
|
|
78
78
|
continue;
|
|
79
79
|
chains[chainId] = initializer(options.chains[chainId], bitcoinRpc, options.bitcoinNetwork, options.chainStorageCtor);
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
const swapPricing = options.getPriceFn != null ?
|
|
82
|
+
new sdk_lib_1.SingleSwapPrice(options.pricingFeeDifferencePPM ?? 10000n, new sdk_lib_1.CustomPriceProvider(pricingAssets.map(val => {
|
|
83
|
+
return {
|
|
84
|
+
coinId: val.ticker,
|
|
85
|
+
chains: val.chains
|
|
86
|
+
};
|
|
87
|
+
}), options.getPriceFn)) :
|
|
88
|
+
sdk_lib_1.RedundantSwapPrice.createFromTokenMap(options.pricingFeeDifferencePPM ?? 10000n, pricingAssets);
|
|
89
|
+
return new sdk_lib_1.Swapper(bitcoinRpc, chains, swapPricing, pricingAssets, options);
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
exports.SwapperFactory = SwapperFactory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atomiqlabs/sdk",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atomiqlabs/base": "^8.0.1",
|
|
25
|
-
"@atomiqlabs/sdk-lib": "^12.0.
|
|
25
|
+
"@atomiqlabs/sdk-lib": "^12.0.8"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "22.13.5",
|
package/src/SwapperFactory.ts
CHANGED
|
@@ -9,10 +9,10 @@ import {
|
|
|
9
9
|
} from "@atomiqlabs/base";
|
|
10
10
|
import {
|
|
11
11
|
BitcoinTokens,
|
|
12
|
-
BtcToken,
|
|
12
|
+
BtcToken, CustomPriceFunction, CustomPriceProvider,
|
|
13
13
|
MempoolApi,
|
|
14
14
|
MempoolBitcoinRpc, RedundantSwapPrice,
|
|
15
|
-
RedundantSwapPriceAssets, SCToken, Swapper,
|
|
15
|
+
RedundantSwapPriceAssets, SCToken, SingleSwapPrice, Swapper,
|
|
16
16
|
SwapperOptions
|
|
17
17
|
} from "@atomiqlabs/sdk-lib";
|
|
18
18
|
import {SmartChainAssets} from "./SmartChainAssets";
|
|
@@ -66,7 +66,8 @@ 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,
|
|
70
|
+
getPriceFn?: CustomPriceFunction
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]> {
|
|
@@ -159,10 +160,19 @@ export class SwapperFactory<T extends readonly ChainInitializer<any, any, any>[]
|
|
|
159
160
|
chains[chainId] = initializer(options.chains[chainId], bitcoinRpc, options.bitcoinNetwork, options.chainStorageCtor) as any;
|
|
160
161
|
}
|
|
161
162
|
|
|
163
|
+
const swapPricing = options.getPriceFn!=null ?
|
|
164
|
+
new SingleSwapPrice(options.pricingFeeDifferencePPM ?? 10000n, new CustomPriceProvider(pricingAssets.map(val => {
|
|
165
|
+
return {
|
|
166
|
+
coinId: val.ticker,
|
|
167
|
+
chains: val.chains
|
|
168
|
+
}
|
|
169
|
+
}), options.getPriceFn)) :
|
|
170
|
+
RedundantSwapPrice.createFromTokenMap<ToMultichain<T>>(options.pricingFeeDifferencePPM ?? 10000n, pricingAssets);
|
|
171
|
+
|
|
162
172
|
return new Swapper<ToMultichain<T>>(
|
|
163
173
|
bitcoinRpc,
|
|
164
174
|
chains as any,
|
|
165
|
-
|
|
175
|
+
swapPricing,
|
|
166
176
|
pricingAssets,
|
|
167
177
|
options
|
|
168
178
|
);
|