@atomiqlabs/sdk 7.0.12 → 8.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -29
- package/dist/SmartChainAssets.d.ts +11 -3
- package/dist/SmartChainAssets.js +7 -3
- package/dist/bitcoin/BitcoinRpcWithAddressIndex.d.ts +68 -0
- package/dist/bitcoin/BitcoinRpcWithAddressIndex.js +2 -0
- package/dist/bitcoin/LightningNetworkApi.d.ts +12 -0
- package/dist/bitcoin/LightningNetworkApi.js +2 -0
- package/dist/bitcoin/coinselect2/accumulative.d.ts +6 -0
- package/dist/bitcoin/coinselect2/accumulative.js +52 -0
- package/dist/bitcoin/coinselect2/blackjack.d.ts +6 -0
- package/dist/bitcoin/coinselect2/blackjack.js +38 -0
- package/dist/bitcoin/coinselect2/index.d.ts +19 -0
- package/dist/bitcoin/coinselect2/index.js +69 -0
- package/dist/bitcoin/coinselect2/utils.d.ts +71 -0
- package/dist/bitcoin/coinselect2/utils.js +123 -0
- package/dist/bitcoin/mempool/MempoolApi.d.ts +350 -0
- package/dist/bitcoin/mempool/MempoolApi.js +311 -0
- package/dist/bitcoin/mempool/MempoolBitcoinBlock.d.ts +44 -0
- package/dist/bitcoin/mempool/MempoolBitcoinBlock.js +48 -0
- package/dist/bitcoin/mempool/MempoolBitcoinRpc.d.ts +119 -0
- package/dist/bitcoin/mempool/MempoolBitcoinRpc.js +361 -0
- package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.d.ts +22 -0
- package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.js +105 -0
- package/dist/bitcoin/wallet/BitcoinWallet.d.ts +93 -0
- package/dist/bitcoin/wallet/BitcoinWallet.js +273 -0
- package/dist/bitcoin/wallet/IBitcoinWallet.d.ts +28 -0
- package/dist/bitcoin/wallet/IBitcoinWallet.js +20 -0
- package/dist/bitcoin/wallet/MinimalBitcoinWalletInterface.d.ts +21 -0
- package/dist/bitcoin/wallet/MinimalBitcoinWalletInterface.js +2 -0
- package/dist/bitcoin/wallet/MinimalLightningNetworkWalletInterface.d.ts +7 -0
- package/dist/bitcoin/wallet/MinimalLightningNetworkWalletInterface.js +2 -0
- package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.d.ts +40 -0
- package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.js +86 -0
- package/dist/enums/FeeType.d.ts +8 -0
- package/dist/enums/FeeType.js +12 -0
- package/dist/enums/SwapAmountType.d.ts +8 -0
- package/dist/enums/SwapAmountType.js +12 -0
- package/dist/enums/SwapDirection.d.ts +8 -0
- package/dist/enums/SwapDirection.js +12 -0
- package/dist/enums/SwapType.d.ts +14 -0
- package/dist/enums/SwapType.js +18 -0
- package/dist/errors/IntermediaryError.d.ts +9 -0
- package/dist/errors/IntermediaryError.js +26 -0
- package/dist/errors/PaymentAuthError.d.ts +11 -0
- package/dist/errors/PaymentAuthError.js +23 -0
- package/dist/errors/RequestError.d.ts +18 -0
- package/dist/errors/RequestError.js +46 -0
- package/dist/errors/UserError.d.ts +7 -0
- package/dist/errors/UserError.js +15 -0
- package/dist/events/UnifiedSwapEventListener.d.ts +23 -0
- package/dist/events/UnifiedSwapEventListener.js +130 -0
- package/dist/http/HttpUtils.d.ts +27 -0
- package/dist/http/HttpUtils.js +91 -0
- package/dist/http/paramcoders/IParamReader.d.ts +8 -0
- package/dist/http/paramcoders/IParamReader.js +2 -0
- package/dist/http/paramcoders/ParamDecoder.d.ts +44 -0
- package/dist/http/paramcoders/ParamDecoder.js +132 -0
- package/dist/http/paramcoders/ParamEncoder.d.ts +20 -0
- package/dist/http/paramcoders/ParamEncoder.js +31 -0
- package/dist/http/paramcoders/SchemaVerifier.d.ts +26 -0
- package/dist/http/paramcoders/SchemaVerifier.js +145 -0
- package/dist/http/paramcoders/client/ResponseParamDecoder.d.ts +11 -0
- package/dist/http/paramcoders/client/ResponseParamDecoder.js +57 -0
- package/dist/http/paramcoders/client/StreamParamEncoder.d.ts +13 -0
- package/dist/http/paramcoders/client/StreamParamEncoder.js +26 -0
- package/dist/http/paramcoders/client/StreamingFetchPromise.d.ts +16 -0
- package/dist/http/paramcoders/client/StreamingFetchPromise.js +174 -0
- package/dist/index.d.ts +82 -4
- package/dist/index.js +128 -4
- package/dist/intermediaries/Intermediary.d.ts +111 -0
- package/dist/intermediaries/Intermediary.js +115 -0
- package/dist/intermediaries/IntermediaryDiscovery.d.ts +166 -0
- package/dist/intermediaries/IntermediaryDiscovery.js +390 -0
- package/dist/intermediaries/apis/IntermediaryAPI.d.ts +436 -0
- package/dist/intermediaries/apis/IntermediaryAPI.js +600 -0
- package/dist/intermediaries/apis/TrustedIntermediaryAPI.d.ts +154 -0
- package/dist/intermediaries/apis/TrustedIntermediaryAPI.js +136 -0
- package/dist/lnurl/LNURL.d.ts +102 -0
- package/dist/lnurl/LNURL.js +321 -0
- package/dist/prices/RedundantSwapPrice.d.ts +89 -0
- package/dist/prices/RedundantSwapPrice.js +202 -0
- package/dist/prices/SingleSwapPrice.d.ts +31 -0
- package/dist/prices/SingleSwapPrice.js +41 -0
- package/dist/prices/SwapPriceWithChain.d.ts +70 -0
- package/dist/prices/SwapPriceWithChain.js +91 -0
- package/dist/prices/abstract/ICachedSwapPrice.d.ts +28 -0
- package/dist/prices/abstract/ICachedSwapPrice.js +62 -0
- package/dist/prices/abstract/IPriceProvider.d.ts +81 -0
- package/dist/prices/abstract/IPriceProvider.js +74 -0
- package/dist/prices/abstract/ISwapPrice.d.ts +117 -0
- package/dist/prices/abstract/ISwapPrice.js +219 -0
- package/dist/prices/providers/BinancePriceProvider.d.ts +16 -0
- package/dist/prices/providers/BinancePriceProvider.js +23 -0
- package/dist/prices/providers/CoinGeckoPriceProvider.d.ts +17 -0
- package/dist/prices/providers/CoinGeckoPriceProvider.js +23 -0
- package/dist/prices/providers/CoinPaprikaPriceProvider.d.ts +19 -0
- package/dist/prices/providers/CoinPaprikaPriceProvider.js +23 -0
- package/dist/prices/providers/CustomPriceProvider.d.ts +13 -0
- package/dist/prices/providers/CustomPriceProvider.js +24 -0
- package/dist/prices/providers/KrakenPriceProvider.d.ts +29 -0
- package/dist/prices/providers/KrakenPriceProvider.js +36 -0
- package/dist/prices/providers/OKXPriceProvider.d.ts +28 -0
- package/dist/prices/providers/OKXPriceProvider.js +23 -0
- package/dist/prices/providers/abstract/ExchangePriceProvider.d.ts +14 -0
- package/dist/prices/providers/abstract/ExchangePriceProvider.js +18 -0
- package/dist/prices/providers/abstract/HttpPriceProvider.d.ts +7 -0
- package/dist/prices/providers/abstract/HttpPriceProvider.js +12 -0
- package/dist/storage/IUnifiedStorage.d.ts +73 -0
- package/dist/storage/IUnifiedStorage.js +2 -0
- package/dist/storage/UnifiedSwapStorage.d.ts +82 -0
- package/dist/storage/UnifiedSwapStorage.js +83 -0
- package/dist/storage-browser/IndexedDBUnifiedStorage.d.ts +39 -0
- package/dist/storage-browser/IndexedDBUnifiedStorage.js +275 -0
- package/dist/{storage → storage-browser}/LocalStorageManager.d.ts +1 -0
- package/dist/{storage → storage-browser}/LocalStorageManager.js +2 -1
- package/dist/swapper/Swapper.d.ts +533 -0
- package/dist/swapper/Swapper.js +1566 -0
- package/dist/swapper/SwapperFactory.d.ts +87 -0
- package/dist/{SwapperFactory.js → swapper/SwapperFactory.js} +37 -19
- package/dist/swapper/SwapperUtils.d.ts +153 -0
- package/dist/swapper/SwapperUtils.js +420 -0
- package/dist/swapper/SwapperWithChain.d.ts +214 -0
- package/dist/swapper/SwapperWithChain.js +315 -0
- package/dist/swapper/SwapperWithSigner.d.ts +178 -0
- package/dist/swapper/SwapperWithSigner.js +172 -0
- package/dist/swaps/IAddressSwap.d.ts +13 -0
- package/dist/swaps/IAddressSwap.js +13 -0
- package/dist/swaps/IBTCWalletSwap.d.ts +55 -0
- package/dist/swaps/IBTCWalletSwap.js +17 -0
- package/dist/swaps/IClaimableSwap.d.ts +17 -0
- package/dist/swaps/IClaimableSwap.js +14 -0
- package/dist/swaps/IClaimableSwapWrapper.d.ts +5 -0
- package/dist/swaps/IClaimableSwapWrapper.js +2 -0
- package/dist/swaps/IRefundableSwap.d.ts +17 -0
- package/dist/swaps/IRefundableSwap.js +13 -0
- package/dist/swaps/ISwap.d.ts +207 -0
- package/dist/swaps/ISwap.js +264 -0
- package/dist/swaps/ISwapWithGasDrop.d.ts +15 -0
- package/dist/swaps/ISwapWithGasDrop.js +11 -0
- package/dist/swaps/ISwapWrapper.d.ts +153 -0
- package/dist/swaps/ISwapWrapper.js +227 -0
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.d.ts +53 -0
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.js +116 -0
- package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +70 -0
- package/dist/swaps/escrow_swaps/IEscrowSwap.js +132 -0
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +85 -0
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +122 -0
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +86 -0
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +115 -0
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.d.ts +93 -0
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.js +121 -0
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.d.ts +45 -0
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.js +65 -0
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +263 -0
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +933 -0
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +110 -0
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +307 -0
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +236 -0
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +898 -0
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +125 -0
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +393 -0
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +245 -0
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +841 -0
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +120 -0
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +294 -0
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +228 -0
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +721 -0
- package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.d.ts +37 -0
- package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.js +93 -0
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.d.ts +86 -0
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.js +213 -0
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +170 -0
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +520 -0
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.d.ts +50 -0
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.js +109 -0
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +93 -0
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +217 -0
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +315 -0
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +1098 -0
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +125 -0
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +631 -0
- package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +107 -0
- package/dist/swaps/trusted/ln/LnForGasSwap.js +343 -0
- package/dist/swaps/trusted/ln/LnForGasWrapper.d.ts +21 -0
- package/dist/swaps/trusted/ln/LnForGasWrapper.js +62 -0
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +164 -0
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +520 -0
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +48 -0
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +74 -0
- package/dist/types/AmountData.d.ts +9 -0
- package/dist/types/AmountData.js +2 -0
- package/dist/types/CustomPriceFunction.d.ts +5 -0
- package/dist/types/CustomPriceFunction.js +2 -0
- package/dist/types/PriceInfoType.d.ts +28 -0
- package/dist/types/PriceInfoType.js +57 -0
- package/dist/types/SwapExecutionAction.d.ts +7 -0
- package/dist/types/SwapExecutionAction.js +2 -0
- package/dist/types/SwapWithSigner.d.ts +14 -0
- package/dist/types/SwapWithSigner.js +40 -0
- package/dist/types/Token.d.ts +53 -0
- package/dist/types/Token.js +58 -0
- package/dist/types/TokenAmount.d.ts +57 -0
- package/dist/types/TokenAmount.js +47 -0
- package/dist/types/fees/Fee.d.ts +49 -0
- package/dist/types/fees/Fee.js +2 -0
- package/dist/types/fees/FeeBreakdown.d.ts +10 -0
- package/dist/types/fees/FeeBreakdown.js +2 -0
- package/dist/types/fees/PercentagePPM.d.ts +15 -0
- package/dist/types/fees/PercentagePPM.js +17 -0
- package/dist/types/lnurl/LNURLPay.d.ts +54 -0
- package/dist/types/lnurl/LNURLPay.js +28 -0
- package/dist/types/lnurl/LNURLWithdraw.d.ts +42 -0
- package/dist/types/lnurl/LNURLWithdraw.js +24 -0
- package/dist/utils/AutomaticClockDriftCorrection.d.ts +1 -0
- package/dist/utils/AutomaticClockDriftCorrection.js +70 -0
- package/dist/utils/BitcoinUtils.d.ts +13 -0
- package/dist/utils/BitcoinUtils.js +98 -0
- package/dist/utils/BitcoinWalletUtils.d.ts +7 -0
- package/dist/utils/BitcoinWalletUtils.js +14 -0
- package/dist/utils/Logger.d.ts +7 -0
- package/dist/utils/Logger.js +12 -0
- package/dist/utils/RetryUtils.d.ts +21 -0
- package/dist/utils/RetryUtils.js +66 -0
- package/dist/utils/SwapUtils.d.ts +31 -0
- package/dist/utils/SwapUtils.js +18 -0
- package/dist/{Utils.d.ts → utils/TimeoutUtils.d.ts} +9 -3
- package/dist/utils/TimeoutUtils.js +55 -0
- package/dist/utils/TokenUtils.d.ts +11 -0
- package/dist/utils/TokenUtils.js +29 -0
- package/dist/utils/TypeUtils.d.ts +7 -0
- package/dist/utils/TypeUtils.js +2 -0
- package/dist/utils/Utils.d.ts +57 -0
- package/dist/utils/Utils.js +178 -0
- package/package.json +14 -6
- package/src/SmartChainAssets.ts +11 -3
- package/src/bitcoin/BitcoinRpcWithAddressIndex.ts +87 -0
- package/src/bitcoin/LightningNetworkApi.ts +16 -0
- package/src/bitcoin/coinselect2/accumulative.ts +68 -0
- package/src/bitcoin/coinselect2/blackjack.ts +49 -0
- package/src/bitcoin/coinselect2/index.ts +92 -0
- package/src/bitcoin/coinselect2/utils.ts +189 -0
- package/src/bitcoin/mempool/MempoolApi.ts +554 -0
- package/src/bitcoin/mempool/MempoolBitcoinBlock.ts +88 -0
- package/src/bitcoin/mempool/MempoolBitcoinRpc.ts +437 -0
- package/src/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.ts +134 -0
- package/src/bitcoin/wallet/BitcoinWallet.ts +375 -0
- package/src/bitcoin/wallet/IBitcoinWallet.ts +44 -0
- package/src/bitcoin/wallet/MinimalBitcoinWalletInterface.ts +19 -0
- package/src/bitcoin/wallet/MinimalLightningNetworkWalletInterface.ts +7 -0
- package/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts +108 -0
- package/src/enums/FeeType.ts +9 -0
- package/src/enums/SwapAmountType.ts +9 -0
- package/src/enums/SwapDirection.ts +9 -0
- package/src/enums/SwapType.ts +15 -0
- package/src/errors/IntermediaryError.ts +24 -0
- package/src/errors/PaymentAuthError.ts +26 -0
- package/src/errors/RequestError.ts +51 -0
- package/src/errors/UserError.ts +14 -0
- package/src/events/UnifiedSwapEventListener.ts +171 -0
- package/src/http/HttpUtils.ts +92 -0
- package/src/http/paramcoders/IParamReader.ts +10 -0
- package/src/http/paramcoders/ParamDecoder.ts +142 -0
- package/src/http/paramcoders/ParamEncoder.ts +37 -0
- package/src/http/paramcoders/SchemaVerifier.ts +153 -0
- package/src/http/paramcoders/client/ResponseParamDecoder.ts +58 -0
- package/src/http/paramcoders/client/StreamParamEncoder.ts +29 -0
- package/src/http/paramcoders/client/StreamingFetchPromise.ts +193 -0
- package/src/index.ts +102 -4
- package/src/intermediaries/Intermediary.ts +204 -0
- package/src/intermediaries/IntermediaryDiscovery.ts +485 -0
- package/src/intermediaries/apis/IntermediaryAPI.ts +940 -0
- package/src/intermediaries/apis/TrustedIntermediaryAPI.ts +257 -0
- package/src/lnurl/LNURL.ts +403 -0
- package/src/prices/RedundantSwapPrice.ts +245 -0
- package/src/prices/SingleSwapPrice.ts +47 -0
- package/src/prices/SwapPriceWithChain.ts +157 -0
- package/src/prices/abstract/ICachedSwapPrice.ts +86 -0
- package/src/prices/abstract/IPriceProvider.ts +128 -0
- package/src/prices/abstract/ISwapPrice.ts +328 -0
- package/src/prices/providers/BinancePriceProvider.ts +41 -0
- package/src/prices/providers/CoinGeckoPriceProvider.ts +40 -0
- package/src/prices/providers/CoinPaprikaPriceProvider.ts +44 -0
- package/src/prices/providers/CustomPriceProvider.ts +29 -0
- package/src/prices/providers/KrakenPriceProvider.ts +74 -0
- package/src/prices/providers/OKXPriceProvider.ts +53 -0
- package/src/prices/providers/abstract/ExchangePriceProvider.ts +29 -0
- package/src/prices/providers/abstract/HttpPriceProvider.ts +15 -0
- package/src/storage/IUnifiedStorage.ts +83 -0
- package/src/storage/UnifiedSwapStorage.ts +104 -0
- package/src/storage-browser/IndexedDBUnifiedStorage.ts +328 -0
- package/src/{storage → storage-browser}/LocalStorageManager.ts +2 -1
- package/src/swapper/Swapper.ts +2107 -0
- package/src/{SwapperFactory.ts → swapper/SwapperFactory.ts} +113 -72
- package/src/swapper/SwapperUtils.ts +510 -0
- package/src/swapper/SwapperWithChain.ts +464 -0
- package/src/swapper/SwapperWithSigner.ts +300 -0
- package/src/swaps/IAddressSwap.ts +20 -0
- package/src/swaps/IBTCWalletSwap.ts +77 -0
- package/src/swaps/IClaimableSwap.ts +30 -0
- package/src/swaps/IClaimableSwapWrapper.ts +9 -0
- package/src/swaps/IRefundableSwap.ts +29 -0
- package/src/swaps/ISwap.ts +490 -0
- package/src/swaps/ISwapWithGasDrop.ts +19 -0
- package/src/swaps/ISwapWrapper.ts +344 -0
- package/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts +168 -0
- package/src/swaps/escrow_swaps/IEscrowSwap.ts +197 -0
- package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +210 -0
- package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +150 -0
- package/src/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.ts +219 -0
- package/src/swaps/escrow_swaps/frombtc/IFromBTCWrapper.ts +84 -0
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +1082 -0
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +429 -0
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +1078 -0
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +549 -0
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +974 -0
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +443 -0
- package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +860 -0
- package/src/swaps/escrow_swaps/tobtc/IToBTCWrapper.ts +104 -0
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.ts +256 -0
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +716 -0
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.ts +151 -0
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +299 -0
- package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +1394 -0
- package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +796 -0
- package/src/swaps/trusted/ln/LnForGasSwap.ts +402 -0
- package/src/swaps/trusted/ln/LnForGasWrapper.ts +70 -0
- package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +633 -0
- package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +110 -0
- package/src/types/AmountData.ts +9 -0
- package/src/types/CustomPriceFunction.ts +5 -0
- package/src/types/PriceInfoType.ts +67 -0
- package/src/types/SwapExecutionAction.ts +8 -0
- package/src/types/SwapWithSigner.ts +57 -0
- package/src/types/Token.ts +90 -0
- package/src/types/TokenAmount.ts +110 -0
- package/src/types/fees/Fee.ts +55 -0
- package/src/types/fees/FeeBreakdown.ts +11 -0
- package/src/types/fees/PercentagePPM.ts +24 -0
- package/src/types/lnurl/LNURLPay.ts +72 -0
- package/src/types/lnurl/LNURLWithdraw.ts +55 -0
- package/src/utils/AutomaticClockDriftCorrection.ts +71 -0
- package/src/utils/BitcoinUtils.ts +86 -0
- package/src/utils/BitcoinWalletUtils.ts +16 -0
- package/src/utils/Logger.ts +15 -0
- package/src/utils/RetryUtils.ts +71 -0
- package/src/utils/SwapUtils.ts +38 -0
- package/src/utils/TimeoutUtils.ts +50 -0
- package/src/utils/TokenUtils.ts +25 -0
- package/src/utils/TypeUtils.ts +9 -0
- package/src/utils/Utils.ts +182 -0
- package/dist/SwapperFactory.d.ts +0 -52
- package/dist/Utils.js +0 -37
- package/dist/fs-storage/FileSystemStorageManager.d.ts +0 -15
- package/dist/fs-storage/FileSystemStorageManager.js +0 -60
- package/dist/fs-storage/index.d.ts +0 -1
- package/dist/fs-storage/index.js +0 -17
- package/src/SmartChainAssets.js +0 -75
- package/src/SwapperFactory.js +0 -120
- package/src/Utils.js +0 -37
- package/src/Utils.ts +0 -31
- package/src/fs-storage/FileSystemStorageManager.ts +0 -71
- package/src/fs-storage/index.ts +0 -1
- package/src/index.js +0 -21
- package/src/storage/LocalStorageManager.js +0 -72
package/dist/index.js
CHANGED
|
@@ -14,8 +14,132 @@ 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.ISwapWrapper = exports.ISwap = exports.OnchainForGasWrapper = exports.OnchainForGasSwapState = exports.OnchainForGasSwap = 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.MempoolApi = void 0;
|
|
17
18
|
__exportStar(require("@atomiqlabs/base"), exports);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
19
|
+
var MempoolApi_1 = require("./bitcoin/mempool/MempoolApi");
|
|
20
|
+
Object.defineProperty(exports, "MempoolApi", { enumerable: true, get: function () { return MempoolApi_1.MempoolApi; } });
|
|
21
|
+
__exportStar(require("./bitcoin/mempool/MempoolBitcoinRpc"), exports);
|
|
22
|
+
__exportStar(require("./bitcoin/wallet/BitcoinWallet"), exports);
|
|
23
|
+
__exportStar(require("./bitcoin/wallet/IBitcoinWallet"), exports);
|
|
24
|
+
__exportStar(require("./bitcoin/wallet/MinimalBitcoinWalletInterface"), exports);
|
|
25
|
+
__exportStar(require("./bitcoin/wallet/MinimalLightningNetworkWalletInterface"), exports);
|
|
26
|
+
__exportStar(require("./bitcoin/wallet/SingleAddressBitcoinWallet"), exports);
|
|
27
|
+
__exportStar(require("./enums/FeeType"), exports);
|
|
28
|
+
__exportStar(require("./enums/SwapAmountType"), exports);
|
|
29
|
+
__exportStar(require("./enums/SwapDirection"), exports);
|
|
30
|
+
__exportStar(require("./enums/SwapType"), exports);
|
|
31
|
+
__exportStar(require("./errors/IntermediaryError"), exports);
|
|
32
|
+
__exportStar(require("./errors/PaymentAuthError"), exports);
|
|
33
|
+
__exportStar(require("./errors/RequestError"), exports);
|
|
34
|
+
__exportStar(require("./errors/UserError"), exports);
|
|
35
|
+
var Intermediary_1 = require("./intermediaries/Intermediary");
|
|
36
|
+
Object.defineProperty(exports, "Intermediary", { enumerable: true, get: function () { return Intermediary_1.Intermediary; } });
|
|
37
|
+
var IntermediaryDiscovery_1 = require("./intermediaries/IntermediaryDiscovery");
|
|
38
|
+
Object.defineProperty(exports, "IntermediaryDiscovery", { enumerable: true, get: function () { return IntermediaryDiscovery_1.IntermediaryDiscovery; } });
|
|
39
|
+
__exportStar(require("./prices/abstract/ISwapPrice"), exports);
|
|
40
|
+
var RedundantSwapPrice_1 = require("./prices/RedundantSwapPrice");
|
|
41
|
+
Object.defineProperty(exports, "RedundantSwapPrice", { enumerable: true, get: function () { return RedundantSwapPrice_1.RedundantSwapPrice; } });
|
|
42
|
+
__exportStar(require("./prices/SingleSwapPrice"), exports);
|
|
43
|
+
__exportStar(require("./prices/SwapPriceWithChain"), exports);
|
|
44
|
+
var BinancePriceProvider_1 = require("./prices/providers/BinancePriceProvider");
|
|
45
|
+
Object.defineProperty(exports, "BinancePriceProvider", { enumerable: true, get: function () { return BinancePriceProvider_1.BinancePriceProvider; } });
|
|
46
|
+
var CoinGeckoPriceProvider_1 = require("./prices/providers/CoinGeckoPriceProvider");
|
|
47
|
+
Object.defineProperty(exports, "CoinGeckoPriceProvider", { enumerable: true, get: function () { return CoinGeckoPriceProvider_1.CoinGeckoPriceProvider; } });
|
|
48
|
+
var CoinPaprikaPriceProvider_1 = require("./prices/providers/CoinPaprikaPriceProvider");
|
|
49
|
+
Object.defineProperty(exports, "CoinPaprikaPriceProvider", { enumerable: true, get: function () { return CoinPaprikaPriceProvider_1.CoinPaprikaPriceProvider; } });
|
|
50
|
+
var KrakenPriceProvider_1 = require("./prices/providers/KrakenPriceProvider");
|
|
51
|
+
Object.defineProperty(exports, "KrakenPriceProvider", { enumerable: true, get: function () { return KrakenPriceProvider_1.KrakenPriceProvider; } });
|
|
52
|
+
var OKXPriceProvider_1 = require("./prices/providers/OKXPriceProvider");
|
|
53
|
+
Object.defineProperty(exports, "OKXPriceProvider", { enumerable: true, get: function () { return OKXPriceProvider_1.OKXPriceProvider; } });
|
|
54
|
+
var CustomPriceProvider_1 = require("./prices/providers/CustomPriceProvider");
|
|
55
|
+
Object.defineProperty(exports, "CustomPriceProvider", { enumerable: true, get: function () { return CustomPriceProvider_1.CustomPriceProvider; } });
|
|
56
|
+
__exportStar(require("./storage/IUnifiedStorage"), exports);
|
|
57
|
+
__exportStar(require("./storage/UnifiedSwapStorage"), exports);
|
|
58
|
+
var IndexedDBUnifiedStorage_1 = require("./storage-browser/IndexedDBUnifiedStorage");
|
|
59
|
+
Object.defineProperty(exports, "IndexedDBUnifiedStorage", { enumerable: true, get: function () { return IndexedDBUnifiedStorage_1.IndexedDBUnifiedStorage; } });
|
|
60
|
+
__exportStar(require("./storage-browser/LocalStorageManager"), exports);
|
|
61
|
+
var Swapper_1 = require("./swapper/Swapper");
|
|
62
|
+
Object.defineProperty(exports, "Swapper", { enumerable: true, get: function () { return Swapper_1.Swapper; } });
|
|
63
|
+
__exportStar(require("./swapper/SwapperFactory"), exports);
|
|
64
|
+
__exportStar(require("./swapper/SwapperUtils"), exports);
|
|
65
|
+
__exportStar(require("./swapper/SwapperWithChain"), exports);
|
|
66
|
+
__exportStar(require("./swapper/SwapperWithSigner"), exports);
|
|
67
|
+
var FromBTCLNSwap_1 = require("./swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap");
|
|
68
|
+
Object.defineProperty(exports, "FromBTCLNSwap", { enumerable: true, get: function () { return FromBTCLNSwap_1.FromBTCLNSwap; } });
|
|
69
|
+
Object.defineProperty(exports, "FromBTCLNSwapState", { enumerable: true, get: function () { return FromBTCLNSwap_1.FromBTCLNSwapState; } });
|
|
70
|
+
var FromBTCLNWrapper_1 = require("./swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper");
|
|
71
|
+
Object.defineProperty(exports, "FromBTCLNWrapper", { enumerable: true, get: function () { return FromBTCLNWrapper_1.FromBTCLNWrapper; } });
|
|
72
|
+
var FromBTCLNAutoSwap_1 = require("./swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap");
|
|
73
|
+
Object.defineProperty(exports, "FromBTCLNAutoSwap", { enumerable: true, get: function () { return FromBTCLNAutoSwap_1.FromBTCLNAutoSwap; } });
|
|
74
|
+
Object.defineProperty(exports, "FromBTCLNAutoSwapState", { enumerable: true, get: function () { return FromBTCLNAutoSwap_1.FromBTCLNAutoSwapState; } });
|
|
75
|
+
var FromBTCLNAutoWrapper_1 = require("./swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper");
|
|
76
|
+
Object.defineProperty(exports, "FromBTCLNAutoWrapper", { enumerable: true, get: function () { return FromBTCLNAutoWrapper_1.FromBTCLNAutoWrapper; } });
|
|
77
|
+
var FromBTCSwap_1 = require("./swaps/escrow_swaps/frombtc/onchain/FromBTCSwap");
|
|
78
|
+
Object.defineProperty(exports, "FromBTCSwap", { enumerable: true, get: function () { return FromBTCSwap_1.FromBTCSwap; } });
|
|
79
|
+
Object.defineProperty(exports, "FromBTCSwapState", { enumerable: true, get: function () { return FromBTCSwap_1.FromBTCSwapState; } });
|
|
80
|
+
var FromBTCWrapper_1 = require("./swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper");
|
|
81
|
+
Object.defineProperty(exports, "FromBTCWrapper", { enumerable: true, get: function () { return FromBTCWrapper_1.FromBTCWrapper; } });
|
|
82
|
+
var IFromBTCLNWrapper_1 = require("./swaps/escrow_swaps/frombtc/IFromBTCLNWrapper");
|
|
83
|
+
Object.defineProperty(exports, "IFromBTCLNWrapper", { enumerable: true, get: function () { return IFromBTCLNWrapper_1.IFromBTCLNWrapper; } });
|
|
84
|
+
var IFromBTCSelfInitSwap_1 = require("./swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap");
|
|
85
|
+
Object.defineProperty(exports, "IFromBTCSelfInitSwap", { enumerable: true, get: function () { return IFromBTCSelfInitSwap_1.IFromBTCSelfInitSwap; } });
|
|
86
|
+
var IFromBTCWrapper_1 = require("./swaps/escrow_swaps/frombtc/IFromBTCWrapper");
|
|
87
|
+
Object.defineProperty(exports, "IFromBTCWrapper", { enumerable: true, get: function () { return IFromBTCWrapper_1.IFromBTCWrapper; } });
|
|
88
|
+
var ToBTCLNSwap_1 = require("./swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap");
|
|
89
|
+
Object.defineProperty(exports, "ToBTCLNSwap", { enumerable: true, get: function () { return ToBTCLNSwap_1.ToBTCLNSwap; } });
|
|
90
|
+
var ToBTCLNWrapper_1 = require("./swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper");
|
|
91
|
+
Object.defineProperty(exports, "ToBTCLNWrapper", { enumerable: true, get: function () { return ToBTCLNWrapper_1.ToBTCLNWrapper; } });
|
|
92
|
+
var ToBTCSwap_1 = require("./swaps/escrow_swaps/tobtc/onchain/ToBTCSwap");
|
|
93
|
+
Object.defineProperty(exports, "ToBTCSwap", { enumerable: true, get: function () { return ToBTCSwap_1.ToBTCSwap; } });
|
|
94
|
+
var ToBTCWrapper_1 = require("./swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper");
|
|
95
|
+
Object.defineProperty(exports, "ToBTCWrapper", { enumerable: true, get: function () { return ToBTCWrapper_1.ToBTCWrapper; } });
|
|
96
|
+
var IToBTCSwap_1 = require("./swaps/escrow_swaps/tobtc/IToBTCSwap");
|
|
97
|
+
Object.defineProperty(exports, "IToBTCSwap", { enumerable: true, get: function () { return IToBTCSwap_1.IToBTCSwap; } });
|
|
98
|
+
Object.defineProperty(exports, "ToBTCSwapState", { enumerable: true, get: function () { return IToBTCSwap_1.ToBTCSwapState; } });
|
|
99
|
+
var IToBTCWrapper_1 = require("./swaps/escrow_swaps/tobtc/IToBTCWrapper");
|
|
100
|
+
Object.defineProperty(exports, "IToBTCWrapper", { enumerable: true, get: function () { return IToBTCWrapper_1.IToBTCWrapper; } });
|
|
101
|
+
var IEscrowSelfInitSwap_1 = require("./swaps/escrow_swaps/IEscrowSelfInitSwap");
|
|
102
|
+
Object.defineProperty(exports, "IEscrowSelfInitSwap", { enumerable: true, get: function () { return IEscrowSelfInitSwap_1.IEscrowSelfInitSwap; } });
|
|
103
|
+
var IEscrowSwap_1 = require("./swaps/escrow_swaps/IEscrowSwap");
|
|
104
|
+
Object.defineProperty(exports, "IEscrowSwap", { enumerable: true, get: function () { return IEscrowSwap_1.IEscrowSwap; } });
|
|
105
|
+
var IEscrowSwapWrapper_1 = require("./swaps/escrow_swaps/IEscrowSwapWrapper");
|
|
106
|
+
Object.defineProperty(exports, "IEscrowSwapWrapper", { enumerable: true, get: function () { return IEscrowSwapWrapper_1.IEscrowSwapWrapper; } });
|
|
107
|
+
var SpvFromBTCSwap_1 = require("./swaps/spv_swaps/SpvFromBTCSwap");
|
|
108
|
+
Object.defineProperty(exports, "SpvFromBTCSwap", { enumerable: true, get: function () { return SpvFromBTCSwap_1.SpvFromBTCSwap; } });
|
|
109
|
+
Object.defineProperty(exports, "SpvFromBTCSwapState", { enumerable: true, get: function () { return SpvFromBTCSwap_1.SpvFromBTCSwapState; } });
|
|
110
|
+
var SpvFromBTCWrapper_1 = require("./swaps/spv_swaps/SpvFromBTCWrapper");
|
|
111
|
+
Object.defineProperty(exports, "SpvFromBTCWrapper", { enumerable: true, get: function () { return SpvFromBTCWrapper_1.SpvFromBTCWrapper; } });
|
|
112
|
+
var LnForGasSwap_1 = require("./swaps/trusted/ln/LnForGasSwap");
|
|
113
|
+
Object.defineProperty(exports, "LnForGasSwap", { enumerable: true, get: function () { return LnForGasSwap_1.LnForGasSwap; } });
|
|
114
|
+
Object.defineProperty(exports, "LnForGasSwapState", { enumerable: true, get: function () { return LnForGasSwap_1.LnForGasSwapState; } });
|
|
115
|
+
var LnForGasWrapper_1 = require("./swaps/trusted/ln/LnForGasWrapper");
|
|
116
|
+
Object.defineProperty(exports, "LnForGasWrapper", { enumerable: true, get: function () { return LnForGasWrapper_1.LnForGasWrapper; } });
|
|
117
|
+
var OnchainForGasSwap_1 = require("./swaps/trusted/onchain/OnchainForGasSwap");
|
|
118
|
+
Object.defineProperty(exports, "OnchainForGasSwap", { enumerable: true, get: function () { return OnchainForGasSwap_1.OnchainForGasSwap; } });
|
|
119
|
+
Object.defineProperty(exports, "OnchainForGasSwapState", { enumerable: true, get: function () { return OnchainForGasSwap_1.OnchainForGasSwapState; } });
|
|
120
|
+
var OnchainForGasWrapper_1 = require("./swaps/trusted/onchain/OnchainForGasWrapper");
|
|
121
|
+
Object.defineProperty(exports, "OnchainForGasWrapper", { enumerable: true, get: function () { return OnchainForGasWrapper_1.OnchainForGasWrapper; } });
|
|
122
|
+
__exportStar(require("./swaps/IAddressSwap"), exports);
|
|
123
|
+
__exportStar(require("./swaps/IBTCWalletSwap"), exports);
|
|
124
|
+
__exportStar(require("./swaps/IClaimableSwap"), exports);
|
|
125
|
+
__exportStar(require("./swaps/IRefundableSwap"), exports);
|
|
126
|
+
__exportStar(require("./swaps/IAddressSwap"), exports);
|
|
127
|
+
var ISwap_1 = require("./swaps/ISwap");
|
|
128
|
+
Object.defineProperty(exports, "ISwap", { enumerable: true, get: function () { return ISwap_1.ISwap; } });
|
|
129
|
+
__exportStar(require("./swaps/ISwapWithGasDrop"), exports);
|
|
130
|
+
var ISwapWrapper_1 = require("./swaps/ISwapWrapper");
|
|
131
|
+
Object.defineProperty(exports, "ISwapWrapper", { enumerable: true, get: function () { return ISwapWrapper_1.ISwapWrapper; } });
|
|
132
|
+
__exportStar(require("./types/fees/Fee"), exports);
|
|
133
|
+
__exportStar(require("./types/fees/FeeBreakdown"), exports);
|
|
134
|
+
__exportStar(require("./types/fees/PercentagePPM"), exports);
|
|
135
|
+
__exportStar(require("./types/lnurl/LNURLPay"), exports);
|
|
136
|
+
__exportStar(require("./types/lnurl/LNURLWithdraw"), exports);
|
|
137
|
+
__exportStar(require("./types/AmountData"), exports);
|
|
138
|
+
__exportStar(require("./types/CustomPriceFunction"), exports);
|
|
139
|
+
__exportStar(require("./types/PriceInfoType"), exports);
|
|
140
|
+
__exportStar(require("./types/SwapExecutionAction"), exports);
|
|
141
|
+
__exportStar(require("./types/SwapWithSigner"), exports);
|
|
142
|
+
__exportStar(require("./types/Token"), exports);
|
|
143
|
+
__exportStar(require("./types/TokenAmount"), exports);
|
|
144
|
+
__exportStar(require("./utils/TokenUtils"), exports);
|
|
145
|
+
__exportStar(require("./utils/SwapUtils"), exports);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { SwapType } from "../enums/SwapType";
|
|
2
|
+
import { SwapHandlerInfoType } from "./IntermediaryDiscovery";
|
|
3
|
+
import { ChainSwapType, SwapContract } from "@atomiqlabs/base";
|
|
4
|
+
import { LNNodeLiquidity } from "../bitcoin/LightningNetworkApi";
|
|
5
|
+
/**
|
|
6
|
+
* Services offered by an intermediary
|
|
7
|
+
* @category Pricing and LPs
|
|
8
|
+
*/
|
|
9
|
+
export type ServicesType = {
|
|
10
|
+
[key in SwapType]?: SwapHandlerInfoType;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Reputation data for an intermediary on a single chain
|
|
14
|
+
* @category Pricing and LPs
|
|
15
|
+
*/
|
|
16
|
+
export type SingleChainReputationType = {
|
|
17
|
+
[token: string]: {
|
|
18
|
+
[key in ChainSwapType]: {
|
|
19
|
+
successVolume: bigint;
|
|
20
|
+
successCount: bigint;
|
|
21
|
+
failVolume: bigint;
|
|
22
|
+
failCount: bigint;
|
|
23
|
+
coopCloseVolume: bigint;
|
|
24
|
+
coopCloseCount: bigint;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Smart chain liquidity data
|
|
30
|
+
* @category Pricing and LPs
|
|
31
|
+
*/
|
|
32
|
+
export type SCLiquidity = {
|
|
33
|
+
[token: string]: bigint;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Represents a liquidity provider/intermediary
|
|
37
|
+
* @category Pricing and LPs
|
|
38
|
+
*/
|
|
39
|
+
export declare class Intermediary {
|
|
40
|
+
readonly url: string;
|
|
41
|
+
readonly addresses: {
|
|
42
|
+
[chainIdentifier: string]: string;
|
|
43
|
+
};
|
|
44
|
+
readonly services: ServicesType;
|
|
45
|
+
readonly swapBounds: {
|
|
46
|
+
[swapType in SwapType]?: {
|
|
47
|
+
[chainIdentifier: string]: {
|
|
48
|
+
[tokenAddress: string]: {
|
|
49
|
+
input: {
|
|
50
|
+
min?: bigint;
|
|
51
|
+
max?: bigint;
|
|
52
|
+
};
|
|
53
|
+
output: {
|
|
54
|
+
min?: bigint;
|
|
55
|
+
max?: bigint;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
reputation: {
|
|
62
|
+
[chainIdentifier: string]: SingleChainReputationType;
|
|
63
|
+
};
|
|
64
|
+
liquidity: {
|
|
65
|
+
[chainIdentifier: string]: SCLiquidity;
|
|
66
|
+
};
|
|
67
|
+
lnData?: LNNodeLiquidity;
|
|
68
|
+
constructor(url: string, addresses: {
|
|
69
|
+
[chainIdentifier: string]: string;
|
|
70
|
+
}, services: ServicesType, reputation?: {
|
|
71
|
+
[chainIdentifier: string]: SingleChainReputationType;
|
|
72
|
+
});
|
|
73
|
+
getSwapLimits(swapType: SwapType, chainId: string, tokenAddress: string): {
|
|
74
|
+
input: {
|
|
75
|
+
min?: bigint;
|
|
76
|
+
max?: bigint;
|
|
77
|
+
};
|
|
78
|
+
output: {
|
|
79
|
+
min?: bigint;
|
|
80
|
+
max?: bigint;
|
|
81
|
+
};
|
|
82
|
+
} | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Returns tokens supported by the intermediary, optionally constrained to the specific swap types
|
|
85
|
+
*
|
|
86
|
+
* @param chainIdentifier
|
|
87
|
+
* @param swapTypesArr
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
private getSupportedTokens;
|
|
91
|
+
/**
|
|
92
|
+
* Fetches, returns and saves the reputation of the intermediary, either for all or just for a single token
|
|
93
|
+
*
|
|
94
|
+
* @param chainIdentifier
|
|
95
|
+
* @param swapContract
|
|
96
|
+
* @param tokens
|
|
97
|
+
* @param abortSignal
|
|
98
|
+
*/
|
|
99
|
+
getReputation(chainIdentifier: string, swapContract: SwapContract<any>, tokens?: string[], abortSignal?: AbortSignal): Promise<SingleChainReputationType>;
|
|
100
|
+
/**
|
|
101
|
+
* Fetches, returns and saves the liquidity of the intermediaryfor a specific token
|
|
102
|
+
*
|
|
103
|
+
* @param chainIdentifier
|
|
104
|
+
* @param swapContract
|
|
105
|
+
* @param token
|
|
106
|
+
* @param abortSignal
|
|
107
|
+
*/
|
|
108
|
+
getLiquidity(chainIdentifier: string, swapContract: SwapContract<any>, token: string, abortSignal?: AbortSignal): Promise<bigint>;
|
|
109
|
+
supportsChain(chainIdentifier: string): boolean;
|
|
110
|
+
getAddress(chainIdentifier: string): string;
|
|
111
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Intermediary = void 0;
|
|
4
|
+
const SwapType_1 = require("../enums/SwapType");
|
|
5
|
+
const RetryUtils_1 = require("../utils/RetryUtils");
|
|
6
|
+
/**
|
|
7
|
+
* Represents a liquidity provider/intermediary
|
|
8
|
+
* @category Pricing and LPs
|
|
9
|
+
*/
|
|
10
|
+
class Intermediary {
|
|
11
|
+
constructor(url, addresses, services, reputation = {}) {
|
|
12
|
+
this.reputation = {};
|
|
13
|
+
this.liquidity = {};
|
|
14
|
+
this.url = url;
|
|
15
|
+
this.addresses = addresses;
|
|
16
|
+
this.services = services;
|
|
17
|
+
this.reputation = reputation;
|
|
18
|
+
this.swapBounds = {};
|
|
19
|
+
for (let _swapType in this.services) {
|
|
20
|
+
const swapType = parseInt(_swapType);
|
|
21
|
+
const serviceInfo = this.services[swapType];
|
|
22
|
+
const btcBounds = { min: BigInt(serviceInfo.min), max: BigInt(serviceInfo.max) };
|
|
23
|
+
const isSend = swapType === SwapType_1.SwapType.TO_BTC || swapType === SwapType_1.SwapType.TO_BTCLN;
|
|
24
|
+
this.swapBounds[swapType] = {};
|
|
25
|
+
for (let chainIdentifier in serviceInfo.chainTokens) {
|
|
26
|
+
this.swapBounds[swapType][chainIdentifier] = {};
|
|
27
|
+
for (let tokenAddress of serviceInfo.chainTokens[chainIdentifier]) {
|
|
28
|
+
this.swapBounds[swapType][chainIdentifier][tokenAddress] = {
|
|
29
|
+
input: isSend ? {} : btcBounds,
|
|
30
|
+
output: !isSend ? {} : btcBounds,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
getSwapLimits(swapType, chainId, tokenAddress) {
|
|
37
|
+
return this.swapBounds[swapType]?.[chainId]?.[tokenAddress];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns tokens supported by the intermediary, optionally constrained to the specific swap types
|
|
41
|
+
*
|
|
42
|
+
* @param chainIdentifier
|
|
43
|
+
* @param swapTypesArr
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
getSupportedTokens(chainIdentifier, swapTypesArr = [
|
|
47
|
+
SwapType_1.SwapType.TO_BTC,
|
|
48
|
+
SwapType_1.SwapType.TO_BTCLN,
|
|
49
|
+
SwapType_1.SwapType.FROM_BTC,
|
|
50
|
+
SwapType_1.SwapType.FROM_BTCLN,
|
|
51
|
+
SwapType_1.SwapType.SPV_VAULT_FROM_BTC,
|
|
52
|
+
SwapType_1.SwapType.FROM_BTCLN_AUTO
|
|
53
|
+
]) {
|
|
54
|
+
const swapTypes = new Set(swapTypesArr);
|
|
55
|
+
let tokens = new Set();
|
|
56
|
+
swapTypes.forEach((swapType) => {
|
|
57
|
+
const supportedTokens = this.services[swapType]?.chainTokens?.[chainIdentifier];
|
|
58
|
+
if (supportedTokens != null)
|
|
59
|
+
supportedTokens.forEach(token => tokens.add(token));
|
|
60
|
+
});
|
|
61
|
+
return tokens;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Fetches, returns and saves the reputation of the intermediary, either for all or just for a single token
|
|
65
|
+
*
|
|
66
|
+
* @param chainIdentifier
|
|
67
|
+
* @param swapContract
|
|
68
|
+
* @param tokens
|
|
69
|
+
* @param abortSignal
|
|
70
|
+
*/
|
|
71
|
+
async getReputation(chainIdentifier, swapContract, tokens, abortSignal) {
|
|
72
|
+
const checkReputationTokens = tokens == null ?
|
|
73
|
+
this.getSupportedTokens(chainIdentifier, [SwapType_1.SwapType.TO_BTC, SwapType_1.SwapType.TO_BTCLN]) :
|
|
74
|
+
new Set(tokens);
|
|
75
|
+
const promises = [];
|
|
76
|
+
const reputation = {};
|
|
77
|
+
for (let token of checkReputationTokens) {
|
|
78
|
+
promises.push((0, RetryUtils_1.tryWithRetries)(() => swapContract.getIntermediaryReputation(this.getAddress(chainIdentifier), token), undefined, undefined, abortSignal).then(result => {
|
|
79
|
+
if (result != null)
|
|
80
|
+
reputation[token] = result;
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
await Promise.all(promises);
|
|
84
|
+
this.reputation ??= {};
|
|
85
|
+
this.reputation[chainIdentifier] ??= {};
|
|
86
|
+
for (let key in reputation) {
|
|
87
|
+
this.reputation[chainIdentifier][key] = reputation[key];
|
|
88
|
+
}
|
|
89
|
+
return reputation;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Fetches, returns and saves the liquidity of the intermediaryfor a specific token
|
|
93
|
+
*
|
|
94
|
+
* @param chainIdentifier
|
|
95
|
+
* @param swapContract
|
|
96
|
+
* @param token
|
|
97
|
+
* @param abortSignal
|
|
98
|
+
*/
|
|
99
|
+
async getLiquidity(chainIdentifier, swapContract, token, abortSignal) {
|
|
100
|
+
const result = await (0, RetryUtils_1.tryWithRetries)(() => swapContract.getBalance(this.getAddress(chainIdentifier), token, true), undefined, undefined, abortSignal);
|
|
101
|
+
this.liquidity ??= {};
|
|
102
|
+
this.liquidity[chainIdentifier] ??= {};
|
|
103
|
+
this.liquidity[chainIdentifier][token] = result;
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
supportsChain(chainIdentifier) {
|
|
107
|
+
if (this.addresses[chainIdentifier] == null)
|
|
108
|
+
return false;
|
|
109
|
+
return this.getSupportedTokens(chainIdentifier).size !== 0;
|
|
110
|
+
}
|
|
111
|
+
getAddress(chainIdentifier) {
|
|
112
|
+
return this.addresses[chainIdentifier];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.Intermediary = Intermediary;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Intermediary } from "./Intermediary";
|
|
3
|
+
import { SwapType } from "../enums/SwapType";
|
|
4
|
+
import { SwapContract } from "@atomiqlabs/base";
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
/**
|
|
7
|
+
* Swap handler type enum for intermediary communication
|
|
8
|
+
* @category Pricing and LPs
|
|
9
|
+
*/
|
|
10
|
+
export declare enum SwapHandlerType {
|
|
11
|
+
TO_BTC = "TO_BTC",
|
|
12
|
+
FROM_BTC = "FROM_BTC",
|
|
13
|
+
TO_BTCLN = "TO_BTCLN",
|
|
14
|
+
FROM_BTCLN = "FROM_BTCLN",
|
|
15
|
+
FROM_BTC_TRUSTED = "FROM_BTC_TRUSTED",
|
|
16
|
+
FROM_BTCLN_TRUSTED = "FROM_BTCLN_TRUSTED",
|
|
17
|
+
FROM_BTC_SPV = "FROM_BTC_SPV",
|
|
18
|
+
FROM_BTCLN_AUTO = "FROM_BTCLN_AUTO"
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Swap handler information type
|
|
22
|
+
* @category Pricing and LPs
|
|
23
|
+
*/
|
|
24
|
+
export type SwapHandlerInfoType = {
|
|
25
|
+
swapFeePPM: number;
|
|
26
|
+
swapBaseFee: number;
|
|
27
|
+
min: number;
|
|
28
|
+
max: number;
|
|
29
|
+
tokens: string[];
|
|
30
|
+
chainTokens?: {
|
|
31
|
+
[chainId: string]: string[];
|
|
32
|
+
};
|
|
33
|
+
data?: any;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Token bounds (min/max) for swaps
|
|
37
|
+
* @category Pricing and LPs
|
|
38
|
+
*/
|
|
39
|
+
export type TokenBounds = {
|
|
40
|
+
[token: string]: {
|
|
41
|
+
min: bigint;
|
|
42
|
+
max: bigint;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Multi-chain token bounds
|
|
47
|
+
* @category Pricing and LPs
|
|
48
|
+
*/
|
|
49
|
+
export type MultichainTokenBounds = {
|
|
50
|
+
[chainId: string]: TokenBounds;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Swap bounds by type
|
|
54
|
+
* @category Pricing and LPs
|
|
55
|
+
*/
|
|
56
|
+
export type SwapBounds = {
|
|
57
|
+
[key in SwapType]?: TokenBounds;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Multi-chain swap bounds
|
|
61
|
+
* @category Pricing and LPs
|
|
62
|
+
*/
|
|
63
|
+
export type MultichainSwapBounds = {
|
|
64
|
+
[key in SwapType]?: MultichainTokenBounds;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Discovery service for available liquidity providers/intermediaries
|
|
68
|
+
* @category Pricing and LPs
|
|
69
|
+
*/
|
|
70
|
+
export declare class IntermediaryDiscovery extends EventEmitter {
|
|
71
|
+
intermediaries: Intermediary[];
|
|
72
|
+
swapContracts: {
|
|
73
|
+
[key: string]: SwapContract;
|
|
74
|
+
};
|
|
75
|
+
registryUrl: string;
|
|
76
|
+
httpRequestTimeout?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Maximum time (in millis) to wait for other LP's responses after the first one was founds
|
|
79
|
+
*/
|
|
80
|
+
maxWaitForOthersTimeout?: number;
|
|
81
|
+
private overrideNodeUrls?;
|
|
82
|
+
constructor(swapContracts: {
|
|
83
|
+
[key: string]: SwapContract;
|
|
84
|
+
}, registryUrl?: string, nodeUrls?: string[], httpRequestTimeout?: number, maxWaitForOthersTimeout?: number);
|
|
85
|
+
/**
|
|
86
|
+
* Fetches the URLs of swap intermediaries from registry or from a pre-defined array of node urls
|
|
87
|
+
*
|
|
88
|
+
* @param abortSignal
|
|
89
|
+
*/
|
|
90
|
+
private getIntermediaryUrls;
|
|
91
|
+
/**
|
|
92
|
+
* Returns data as reported by a specific node (as identified by its URL). This function is specifically made
|
|
93
|
+
* in a way, that in case the abortSignal fires AFTER the LP response was received (and during signature checking),
|
|
94
|
+
* it proceeds with the addresses it was able to verify already. Hence after calling abort, this function is guaranteed
|
|
95
|
+
* to either reject or resolve instantly.
|
|
96
|
+
*
|
|
97
|
+
* @param url
|
|
98
|
+
* @param abortSignal
|
|
99
|
+
*/
|
|
100
|
+
private getNodeInfo;
|
|
101
|
+
/**
|
|
102
|
+
* Inherits abort signal logic from `getNodeInfo()`, check those function docs to better understand
|
|
103
|
+
*
|
|
104
|
+
* @param url
|
|
105
|
+
* @param abortSignal
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
private loadIntermediary;
|
|
109
|
+
/**
|
|
110
|
+
* Returns the intermediary at the provided URL, either from the already fetched list of LPs or fetches the data on-demand
|
|
111
|
+
*
|
|
112
|
+
* @param url
|
|
113
|
+
* @param abortSignal
|
|
114
|
+
*/
|
|
115
|
+
getIntermediary(url: string, abortSignal?: AbortSignal): Promise<Intermediary | null>;
|
|
116
|
+
/**
|
|
117
|
+
* Reloads the saves a list of intermediaries
|
|
118
|
+
* @param abortSignal
|
|
119
|
+
*/
|
|
120
|
+
reloadIntermediaries(abortSignal?: AbortSignal): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Initializes the discovery by fetching/reloading intermediaries
|
|
123
|
+
*
|
|
124
|
+
* @param abortSignal
|
|
125
|
+
*/
|
|
126
|
+
init(abortSignal?: AbortSignal): Promise<void>;
|
|
127
|
+
getMultichainSwapBounds(): MultichainSwapBounds;
|
|
128
|
+
/**
|
|
129
|
+
* Returns aggregate swap bounds (in sats - BTC) as indicated by the intermediaries
|
|
130
|
+
*/
|
|
131
|
+
getSwapBounds(chainIdentifier: string): SwapBounds;
|
|
132
|
+
/**
|
|
133
|
+
* Returns the aggregate swap minimum (in sats - BTC) for a specific swap type & token
|
|
134
|
+
* as indicated by the intermediaries
|
|
135
|
+
*
|
|
136
|
+
* @param chainIdentifier
|
|
137
|
+
* @param swapType
|
|
138
|
+
* @param token
|
|
139
|
+
*/
|
|
140
|
+
getSwapMinimum(chainIdentifier: string, swapType: SwapType, token: any): number | null;
|
|
141
|
+
/**
|
|
142
|
+
* Returns the aggregate swap maximum (in sats - BTC) for a specific swap type & token
|
|
143
|
+
* as indicated by the intermediaries
|
|
144
|
+
*
|
|
145
|
+
* @param chainIdentifier
|
|
146
|
+
* @param swapType
|
|
147
|
+
* @param token
|
|
148
|
+
*/
|
|
149
|
+
getSwapMaximum(chainIdentifier: string, swapType: SwapType, token: any): number | null;
|
|
150
|
+
/**
|
|
151
|
+
* Returns swap candidates for a specific swap type & token address
|
|
152
|
+
*
|
|
153
|
+
* @param chainIdentifier
|
|
154
|
+
* @param swapType
|
|
155
|
+
* @param tokenAddress
|
|
156
|
+
* @param amount Amount to be swapped in sats - BTC
|
|
157
|
+
* @param count How many intermediaries to return at most
|
|
158
|
+
*/
|
|
159
|
+
getSwapCandidates(chainIdentifier: string, swapType: SwapType, tokenAddress: any, amount?: bigint, count?: number): Intermediary[];
|
|
160
|
+
/**
|
|
161
|
+
* Removes a specific intermediary from the list of active intermediaries (used for blacklisting)
|
|
162
|
+
*
|
|
163
|
+
* @param intermediary
|
|
164
|
+
*/
|
|
165
|
+
removeIntermediary(intermediary: Intermediary): boolean;
|
|
166
|
+
}
|