@atomiqlabs/sdk 8.1.8 → 8.3.5

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 (261) hide show
  1. package/dist/bitcoin/coinselect2/utils.d.ts +6 -0
  2. package/dist/bitcoin/wallet/BitcoinWallet.d.ts +41 -5
  3. package/dist/bitcoin/wallet/BitcoinWallet.js +36 -1
  4. package/dist/bitcoin/wallet/IBitcoinWallet.d.ts +52 -2
  5. package/dist/bitcoin/wallet/IBitcoinWallet.js +2 -1
  6. package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.d.ts +42 -7
  7. package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.js +36 -1
  8. package/dist/enums/FeeType.d.ts +8 -1
  9. package/dist/enums/FeeType.js +8 -1
  10. package/dist/enums/SwapAmountType.d.ts +7 -0
  11. package/dist/enums/SwapAmountType.js +7 -0
  12. package/dist/enums/SwapDirection.d.ts +7 -0
  13. package/dist/enums/SwapDirection.js +7 -0
  14. package/dist/enums/SwapType.d.ts +62 -1
  15. package/dist/enums/SwapType.js +62 -1
  16. package/dist/errors/IntermediaryError.d.ts +4 -0
  17. package/dist/errors/IntermediaryError.js +1 -0
  18. package/dist/errors/RequestError.d.ts +15 -1
  19. package/dist/errors/RequestError.js +8 -0
  20. package/dist/errors/UserError.d.ts +1 -0
  21. package/dist/errors/UserError.js +1 -0
  22. package/dist/index.d.ts +5 -5
  23. package/dist/index.js +7 -6
  24. package/dist/intermediaries/Intermediary.d.ts +61 -14
  25. package/dist/intermediaries/Intermediary.js +38 -11
  26. package/dist/intermediaries/IntermediaryDiscovery.d.ts +62 -29
  27. package/dist/intermediaries/IntermediaryDiscovery.js +39 -24
  28. package/dist/prices/RedundantSwapPrice.d.ts +26 -5
  29. package/dist/prices/RedundantSwapPrice.js +22 -2
  30. package/dist/prices/SingleSwapPrice.d.ts +10 -7
  31. package/dist/prices/SingleSwapPrice.js +11 -8
  32. package/dist/prices/SwapPriceWithChain.d.ts +56 -19
  33. package/dist/prices/SwapPriceWithChain.js +62 -25
  34. package/dist/prices/abstract/IPriceProvider.d.ts +4 -4
  35. package/dist/prices/abstract/IPriceProvider.js +1 -1
  36. package/dist/prices/abstract/ISwapPrice.d.ts +95 -46
  37. package/dist/prices/abstract/ISwapPrice.js +104 -56
  38. package/dist/prices/providers/BinancePriceProvider.d.ts +8 -1
  39. package/dist/prices/providers/BinancePriceProvider.js +8 -1
  40. package/dist/prices/providers/CoinGeckoPriceProvider.d.ts +7 -1
  41. package/dist/prices/providers/CoinGeckoPriceProvider.js +7 -1
  42. package/dist/prices/providers/CoinPaprikaPriceProvider.d.ts +7 -1
  43. package/dist/prices/providers/CoinPaprikaPriceProvider.js +7 -1
  44. package/dist/prices/providers/CustomPriceProvider.d.ts +12 -1
  45. package/dist/prices/providers/CustomPriceProvider.js +12 -1
  46. package/dist/prices/providers/KrakenPriceProvider.d.ts +10 -1
  47. package/dist/prices/providers/KrakenPriceProvider.js +10 -1
  48. package/dist/prices/providers/OKXPriceProvider.d.ts +7 -1
  49. package/dist/prices/providers/OKXPriceProvider.js +7 -1
  50. package/dist/prices/providers/abstract/ExchangePriceProvider.d.ts +3 -0
  51. package/dist/prices/providers/abstract/ExchangePriceProvider.js +3 -0
  52. package/dist/storage/IUnifiedStorage.d.ts +19 -7
  53. package/dist/storage/UnifiedSwapStorage.d.ts +33 -3
  54. package/dist/storage/UnifiedSwapStorage.js +29 -1
  55. package/dist/storage-browser/IndexedDBUnifiedStorage.d.ts +31 -7
  56. package/dist/storage-browser/IndexedDBUnifiedStorage.js +29 -6
  57. package/dist/storage-browser/LocalStorageManager.d.ts +25 -1
  58. package/dist/storage-browser/LocalStorageManager.js +25 -1
  59. package/dist/swapper/Swapper.d.ts +380 -226
  60. package/dist/swapper/Swapper.js +383 -349
  61. package/dist/swapper/SwapperFactory.d.ts +66 -18
  62. package/dist/swapper/SwapperFactory.js +24 -3
  63. package/dist/swapper/SwapperUtils.d.ts +75 -28
  64. package/dist/swapper/SwapperUtils.js +107 -60
  65. package/dist/swapper/SwapperWithChain.d.ts +286 -91
  66. package/dist/swapper/SwapperWithChain.js +218 -64
  67. package/dist/swapper/SwapperWithSigner.d.ts +229 -80
  68. package/dist/swapper/SwapperWithSigner.js +190 -44
  69. package/dist/swaps/IAddressSwap.d.ts +12 -3
  70. package/dist/swaps/IAddressSwap.js +3 -2
  71. package/dist/swaps/IBTCWalletSwap.d.ts +26 -8
  72. package/dist/swaps/IBTCWalletSwap.js +3 -2
  73. package/dist/swaps/IClaimableSwap.d.ts +38 -6
  74. package/dist/swaps/IClaimableSwap.js +3 -2
  75. package/dist/swaps/IClaimableSwapWrapper.d.ts +11 -1
  76. package/dist/swaps/IRefundableSwap.d.ts +31 -5
  77. package/dist/swaps/IRefundableSwap.js +3 -2
  78. package/dist/swaps/ISwap.d.ts +162 -24
  79. package/dist/swaps/ISwap.js +92 -35
  80. package/dist/swaps/ISwapWithGasDrop.d.ts +8 -2
  81. package/dist/swaps/ISwapWithGasDrop.js +2 -1
  82. package/dist/swaps/ISwapWrapper.d.ts +161 -52
  83. package/dist/swaps/ISwapWrapper.js +131 -73
  84. package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.d.ts +51 -6
  85. package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.js +22 -12
  86. package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +65 -12
  87. package/dist/swaps/escrow_swaps/IEscrowSwap.js +38 -19
  88. package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +39 -9
  89. package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +30 -21
  90. package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +31 -15
  91. package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +33 -18
  92. package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.d.ts +97 -28
  93. package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.js +91 -27
  94. package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.d.ts +22 -9
  95. package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.js +24 -11
  96. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +278 -60
  97. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +519 -241
  98. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +77 -26
  99. package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +132 -50
  100. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +313 -52
  101. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +544 -194
  102. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +87 -26
  103. package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +147 -58
  104. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +222 -55
  105. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +462 -244
  106. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +77 -23
  107. package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +116 -46
  108. package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +195 -58
  109. package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +324 -191
  110. package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.d.ts +30 -5
  111. package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.js +44 -19
  112. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.d.ts +61 -20
  113. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.js +75 -32
  114. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +76 -50
  115. package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +106 -101
  116. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.d.ts +37 -14
  117. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.js +66 -20
  118. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +46 -17
  119. package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +82 -27
  120. package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +350 -88
  121. package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +482 -215
  122. package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +76 -24
  123. package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +247 -124
  124. package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +148 -20
  125. package/dist/swaps/trusted/ln/LnForGasSwap.js +175 -45
  126. package/dist/swaps/trusted/ln/LnForGasWrapper.d.ts +29 -10
  127. package/dist/swaps/trusted/ln/LnForGasWrapper.js +30 -11
  128. package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +202 -49
  129. package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +232 -80
  130. package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +34 -12
  131. package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +33 -14
  132. package/dist/types/AmountData.d.ts +2 -1
  133. package/dist/types/CustomPriceFunction.d.ts +8 -2
  134. package/dist/types/PriceInfoType.d.ts +4 -4
  135. package/dist/types/PriceInfoType.js +3 -3
  136. package/dist/types/SwapExecutionAction.d.ts +85 -4
  137. package/dist/types/SwapWithSigner.d.ts +5 -2
  138. package/dist/types/SwapWithSigner.js +5 -2
  139. package/dist/types/Token.d.ts +11 -5
  140. package/dist/types/Token.js +6 -3
  141. package/dist/types/TokenAmount.d.ts +3 -0
  142. package/dist/types/TokenAmount.js +2 -0
  143. package/dist/types/fees/Fee.d.ts +3 -2
  144. package/dist/types/fees/FeeBreakdown.d.ts +3 -2
  145. package/dist/types/fees/PercentagePPM.d.ts +4 -2
  146. package/dist/types/fees/PercentagePPM.js +2 -1
  147. package/dist/types/lnurl/LNURLPay.d.ts +20 -12
  148. package/dist/types/lnurl/LNURLPay.js +8 -4
  149. package/dist/types/lnurl/LNURLWithdraw.d.ts +17 -10
  150. package/dist/types/lnurl/LNURLWithdraw.js +8 -4
  151. package/dist/types/wallets/LightningInvoiceCreateService.d.ts +24 -0
  152. package/dist/types/wallets/LightningInvoiceCreateService.js +15 -0
  153. package/dist/types/wallets/MinimalBitcoinWalletInterface.d.ts +3 -1
  154. package/dist/types/wallets/MinimalLightningNetworkWalletInterface.d.ts +4 -2
  155. package/dist/utils/BitcoinUtils.d.ts +1 -0
  156. package/dist/utils/BitcoinUtils.js +5 -1
  157. package/dist/utils/SwapUtils.d.ts +58 -1
  158. package/dist/utils/SwapUtils.js +55 -1
  159. package/dist/utils/TokenUtils.d.ts +10 -2
  160. package/dist/utils/TokenUtils.js +12 -4
  161. package/package.json +3 -3
  162. package/src/bitcoin/coinselect2/utils.ts +6 -0
  163. package/src/bitcoin/wallet/BitcoinWallet.ts +41 -5
  164. package/src/bitcoin/wallet/IBitcoinWallet.ts +57 -2
  165. package/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts +42 -6
  166. package/src/enums/FeeType.ts +8 -1
  167. package/src/enums/SwapAmountType.ts +7 -0
  168. package/src/enums/SwapDirection.ts +7 -0
  169. package/src/enums/SwapType.ts +62 -2
  170. package/src/errors/IntermediaryError.ts +4 -0
  171. package/src/errors/RequestError.ts +15 -1
  172. package/src/errors/UserError.ts +1 -0
  173. package/src/index.ts +12 -5
  174. package/src/intermediaries/Intermediary.ts +61 -14
  175. package/src/intermediaries/IntermediaryDiscovery.ts +69 -34
  176. package/src/prices/RedundantSwapPrice.ts +26 -6
  177. package/src/prices/SingleSwapPrice.ts +11 -8
  178. package/src/prices/SwapPriceWithChain.ts +63 -26
  179. package/src/prices/abstract/IPriceProvider.ts +4 -4
  180. package/src/prices/abstract/ISwapPrice.ts +115 -66
  181. package/src/prices/providers/BinancePriceProvider.ts +8 -1
  182. package/src/prices/providers/CoinGeckoPriceProvider.ts +7 -1
  183. package/src/prices/providers/CoinPaprikaPriceProvider.ts +7 -1
  184. package/src/prices/providers/CustomPriceProvider.ts +12 -1
  185. package/src/prices/providers/KrakenPriceProvider.ts +10 -1
  186. package/src/prices/providers/OKXPriceProvider.ts +7 -1
  187. package/src/prices/providers/abstract/ExchangePriceProvider.ts +3 -0
  188. package/src/storage/IUnifiedStorage.ts +19 -7
  189. package/src/storage/UnifiedSwapStorage.ts +33 -3
  190. package/src/storage-browser/IndexedDBUnifiedStorage.ts +31 -8
  191. package/src/storage-browser/LocalStorageManager.ts +25 -1
  192. package/src/swapper/Swapper.ts +599 -390
  193. package/src/swapper/SwapperFactory.ts +73 -24
  194. package/src/swapper/SwapperUtils.ts +107 -60
  195. package/src/swapper/SwapperWithChain.ts +320 -81
  196. package/src/swapper/SwapperWithSigner.ts +263 -56
  197. package/src/swaps/IAddressSwap.ts +13 -3
  198. package/src/swaps/IBTCWalletSwap.ts +26 -10
  199. package/src/swaps/IClaimableSwap.ts +41 -6
  200. package/src/swaps/IClaimableSwapWrapper.ts +11 -2
  201. package/src/swaps/IRefundableSwap.ts +34 -5
  202. package/src/swaps/ISwap.ts +224 -85
  203. package/src/swaps/ISwapWithGasDrop.ts +8 -2
  204. package/src/swaps/ISwapWrapper.ts +216 -98
  205. package/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts +64 -18
  206. package/src/swaps/escrow_swaps/IEscrowSwap.ts +83 -37
  207. package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +61 -30
  208. package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +37 -19
  209. package/src/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.ts +123 -50
  210. package/src/swaps/escrow_swaps/frombtc/IFromBTCWrapper.ts +24 -11
  211. package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +562 -258
  212. package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +156 -62
  213. package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +592 -227
  214. package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +177 -74
  215. package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +483 -245
  216. package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +141 -59
  217. package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +350 -195
  218. package/src/swaps/escrow_swaps/tobtc/IToBTCWrapper.ts +48 -23
  219. package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.ts +87 -40
  220. package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +110 -110
  221. package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.ts +89 -34
  222. package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +101 -31
  223. package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +556 -259
  224. package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +292 -148
  225. package/src/swaps/trusted/ln/LnForGasSwap.ts +186 -47
  226. package/src/swaps/trusted/ln/LnForGasWrapper.ts +34 -15
  227. package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +262 -88
  228. package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +41 -19
  229. package/src/types/AmountData.ts +2 -1
  230. package/src/types/CustomPriceFunction.ts +8 -2
  231. package/src/types/PriceInfoType.ts +4 -4
  232. package/src/types/SwapExecutionAction.ts +97 -5
  233. package/src/types/SwapWithSigner.ts +8 -4
  234. package/src/types/Token.ts +12 -5
  235. package/src/types/TokenAmount.ts +3 -0
  236. package/src/types/fees/Fee.ts +3 -2
  237. package/src/types/fees/FeeBreakdown.ts +3 -2
  238. package/src/types/fees/PercentagePPM.ts +4 -2
  239. package/src/types/lnurl/LNURLPay.ts +20 -12
  240. package/src/types/lnurl/LNURLWithdraw.ts +17 -10
  241. package/src/types/wallets/LightningInvoiceCreateService.ts +30 -0
  242. package/src/types/wallets/MinimalBitcoinWalletInterface.ts +3 -1
  243. package/src/types/wallets/MinimalLightningNetworkWalletInterface.ts +4 -2
  244. package/src/utils/BitcoinUtils.ts +5 -0
  245. package/src/utils/SwapUtils.ts +63 -1
  246. package/src/utils/TokenUtils.ts +12 -4
  247. package/dist/bitcoin/BitcoinRpcWithAddressIndex.d.ts +0 -68
  248. package/dist/bitcoin/BitcoinRpcWithAddressIndex.js +0 -2
  249. package/dist/bitcoin/LightningNetworkApi.d.ts +0 -12
  250. package/dist/bitcoin/LightningNetworkApi.js +0 -2
  251. package/dist/bitcoin/mempool/MempoolApi.d.ts +0 -350
  252. package/dist/bitcoin/mempool/MempoolApi.js +0 -311
  253. package/dist/bitcoin/mempool/MempoolBitcoinBlock.d.ts +0 -44
  254. package/dist/bitcoin/mempool/MempoolBitcoinBlock.js +0 -48
  255. package/dist/bitcoin/mempool/MempoolBitcoinRpc.d.ts +0 -119
  256. package/dist/bitcoin/mempool/MempoolBitcoinRpc.js +0 -361
  257. package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.d.ts +0 -22
  258. package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.js +0 -105
  259. package/dist/errors/PaymentAuthError.d.ts +0 -11
  260. package/dist/errors/PaymentAuthError.js +0 -23
  261. package/src/errors/PaymentAuthError.ts +0 -26
@@ -2,17 +2,78 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SwapType = void 0;
4
4
  /**
5
- * Enum representing different types of swaps
5
+ * Enum representing different types of swap protocols used by atomiq.
6
+ *
6
7
  * @category Core
7
8
  */
8
9
  var SwapType;
9
10
  (function (SwapType) {
11
+ /**
12
+ * Legacy escrow (PrTLC) based swap for Bitcoin -> Smart chains, requires manual initiation of the swap
13
+ * on the destination chain.
14
+ *
15
+ * Handled by {@link FromBTCWrapper} & {@link FromBTCSwap}.
16
+ *
17
+ * Legacy swaps are only used on Solana!
18
+ */
10
19
  SwapType[SwapType["FROM_BTC"] = 0] = "FROM_BTC";
20
+ /**
21
+ * Legacy escrow (HTLC) based swap for Bitcoin Lightning -> Smart chains, requires manual settlement of the swap on the
22
+ * destination network once the lightning network payment is received by the LP
23
+ *
24
+ * Handled by {@link FromBTCLNWrapper} & {@link FromBTCLNSwap}.
25
+ *
26
+ * Legacy swaps are only used on Solana!
27
+ */
11
28
  SwapType[SwapType["FROM_BTCLN"] = 1] = "FROM_BTCLN";
29
+ /**
30
+ * Escrow based (PrTLC) swap for Smart chains -> Bitcoin
31
+ *
32
+ * Handled by {@link ToBTCWrapper} & {@link ToBTCSwap}.
33
+ */
12
34
  SwapType[SwapType["TO_BTC"] = 2] = "TO_BTC";
35
+ /**
36
+ * Escrow based (HTLC) swap for Smart chains -> Bitcoin Lightning
37
+ *
38
+ * Handled by {@link ToBTCLNWrapper} & {@link ToBTCLNSwap}.
39
+ */
13
40
  SwapType[SwapType["TO_BTCLN"] = 3] = "TO_BTCLN";
41
+ /**
42
+ * Trusted swap for Bitcoin -> Smart chains, to be used for minor amounts to get gas tokens on the destination
43
+ * chain, which is only needed for Solana, which still uses legacy swaps and doesn't support newer
44
+ * {@link SPV_VAULT_FROM_BTC} & {@link FROM_BTCLN_AUTO} swaps.
45
+ *
46
+ * Handled by {@link OnchainForGasWrapper} & {@link OnchainForGasSwap}.
47
+ */
14
48
  SwapType[SwapType["TRUSTED_FROM_BTC"] = 4] = "TRUSTED_FROM_BTC";
49
+ /**
50
+ * Trusted swap for Bitcoin Lightning -> Smart chains, to be used for minor amounts to get gas tokens on the
51
+ * destination chain, which is only needed for Solana, which still uses legacy swaps and doesn't support newer
52
+ * {@link SPV_VAULT_FROM_BTC} & {@link FROM_BTCLN_AUTO} swaps.
53
+ *
54
+ * Handled by {@link LnForGasWrapper} & {@link LnForGasSwap}.
55
+ */
15
56
  SwapType[SwapType["TRUSTED_FROM_BTCLN"] = 5] = "TRUSTED_FROM_BTCLN";
57
+ /**
58
+ * New spv vault (UTXO-controlled vault) based swaps for Bitcoin -> Smart chain swaps not requiring any
59
+ * initiation on the destination chain, and with the added possibility for the user to receive a
60
+ * native token on the destination chain as part of the swap (a "gas drop" feature).
61
+ *
62
+ * Handled by {@link SpvFromBTCWrapper} & {@link SpvFromBTCSwap}.
63
+ *
64
+ * Used on all the supported chains except Solana!
65
+ */
16
66
  SwapType[SwapType["SPV_VAULT_FROM_BTC"] = 6] = "SPV_VAULT_FROM_BTC";
67
+ /**
68
+ * New escrow based (HTLC) swaps for Bitcoin Lightning -> Smart chain swaps not requiring manual
69
+ * settlement on the destination by the user, and instead letting the LP initiate the escrow,
70
+ * with the permissionless watchtower network managing the claiming of HTLC, with the swap secret
71
+ * broadcasted over Nostr. Also adds a possibility for the user to receive a native token on the
72
+ * destination chain as part of the swap (a "gas drop" feature).
73
+ *
74
+ * Handled by {@link FromBTCLNAutoWrapper} & {@link FromBTCLNAutoSwap}.
75
+ *
76
+ * Used on all the supported chains except Solana!
77
+ */
17
78
  SwapType[SwapType["FROM_BTCLN_AUTO"] = 7] = "FROM_BTCLN_AUTO";
18
79
  })(SwapType = exports.SwapType || (exports.SwapType = {}));
@@ -1,8 +1,12 @@
1
1
  /**
2
2
  * An error or inconsistency in the intermediary's returned data, this will blacklist the intermediary
3
+ *
3
4
  * @category Errors
4
5
  */
5
6
  export declare class IntermediaryError extends Error {
7
+ /**
8
+ * Whether the error is recoverable and intermediary (LP) shouldn't be blacklisted for it
9
+ */
6
10
  recoverable: boolean;
7
11
  originalStack?: string;
8
12
  constructor(msg: string, originalError?: any, recoverable?: boolean);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IntermediaryError = void 0;
4
4
  /**
5
5
  * An error or inconsistency in the intermediary's returned data, this will blacklist the intermediary
6
+ *
6
7
  * @category Errors
7
8
  */
8
9
  class IntermediaryError extends Error {
@@ -1,18 +1,32 @@
1
1
  /**
2
2
  * An error returned by the intermediary in a http response
3
+ *
3
4
  * @category Errors
4
5
  */
5
6
  export declare class RequestError extends Error {
6
7
  httpCode: number;
7
8
  constructor(msg: string, httpCode: number);
8
- static parse(msg: string, httpCode: number): RequestError;
9
+ /**
10
+ * Parses a message + a response code returned by the intermediary (LP) as an error
11
+ *
12
+ * @param msg Raw response
13
+ * @param httpCode HTTP response status code
14
+ */
15
+ static parse(msg: string, httpCode: number): RequestError | OutOfBoundsError;
9
16
  }
10
17
  /**
11
18
  * An error indicating out of bounds (amount too high or too low) on swap initialization
19
+ *
12
20
  * @category Errors
13
21
  */
14
22
  export declare class OutOfBoundsError extends RequestError {
23
+ /**
24
+ * Swap minimum in base units of the token in which the quote was requested
25
+ */
15
26
  min: bigint;
27
+ /**
28
+ * Swap maximum in base units of the token in which the quote was requested
29
+ */
16
30
  max: bigint;
17
31
  constructor(msg: string, httpCode: number, min: bigint, max: bigint);
18
32
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OutOfBoundsError = exports.RequestError = void 0;
4
4
  /**
5
5
  * An error returned by the intermediary in a http response
6
+ *
6
7
  * @category Errors
7
8
  */
8
9
  class RequestError extends Error {
@@ -18,6 +19,12 @@ class RequestError extends Error {
18
19
  Object.setPrototypeOf(this, RequestError.prototype);
19
20
  this.httpCode = httpCode;
20
21
  }
22
+ /**
23
+ * Parses a message + a response code returned by the intermediary (LP) as an error
24
+ *
25
+ * @param msg Raw response
26
+ * @param httpCode HTTP response status code
27
+ */
21
28
  static parse(msg, httpCode) {
22
29
  try {
23
30
  const parsed = JSON.parse(msg);
@@ -33,6 +40,7 @@ class RequestError extends Error {
33
40
  exports.RequestError = RequestError;
34
41
  /**
35
42
  * An error indicating out of bounds (amount too high or too low) on swap initialization
43
+ *
36
44
  * @category Errors
37
45
  */
38
46
  class OutOfBoundsError extends RequestError {
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * An error on the user side, such as invalid address provided
3
+ *
3
4
  * @category Errors
4
5
  */
5
6
  export declare class UserError extends Error {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserError = void 0;
4
4
  /**
5
5
  * An error on the user side, such as invalid address provided
6
+ *
6
7
  * @category Errors
7
8
  */
8
9
  class UserError extends Error {
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- export { LightningNetworkApi, BitcoinRpc, BitcoinRpcWithAddressIndex, BitcoinNetwork, BtcRelay, ChainData, ChainInterface, ChainType, CannotInitializeATAError, SignatureVerificationError, SwapDataVerificationError, TransactionRevertedError, ChainEvents, Messenger, SpvVaultContract, SpvVaultData, SpvWithdrawalTransactionData, ExecutionData, IStorageManager, StorageObject, SwapContract, SwapData } from "@atomiqlabs/base";
1
+ export { LightningNetworkApi, BitcoinRpc, BitcoinRpcWithAddressIndex, BitcoinNetwork, BtcHeader, BtcStoredHeader, BtcRelay, ChainData, ChainInterface, ChainType, CannotInitializeATAError, SignatureVerificationError, SwapDataVerificationError, TransactionRevertedError, ChainEvents, Messenger, SpvVaultContract, SpvVaultData, SpvWithdrawalTransactionData, ExecutionData, IStorageManager, StorageObject, SwapContract, SwapData, AbstractSigner } from "@atomiqlabs/base";
2
2
  export { MempoolApi, MempoolBitcoinRpc, MempoolApiError } from "@atomiqlabs/btc-mempool";
3
+ export { NostrMessenger } from "@atomiqlabs/messenger-nostr";
3
4
  export * from "./bitcoin/wallet/BitcoinWallet";
4
5
  export * from "./bitcoin/wallet/IBitcoinWallet";
5
- export * from "./types/wallets/MinimalBitcoinWalletInterface";
6
- export * from "./types/wallets/MinimalLightningNetworkWalletInterface";
7
6
  export * from "./bitcoin/wallet/SingleAddressBitcoinWallet";
8
7
  export { CoinselectAddressTypes } from "./bitcoin/coinselect2";
9
8
  export * from "./enums/FeeType";
@@ -11,7 +10,6 @@ export * from "./enums/SwapAmountType";
11
10
  export * from "./enums/SwapDirection";
12
11
  export * from "./enums/SwapType";
13
12
  export * from "./errors/IntermediaryError";
14
- export * from "./errors/PaymentAuthError";
15
13
  export * from "./errors/RequestError";
16
14
  export * from "./errors/UserError";
17
15
  export { Intermediary } from "./intermediaries/Intermediary";
@@ -72,9 +70,11 @@ export * from "./types/fees/FeeBreakdown";
72
70
  export * from "./types/fees/PercentagePPM";
73
71
  export * from "./types/lnurl/LNURLPay";
74
72
  export * from "./types/lnurl/LNURLWithdraw";
73
+ export * from "./types/wallets/MinimalBitcoinWalletInterface";
74
+ export * from "./types/wallets/MinimalLightningNetworkWalletInterface";
75
+ export * from "./types/wallets/LightningInvoiceCreateService";
75
76
  export * from "./types/AmountData";
76
77
  export * from "./types/CustomPriceFunction";
77
- export * from "./types/PriceInfoType";
78
78
  export * from "./types/SwapExecutionAction";
79
79
  export * from "./types/SwapWithSigner";
80
80
  export * from "./types/Token";
package/dist/index.js CHANGED
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.LnForGasWrapper = exports.LnForGasSwapState = exports.LnForGasSwap = exports.SpvFromBTCWrapper = exports.SpvFromBTCSwapState = exports.SpvFromBTCSwap = exports.IEscrowSwapWrapper = exports.IEscrowSwap = exports.IEscrowSelfInitSwap = exports.IToBTCWrapper = exports.ToBTCSwapState = exports.IToBTCSwap = exports.ToBTCWrapper = exports.ToBTCSwap = exports.ToBTCLNWrapper = exports.ToBTCLNSwap = exports.IFromBTCWrapper = exports.IFromBTCSelfInitSwap = exports.IFromBTCLNWrapper = exports.FromBTCWrapper = exports.FromBTCSwapState = exports.FromBTCSwap = exports.FromBTCLNAutoWrapper = exports.FromBTCLNAutoSwapState = exports.FromBTCLNAutoSwap = exports.FromBTCLNWrapper = exports.FromBTCLNSwapState = exports.FromBTCLNSwap = exports.Swapper = exports.IndexedDBUnifiedStorage = exports.CustomPriceProvider = exports.OKXPriceProvider = exports.KrakenPriceProvider = exports.CoinPaprikaPriceProvider = exports.CoinGeckoPriceProvider = exports.BinancePriceProvider = exports.RedundantSwapPrice = exports.IntermediaryDiscovery = exports.Intermediary = exports.MempoolApiError = exports.MempoolBitcoinRpc = exports.MempoolApi = exports.SwapData = exports.SpvWithdrawalTransactionData = exports.SpvVaultData = exports.TransactionRevertedError = exports.SwapDataVerificationError = exports.SignatureVerificationError = exports.CannotInitializeATAError = exports.BitcoinNetwork = void 0;
18
- exports.ISwapWrapper = exports.ISwap = exports.OnchainForGasWrapper = exports.OnchainForGasSwapState = exports.OnchainForGasSwap = void 0;
17
+ exports.LnForGasSwapState = exports.LnForGasSwap = exports.SpvFromBTCWrapper = exports.SpvFromBTCSwapState = exports.SpvFromBTCSwap = exports.IEscrowSwapWrapper = exports.IEscrowSwap = exports.IEscrowSelfInitSwap = exports.IToBTCWrapper = exports.ToBTCSwapState = exports.IToBTCSwap = exports.ToBTCWrapper = exports.ToBTCSwap = exports.ToBTCLNWrapper = exports.ToBTCLNSwap = exports.IFromBTCWrapper = exports.IFromBTCSelfInitSwap = exports.IFromBTCLNWrapper = exports.FromBTCWrapper = exports.FromBTCSwapState = exports.FromBTCSwap = exports.FromBTCLNAutoWrapper = exports.FromBTCLNAutoSwapState = exports.FromBTCLNAutoSwap = exports.FromBTCLNWrapper = exports.FromBTCLNSwapState = exports.FromBTCLNSwap = exports.Swapper = exports.IndexedDBUnifiedStorage = exports.CustomPriceProvider = exports.OKXPriceProvider = exports.KrakenPriceProvider = exports.CoinPaprikaPriceProvider = exports.CoinGeckoPriceProvider = exports.BinancePriceProvider = exports.RedundantSwapPrice = exports.IntermediaryDiscovery = exports.Intermediary = exports.NostrMessenger = exports.MempoolApiError = exports.MempoolBitcoinRpc = exports.MempoolApi = exports.SwapData = exports.SpvWithdrawalTransactionData = exports.SpvVaultData = exports.TransactionRevertedError = exports.SwapDataVerificationError = exports.SignatureVerificationError = exports.CannotInitializeATAError = exports.BitcoinNetwork = void 0;
18
+ exports.ISwapWrapper = exports.ISwap = exports.OnchainForGasWrapper = exports.OnchainForGasSwapState = exports.OnchainForGasSwap = exports.LnForGasWrapper = void 0;
19
19
  var base_1 = require("@atomiqlabs/base");
20
20
  Object.defineProperty(exports, "BitcoinNetwork", { enumerable: true, get: function () { return base_1.BitcoinNetwork; } });
21
21
  Object.defineProperty(exports, "CannotInitializeATAError", { enumerable: true, get: function () { return base_1.CannotInitializeATAError; } });
@@ -29,17 +29,16 @@ var btc_mempool_1 = require("@atomiqlabs/btc-mempool");
29
29
  Object.defineProperty(exports, "MempoolApi", { enumerable: true, get: function () { return btc_mempool_1.MempoolApi; } });
30
30
  Object.defineProperty(exports, "MempoolBitcoinRpc", { enumerable: true, get: function () { return btc_mempool_1.MempoolBitcoinRpc; } });
31
31
  Object.defineProperty(exports, "MempoolApiError", { enumerable: true, get: function () { return btc_mempool_1.MempoolApiError; } });
32
+ var messenger_nostr_1 = require("@atomiqlabs/messenger-nostr");
33
+ Object.defineProperty(exports, "NostrMessenger", { enumerable: true, get: function () { return messenger_nostr_1.NostrMessenger; } });
32
34
  __exportStar(require("./bitcoin/wallet/BitcoinWallet"), exports);
33
35
  __exportStar(require("./bitcoin/wallet/IBitcoinWallet"), exports);
34
- __exportStar(require("./types/wallets/MinimalBitcoinWalletInterface"), exports);
35
- __exportStar(require("./types/wallets/MinimalLightningNetworkWalletInterface"), exports);
36
36
  __exportStar(require("./bitcoin/wallet/SingleAddressBitcoinWallet"), exports);
37
37
  __exportStar(require("./enums/FeeType"), exports);
38
38
  __exportStar(require("./enums/SwapAmountType"), exports);
39
39
  __exportStar(require("./enums/SwapDirection"), exports);
40
40
  __exportStar(require("./enums/SwapType"), exports);
41
41
  __exportStar(require("./errors/IntermediaryError"), exports);
42
- __exportStar(require("./errors/PaymentAuthError"), exports);
43
42
  __exportStar(require("./errors/RequestError"), exports);
44
43
  __exportStar(require("./errors/UserError"), exports);
45
44
  var Intermediary_1 = require("./intermediaries/Intermediary");
@@ -144,9 +143,11 @@ __exportStar(require("./types/fees/FeeBreakdown"), exports);
144
143
  __exportStar(require("./types/fees/PercentagePPM"), exports);
145
144
  __exportStar(require("./types/lnurl/LNURLPay"), exports);
146
145
  __exportStar(require("./types/lnurl/LNURLWithdraw"), exports);
146
+ __exportStar(require("./types/wallets/MinimalBitcoinWalletInterface"), exports);
147
+ __exportStar(require("./types/wallets/MinimalLightningNetworkWalletInterface"), exports);
148
+ __exportStar(require("./types/wallets/LightningInvoiceCreateService"), exports);
147
149
  __exportStar(require("./types/AmountData"), exports);
148
150
  __exportStar(require("./types/CustomPriceFunction"), exports);
149
- __exportStar(require("./types/PriceInfoType"), exports);
150
151
  __exportStar(require("./types/SwapExecutionAction"), exports);
151
152
  __exportStar(require("./types/SwapWithSigner"), exports);
152
153
  __exportStar(require("./types/Token"), exports);
@@ -3,14 +3,16 @@ import { SwapHandlerInfoType } from "./IntermediaryDiscovery";
3
3
  import { ChainSwapType, LNNodeLiquidity, SwapContract } from "@atomiqlabs/base";
4
4
  /**
5
5
  * Services offered by an intermediary
6
- * @category Pricing and LPs
6
+ *
7
+ * @category LPs
7
8
  */
8
9
  export type ServicesType = {
9
10
  [key in SwapType]?: SwapHandlerInfoType;
10
11
  };
11
12
  /**
12
13
  * Reputation data for an intermediary on a single chain
13
- * @category Pricing and LPs
14
+ *
15
+ * @category LPs
14
16
  */
15
17
  export type SingleChainReputationType = {
16
18
  [token: string]: {
@@ -26,21 +28,35 @@ export type SingleChainReputationType = {
26
28
  };
27
29
  /**
28
30
  * Smart chain liquidity data
29
- * @category Pricing and LPs
31
+ *
32
+ * @category LPs
30
33
  */
31
34
  export type SCLiquidity = {
32
35
  [token: string]: bigint;
33
36
  };
34
37
  /**
35
- * Represents a liquidity provider/intermediary
36
- * @category Pricing and LPs
38
+ * Represents an intermediary (liquidity provider)
39
+ *
40
+ * @category LPs
37
41
  */
38
42
  export declare class Intermediary {
43
+ /**
44
+ * Base URL where the intermediary is listening for HTTP requests
45
+ */
39
46
  readonly url: string;
47
+ /**
48
+ * Addresses of the intermediary on smart chains, used for checking the provided signatures
49
+ */
40
50
  readonly addresses: {
41
51
  [chainIdentifier: string]: string;
42
52
  };
53
+ /**
54
+ * Swap protocol services offered by the intermediary
55
+ */
43
56
  readonly services: ServicesType;
57
+ /**
58
+ * Input/output swap bounds for various swap protocols offered by the intermediary
59
+ */
44
60
  readonly swapBounds: {
45
61
  [swapType in SwapType]?: {
46
62
  [chainIdentifier: string]: {
@@ -57,18 +73,38 @@ export declare class Intermediary {
57
73
  };
58
74
  };
59
75
  };
76
+ /**
77
+ * Reputation of the intermediary on different smart chains, this is only fetched
78
+ * on-demand when creating a swap where reputation is checked
79
+ */
60
80
  reputation: {
61
81
  [chainIdentifier: string]: SingleChainReputationType;
62
82
  };
83
+ /**
84
+ * Liquidity of the intermediary across different smart chains, this is only fetched
85
+ * on-demand when creating a swap where intermediary's liquidity is checked
86
+ */
63
87
  liquidity: {
64
88
  [chainIdentifier: string]: SCLiquidity;
65
89
  };
90
+ /**
91
+ * Data about a lightning network node used by this intermediary, if it offers lightning
92
+ * network swaps, this is only fetched on-demand when creating a Bitcoin Lightning -> Smart chain
93
+ * swap through the intermediary (which necessitates checking intermediary's channel capacities)
94
+ */
66
95
  lnData?: LNNodeLiquidity;
67
96
  constructor(url: string, addresses: {
68
97
  [chainIdentifier: string]: string;
69
98
  }, services: ServicesType, reputation?: {
70
99
  [chainIdentifier: string]: SingleChainReputationType;
71
100
  });
101
+ /**
102
+ * Returns the input/output swap limit for given swap type, chain and token
103
+ *
104
+ * @param swapType Swap protocol service to check
105
+ * @param chainId Chain identifier of the smart chain to check
106
+ * @param tokenAddress Address of the token to check
107
+ */
72
108
  getSwapLimits(swapType: SwapType, chainId: string, tokenAddress: string): {
73
109
  input: {
74
110
  min?: bigint;
@@ -82,29 +118,40 @@ export declare class Intermediary {
82
118
  /**
83
119
  * Returns tokens supported by the intermediary, optionally constrained to the specific swap types
84
120
  *
85
- * @param chainIdentifier
86
- * @param swapTypesArr
121
+ * @param chainIdentifier Chain identifier of the smart chain to check
122
+ * @param swapTypesArr An array of swap type services to check
87
123
  * @private
88
124
  */
89
125
  private getSupportedTokens;
90
126
  /**
91
127
  * Fetches, returns and saves the reputation of the intermediary, either for all or just for a single token
92
128
  *
93
- * @param chainIdentifier
94
- * @param swapContract
95
- * @param tokens
129
+ * @param chainIdentifier Chain identifier of the chain on which to fetch the reputation
130
+ * @param swapContract Swap contract for the requested smart chain
131
+ * @param tokens An optional array of tokens to fetch the data for (by default it uses all tokens supported
132
+ * by the intermediary)
96
133
  * @param abortSignal
97
134
  */
98
135
  getReputation(chainIdentifier: string, swapContract: SwapContract<any>, tokens?: string[], abortSignal?: AbortSignal): Promise<SingleChainReputationType>;
99
136
  /**
100
- * Fetches, returns and saves the liquidity of the intermediaryfor a specific token
137
+ * Fetches, returns and saves the liquidity of the intermediary for a specific token
101
138
  *
102
- * @param chainIdentifier
103
- * @param swapContract
104
- * @param token
139
+ * @param chainIdentifier Chain identifier of the chain on which to fetch the reputation
140
+ * @param swapContract Swap contract for the requested smart chain
141
+ * @param token Token address of the token to fetch the liquidity for
105
142
  * @param abortSignal
106
143
  */
107
144
  getLiquidity(chainIdentifier: string, swapContract: SwapContract<any>, token: string, abortSignal?: AbortSignal): Promise<bigint>;
145
+ /**
146
+ * Checks whether the intermediary supports swaps of any tokens on the smart chain
147
+ *
148
+ * @param chainIdentifier Chain identifier of the smart chain
149
+ */
108
150
  supportsChain(chainIdentifier: string): boolean;
151
+ /**
152
+ * Returns intermediary's address on a given smart chain
153
+ *
154
+ * @param chainIdentifier Chain identifier of the smart chain
155
+ */
109
156
  getAddress(chainIdentifier: string): string;
110
157
  }
@@ -4,12 +4,21 @@ exports.Intermediary = void 0;
4
4
  const SwapType_1 = require("../enums/SwapType");
5
5
  const RetryUtils_1 = require("../utils/RetryUtils");
6
6
  /**
7
- * Represents a liquidity provider/intermediary
8
- * @category Pricing and LPs
7
+ * Represents an intermediary (liquidity provider)
8
+ *
9
+ * @category LPs
9
10
  */
10
11
  class Intermediary {
11
12
  constructor(url, addresses, services, reputation = {}) {
13
+ /**
14
+ * Reputation of the intermediary on different smart chains, this is only fetched
15
+ * on-demand when creating a swap where reputation is checked
16
+ */
12
17
  this.reputation = {};
18
+ /**
19
+ * Liquidity of the intermediary across different smart chains, this is only fetched
20
+ * on-demand when creating a swap where intermediary's liquidity is checked
21
+ */
13
22
  this.liquidity = {};
14
23
  this.url = url;
15
24
  this.addresses = addresses;
@@ -33,14 +42,21 @@ class Intermediary {
33
42
  }
34
43
  }
35
44
  }
45
+ /**
46
+ * Returns the input/output swap limit for given swap type, chain and token
47
+ *
48
+ * @param swapType Swap protocol service to check
49
+ * @param chainId Chain identifier of the smart chain to check
50
+ * @param tokenAddress Address of the token to check
51
+ */
36
52
  getSwapLimits(swapType, chainId, tokenAddress) {
37
53
  return this.swapBounds[swapType]?.[chainId]?.[tokenAddress];
38
54
  }
39
55
  /**
40
56
  * Returns tokens supported by the intermediary, optionally constrained to the specific swap types
41
57
  *
42
- * @param chainIdentifier
43
- * @param swapTypesArr
58
+ * @param chainIdentifier Chain identifier of the smart chain to check
59
+ * @param swapTypesArr An array of swap type services to check
44
60
  * @private
45
61
  */
46
62
  getSupportedTokens(chainIdentifier, swapTypesArr = [
@@ -63,9 +79,10 @@ class Intermediary {
63
79
  /**
64
80
  * Fetches, returns and saves the reputation of the intermediary, either for all or just for a single token
65
81
  *
66
- * @param chainIdentifier
67
- * @param swapContract
68
- * @param tokens
82
+ * @param chainIdentifier Chain identifier of the chain on which to fetch the reputation
83
+ * @param swapContract Swap contract for the requested smart chain
84
+ * @param tokens An optional array of tokens to fetch the data for (by default it uses all tokens supported
85
+ * by the intermediary)
69
86
  * @param abortSignal
70
87
  */
71
88
  async getReputation(chainIdentifier, swapContract, tokens, abortSignal) {
@@ -89,11 +106,11 @@ class Intermediary {
89
106
  return reputation;
90
107
  }
91
108
  /**
92
- * Fetches, returns and saves the liquidity of the intermediaryfor a specific token
109
+ * Fetches, returns and saves the liquidity of the intermediary for a specific token
93
110
  *
94
- * @param chainIdentifier
95
- * @param swapContract
96
- * @param token
111
+ * @param chainIdentifier Chain identifier of the chain on which to fetch the reputation
112
+ * @param swapContract Swap contract for the requested smart chain
113
+ * @param token Token address of the token to fetch the liquidity for
97
114
  * @param abortSignal
98
115
  */
99
116
  async getLiquidity(chainIdentifier, swapContract, token, abortSignal) {
@@ -103,11 +120,21 @@ class Intermediary {
103
120
  this.liquidity[chainIdentifier][token] = result;
104
121
  return result;
105
122
  }
123
+ /**
124
+ * Checks whether the intermediary supports swaps of any tokens on the smart chain
125
+ *
126
+ * @param chainIdentifier Chain identifier of the smart chain
127
+ */
106
128
  supportsChain(chainIdentifier) {
107
129
  if (this.addresses[chainIdentifier] == null)
108
130
  return false;
109
131
  return this.getSupportedTokens(chainIdentifier).size !== 0;
110
132
  }
133
+ /**
134
+ * Returns intermediary's address on a given smart chain
135
+ *
136
+ * @param chainIdentifier Chain identifier of the smart chain
137
+ */
111
138
  getAddress(chainIdentifier) {
112
139
  return this.addresses[chainIdentifier];
113
140
  }