@atomiqlabs/sdk 8.6.5 → 8.6.6

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.
Files changed (227) hide show
  1. package/dist/SmartChainAssets.d.ts +181 -181
  2. package/dist/SmartChainAssets.js +181 -181
  3. package/dist/bitcoin/coinselect2/accumulative.d.ts +6 -6
  4. package/dist/bitcoin/coinselect2/accumulative.js +51 -52
  5. package/dist/bitcoin/coinselect2/blackjack.d.ts +6 -6
  6. package/dist/bitcoin/coinselect2/blackjack.js +37 -38
  7. package/dist/bitcoin/coinselect2/index.d.ts +17 -19
  8. package/dist/bitcoin/coinselect2/index.js +69 -69
  9. package/dist/bitcoin/coinselect2/utils.d.ts +75 -77
  10. package/dist/bitcoin/coinselect2/utils.js +123 -123
  11. package/dist/bitcoin/wallet/BitcoinWallet.d.ts +128 -130
  12. package/dist/bitcoin/wallet/BitcoinWallet.js +322 -322
  13. package/dist/bitcoin/wallet/IBitcoinWallet.d.ts +78 -78
  14. package/dist/bitcoin/wallet/IBitcoinWallet.js +20 -21
  15. package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.d.ts +99 -101
  16. package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.js +176 -176
  17. package/dist/enums/FeeType.d.ts +15 -15
  18. package/dist/enums/FeeType.js +19 -19
  19. package/dist/enums/SwapAmountType.d.ts +15 -15
  20. package/dist/enums/SwapAmountType.js +19 -19
  21. package/dist/enums/SwapDirection.d.ts +15 -15
  22. package/dist/enums/SwapDirection.js +19 -19
  23. package/dist/enums/SwapSide.d.ts +15 -15
  24. package/dist/enums/SwapSide.js +19 -19
  25. package/dist/enums/SwapType.d.ts +75 -75
  26. package/dist/enums/SwapType.js +79 -79
  27. package/dist/errors/IntermediaryError.d.ts +13 -13
  28. package/dist/errors/IntermediaryError.js +27 -27
  29. package/dist/errors/RequestError.d.ts +32 -32
  30. package/dist/errors/RequestError.js +54 -54
  31. package/dist/errors/UserError.d.ts +8 -8
  32. package/dist/errors/UserError.js +16 -16
  33. package/dist/events/UnifiedSwapEventListener.d.ts +23 -23
  34. package/dist/events/UnifiedSwapEventListener.js +130 -130
  35. package/dist/http/HttpUtils.d.ts +27 -27
  36. package/dist/http/HttpUtils.js +90 -91
  37. package/dist/http/paramcoders/IParamReader.d.ts +8 -8
  38. package/dist/http/paramcoders/IParamReader.js +2 -2
  39. package/dist/http/paramcoders/ParamDecoder.d.ts +42 -44
  40. package/dist/http/paramcoders/ParamDecoder.js +137 -137
  41. package/dist/http/paramcoders/ParamEncoder.d.ts +18 -20
  42. package/dist/http/paramcoders/ParamEncoder.js +36 -36
  43. package/dist/http/paramcoders/SchemaVerifier.d.ts +26 -26
  44. package/dist/http/paramcoders/SchemaVerifier.js +145 -145
  45. package/dist/http/paramcoders/client/ResponseParamDecoder.d.ts +11 -11
  46. package/dist/http/paramcoders/client/ResponseParamDecoder.js +57 -57
  47. package/dist/http/paramcoders/client/StreamParamEncoder.d.ts +11 -13
  48. package/dist/http/paramcoders/client/StreamParamEncoder.js +26 -26
  49. package/dist/http/paramcoders/client/StreamingFetchPromise.d.ts +16 -16
  50. package/dist/http/paramcoders/client/StreamingFetchPromise.js +173 -174
  51. package/dist/index.d.ts +85 -85
  52. package/dist/index.js +158 -158
  53. package/dist/intermediaries/Intermediary.d.ts +157 -157
  54. package/dist/intermediaries/Intermediary.js +142 -142
  55. package/dist/intermediaries/IntermediaryDiscovery.d.ts +198 -199
  56. package/dist/intermediaries/IntermediaryDiscovery.js +406 -406
  57. package/dist/intermediaries/apis/IntermediaryAPI.d.ts +437 -438
  58. package/dist/intermediaries/apis/IntermediaryAPI.js +603 -602
  59. package/dist/intermediaries/apis/TrustedIntermediaryAPI.d.ts +155 -155
  60. package/dist/intermediaries/apis/TrustedIntermediaryAPI.js +137 -137
  61. package/dist/lnurl/LNURL.d.ts +102 -102
  62. package/dist/lnurl/LNURL.js +321 -321
  63. package/dist/prices/RedundantSwapPrice.d.ts +110 -110
  64. package/dist/prices/RedundantSwapPrice.js +222 -222
  65. package/dist/prices/SingleSwapPrice.d.ts +34 -34
  66. package/dist/prices/SingleSwapPrice.js +44 -44
  67. package/dist/prices/SwapPriceWithChain.d.ts +107 -107
  68. package/dist/prices/SwapPriceWithChain.js +128 -128
  69. package/dist/prices/abstract/ICachedSwapPrice.d.ts +28 -28
  70. package/dist/prices/abstract/ICachedSwapPrice.js +62 -62
  71. package/dist/prices/abstract/IPriceProvider.d.ts +81 -81
  72. package/dist/prices/abstract/IPriceProvider.js +74 -74
  73. package/dist/prices/abstract/ISwapPrice.d.ts +168 -168
  74. package/dist/prices/abstract/ISwapPrice.js +279 -279
  75. package/dist/prices/providers/BinancePriceProvider.d.ts +23 -23
  76. package/dist/prices/providers/BinancePriceProvider.js +30 -30
  77. package/dist/prices/providers/CoinGeckoPriceProvider.d.ts +23 -23
  78. package/dist/prices/providers/CoinGeckoPriceProvider.js +29 -29
  79. package/dist/prices/providers/CoinPaprikaPriceProvider.d.ts +25 -25
  80. package/dist/prices/providers/CoinPaprikaPriceProvider.js +29 -29
  81. package/dist/prices/providers/CustomPriceProvider.d.ts +24 -24
  82. package/dist/prices/providers/CustomPriceProvider.js +35 -35
  83. package/dist/prices/providers/KrakenPriceProvider.d.ts +38 -38
  84. package/dist/prices/providers/KrakenPriceProvider.js +45 -45
  85. package/dist/prices/providers/OKXPriceProvider.d.ts +34 -34
  86. package/dist/prices/providers/OKXPriceProvider.js +29 -29
  87. package/dist/prices/providers/abstract/ExchangePriceProvider.d.ts +17 -17
  88. package/dist/prices/providers/abstract/ExchangePriceProvider.js +21 -21
  89. package/dist/prices/providers/abstract/HttpPriceProvider.d.ts +7 -7
  90. package/dist/prices/providers/abstract/HttpPriceProvider.js +12 -12
  91. package/dist/storage/IUnifiedStorage.d.ts +85 -85
  92. package/dist/storage/IUnifiedStorage.js +2 -2
  93. package/dist/storage/UnifiedSwapStorage.d.ts +114 -114
  94. package/dist/storage/UnifiedSwapStorage.js +116 -116
  95. package/dist/storage-browser/IndexedDBUnifiedStorage.d.ts +63 -63
  96. package/dist/storage-browser/IndexedDBUnifiedStorage.js +298 -298
  97. package/dist/storage-browser/LocalStorageManager.d.ts +49 -49
  98. package/dist/storage-browser/LocalStorageManager.js +93 -93
  99. package/dist/swapper/Swapper.d.ts +686 -687
  100. package/dist/swapper/Swapper.js +1603 -1603
  101. package/dist/swapper/SwapperFactory.d.ts +135 -135
  102. package/dist/swapper/SwapperFactory.js +162 -162
  103. package/dist/swapper/SwapperUtils.d.ts +200 -200
  104. package/dist/swapper/SwapperUtils.js +467 -467
  105. package/dist/swapper/SwapperWithChain.d.ts +404 -404
  106. package/dist/swapper/SwapperWithChain.js +469 -469
  107. package/dist/swapper/SwapperWithSigner.d.ts +322 -322
  108. package/dist/swapper/SwapperWithSigner.js +318 -318
  109. package/dist/swaps/IAddressSwap.d.ts +22 -22
  110. package/dist/swaps/IAddressSwap.js +13 -14
  111. package/dist/swaps/IBTCWalletSwap.d.ts +73 -73
  112. package/dist/swaps/IBTCWalletSwap.js +17 -18
  113. package/dist/swaps/IClaimableSwap.d.ts +49 -49
  114. package/dist/swaps/IClaimableSwap.js +14 -15
  115. package/dist/swaps/IClaimableSwapWrapper.d.ts +15 -15
  116. package/dist/swaps/IClaimableSwapWrapper.js +2 -2
  117. package/dist/swaps/IRefundableSwap.d.ts +43 -43
  118. package/dist/swaps/IRefundableSwap.js +13 -14
  119. package/dist/swaps/ISwap.d.ts +386 -387
  120. package/dist/swaps/ISwap.js +346 -346
  121. package/dist/swaps/ISwapWithGasDrop.d.ts +21 -21
  122. package/dist/swaps/ISwapWithGasDrop.js +11 -12
  123. package/dist/swaps/ISwapWrapper.d.ts +283 -285
  124. package/dist/swaps/ISwapWrapper.js +353 -353
  125. package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.d.ts +98 -98
  126. package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.js +126 -126
  127. package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +133 -135
  128. package/dist/swaps/escrow_swaps/IEscrowSwap.js +169 -169
  129. package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +114 -115
  130. package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +134 -134
  131. package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +98 -101
  132. package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +130 -130
  133. package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.d.ts +162 -162
  134. package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.js +190 -190
  135. package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.d.ts +58 -58
  136. package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.js +78 -78
  137. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +529 -531
  138. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +1285 -1285
  139. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +181 -184
  140. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +418 -418
  141. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +581 -583
  142. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +1371 -1371
  143. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +225 -228
  144. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +506 -506
  145. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +458 -458
  146. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +1126 -1126
  147. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +190 -191
  148. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +378 -378
  149. package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +403 -403
  150. package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +924 -924
  151. package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.d.ts +62 -62
  152. package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.js +112 -112
  153. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.d.ts +125 -127
  154. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.js +256 -256
  155. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +241 -242
  156. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +520 -520
  157. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.d.ts +73 -73
  158. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.js +155 -155
  159. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +127 -128
  160. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +278 -278
  161. package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +630 -630
  162. package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +1443 -1443
  163. package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +213 -207
  164. package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +756 -755
  165. package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +261 -261
  166. package/dist/swaps/trusted/ln/LnForGasSwap.js +511 -511
  167. package/dist/swaps/trusted/ln/LnForGasWrapper.d.ts +40 -40
  168. package/dist/swaps/trusted/ln/LnForGasWrapper.js +82 -82
  169. package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +342 -342
  170. package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +715 -715
  171. package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +68 -69
  172. package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +92 -92
  173. package/dist/types/AmountData.d.ts +10 -10
  174. package/dist/types/AmountData.js +2 -2
  175. package/dist/types/CustomPriceFunction.d.ts +11 -11
  176. package/dist/types/CustomPriceFunction.js +2 -2
  177. package/dist/types/PriceInfoType.d.ts +28 -28
  178. package/dist/types/PriceInfoType.js +56 -57
  179. package/dist/types/SwapExecutionAction.d.ts +88 -88
  180. package/dist/types/SwapExecutionAction.js +2 -2
  181. package/dist/types/SwapStateInfo.d.ts +5 -5
  182. package/dist/types/SwapStateInfo.js +2 -2
  183. package/dist/types/SwapWithSigner.d.ts +17 -17
  184. package/dist/types/SwapWithSigner.js +42 -43
  185. package/dist/types/Token.d.ts +99 -99
  186. package/dist/types/Token.js +76 -76
  187. package/dist/types/TokenAmount.d.ts +69 -69
  188. package/dist/types/TokenAmount.js +59 -60
  189. package/dist/types/fees/Fee.d.ts +50 -50
  190. package/dist/types/fees/Fee.js +2 -2
  191. package/dist/types/fees/FeeBreakdown.d.ts +11 -11
  192. package/dist/types/fees/FeeBreakdown.js +2 -2
  193. package/dist/types/fees/PercentagePPM.d.ts +17 -17
  194. package/dist/types/fees/PercentagePPM.js +17 -18
  195. package/dist/types/lnurl/LNURLPay.d.ts +61 -61
  196. package/dist/types/lnurl/LNURLPay.js +30 -31
  197. package/dist/types/lnurl/LNURLWithdraw.d.ts +48 -48
  198. package/dist/types/lnurl/LNURLWithdraw.js +26 -27
  199. package/dist/types/wallets/LightningInvoiceCreateService.d.ts +24 -24
  200. package/dist/types/wallets/LightningInvoiceCreateService.js +14 -15
  201. package/dist/types/wallets/MinimalBitcoinWalletInterface.d.ts +23 -23
  202. package/dist/types/wallets/MinimalBitcoinWalletInterface.js +2 -2
  203. package/dist/types/wallets/MinimalLightningNetworkWalletInterface.d.ts +9 -9
  204. package/dist/types/wallets/MinimalLightningNetworkWalletInterface.js +2 -2
  205. package/dist/utils/AutomaticClockDriftCorrection.d.ts +1 -1
  206. package/dist/utils/AutomaticClockDriftCorrection.js +69 -70
  207. package/dist/utils/BitcoinUtils.d.ts +12 -14
  208. package/dist/utils/BitcoinUtils.js +101 -102
  209. package/dist/utils/BitcoinWalletUtils.d.ts +7 -7
  210. package/dist/utils/BitcoinWalletUtils.js +13 -14
  211. package/dist/utils/Logger.d.ts +7 -7
  212. package/dist/utils/Logger.js +11 -12
  213. package/dist/utils/RetryUtils.d.ts +22 -22
  214. package/dist/utils/RetryUtils.js +66 -67
  215. package/dist/utils/SwapUtils.d.ts +88 -88
  216. package/dist/utils/SwapUtils.js +72 -72
  217. package/dist/utils/TimeoutUtils.d.ts +17 -17
  218. package/dist/utils/TimeoutUtils.js +54 -55
  219. package/dist/utils/TokenUtils.d.ts +19 -19
  220. package/dist/utils/TokenUtils.js +36 -37
  221. package/dist/utils/TypeUtils.d.ts +7 -7
  222. package/dist/utils/TypeUtils.js +2 -2
  223. package/dist/utils/Utils.d.ts +56 -58
  224. package/dist/utils/Utils.js +193 -194
  225. package/package.json +1 -1
  226. package/src/intermediaries/apis/IntermediaryAPI.ts +4 -2
  227. package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +8 -0
@@ -1,687 +1,686 @@
1
- /// <reference types="node" />
2
- import { ISwapPrice } from "../prices/abstract/ISwapPrice";
3
- import { BitcoinNetwork, BitcoinRpcWithAddressIndex, BtcBlock, BtcRelay, ChainData, ChainType, LightningNetworkApi, Messenger, RelaySynchronizer } from "@atomiqlabs/base";
4
- import { ToBTCLNOptions, ToBTCLNWrapper } from "../swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper";
5
- import { ToBTCOptions, ToBTCWrapper } from "../swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper";
6
- import { FromBTCLNOptions, FromBTCLNWrapper } from "../swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper";
7
- import { FromBTCOptions, FromBTCWrapper } from "../swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper";
8
- import { IntermediaryDiscovery } from "../intermediaries/IntermediaryDiscovery";
9
- import { ISwap } from "../swaps/ISwap";
10
- import { SwapType } from "../enums/SwapType";
11
- import { FromBTCLNSwap } from "../swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap";
12
- import { FromBTCSwap } from "../swaps/escrow_swaps/frombtc/onchain/FromBTCSwap";
13
- import { ToBTCLNSwap } from "../swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap";
14
- import { ToBTCSwap } from "../swaps/escrow_swaps/tobtc/onchain/ToBTCSwap";
15
- import { LnForGasWrapper } from "../swaps/trusted/ln/LnForGasWrapper";
16
- import { LnForGasSwap } from "../swaps/trusted/ln/LnForGasSwap";
17
- import { EventEmitter } from "events";
18
- import { Intermediary } from "../intermediaries/Intermediary";
19
- import { SwapperWithChain } from "./SwapperWithChain";
20
- import { OnchainForGasSwap } from "../swaps/trusted/onchain/OnchainForGasSwap";
21
- import { OnchainForGasWrapper } from "../swaps/trusted/onchain/OnchainForGasWrapper";
22
- import { BTC_NETWORK } from "@scure/btc-signer/utils";
23
- import { IUnifiedStorage } from "../storage/IUnifiedStorage";
24
- import { UnifiedSwapStorage, UnifiedSwapStorageCompositeIndexes, UnifiedSwapStorageIndexes } from "../storage/UnifiedSwapStorage";
25
- import { UnifiedSwapEventListener } from "../events/UnifiedSwapEventListener";
26
- import { IToBTCSwap } from "../swaps/escrow_swaps/tobtc/IToBTCSwap";
27
- import { SpvFromBTCOptions, SpvFromBTCWrapper } from "../swaps/spv_swaps/SpvFromBTCWrapper";
28
- import { SpvFromBTCSwap } from "../swaps/spv_swaps/SpvFromBTCSwap";
29
- import { SwapperUtils } from "./SwapperUtils";
30
- import { FromBTCLNAutoOptions, FromBTCLNAutoWrapper } from "../swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper";
31
- import { FromBTCLNAutoSwap } from "../swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap";
32
- import { SwapAmountType } from "../enums/SwapAmountType";
33
- import { IClaimableSwap } from "../swaps/IClaimableSwap";
34
- import { SwapTypeMapping } from "../utils/SwapUtils";
35
- import { TokenAmount } from "../types/TokenAmount";
36
- import { BtcToken, SCToken, Token } from "../types/Token";
37
- import { LNURLWithdraw } from "../types/lnurl/LNURLWithdraw";
38
- import { LNURLPay } from "../types/lnurl/LNURLPay";
39
- import { NotNever } from "../utils/TypeUtils";
40
- import { LightningInvoiceCreateService } from "../types/wallets/LightningInvoiceCreateService";
41
- import { SwapSide } from "../enums/SwapSide";
42
- /**
43
- * Configuration options for the Swapper
44
- * @category Core
45
- */
46
- export type SwapperOptions = {
47
- /**
48
- * Manual override for the intermediary (LP) URLs for the SDK to use, by default these are fetched automatically
49
- * from the registry
50
- */
51
- intermediaryUrl?: string | string[];
52
- /**
53
- * Registry URL for where to look for active intermediary (LP) endpoint URLs
54
- */
55
- registryUrl?: string;
56
- /**
57
- * Bitcoin network to use for the swaps,
58
- */
59
- bitcoinNetwork?: BitcoinNetwork;
60
- /**
61
- * Timeout (in milliseconds) for HTTP GET requests done by the SDK
62
- */
63
- getRequestTimeout?: number;
64
- /**
65
- * Timeout (in milliseconds) for HTTP POST requests done by the SDK
66
- */
67
- postRequestTimeout?: number;
68
- /**
69
- * Additional parameters to be sent to the intermediaries (LPs), when requesting quotes from them
70
- */
71
- defaultAdditionalParameters?: {
72
- [key: string]: any;
73
- };
74
- /**
75
- * Optional name prefix to use when creating a swap storage, you can use this to create separate storage
76
- * instances that don't overlap.
77
- */
78
- storagePrefix?: string;
79
- /**
80
- * Sets the default intermediary (LP) to use for the trusted gas swaps, if not set the SDK uses a default one
81
- */
82
- defaultTrustedIntermediaryUrl?: string;
83
- /**
84
- * A function callback to retrieve a specific named storage container for swap persistency. If not present, the
85
- * default IndexedDB storage adapter is used. When you use the SDK in non-browser based environments you need to
86
- * provide this callback such that the SDK is able to use a custom storage adapter.
87
- *
88
- * @param storageName Name of the container to retrieve
89
- */
90
- swapStorage?: (storageName: string) => IUnifiedStorage<UnifiedSwapStorageIndexes, UnifiedSwapStorageCompositeIndexes>;
91
- /**
92
- * By setting this flag, the swapper doesn't schedule automatic tick timers. To make sure the swap states are
93
- * properly updated (e.g. the expired swaps properly move to the expired state), you should call the
94
- * {@link Swapper._syncSwaps} function periodically. This flag should be set when you run an environment that
95
- * doesn't support long-running timers - e.g. serverless environments like Azure Function Apps or AWS Lambda
96
- */
97
- noTimers?: boolean;
98
- /**
99
- * By setting this flag, the swapper doesn't subscribe to on-chain events. To make sure the swap states are
100
- * properly updated you should call the {@link Swapper._syncSwaps} function periodically. This flag should be
101
- * set when you run an environment that doesn't support long-running timers and websocket connections - e.g.
102
- * serverless environments like Azure Function Apps or AWS Lambda
103
- */
104
- noEvents?: boolean;
105
- /**
106
- * By setting this flag, the swap objects will not be cached in the SDK and instead will always be loaded from
107
- * the persistent storage. By default, the SDK uses a `WeakRef` mapping of swaps, to ensure that when the same
108
- * swap is loaded concurrently, it returns the same object reference to both, making the changes on the object
109
- * atomic. This flag should be set to `true` when running in an environment where multiple instances of the SDK
110
- * access the same swap database - e.g. serverless environments like Azure Function Apps or AWS Lambda
111
- */
112
- noSwapCache?: boolean;
113
- /**
114
- * Skip checking past swaps when the swapper is initiated with {@link Swapper.init}, you can call the
115
- * {@link Swapper._syncSwaps} function later, to check the swaps. By default, the SDK checks the state
116
- * of all the known swaps during init.
117
- */
118
- dontCheckPastSwaps?: boolean;
119
- /**
120
- * Skip fetching the LPs when the swapper is initiated with {@link Swapper.init}, this means the list of available
121
- * tokens and swap limits won't be available immediately. LPs will be fetched automatically later, when a swap
122
- * is requested
123
- */
124
- dontFetchLPs?: boolean;
125
- /**
126
- * Defaults to `true`, this means every swap regardless of it being initiated (i.e. when `commit()`, `execute()` or
127
- * `waitTillPayment` is called) is saved to the persistent storage. This is a reasonable default for when you
128
- * want to only create a swap, and then later on retrieve it with the `swapper.getSwapById()` function.
129
- *
130
- * Setting this to `false` means the SDK only saves and persists swaps that are considered initiated, i.e. when
131
- * `commit()`, `execute()` or `waitTillPayment` is called (or their respective txs... prefixed variations). This
132
- * might save calls to the persistent storage for swaps that are never initiated. This is useful in e.g.
133
- * frontend implementations where the frontend holds the swap object reference until it is initiated anyway, not
134
- * necessitating the saving of the swap data to the persistent storage until it is actually initiated.
135
- */
136
- saveUninitializedSwaps?: boolean;
137
- /**
138
- * Automatically checks system time on initialize, if the system time drifts too far from the actual time
139
- * (as checked from multiple server sources) it adjusts the `Date.now()` function to return proper actual time.
140
- */
141
- automaticClockDriftCorrection?: boolean;
142
- };
143
- /**
144
- * Type representing multiple blockchain configurations
145
- * @category Core
146
- */
147
- export type MultiChain = {
148
- [chainIdentifier in string]: ChainType;
149
- };
150
- type ChainSpecificData<T extends ChainType> = {
151
- wrappers: {
152
- [SwapType.TO_BTCLN]: ToBTCLNWrapper<T>;
153
- [SwapType.TO_BTC]: ToBTCWrapper<T>;
154
- [SwapType.FROM_BTCLN]: FromBTCLNWrapper<T>;
155
- [SwapType.FROM_BTC]: FromBTCWrapper<T>;
156
- [SwapType.TRUSTED_FROM_BTCLN]: LnForGasWrapper<T>;
157
- [SwapType.TRUSTED_FROM_BTC]: OnchainForGasWrapper<T>;
158
- [SwapType.SPV_VAULT_FROM_BTC]: SpvFromBTCWrapper<T>;
159
- [SwapType.FROM_BTCLN_AUTO]: FromBTCLNAutoWrapper<T>;
160
- };
161
- chainEvents: T["Events"];
162
- swapContract: T["Contract"];
163
- spvVaultContract: T["SpvVaultContract"];
164
- chainInterface: T["ChainInterface"];
165
- btcRelay: BtcRelay<any, T["TX"], BtcBlock, T["Signer"]>;
166
- synchronizer: RelaySynchronizer<any, T["TX"], BtcBlock>;
167
- unifiedChainEvents: UnifiedSwapEventListener<T>;
168
- unifiedSwapStorage: UnifiedSwapStorage<T>;
169
- reviver: (val: any) => ISwap<T>;
170
- };
171
- type MultiChainData<T extends MultiChain> = {
172
- [chainIdentifier in keyof T]: ChainSpecificData<T[chainIdentifier]>;
173
- };
174
- type CtorMultiChainData<T extends MultiChain> = {
175
- [chainIdentifier in keyof T]: ChainData<T[chainIdentifier]>;
176
- };
177
- /**
178
- * Type extracting chain identifiers from a MultiChain type
179
- * @category Core
180
- */
181
- export type ChainIds<T extends MultiChain> = keyof T & string;
182
- /**
183
- * Type helper to check if a chain supports a specific swap type
184
- * @category Core
185
- */
186
- export type SupportsSwapType<C extends ChainType, Type extends SwapType> = Type extends SwapType.SPV_VAULT_FROM_BTC ? NotNever<C["SpvVaultContract"]> : Type extends (SwapType.TRUSTED_FROM_BTCLN | SwapType.TRUSTED_FROM_BTC) ? true : Type extends SwapType.FROM_BTCLN_AUTO ? (C["Contract"]["supportsInitWithoutClaimer"] extends true ? true : false) : NotNever<C["Contract"]>;
187
- /**
188
- * Core orchestrator for all atomiq swap operations
189
- *
190
- * @category Core
191
- */
192
- export declare class Swapper<T extends MultiChain> extends EventEmitter<{
193
- lpsRemoved: [Intermediary[]];
194
- lpsAdded: [Intermediary[]];
195
- swapState: [ISwap];
196
- swapLimitsChanged: [];
197
- }> {
198
- private readonly logger;
199
- private readonly swapStateListener;
200
- private defaultTrustedIntermediary?;
201
- private readonly bitcoinNetwork;
202
- private readonly options;
203
- /**
204
- * Data propagation layer used for broadcasting messages to watchtowers
205
- */
206
- private readonly messenger;
207
- /**
208
- * A dictionary of smart chains used by the SDK
209
- * @internal
210
- */
211
- readonly _chains: MultiChainData<T>;
212
- /**
213
- * Bitcoin RPC for fetching bitcoin chain data
214
- * @internal
215
- */
216
- readonly _bitcoinRpc: BitcoinRpcWithAddressIndex<any>;
217
- /**
218
- * Bitcoin network specification
219
- * @internal
220
- */
221
- readonly _btcNetwork: BTC_NETWORK;
222
- /**
223
- * Token data indexed by chain identifier and token addresses
224
- * @internal
225
- */
226
- readonly _tokens: {
227
- [chainId: string]: {
228
- [tokenAddress: string]: SCToken;
229
- };
230
- };
231
- /**
232
- * Token data indexed by chain identifier and token tickers
233
- * @internal
234
- */
235
- readonly _tokensByTicker: {
236
- [chainId: string]: {
237
- [tokenTicker: string]: SCToken;
238
- };
239
- };
240
- /**
241
- * Pricing API used by the SDK
242
- */
243
- readonly prices: ISwapPrice<T>;
244
- /**
245
- * Intermediary discovery instance
246
- */
247
- readonly intermediaryDiscovery: IntermediaryDiscovery;
248
- /**
249
- * Miscellaneous utility functions
250
- */
251
- readonly Utils: SwapperUtils<T>;
252
- /**
253
- * @internal
254
- */
255
- constructor(bitcoinRpc: BitcoinRpcWithAddressIndex<any>, lightningApi: LightningNetworkApi, bitcoinSynchronizer: (btcRelay: BtcRelay<any, any, any>) => RelaySynchronizer<any, any, any>, chainsData: CtorMultiChainData<T>, pricing: ISwapPrice<T>, tokens: SCToken[], messenger: Messenger, options?: SwapperOptions);
256
- private _init;
257
- private initPromise?;
258
- private initialized;
259
- /**
260
- * Initializes the swap storage and loads existing swaps, needs to be called before any other action
261
- */
262
- init(): Promise<void>;
263
- /**
264
- * Stops listening for onchain events and closes this Swapper instance
265
- */
266
- stop(): Promise<void>;
267
- /**
268
- * Creates swap & handles intermediary, quote selection
269
- *
270
- * @param chainIdentifier
271
- * @param create Callback to create the
272
- * @param amountData Amount data as passed to the function
273
- * @param swapType Swap type of the execution
274
- * @param maxWaitTimeMS Maximum waiting time after the first intermediary returns the quote
275
- * @private
276
- * @throws {Error} when no intermediary was found
277
- * @throws {Error} if the chain with the provided identifier cannot be found
278
- */
279
- private createSwap;
280
- /**
281
- * Creates Smart chain -> Bitcoin ({@link SwapType.TO_BTC}) swap
282
- *
283
- * @param chainIdentifier Chain identifier string of the source smart chain
284
- * @param signer Signer's address on the source chain
285
- * @param tokenAddress Token address to pay with
286
- * @param address Recipient's bitcoin address
287
- * @param amount Amount to send in token based units (if `exactIn=true`) or receive in satoshis (if `exactIn=false`)
288
- * @param exactIn Whether to use exact in instead of exact out
289
- * @param additionalParams Additional parameters sent to the LP when creating the swap
290
- * @param options Additional options for the swap
291
- */
292
- createToBTCSwap<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, signer: string, tokenAddress: string, address: string, amount: bigint, exactIn?: boolean, additionalParams?: Record<string, any> | undefined, options?: ToBTCOptions): Promise<ToBTCSwap<T[ChainIdentifier]>>;
293
- /**
294
- * Creates Smart chain -> Bitcoin Lightning ({@link SwapType.TO_BTCLN}) swap
295
- *
296
- * @param chainIdentifier Chain identifier string of the source smart chain
297
- * @param signer Signer's address on the source chain
298
- * @param tokenAddress Token address to pay with
299
- * @param paymentRequest BOLT11 lightning network invoice to be paid (needs to have a fixed amount), and the swap
300
- * amount is taken from this fixed amount, hence only exact output swaps are supported
301
- * @param additionalParams Additional parameters sent to the LP when creating the swap
302
- * @param options Additional options for the swap
303
- */
304
- createToBTCLNSwap<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, signer: string, tokenAddress: string, paymentRequest: string, additionalParams?: Record<string, any> | undefined, options?: ToBTCLNOptions): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;
305
- /**
306
- * Creates Smart chain -> Bitcoin Lightning ({@link SwapType.TO_BTCLN}) swap via LNURL-pay link
307
- *
308
- * @param chainIdentifier Chain identifier string of the source smart chain
309
- * @param signer Signer's address on the source chain
310
- * @param tokenAddress Token address to pay with
311
- * @param lnurlPay LNURL-pay link to use for the payment
312
- * @param amount Amount to send in token based units (if `exactIn=true`) or receive in satoshis (if `exactIn=false`)
313
- * @param exactIn Whether to do an exact in swap instead of exact out
314
- * @param additionalParams Additional parameters sent to the LP when creating the swap
315
- * @param options Additional options for the swap
316
- */
317
- createToBTCLNSwapViaLNURL<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, signer: string, tokenAddress: string, lnurlPay: string | LNURLPay, amount: bigint, exactIn?: boolean, additionalParams?: Record<string, any> | undefined, options?: ToBTCLNOptions & {
318
- comment?: string;
319
- }): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;
320
- /**
321
- * Creates Smart chain -> Bitcoin Lightning ({@link SwapType.TO_BTCLN}) swap via {@link LightningInvoiceCreateService}
322
- *
323
- * @param chainIdentifier Chain identifier string of the source smart chain
324
- * @param signer Signer's address on the source chain
325
- * @param tokenAddress Token address to pay with
326
- * @param service Invoice create service object which facilitates the creation of fixed amount LN invoices
327
- * @param amount Amount to send in token based units (if `exactIn=true`) or receive in satoshis (if `exactIn=false`)
328
- * @param exactIn Whether to do an exact in swap instead of exact out
329
- * @param additionalParams Additional parameters sent to the LP when creating the swap
330
- * @param options Additional options for the swap
331
- */
332
- createToBTCLNSwapViaInvoiceCreateService<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, signer: string, tokenAddress: string, service: LightningInvoiceCreateService, amount: bigint, exactIn?: boolean, additionalParams?: Record<string, any> | undefined, options?: ToBTCLNOptions): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;
333
- /**
334
- * Creates Bitcoin -> Smart chain ({@link SwapType.SPV_VAULT_FROM_BTC}) swap
335
- *
336
- * @param chainIdentifier Chain identifier string of the destination smart chain
337
- * @param recipient Recipient address on the destination chain
338
- * @param tokenAddress Token address to receive
339
- * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
340
- * @param exactOut Whether to use a exact out instead of exact in
341
- * @param additionalParams Additional parameters sent to the LP when creating the swap
342
- * @param options Additional options for the swap
343
- */
344
- createFromBTCSwapNew<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: SpvFromBTCOptions): Promise<SpvFromBTCSwap<T[ChainIdentifier]>>;
345
- /**
346
- * Creates LEGACY Bitcoin -> Smart chain ({@link SwapType.FROM_BTC}) swap
347
- *
348
- * @param chainIdentifier Chain identifier string of the destination smart chain
349
- * @param recipient Recipient address on the destination chain
350
- * @param tokenAddress Token address to receive
351
- * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
352
- * @param exactOut Whether to use a exact out instead of exact in
353
- * @param additionalParams Additional parameters sent to the LP when creating the swap
354
- * @param options Additional options for the swap
355
- */
356
- createFromBTCSwap<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCOptions): Promise<FromBTCSwap<T[ChainIdentifier]>>;
357
- /**
358
- * Creates LEGACY Bitcoin Lightning -> Smart chain ({@link SwapType.FROM_BTCLN}) swap
359
- *
360
- * @param chainIdentifier Chain identifier string of the destination smart chain
361
- * @param recipient Recipient address on the destination chain
362
- * @param tokenAddress Token address to receive
363
- * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
364
- * @param exactOut Whether to use a exact out instead of exact in
365
- * @param additionalParams Additional parameters sent to the LP when creating the swap
366
- * @param options Additional options for the swap
367
- */
368
- createFromBTCLNSwap<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCLNOptions): Promise<FromBTCLNSwap<T[ChainIdentifier]>>;
369
- /**
370
- * Creates LEGACY Bitcoin Lightning -> Smart chain ({@link SwapType.FROM_BTCLN}) swap, withdrawing from
371
- * an LNURL-withdraw link
372
- *
373
- * @param chainIdentifier Chain identifier string of the destination smart chain
374
- * @param recipient Recipient address on the destination chain
375
- * @param tokenAddress Token address to receive
376
- * @param lnurl LNURL-withdraw link to pull the funds from
377
- * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
378
- * @param exactOut Whether to use a exact out instead of exact in
379
- * @param additionalParams Additional parameters sent to the LP when creating the swap
380
- * @param options Additional options for the swap
381
- */
382
- createFromBTCLNSwapViaLNURL<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, lnurl: string | LNURLWithdraw, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCLNOptions): Promise<FromBTCLNSwap<T[ChainIdentifier]>>;
383
- /**
384
- * Creates Bitcoin Lightning -> Smart chain ({@link SwapType.FROM_BTCLN_AUTO}) swap
385
- *
386
- * @param chainIdentifier Chain identifier string of the destination smart chain
387
- * @param recipient Recipient address on the destination chain
388
- * @param tokenAddress Token address to receive
389
- * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
390
- * @param exactOut Whether to use a exact out instead of exact in
391
- * @param additionalParams Additional parameters sent to the LP when creating the swap
392
- * @param options Additional options for the swap
393
- */
394
- createFromBTCLNSwapNew<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCLNAutoOptions): Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>>;
395
- /**
396
- * Creates Bitcoin Lightning -> Smart chain ({@link SwapType.FROM_BTCLN_AUTO}) swap, withdrawing from
397
- * an LNURL-withdraw link
398
- *
399
- * @param chainIdentifier Chain identifier string of the destination smart chain
400
- * @param recipient Recipient address on the destination chain
401
- * @param tokenAddress Token address to receive
402
- * @param lnurl LNURL-withdraw link to pull the funds from
403
- * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
404
- * @param exactOut Whether to use a exact out instead of exact in
405
- * @param additionalParams Additional parameters sent to the LP when creating the swap
406
- * @param options Additional options for the swap
407
- */
408
- createFromBTCLNSwapNewViaLNURL<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, lnurl: string | LNURLWithdraw, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCLNAutoOptions): Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>>;
409
- /**
410
- * Creates a trusted Bitcoin Lightning -> Smart chain ({@link SwapType.TRUSTED_FROM_BTCLN}) gas swap
411
- *
412
- * @param chainIdentifier Chain identifier string of the destination smart chain
413
- * @param recipient Recipient address on the destination chain
414
- * @param amount Amount of native token to receive, in base units
415
- * @param trustedIntermediaryOrUrl URL or Intermediary object of the trusted intermediary to use, otherwise uses default
416
- * @throws {Error} If no trusted intermediary specified
417
- */
418
- createTrustedLNForGasSwap<C extends ChainIds<T>>(chainIdentifier: C, recipient: string, amount: bigint, trustedIntermediaryOrUrl?: Intermediary | string): Promise<LnForGasSwap<T[C]>>;
419
- /**
420
- * Creates a trusted Bitcoin -> Smart chain ({@link SwapType.TRUSTED_FROM_BTC}) gas swap
421
- *
422
- * @param chainIdentifier Chain identifier string of the destination smart chain
423
- * @param recipient Recipient address on the destination chain
424
- * @param amount Amount of native token to receive, in base units
425
- * @param refundAddress Bitcoin refund address, in case the swap fails the funds are refunded here
426
- * @param trustedIntermediaryOrUrl URL or Intermediary object of the trusted intermediary to use, otherwise uses default
427
- * @throws {Error} If no trusted intermediary specified
428
- */
429
- createTrustedOnchainForGasSwap<C extends ChainIds<T>>(chainIdentifier: C, recipient: string, amount: bigint, refundAddress?: string, trustedIntermediaryOrUrl?: Intermediary | string): Promise<OnchainForGasSwap<T[C]>>;
430
- /**
431
- * @internal
432
- */
433
- create<C extends ChainIds<T>>(signer: string, srcToken: BtcToken<true>, dstToken: SCToken<C>, amount: bigint, exactIn: boolean, lnurlWithdraw?: string | LNURLWithdraw): Promise<(SupportsSwapType<T[C], SwapType.FROM_BTCLN_AUTO> extends true ? FromBTCLNAutoSwap<T[C]> : FromBTCLNSwap<T[C]>)>;
434
- /**
435
- * @internal
436
- */
437
- create<C extends ChainIds<T>>(signer: string, srcToken: BtcToken<false>, dstToken: SCToken<C>, amount: bigint, exactIn: boolean): Promise<(SupportsSwapType<T[C], SwapType.SPV_VAULT_FROM_BTC> extends true ? SpvFromBTCSwap<T[C]> : FromBTCSwap<T[C]>)>;
438
- /**
439
- * @internal
440
- */
441
- create<C extends ChainIds<T>>(signer: string, srcToken: SCToken<C>, dstToken: BtcToken<false>, amount: bigint, exactIn: boolean, address: string): Promise<ToBTCSwap<T[C]>>;
442
- /**
443
- * @internal
444
- */
445
- create<C extends ChainIds<T>>(signer: string, srcToken: SCToken<C>, dstToken: BtcToken<true>, amount: bigint, exactIn: boolean, lnurlPay: string | LNURLPay): Promise<ToBTCLNSwap<T[C]>>;
446
- /**
447
- * @internal
448
- */
449
- create<C extends ChainIds<T>>(signer: string, srcToken: SCToken<C>, dstToken: BtcToken<true>, amount: undefined, exactIn: false, lightningInvoice: string): Promise<ToBTCLNSwap<T[C]>>;
450
- /**
451
- * Creates a swap from srcToken to dstToken, of a specific token amount, either specifying input amount (exactIn=true)
452
- * or output amount (exactIn=false), NOTE: For regular -> BTC-LN (lightning) swaps the passed amount is ignored and
453
- * invoice's pre-set amount is used instead.
454
- * @deprecated Use {@link swap} instead
455
- *
456
- * @param signer Smartchain (Solana, Starknet, etc.) address of the user
457
- * @param srcToken Source token of the swap, user pays this token
458
- * @param dstToken Destination token of the swap, user receives this token
459
- * @param amount Amount of the swap
460
- * @param exactIn Whether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false)
461
- * @param addressLnurlLightningInvoice Bitcoin on-chain address, lightning invoice, LNURL-pay to pay or
462
- * LNURL-withdrawal to withdraw money from
463
- */
464
- create<C extends ChainIds<T>>(signer: string, srcToken: Token<C>, dstToken: Token<C>, amount: bigint | undefined, exactIn: boolean, addressLnurlLightningInvoice?: string | LNURLWithdraw | LNURLPay): Promise<ISwap<T[C]>>;
465
- /**
466
- * @internal
467
- */
468
- swap<C extends ChainIds<T>>(srcToken: BtcToken<true> | "BTCLN" | "BTC-LN" | "LIGHTNING-BTC", dstToken: SCToken<C> | string, amount: bigint | string, exactIn: boolean | SwapAmountType, src: undefined | string | LNURLWithdraw, dstSmartchainWallet: string, options?: (SupportsSwapType<T[C], SwapType.FROM_BTCLN_AUTO> extends true ? FromBTCLNAutoOptions : FromBTCLNOptions)): Promise<(SupportsSwapType<T[C], SwapType.FROM_BTCLN_AUTO> extends true ? FromBTCLNAutoSwap<T[C]> : FromBTCLNSwap<T[C]>)>;
469
- /**
470
- * @internal
471
- */
472
- swap<C extends ChainIds<T>>(srcToken: BtcToken<false> | "BTC" | "BITCOIN-BTC", dstToken: SCToken<C> | string, amount: bigint | string, exactIn: boolean | SwapAmountType, src: undefined | string, dstSmartchainWallet: string, options?: (SupportsSwapType<T[C], SwapType.SPV_VAULT_FROM_BTC> extends true ? SpvFromBTCOptions : FromBTCOptions)): Promise<(SupportsSwapType<T[C], SwapType.SPV_VAULT_FROM_BTC> extends true ? SpvFromBTCSwap<T[C]> : FromBTCSwap<T[C]>)>;
473
- /**
474
- * @internal
475
- */
476
- swap<C extends ChainIds<T>>(srcToken: SCToken<C> | string, dstToken: BtcToken<false> | "BTC" | "BITCOIN-BTC", amount: bigint | string, exactIn: boolean | SwapAmountType, src: string, dstAddress: string, options?: ToBTCOptions): Promise<ToBTCSwap<T[C]>>;
477
- /**
478
- * @internal
479
- */
480
- swap<C extends ChainIds<T>>(srcToken: SCToken<C> | string, dstToken: BtcToken<true> | "BTCLN" | "BTC-LN" | "LIGHTNING-BTC", amount: bigint | string, exactIn: boolean | SwapAmountType, src: string, dstLnurlPayOrInvoiceCreateService: string | LNURLPay | LightningInvoiceCreateService, options?: ToBTCLNOptions & {
481
- comment?: string;
482
- }): Promise<ToBTCLNSwap<T[C]>>;
483
- /**
484
- * @internal
485
- */
486
- swap<C extends ChainIds<T>>(srcToken: SCToken<C> | string, dstToken: BtcToken<true> | "BTCLN" | "BTC-LN" | "LIGHTNING-BTC", amount: undefined, exactIn: false | SwapAmountType.EXACT_OUT, src: string, dstLightningInvoice: string, options?: ToBTCLNOptions): Promise<ToBTCLNSwap<T[C]>>;
487
- /**
488
- * Creates a swap from srcToken to dstToken, of a specific token amount, either specifying input amount (if `exactIn=true`)
489
- * or output amount (if `exactIn=false`), NOTE: For regular Smart chain -> BTC-LN (lightning) swaps the passed amount is ignored and
490
- * invoice's pre-set amount is used instead, use LNURL-pay links for dynamic amounts
491
- *
492
- * @param srcToken Source token of the swap, user pays this token
493
- * @param dstToken Destination token of the swap, user receives this token
494
- * @param amount Amount of the swap either in base units as {bigint} or in human readable format (with decimals) as {string}
495
- * @param exactIn Whether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false)
496
- * @param src Source wallet/lnurl-withdraw of the swap
497
- * @param dst Destination smart chain address, bitcoin on-chain address, lightning invoice, LNURL-pay
498
- * @param options Options for the swap
499
- */
500
- swap<C extends ChainIds<T>>(srcToken: Token<C> | string, dstToken: Token<C> | string, amount: bigint | string | undefined, exactIn: boolean | SwapAmountType, src: undefined | string | LNURLWithdraw, dst: string | LNURLPay | LightningInvoiceCreateService, options?: FromBTCLNOptions | SpvFromBTCOptions | FromBTCOptions | ToBTCOptions | (ToBTCLNOptions & {
501
- comment?: string;
502
- }) | FromBTCLNAutoOptions): Promise<ISwap<T[C]>>;
503
- /**
504
- * Returns all swaps
505
- */
506
- getAllSwaps(): Promise<ISwap[]>;
507
- /**
508
- * Returns all swaps for the specific chain, and optionally also for a specific signer's address
509
- */
510
- getAllSwaps<C extends ChainIds<T>>(chainId: C, signer?: string): Promise<ISwap<T[C]>[]>;
511
- /**
512
- * Returns all swaps where an action is required (either claim or refund)
513
- */
514
- getActionableSwaps(): Promise<ISwap[]>;
515
- /**
516
- * Returns swaps where an action is required (either claim or refund) for the specific chain, and optionally also for a specific signer's address
517
- */
518
- getActionableSwaps<C extends ChainIds<T>>(chainId: C, signer?: string): Promise<ISwap<T[C]>[]>;
519
- /**
520
- * Returns all swaps that are refundable
521
- */
522
- getRefundableSwaps(): Promise<IToBTCSwap[]>;
523
- /**
524
- * Returns swaps which are refundable for the specific chain, and optionally also for a specific signer's address
525
- */
526
- getRefundableSwaps<C extends ChainIds<T>>(chainId: C, signer?: string): Promise<IToBTCSwap<T[C]>[]>;
527
- /**
528
- * Returns all swaps that are manually claimable
529
- */
530
- getClaimableSwaps(): Promise<IClaimableSwap[]>;
531
- /**
532
- * Returns all swaps that are manually claimable for the specific chain, and optionally also for a specific signer's address
533
- */
534
- getClaimableSwaps<C extends ChainIds<T>>(chainId: C, signer?: string): Promise<IClaimableSwap<T[C]>[]>;
535
- /**
536
- * Returns swap with a specific id (identifier)
537
- */
538
- getSwapById(id: string): Promise<ISwap>;
539
- /**
540
- * Returns swap with a specific id (identifier) on a specific chain and optionally with a signer
541
- */
542
- getSwapById<C extends ChainIds<T>>(id: string, chainId: C, signer?: string): Promise<ISwap<T[C]>>;
543
- /**
544
- * Returns the swap with a proper return type, or `undefined` if not found or has wrong type
545
- *
546
- * @param id An ID of the swap ({@link ISwap.getId})
547
- * @param chainId Chain identifier of the smart chain where the swap was initiated
548
- * @param swapType Type of the swap
549
- * @param signer An optional required smart chain signer address to fetch the swap for
550
- */
551
- getTypedSwapById<C extends ChainIds<T>, S extends SwapType>(id: string, chainId: C, swapType: S, signer?: string): Promise<SwapTypeMapping<T[C]>[S] | undefined>;
552
- private syncSwapsForChain;
553
- /**
554
- * Deletes the swaps from the persistent storage backend. Note that some data (like lightning network
555
- * amounts and bolt11 invoices) are purely off-chain and can never be recovered later just from
556
- * on-chain data!
557
- *
558
- * @param chainId Optional, to only delete swaps for this smart chain
559
- * @param signer Optional, to only delete swaps for this smart chain signer (`chainId` param must be
560
- * set to delete only signer's swaps)
561
- */
562
- wipeStorage<C extends ChainIds<T>>(chainId?: C, signer?: string): Promise<void>;
563
- /**
564
- * Synchronizes swaps from on-chain, this is ran automatically when SDK is initialized, hence
565
- * should only be ran manually when `dontCheckPastSwaps=true` is passed in the swapper options,
566
- * also deletes expired quotes
567
- *
568
- * @param chainId Optional chain identifier to only run swap sync for a single smart chain
569
- * @param signer Optional signer to only run swap sync for swaps initiated by this signer
570
- */
571
- _syncSwaps<C extends ChainIds<T>>(chainId?: C, signer?: string): Promise<void>;
572
- /**
573
- * Recovers swaps from on-chain historical data.
574
- *
575
- * Please note that the recovered swaps might not be complete (i.e. missing amounts or addresses), as some
576
- * of the swap data is purely off-chain and can never be recovered purely from on-chain data. This
577
- * functions tries to recover as much swap data as possible.
578
- *
579
- * @param chainId Smart chain identifier string to recover the swaps from
580
- * @param signer Signer address to recover the swaps for
581
- * @param startBlockheight Optional starting blockheight for swap data recovery, will only check swaps
582
- * initiated after this blockheight
583
- */
584
- recoverSwaps<C extends ChainIds<T>>(chainId: C, signer: string, startBlockheight?: number): Promise<ISwap<T[C]>[]>;
585
- getToken(ticker: "BTC" | "BITCOIN-BTC"): BtcToken<false>;
586
- getToken(ticker: "BTCLN" | "BTC-LN" | "LIGHTNING-BTC"): BtcToken<true>;
587
- getToken<ChainIdentifier extends ChainIds<T>>(ticker: `${ChainIdentifier}-${string}`): SCToken<ChainIdentifier>;
588
- getToken(tickerOrAddress: string): Token<ChainIds<T>>;
589
- /**
590
- * Creates a child swapper instance with a given smart chain
591
- *
592
- * @param chainIdentifier Smart chain identifier for the created child swapper instance
593
- */
594
- withChain<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier): SwapperWithChain<T, ChainIdentifier>;
595
- /**
596
- * Returns an array of all the supported smart chains
597
- */
598
- getSmartChains(): ChainIds<T>[];
599
- /**
600
- * Returns whether the SDK supports a given swap type on a given chain based on currently known LPs
601
- *
602
- * @param chainId Smart chain identifier string
603
- * @param swapType Swap protocol type
604
- */
605
- supportsSwapType<ChainIdentifier extends ChainIds<T>, Type extends SwapType>(chainId: ChainIdentifier, swapType: Type): SupportsSwapType<T[ChainIdentifier], Type>;
606
- /**
607
- * @internal
608
- */
609
- getSwapType<C extends ChainIds<T>>(srcToken: BtcToken<true>, dstToken: SCToken<C>): (SupportsSwapType<T[C], SwapType.FROM_BTCLN_AUTO> extends true ? SwapType.FROM_BTCLN_AUTO : SwapType.FROM_BTCLN);
610
- /**
611
- * @internal
612
- */
613
- getSwapType<C extends ChainIds<T>>(srcToken: BtcToken<false>, dstToken: SCToken<C>): (SupportsSwapType<T[C], SwapType.SPV_VAULT_FROM_BTC> extends true ? SwapType.SPV_VAULT_FROM_BTC : SwapType.FROM_BTC);
614
- /**
615
- * @internal
616
- */
617
- getSwapType<C extends ChainIds<T>>(srcToken: SCToken<C>, dstToken: BtcToken<false>): SwapType.TO_BTC;
618
- /**
619
- * @internal
620
- */
621
- getSwapType<C extends ChainIds<T>>(srcToken: SCToken<C>, dstToken: BtcToken<true>): SwapType.TO_BTCLN;
622
- /**
623
- * Returns type of the swap based on input and output tokens specified
624
- *
625
- * @param srcToken Source token
626
- * @param dstToken Destination token
627
- */
628
- getSwapType<C extends ChainIds<T>>(srcToken: Token<C>, dstToken: Token<C>): SwapType.FROM_BTCLN_AUTO | SwapType.FROM_BTCLN | SwapType.SPV_VAULT_FROM_BTC | SwapType.FROM_BTC | SwapType.TO_BTC | SwapType.TO_BTCLN;
629
- /**
630
- * Helper information about various swap protocol and their features:
631
- * - `requiresInputWallet`: Whether a swap requires a connected wallet on the input chain able to sign
632
- * arbitrary transaction
633
- * - `requiresOutputWallet`: Whether a swap requires a connected wallet on the output chain able to sign
634
- * arbitrary transactions
635
- * - `supportsGasDrop`: Whether a swap supports the "gas drop" feature, allowing to user to receive a small
636
- * amount of native token as part of the swap when swapping to smart chains
637
- *
638
- * Uses a `Record` type here, use the {@link SwapProtocolInfo} import for a literal readonly type, with
639
- * pre-filled exact values in the type.
640
- */
641
- readonly SwapTypeInfo: Record<SwapType, {
642
- requiresInputWallet: boolean;
643
- requiresOutputWallet: boolean;
644
- supportsGasDrop: boolean;
645
- }>;
646
- /**
647
- * Returns minimum/maximum limits for inputs and outputs for a swap between given tokens
648
- *
649
- * @param srcToken Source token
650
- * @param dstToken Destination token
651
- */
652
- getSwapLimits<C extends ChainIds<T>, A extends Token<C>, B extends Token<C>>(srcToken: A, dstToken: B): {
653
- input: {
654
- min: TokenAmount<A>;
655
- max?: TokenAmount<A>;
656
- };
657
- output: {
658
- min: TokenAmount<B>;
659
- max?: TokenAmount<B>;
660
- };
661
- };
662
- /**
663
- * Returns an array of supported tokens either on the input or on the output of a swap
664
- *
665
- * @param input Whether to return input tokens or output tokens
666
- */
667
- getSupportedTokens(input: SwapSide | boolean): Token[];
668
- /**
669
- * Returns a set of supported tokens by all the intermediaries offering a specific swap service
670
- *
671
- * @param _swapType Swap service type to check supported tokens for
672
- */
673
- private getSupportedTokensForSwapType;
674
- /**
675
- * Returns the set of supported token addresses by all the intermediaries we know of offering a specific swapType service
676
- *
677
- * @param chainIdentifier Chain identifier string
678
- * @param swapType Specific swap type for which to obtain supported tokens
679
- */
680
- private getSupportedTokenAddresses;
681
- /**
682
- * Returns tokens that you can swap to (if input=true) from a given token,
683
- * or tokens that you can swap from (if input=false) to a given token
684
- */
685
- getSwapCounterTokens(token: Token, input: SwapSide | boolean): Token[];
686
- }
687
- export {};
1
+ import { ISwapPrice } from "../prices/abstract/ISwapPrice";
2
+ import { BitcoinNetwork, BitcoinRpcWithAddressIndex, BtcBlock, BtcRelay, ChainData, ChainType, LightningNetworkApi, Messenger, RelaySynchronizer } from "@atomiqlabs/base";
3
+ import { ToBTCLNOptions, ToBTCLNWrapper } from "../swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper";
4
+ import { ToBTCOptions, ToBTCWrapper } from "../swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper";
5
+ import { FromBTCLNOptions, FromBTCLNWrapper } from "../swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper";
6
+ import { FromBTCOptions, FromBTCWrapper } from "../swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper";
7
+ import { IntermediaryDiscovery } from "../intermediaries/IntermediaryDiscovery";
8
+ import { ISwap } from "../swaps/ISwap";
9
+ import { SwapType } from "../enums/SwapType";
10
+ import { FromBTCLNSwap } from "../swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap";
11
+ import { FromBTCSwap } from "../swaps/escrow_swaps/frombtc/onchain/FromBTCSwap";
12
+ import { ToBTCLNSwap } from "../swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap";
13
+ import { ToBTCSwap } from "../swaps/escrow_swaps/tobtc/onchain/ToBTCSwap";
14
+ import { LnForGasWrapper } from "../swaps/trusted/ln/LnForGasWrapper";
15
+ import { LnForGasSwap } from "../swaps/trusted/ln/LnForGasSwap";
16
+ import { EventEmitter } from "events";
17
+ import { Intermediary } from "../intermediaries/Intermediary";
18
+ import { SwapperWithChain } from "./SwapperWithChain";
19
+ import { OnchainForGasSwap } from "../swaps/trusted/onchain/OnchainForGasSwap";
20
+ import { OnchainForGasWrapper } from "../swaps/trusted/onchain/OnchainForGasWrapper";
21
+ import { BTC_NETWORK } from "@scure/btc-signer/utils";
22
+ import { IUnifiedStorage } from "../storage/IUnifiedStorage";
23
+ import { UnifiedSwapStorage, UnifiedSwapStorageCompositeIndexes, UnifiedSwapStorageIndexes } from "../storage/UnifiedSwapStorage";
24
+ import { UnifiedSwapEventListener } from "../events/UnifiedSwapEventListener";
25
+ import { IToBTCSwap } from "../swaps/escrow_swaps/tobtc/IToBTCSwap";
26
+ import { SpvFromBTCOptions, SpvFromBTCWrapper } from "../swaps/spv_swaps/SpvFromBTCWrapper";
27
+ import { SpvFromBTCSwap } from "../swaps/spv_swaps/SpvFromBTCSwap";
28
+ import { SwapperUtils } from "./SwapperUtils";
29
+ import { FromBTCLNAutoOptions, FromBTCLNAutoWrapper } from "../swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper";
30
+ import { FromBTCLNAutoSwap } from "../swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap";
31
+ import { SwapAmountType } from "../enums/SwapAmountType";
32
+ import { IClaimableSwap } from "../swaps/IClaimableSwap";
33
+ import { SwapTypeMapping } from "../utils/SwapUtils";
34
+ import { TokenAmount } from "../types/TokenAmount";
35
+ import { BtcToken, SCToken, Token } from "../types/Token";
36
+ import { LNURLWithdraw } from "../types/lnurl/LNURLWithdraw";
37
+ import { LNURLPay } from "../types/lnurl/LNURLPay";
38
+ import { NotNever } from "../utils/TypeUtils";
39
+ import { LightningInvoiceCreateService } from "../types/wallets/LightningInvoiceCreateService";
40
+ import { SwapSide } from "../enums/SwapSide";
41
+ /**
42
+ * Configuration options for the Swapper
43
+ * @category Core
44
+ */
45
+ export type SwapperOptions = {
46
+ /**
47
+ * Manual override for the intermediary (LP) URLs for the SDK to use, by default these are fetched automatically
48
+ * from the registry
49
+ */
50
+ intermediaryUrl?: string | string[];
51
+ /**
52
+ * Registry URL for where to look for active intermediary (LP) endpoint URLs
53
+ */
54
+ registryUrl?: string;
55
+ /**
56
+ * Bitcoin network to use for the swaps,
57
+ */
58
+ bitcoinNetwork?: BitcoinNetwork;
59
+ /**
60
+ * Timeout (in milliseconds) for HTTP GET requests done by the SDK
61
+ */
62
+ getRequestTimeout?: number;
63
+ /**
64
+ * Timeout (in milliseconds) for HTTP POST requests done by the SDK
65
+ */
66
+ postRequestTimeout?: number;
67
+ /**
68
+ * Additional parameters to be sent to the intermediaries (LPs), when requesting quotes from them
69
+ */
70
+ defaultAdditionalParameters?: {
71
+ [key: string]: any;
72
+ };
73
+ /**
74
+ * Optional name prefix to use when creating a swap storage, you can use this to create separate storage
75
+ * instances that don't overlap.
76
+ */
77
+ storagePrefix?: string;
78
+ /**
79
+ * Sets the default intermediary (LP) to use for the trusted gas swaps, if not set the SDK uses a default one
80
+ */
81
+ defaultTrustedIntermediaryUrl?: string;
82
+ /**
83
+ * A function callback to retrieve a specific named storage container for swap persistency. If not present, the
84
+ * default IndexedDB storage adapter is used. When you use the SDK in non-browser based environments you need to
85
+ * provide this callback such that the SDK is able to use a custom storage adapter.
86
+ *
87
+ * @param storageName Name of the container to retrieve
88
+ */
89
+ swapStorage?: (storageName: string) => IUnifiedStorage<UnifiedSwapStorageIndexes, UnifiedSwapStorageCompositeIndexes>;
90
+ /**
91
+ * By setting this flag, the swapper doesn't schedule automatic tick timers. To make sure the swap states are
92
+ * properly updated (e.g. the expired swaps properly move to the expired state), you should call the
93
+ * {@link Swapper._syncSwaps} function periodically. This flag should be set when you run an environment that
94
+ * doesn't support long-running timers - e.g. serverless environments like Azure Function Apps or AWS Lambda
95
+ */
96
+ noTimers?: boolean;
97
+ /**
98
+ * By setting this flag, the swapper doesn't subscribe to on-chain events. To make sure the swap states are
99
+ * properly updated you should call the {@link Swapper._syncSwaps} function periodically. This flag should be
100
+ * set when you run an environment that doesn't support long-running timers and websocket connections - e.g.
101
+ * serverless environments like Azure Function Apps or AWS Lambda
102
+ */
103
+ noEvents?: boolean;
104
+ /**
105
+ * By setting this flag, the swap objects will not be cached in the SDK and instead will always be loaded from
106
+ * the persistent storage. By default, the SDK uses a `WeakRef` mapping of swaps, to ensure that when the same
107
+ * swap is loaded concurrently, it returns the same object reference to both, making the changes on the object
108
+ * atomic. This flag should be set to `true` when running in an environment where multiple instances of the SDK
109
+ * access the same swap database - e.g. serverless environments like Azure Function Apps or AWS Lambda
110
+ */
111
+ noSwapCache?: boolean;
112
+ /**
113
+ * Skip checking past swaps when the swapper is initiated with {@link Swapper.init}, you can call the
114
+ * {@link Swapper._syncSwaps} function later, to check the swaps. By default, the SDK checks the state
115
+ * of all the known swaps during init.
116
+ */
117
+ dontCheckPastSwaps?: boolean;
118
+ /**
119
+ * Skip fetching the LPs when the swapper is initiated with {@link Swapper.init}, this means the list of available
120
+ * tokens and swap limits won't be available immediately. LPs will be fetched automatically later, when a swap
121
+ * is requested
122
+ */
123
+ dontFetchLPs?: boolean;
124
+ /**
125
+ * Defaults to `true`, this means every swap regardless of it being initiated (i.e. when `commit()`, `execute()` or
126
+ * `waitTillPayment` is called) is saved to the persistent storage. This is a reasonable default for when you
127
+ * want to only create a swap, and then later on retrieve it with the `swapper.getSwapById()` function.
128
+ *
129
+ * Setting this to `false` means the SDK only saves and persists swaps that are considered initiated, i.e. when
130
+ * `commit()`, `execute()` or `waitTillPayment` is called (or their respective txs... prefixed variations). This
131
+ * might save calls to the persistent storage for swaps that are never initiated. This is useful in e.g.
132
+ * frontend implementations where the frontend holds the swap object reference until it is initiated anyway, not
133
+ * necessitating the saving of the swap data to the persistent storage until it is actually initiated.
134
+ */
135
+ saveUninitializedSwaps?: boolean;
136
+ /**
137
+ * Automatically checks system time on initialize, if the system time drifts too far from the actual time
138
+ * (as checked from multiple server sources) it adjusts the `Date.now()` function to return proper actual time.
139
+ */
140
+ automaticClockDriftCorrection?: boolean;
141
+ };
142
+ /**
143
+ * Type representing multiple blockchain configurations
144
+ * @category Core
145
+ */
146
+ export type MultiChain = {
147
+ [chainIdentifier in string]: ChainType;
148
+ };
149
+ type ChainSpecificData<T extends ChainType> = {
150
+ wrappers: {
151
+ [SwapType.TO_BTCLN]: ToBTCLNWrapper<T>;
152
+ [SwapType.TO_BTC]: ToBTCWrapper<T>;
153
+ [SwapType.FROM_BTCLN]: FromBTCLNWrapper<T>;
154
+ [SwapType.FROM_BTC]: FromBTCWrapper<T>;
155
+ [SwapType.TRUSTED_FROM_BTCLN]: LnForGasWrapper<T>;
156
+ [SwapType.TRUSTED_FROM_BTC]: OnchainForGasWrapper<T>;
157
+ [SwapType.SPV_VAULT_FROM_BTC]: SpvFromBTCWrapper<T>;
158
+ [SwapType.FROM_BTCLN_AUTO]: FromBTCLNAutoWrapper<T>;
159
+ };
160
+ chainEvents: T["Events"];
161
+ swapContract: T["Contract"];
162
+ spvVaultContract: T["SpvVaultContract"];
163
+ chainInterface: T["ChainInterface"];
164
+ btcRelay: BtcRelay<any, T["TX"], BtcBlock, T["Signer"]>;
165
+ synchronizer: RelaySynchronizer<any, T["TX"], BtcBlock>;
166
+ unifiedChainEvents: UnifiedSwapEventListener<T>;
167
+ unifiedSwapStorage: UnifiedSwapStorage<T>;
168
+ reviver: (val: any) => ISwap<T>;
169
+ };
170
+ type MultiChainData<T extends MultiChain> = {
171
+ [chainIdentifier in keyof T]: ChainSpecificData<T[chainIdentifier]>;
172
+ };
173
+ type CtorMultiChainData<T extends MultiChain> = {
174
+ [chainIdentifier in keyof T]: ChainData<T[chainIdentifier]>;
175
+ };
176
+ /**
177
+ * Type extracting chain identifiers from a MultiChain type
178
+ * @category Core
179
+ */
180
+ export type ChainIds<T extends MultiChain> = keyof T & string;
181
+ /**
182
+ * Type helper to check if a chain supports a specific swap type
183
+ * @category Core
184
+ */
185
+ export type SupportsSwapType<C extends ChainType, Type extends SwapType> = Type extends SwapType.SPV_VAULT_FROM_BTC ? NotNever<C["SpvVaultContract"]> : Type extends (SwapType.TRUSTED_FROM_BTCLN | SwapType.TRUSTED_FROM_BTC) ? true : Type extends SwapType.FROM_BTCLN_AUTO ? (C["Contract"]["supportsInitWithoutClaimer"] extends true ? true : false) : NotNever<C["Contract"]>;
186
+ /**
187
+ * Core orchestrator for all atomiq swap operations
188
+ *
189
+ * @category Core
190
+ */
191
+ export declare class Swapper<T extends MultiChain> extends EventEmitter<{
192
+ lpsRemoved: [Intermediary[]];
193
+ lpsAdded: [Intermediary[]];
194
+ swapState: [ISwap];
195
+ swapLimitsChanged: [];
196
+ }> {
197
+ private readonly logger;
198
+ private readonly swapStateListener;
199
+ private defaultTrustedIntermediary?;
200
+ private readonly bitcoinNetwork;
201
+ private readonly options;
202
+ /**
203
+ * Data propagation layer used for broadcasting messages to watchtowers
204
+ */
205
+ private readonly messenger;
206
+ /**
207
+ * A dictionary of smart chains used by the SDK
208
+ * @internal
209
+ */
210
+ readonly _chains: MultiChainData<T>;
211
+ /**
212
+ * Bitcoin RPC for fetching bitcoin chain data
213
+ * @internal
214
+ */
215
+ readonly _bitcoinRpc: BitcoinRpcWithAddressIndex<any>;
216
+ /**
217
+ * Bitcoin network specification
218
+ * @internal
219
+ */
220
+ readonly _btcNetwork: BTC_NETWORK;
221
+ /**
222
+ * Token data indexed by chain identifier and token addresses
223
+ * @internal
224
+ */
225
+ readonly _tokens: {
226
+ [chainId: string]: {
227
+ [tokenAddress: string]: SCToken;
228
+ };
229
+ };
230
+ /**
231
+ * Token data indexed by chain identifier and token tickers
232
+ * @internal
233
+ */
234
+ readonly _tokensByTicker: {
235
+ [chainId: string]: {
236
+ [tokenTicker: string]: SCToken;
237
+ };
238
+ };
239
+ /**
240
+ * Pricing API used by the SDK
241
+ */
242
+ readonly prices: ISwapPrice<T>;
243
+ /**
244
+ * Intermediary discovery instance
245
+ */
246
+ readonly intermediaryDiscovery: IntermediaryDiscovery;
247
+ /**
248
+ * Miscellaneous utility functions
249
+ */
250
+ readonly Utils: SwapperUtils<T>;
251
+ /**
252
+ * @internal
253
+ */
254
+ constructor(bitcoinRpc: BitcoinRpcWithAddressIndex<any>, lightningApi: LightningNetworkApi, bitcoinSynchronizer: (btcRelay: BtcRelay<any, any, any>) => RelaySynchronizer<any, any, any>, chainsData: CtorMultiChainData<T>, pricing: ISwapPrice<T>, tokens: SCToken[], messenger: Messenger, options?: SwapperOptions);
255
+ private _init;
256
+ private initPromise?;
257
+ private initialized;
258
+ /**
259
+ * Initializes the swap storage and loads existing swaps, needs to be called before any other action
260
+ */
261
+ init(): Promise<void>;
262
+ /**
263
+ * Stops listening for onchain events and closes this Swapper instance
264
+ */
265
+ stop(): Promise<void>;
266
+ /**
267
+ * Creates swap & handles intermediary, quote selection
268
+ *
269
+ * @param chainIdentifier
270
+ * @param create Callback to create the
271
+ * @param amountData Amount data as passed to the function
272
+ * @param swapType Swap type of the execution
273
+ * @param maxWaitTimeMS Maximum waiting time after the first intermediary returns the quote
274
+ * @private
275
+ * @throws {Error} when no intermediary was found
276
+ * @throws {Error} if the chain with the provided identifier cannot be found
277
+ */
278
+ private createSwap;
279
+ /**
280
+ * Creates Smart chain -> Bitcoin ({@link SwapType.TO_BTC}) swap
281
+ *
282
+ * @param chainIdentifier Chain identifier string of the source smart chain
283
+ * @param signer Signer's address on the source chain
284
+ * @param tokenAddress Token address to pay with
285
+ * @param address Recipient's bitcoin address
286
+ * @param amount Amount to send in token based units (if `exactIn=true`) or receive in satoshis (if `exactIn=false`)
287
+ * @param exactIn Whether to use exact in instead of exact out
288
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
289
+ * @param options Additional options for the swap
290
+ */
291
+ createToBTCSwap<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, signer: string, tokenAddress: string, address: string, amount: bigint, exactIn?: boolean, additionalParams?: Record<string, any> | undefined, options?: ToBTCOptions): Promise<ToBTCSwap<T[ChainIdentifier]>>;
292
+ /**
293
+ * Creates Smart chain -> Bitcoin Lightning ({@link SwapType.TO_BTCLN}) swap
294
+ *
295
+ * @param chainIdentifier Chain identifier string of the source smart chain
296
+ * @param signer Signer's address on the source chain
297
+ * @param tokenAddress Token address to pay with
298
+ * @param paymentRequest BOLT11 lightning network invoice to be paid (needs to have a fixed amount), and the swap
299
+ * amount is taken from this fixed amount, hence only exact output swaps are supported
300
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
301
+ * @param options Additional options for the swap
302
+ */
303
+ createToBTCLNSwap<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, signer: string, tokenAddress: string, paymentRequest: string, additionalParams?: Record<string, any> | undefined, options?: ToBTCLNOptions): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;
304
+ /**
305
+ * Creates Smart chain -> Bitcoin Lightning ({@link SwapType.TO_BTCLN}) swap via LNURL-pay link
306
+ *
307
+ * @param chainIdentifier Chain identifier string of the source smart chain
308
+ * @param signer Signer's address on the source chain
309
+ * @param tokenAddress Token address to pay with
310
+ * @param lnurlPay LNURL-pay link to use for the payment
311
+ * @param amount Amount to send in token based units (if `exactIn=true`) or receive in satoshis (if `exactIn=false`)
312
+ * @param exactIn Whether to do an exact in swap instead of exact out
313
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
314
+ * @param options Additional options for the swap
315
+ */
316
+ createToBTCLNSwapViaLNURL<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, signer: string, tokenAddress: string, lnurlPay: string | LNURLPay, amount: bigint, exactIn?: boolean, additionalParams?: Record<string, any> | undefined, options?: ToBTCLNOptions & {
317
+ comment?: string;
318
+ }): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;
319
+ /**
320
+ * Creates Smart chain -> Bitcoin Lightning ({@link SwapType.TO_BTCLN}) swap via {@link LightningInvoiceCreateService}
321
+ *
322
+ * @param chainIdentifier Chain identifier string of the source smart chain
323
+ * @param signer Signer's address on the source chain
324
+ * @param tokenAddress Token address to pay with
325
+ * @param service Invoice create service object which facilitates the creation of fixed amount LN invoices
326
+ * @param amount Amount to send in token based units (if `exactIn=true`) or receive in satoshis (if `exactIn=false`)
327
+ * @param exactIn Whether to do an exact in swap instead of exact out
328
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
329
+ * @param options Additional options for the swap
330
+ */
331
+ createToBTCLNSwapViaInvoiceCreateService<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, signer: string, tokenAddress: string, service: LightningInvoiceCreateService, amount: bigint, exactIn?: boolean, additionalParams?: Record<string, any> | undefined, options?: ToBTCLNOptions): Promise<ToBTCLNSwap<T[ChainIdentifier]>>;
332
+ /**
333
+ * Creates Bitcoin -> Smart chain ({@link SwapType.SPV_VAULT_FROM_BTC}) swap
334
+ *
335
+ * @param chainIdentifier Chain identifier string of the destination smart chain
336
+ * @param recipient Recipient address on the destination chain
337
+ * @param tokenAddress Token address to receive
338
+ * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
339
+ * @param exactOut Whether to use a exact out instead of exact in
340
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
341
+ * @param options Additional options for the swap
342
+ */
343
+ createFromBTCSwapNew<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: SpvFromBTCOptions): Promise<SpvFromBTCSwap<T[ChainIdentifier]>>;
344
+ /**
345
+ * Creates LEGACY Bitcoin -> Smart chain ({@link SwapType.FROM_BTC}) swap
346
+ *
347
+ * @param chainIdentifier Chain identifier string of the destination smart chain
348
+ * @param recipient Recipient address on the destination chain
349
+ * @param tokenAddress Token address to receive
350
+ * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
351
+ * @param exactOut Whether to use a exact out instead of exact in
352
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
353
+ * @param options Additional options for the swap
354
+ */
355
+ createFromBTCSwap<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCOptions): Promise<FromBTCSwap<T[ChainIdentifier]>>;
356
+ /**
357
+ * Creates LEGACY Bitcoin Lightning -> Smart chain ({@link SwapType.FROM_BTCLN}) swap
358
+ *
359
+ * @param chainIdentifier Chain identifier string of the destination smart chain
360
+ * @param recipient Recipient address on the destination chain
361
+ * @param tokenAddress Token address to receive
362
+ * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
363
+ * @param exactOut Whether to use a exact out instead of exact in
364
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
365
+ * @param options Additional options for the swap
366
+ */
367
+ createFromBTCLNSwap<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCLNOptions): Promise<FromBTCLNSwap<T[ChainIdentifier]>>;
368
+ /**
369
+ * Creates LEGACY Bitcoin Lightning -> Smart chain ({@link SwapType.FROM_BTCLN}) swap, withdrawing from
370
+ * an LNURL-withdraw link
371
+ *
372
+ * @param chainIdentifier Chain identifier string of the destination smart chain
373
+ * @param recipient Recipient address on the destination chain
374
+ * @param tokenAddress Token address to receive
375
+ * @param lnurl LNURL-withdraw link to pull the funds from
376
+ * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
377
+ * @param exactOut Whether to use a exact out instead of exact in
378
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
379
+ * @param options Additional options for the swap
380
+ */
381
+ createFromBTCLNSwapViaLNURL<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, lnurl: string | LNURLWithdraw, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCLNOptions): Promise<FromBTCLNSwap<T[ChainIdentifier]>>;
382
+ /**
383
+ * Creates Bitcoin Lightning -> Smart chain ({@link SwapType.FROM_BTCLN_AUTO}) swap
384
+ *
385
+ * @param chainIdentifier Chain identifier string of the destination smart chain
386
+ * @param recipient Recipient address on the destination chain
387
+ * @param tokenAddress Token address to receive
388
+ * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
389
+ * @param exactOut Whether to use a exact out instead of exact in
390
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
391
+ * @param options Additional options for the swap
392
+ */
393
+ createFromBTCLNSwapNew<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCLNAutoOptions): Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>>;
394
+ /**
395
+ * Creates Bitcoin Lightning -> Smart chain ({@link SwapType.FROM_BTCLN_AUTO}) swap, withdrawing from
396
+ * an LNURL-withdraw link
397
+ *
398
+ * @param chainIdentifier Chain identifier string of the destination smart chain
399
+ * @param recipient Recipient address on the destination chain
400
+ * @param tokenAddress Token address to receive
401
+ * @param lnurl LNURL-withdraw link to pull the funds from
402
+ * @param amount Amount to send in satoshis (if `exactOut=false`) or receive in token based units (if `exactOut=true`)
403
+ * @param exactOut Whether to use a exact out instead of exact in
404
+ * @param additionalParams Additional parameters sent to the LP when creating the swap
405
+ * @param options Additional options for the swap
406
+ */
407
+ createFromBTCLNSwapNewViaLNURL<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier, recipient: string, tokenAddress: string, lnurl: string | LNURLWithdraw, amount: bigint, exactOut?: boolean, additionalParams?: Record<string, any> | undefined, options?: FromBTCLNAutoOptions): Promise<FromBTCLNAutoSwap<T[ChainIdentifier]>>;
408
+ /**
409
+ * Creates a trusted Bitcoin Lightning -> Smart chain ({@link SwapType.TRUSTED_FROM_BTCLN}) gas swap
410
+ *
411
+ * @param chainIdentifier Chain identifier string of the destination smart chain
412
+ * @param recipient Recipient address on the destination chain
413
+ * @param amount Amount of native token to receive, in base units
414
+ * @param trustedIntermediaryOrUrl URL or Intermediary object of the trusted intermediary to use, otherwise uses default
415
+ * @throws {Error} If no trusted intermediary specified
416
+ */
417
+ createTrustedLNForGasSwap<C extends ChainIds<T>>(chainIdentifier: C, recipient: string, amount: bigint, trustedIntermediaryOrUrl?: Intermediary | string): Promise<LnForGasSwap<T[C]>>;
418
+ /**
419
+ * Creates a trusted Bitcoin -> Smart chain ({@link SwapType.TRUSTED_FROM_BTC}) gas swap
420
+ *
421
+ * @param chainIdentifier Chain identifier string of the destination smart chain
422
+ * @param recipient Recipient address on the destination chain
423
+ * @param amount Amount of native token to receive, in base units
424
+ * @param refundAddress Bitcoin refund address, in case the swap fails the funds are refunded here
425
+ * @param trustedIntermediaryOrUrl URL or Intermediary object of the trusted intermediary to use, otherwise uses default
426
+ * @throws {Error} If no trusted intermediary specified
427
+ */
428
+ createTrustedOnchainForGasSwap<C extends ChainIds<T>>(chainIdentifier: C, recipient: string, amount: bigint, refundAddress?: string, trustedIntermediaryOrUrl?: Intermediary | string): Promise<OnchainForGasSwap<T[C]>>;
429
+ /**
430
+ * @internal
431
+ */
432
+ create<C extends ChainIds<T>>(signer: string, srcToken: BtcToken<true>, dstToken: SCToken<C>, amount: bigint, exactIn: boolean, lnurlWithdraw?: string | LNURLWithdraw): Promise<(SupportsSwapType<T[C], SwapType.FROM_BTCLN_AUTO> extends true ? FromBTCLNAutoSwap<T[C]> : FromBTCLNSwap<T[C]>)>;
433
+ /**
434
+ * @internal
435
+ */
436
+ create<C extends ChainIds<T>>(signer: string, srcToken: BtcToken<false>, dstToken: SCToken<C>, amount: bigint, exactIn: boolean): Promise<(SupportsSwapType<T[C], SwapType.SPV_VAULT_FROM_BTC> extends true ? SpvFromBTCSwap<T[C]> : FromBTCSwap<T[C]>)>;
437
+ /**
438
+ * @internal
439
+ */
440
+ create<C extends ChainIds<T>>(signer: string, srcToken: SCToken<C>, dstToken: BtcToken<false>, amount: bigint, exactIn: boolean, address: string): Promise<ToBTCSwap<T[C]>>;
441
+ /**
442
+ * @internal
443
+ */
444
+ create<C extends ChainIds<T>>(signer: string, srcToken: SCToken<C>, dstToken: BtcToken<true>, amount: bigint, exactIn: boolean, lnurlPay: string | LNURLPay): Promise<ToBTCLNSwap<T[C]>>;
445
+ /**
446
+ * @internal
447
+ */
448
+ create<C extends ChainIds<T>>(signer: string, srcToken: SCToken<C>, dstToken: BtcToken<true>, amount: undefined, exactIn: false, lightningInvoice: string): Promise<ToBTCLNSwap<T[C]>>;
449
+ /**
450
+ * Creates a swap from srcToken to dstToken, of a specific token amount, either specifying input amount (exactIn=true)
451
+ * or output amount (exactIn=false), NOTE: For regular -> BTC-LN (lightning) swaps the passed amount is ignored and
452
+ * invoice's pre-set amount is used instead.
453
+ * @deprecated Use {@link swap} instead
454
+ *
455
+ * @param signer Smartchain (Solana, Starknet, etc.) address of the user
456
+ * @param srcToken Source token of the swap, user pays this token
457
+ * @param dstToken Destination token of the swap, user receives this token
458
+ * @param amount Amount of the swap
459
+ * @param exactIn Whether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false)
460
+ * @param addressLnurlLightningInvoice Bitcoin on-chain address, lightning invoice, LNURL-pay to pay or
461
+ * LNURL-withdrawal to withdraw money from
462
+ */
463
+ create<C extends ChainIds<T>>(signer: string, srcToken: Token<C>, dstToken: Token<C>, amount: bigint | undefined, exactIn: boolean, addressLnurlLightningInvoice?: string | LNURLWithdraw | LNURLPay): Promise<ISwap<T[C]>>;
464
+ /**
465
+ * @internal
466
+ */
467
+ swap<C extends ChainIds<T>>(srcToken: BtcToken<true> | "BTCLN" | "BTC-LN" | "LIGHTNING-BTC", dstToken: SCToken<C> | string, amount: bigint | string, exactIn: boolean | SwapAmountType, src: undefined | string | LNURLWithdraw, dstSmartchainWallet: string, options?: (SupportsSwapType<T[C], SwapType.FROM_BTCLN_AUTO> extends true ? FromBTCLNAutoOptions : FromBTCLNOptions)): Promise<(SupportsSwapType<T[C], SwapType.FROM_BTCLN_AUTO> extends true ? FromBTCLNAutoSwap<T[C]> : FromBTCLNSwap<T[C]>)>;
468
+ /**
469
+ * @internal
470
+ */
471
+ swap<C extends ChainIds<T>>(srcToken: BtcToken<false> | "BTC" | "BITCOIN-BTC", dstToken: SCToken<C> | string, amount: bigint | string, exactIn: boolean | SwapAmountType, src: undefined | string, dstSmartchainWallet: string, options?: (SupportsSwapType<T[C], SwapType.SPV_VAULT_FROM_BTC> extends true ? SpvFromBTCOptions : FromBTCOptions)): Promise<(SupportsSwapType<T[C], SwapType.SPV_VAULT_FROM_BTC> extends true ? SpvFromBTCSwap<T[C]> : FromBTCSwap<T[C]>)>;
472
+ /**
473
+ * @internal
474
+ */
475
+ swap<C extends ChainIds<T>>(srcToken: SCToken<C> | string, dstToken: BtcToken<false> | "BTC" | "BITCOIN-BTC", amount: bigint | string, exactIn: boolean | SwapAmountType, src: string, dstAddress: string, options?: ToBTCOptions): Promise<ToBTCSwap<T[C]>>;
476
+ /**
477
+ * @internal
478
+ */
479
+ swap<C extends ChainIds<T>>(srcToken: SCToken<C> | string, dstToken: BtcToken<true> | "BTCLN" | "BTC-LN" | "LIGHTNING-BTC", amount: bigint | string, exactIn: boolean | SwapAmountType, src: string, dstLnurlPayOrInvoiceCreateService: string | LNURLPay | LightningInvoiceCreateService, options?: ToBTCLNOptions & {
480
+ comment?: string;
481
+ }): Promise<ToBTCLNSwap<T[C]>>;
482
+ /**
483
+ * @internal
484
+ */
485
+ swap<C extends ChainIds<T>>(srcToken: SCToken<C> | string, dstToken: BtcToken<true> | "BTCLN" | "BTC-LN" | "LIGHTNING-BTC", amount: undefined, exactIn: false | SwapAmountType.EXACT_OUT, src: string, dstLightningInvoice: string, options?: ToBTCLNOptions): Promise<ToBTCLNSwap<T[C]>>;
486
+ /**
487
+ * Creates a swap from srcToken to dstToken, of a specific token amount, either specifying input amount (if `exactIn=true`)
488
+ * or output amount (if `exactIn=false`), NOTE: For regular Smart chain -> BTC-LN (lightning) swaps the passed amount is ignored and
489
+ * invoice's pre-set amount is used instead, use LNURL-pay links for dynamic amounts
490
+ *
491
+ * @param srcToken Source token of the swap, user pays this token
492
+ * @param dstToken Destination token of the swap, user receives this token
493
+ * @param amount Amount of the swap either in base units as {bigint} or in human readable format (with decimals) as {string}
494
+ * @param exactIn Whether the amount specified is an input amount (exactIn=true) or an output amount (exactIn=false)
495
+ * @param src Source wallet/lnurl-withdraw of the swap
496
+ * @param dst Destination smart chain address, bitcoin on-chain address, lightning invoice, LNURL-pay
497
+ * @param options Options for the swap
498
+ */
499
+ swap<C extends ChainIds<T>>(srcToken: Token<C> | string, dstToken: Token<C> | string, amount: bigint | string | undefined, exactIn: boolean | SwapAmountType, src: undefined | string | LNURLWithdraw, dst: string | LNURLPay | LightningInvoiceCreateService, options?: FromBTCLNOptions | SpvFromBTCOptions | FromBTCOptions | ToBTCOptions | (ToBTCLNOptions & {
500
+ comment?: string;
501
+ }) | FromBTCLNAutoOptions): Promise<ISwap<T[C]>>;
502
+ /**
503
+ * Returns all swaps
504
+ */
505
+ getAllSwaps(): Promise<ISwap[]>;
506
+ /**
507
+ * Returns all swaps for the specific chain, and optionally also for a specific signer's address
508
+ */
509
+ getAllSwaps<C extends ChainIds<T>>(chainId: C, signer?: string): Promise<ISwap<T[C]>[]>;
510
+ /**
511
+ * Returns all swaps where an action is required (either claim or refund)
512
+ */
513
+ getActionableSwaps(): Promise<ISwap[]>;
514
+ /**
515
+ * Returns swaps where an action is required (either claim or refund) for the specific chain, and optionally also for a specific signer's address
516
+ */
517
+ getActionableSwaps<C extends ChainIds<T>>(chainId: C, signer?: string): Promise<ISwap<T[C]>[]>;
518
+ /**
519
+ * Returns all swaps that are refundable
520
+ */
521
+ getRefundableSwaps(): Promise<IToBTCSwap[]>;
522
+ /**
523
+ * Returns swaps which are refundable for the specific chain, and optionally also for a specific signer's address
524
+ */
525
+ getRefundableSwaps<C extends ChainIds<T>>(chainId: C, signer?: string): Promise<IToBTCSwap<T[C]>[]>;
526
+ /**
527
+ * Returns all swaps that are manually claimable
528
+ */
529
+ getClaimableSwaps(): Promise<IClaimableSwap[]>;
530
+ /**
531
+ * Returns all swaps that are manually claimable for the specific chain, and optionally also for a specific signer's address
532
+ */
533
+ getClaimableSwaps<C extends ChainIds<T>>(chainId: C, signer?: string): Promise<IClaimableSwap<T[C]>[]>;
534
+ /**
535
+ * Returns swap with a specific id (identifier)
536
+ */
537
+ getSwapById(id: string): Promise<ISwap>;
538
+ /**
539
+ * Returns swap with a specific id (identifier) on a specific chain and optionally with a signer
540
+ */
541
+ getSwapById<C extends ChainIds<T>>(id: string, chainId: C, signer?: string): Promise<ISwap<T[C]>>;
542
+ /**
543
+ * Returns the swap with a proper return type, or `undefined` if not found or has wrong type
544
+ *
545
+ * @param id An ID of the swap ({@link ISwap.getId})
546
+ * @param chainId Chain identifier of the smart chain where the swap was initiated
547
+ * @param swapType Type of the swap
548
+ * @param signer An optional required smart chain signer address to fetch the swap for
549
+ */
550
+ getTypedSwapById<C extends ChainIds<T>, S extends SwapType>(id: string, chainId: C, swapType: S, signer?: string): Promise<SwapTypeMapping<T[C]>[S] | undefined>;
551
+ private syncSwapsForChain;
552
+ /**
553
+ * Deletes the swaps from the persistent storage backend. Note that some data (like lightning network
554
+ * amounts and bolt11 invoices) are purely off-chain and can never be recovered later just from
555
+ * on-chain data!
556
+ *
557
+ * @param chainId Optional, to only delete swaps for this smart chain
558
+ * @param signer Optional, to only delete swaps for this smart chain signer (`chainId` param must be
559
+ * set to delete only signer's swaps)
560
+ */
561
+ wipeStorage<C extends ChainIds<T>>(chainId?: C, signer?: string): Promise<void>;
562
+ /**
563
+ * Synchronizes swaps from on-chain, this is ran automatically when SDK is initialized, hence
564
+ * should only be ran manually when `dontCheckPastSwaps=true` is passed in the swapper options,
565
+ * also deletes expired quotes
566
+ *
567
+ * @param chainId Optional chain identifier to only run swap sync for a single smart chain
568
+ * @param signer Optional signer to only run swap sync for swaps initiated by this signer
569
+ */
570
+ _syncSwaps<C extends ChainIds<T>>(chainId?: C, signer?: string): Promise<void>;
571
+ /**
572
+ * Recovers swaps from on-chain historical data.
573
+ *
574
+ * Please note that the recovered swaps might not be complete (i.e. missing amounts or addresses), as some
575
+ * of the swap data is purely off-chain and can never be recovered purely from on-chain data. This
576
+ * functions tries to recover as much swap data as possible.
577
+ *
578
+ * @param chainId Smart chain identifier string to recover the swaps from
579
+ * @param signer Signer address to recover the swaps for
580
+ * @param startBlockheight Optional starting blockheight for swap data recovery, will only check swaps
581
+ * initiated after this blockheight
582
+ */
583
+ recoverSwaps<C extends ChainIds<T>>(chainId: C, signer: string, startBlockheight?: number): Promise<ISwap<T[C]>[]>;
584
+ getToken(ticker: "BTC" | "BITCOIN-BTC"): BtcToken<false>;
585
+ getToken(ticker: "BTCLN" | "BTC-LN" | "LIGHTNING-BTC"): BtcToken<true>;
586
+ getToken<ChainIdentifier extends ChainIds<T>>(ticker: `${ChainIdentifier}-${string}`): SCToken<ChainIdentifier>;
587
+ getToken(tickerOrAddress: string): Token<ChainIds<T>>;
588
+ /**
589
+ * Creates a child swapper instance with a given smart chain
590
+ *
591
+ * @param chainIdentifier Smart chain identifier for the created child swapper instance
592
+ */
593
+ withChain<ChainIdentifier extends ChainIds<T>>(chainIdentifier: ChainIdentifier): SwapperWithChain<T, ChainIdentifier>;
594
+ /**
595
+ * Returns an array of all the supported smart chains
596
+ */
597
+ getSmartChains(): ChainIds<T>[];
598
+ /**
599
+ * Returns whether the SDK supports a given swap type on a given chain based on currently known LPs
600
+ *
601
+ * @param chainId Smart chain identifier string
602
+ * @param swapType Swap protocol type
603
+ */
604
+ supportsSwapType<ChainIdentifier extends ChainIds<T>, Type extends SwapType>(chainId: ChainIdentifier, swapType: Type): SupportsSwapType<T[ChainIdentifier], Type>;
605
+ /**
606
+ * @internal
607
+ */
608
+ getSwapType<C extends ChainIds<T>>(srcToken: BtcToken<true>, dstToken: SCToken<C>): (SupportsSwapType<T[C], SwapType.FROM_BTCLN_AUTO> extends true ? SwapType.FROM_BTCLN_AUTO : SwapType.FROM_BTCLN);
609
+ /**
610
+ * @internal
611
+ */
612
+ getSwapType<C extends ChainIds<T>>(srcToken: BtcToken<false>, dstToken: SCToken<C>): (SupportsSwapType<T[C], SwapType.SPV_VAULT_FROM_BTC> extends true ? SwapType.SPV_VAULT_FROM_BTC : SwapType.FROM_BTC);
613
+ /**
614
+ * @internal
615
+ */
616
+ getSwapType<C extends ChainIds<T>>(srcToken: SCToken<C>, dstToken: BtcToken<false>): SwapType.TO_BTC;
617
+ /**
618
+ * @internal
619
+ */
620
+ getSwapType<C extends ChainIds<T>>(srcToken: SCToken<C>, dstToken: BtcToken<true>): SwapType.TO_BTCLN;
621
+ /**
622
+ * Returns type of the swap based on input and output tokens specified
623
+ *
624
+ * @param srcToken Source token
625
+ * @param dstToken Destination token
626
+ */
627
+ getSwapType<C extends ChainIds<T>>(srcToken: Token<C>, dstToken: Token<C>): SwapType.FROM_BTCLN_AUTO | SwapType.FROM_BTCLN | SwapType.SPV_VAULT_FROM_BTC | SwapType.FROM_BTC | SwapType.TO_BTC | SwapType.TO_BTCLN;
628
+ /**
629
+ * Helper information about various swap protocol and their features:
630
+ * - `requiresInputWallet`: Whether a swap requires a connected wallet on the input chain able to sign
631
+ * arbitrary transaction
632
+ * - `requiresOutputWallet`: Whether a swap requires a connected wallet on the output chain able to sign
633
+ * arbitrary transactions
634
+ * - `supportsGasDrop`: Whether a swap supports the "gas drop" feature, allowing to user to receive a small
635
+ * amount of native token as part of the swap when swapping to smart chains
636
+ *
637
+ * Uses a `Record` type here, use the {@link SwapProtocolInfo} import for a literal readonly type, with
638
+ * pre-filled exact values in the type.
639
+ */
640
+ readonly SwapTypeInfo: Record<SwapType, {
641
+ requiresInputWallet: boolean;
642
+ requiresOutputWallet: boolean;
643
+ supportsGasDrop: boolean;
644
+ }>;
645
+ /**
646
+ * Returns minimum/maximum limits for inputs and outputs for a swap between given tokens
647
+ *
648
+ * @param srcToken Source token
649
+ * @param dstToken Destination token
650
+ */
651
+ getSwapLimits<C extends ChainIds<T>, A extends Token<C>, B extends Token<C>>(srcToken: A, dstToken: B): {
652
+ input: {
653
+ min: TokenAmount<A>;
654
+ max?: TokenAmount<A>;
655
+ };
656
+ output: {
657
+ min: TokenAmount<B>;
658
+ max?: TokenAmount<B>;
659
+ };
660
+ };
661
+ /**
662
+ * Returns an array of supported tokens either on the input or on the output of a swap
663
+ *
664
+ * @param input Whether to return input tokens or output tokens
665
+ */
666
+ getSupportedTokens(input: SwapSide | boolean): Token[];
667
+ /**
668
+ * Returns a set of supported tokens by all the intermediaries offering a specific swap service
669
+ *
670
+ * @param _swapType Swap service type to check supported tokens for
671
+ */
672
+ private getSupportedTokensForSwapType;
673
+ /**
674
+ * Returns the set of supported token addresses by all the intermediaries we know of offering a specific swapType service
675
+ *
676
+ * @param chainIdentifier Chain identifier string
677
+ * @param swapType Specific swap type for which to obtain supported tokens
678
+ */
679
+ private getSupportedTokenAddresses;
680
+ /**
681
+ * Returns tokens that you can swap to (if input=true) from a given token,
682
+ * or tokens that you can swap from (if input=false) to a given token
683
+ */
684
+ getSwapCounterTokens(token: Token, input: SwapSide | boolean): Token[];
685
+ }
686
+ export {};