@atomiqlabs/sdk 8.3.1 → 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.
- package/dist/bitcoin/coinselect2/utils.d.ts +6 -0
- package/dist/enums/FeeType.d.ts +1 -1
- package/dist/enums/FeeType.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -2
- package/dist/intermediaries/Intermediary.d.ts +4 -4
- package/dist/intermediaries/Intermediary.js +1 -1
- package/dist/intermediaries/IntermediaryDiscovery.d.ts +7 -7
- package/dist/intermediaries/IntermediaryDiscovery.js +4 -2
- package/dist/prices/RedundantSwapPrice.d.ts +2 -2
- package/dist/prices/RedundantSwapPrice.js +1 -1
- package/dist/prices/SingleSwapPrice.d.ts +1 -1
- package/dist/prices/SingleSwapPrice.js +1 -1
- package/dist/prices/SwapPriceWithChain.d.ts +5 -6
- package/dist/prices/SwapPriceWithChain.js +6 -7
- package/dist/prices/abstract/IPriceProvider.d.ts +4 -4
- package/dist/prices/abstract/IPriceProvider.js +1 -1
- package/dist/prices/abstract/ISwapPrice.d.ts +1 -1
- package/dist/prices/abstract/ISwapPrice.js +1 -1
- package/dist/prices/providers/BinancePriceProvider.d.ts +1 -1
- package/dist/prices/providers/BinancePriceProvider.js +1 -1
- package/dist/prices/providers/CoinGeckoPriceProvider.d.ts +1 -1
- package/dist/prices/providers/CoinGeckoPriceProvider.js +1 -1
- package/dist/prices/providers/CoinPaprikaPriceProvider.d.ts +1 -1
- package/dist/prices/providers/CoinPaprikaPriceProvider.js +1 -1
- package/dist/prices/providers/CustomPriceProvider.d.ts +1 -1
- package/dist/prices/providers/CustomPriceProvider.js +1 -1
- package/dist/prices/providers/KrakenPriceProvider.d.ts +1 -1
- package/dist/prices/providers/KrakenPriceProvider.js +1 -1
- package/dist/prices/providers/OKXPriceProvider.d.ts +1 -1
- package/dist/prices/providers/OKXPriceProvider.js +1 -1
- package/dist/swapper/Swapper.d.ts +80 -7
- package/dist/swapper/Swapper.js +7 -5
- package/dist/swapper/SwapperFactory.d.ts +25 -1
- package/dist/swapper/SwapperFactory.js +1 -1
- package/dist/swaps/IAddressSwap.d.ts +2 -2
- package/dist/swaps/IAddressSwap.js +1 -1
- package/dist/swaps/IBTCWalletSwap.d.ts +2 -2
- package/dist/swaps/IBTCWalletSwap.js +1 -1
- package/dist/swaps/IClaimableSwap.d.ts +3 -3
- package/dist/swaps/IClaimableSwap.js +1 -1
- package/dist/swaps/IClaimableSwapWrapper.d.ts +1 -1
- package/dist/swaps/IRefundableSwap.d.ts +2 -2
- package/dist/swaps/IRefundableSwap.js +1 -1
- package/dist/swaps/ISwap.d.ts +3 -3
- package/dist/swaps/ISwap.js +2 -2
- package/dist/swaps/ISwapWithGasDrop.d.ts +2 -2
- package/dist/swaps/ISwapWithGasDrop.js +1 -1
- package/dist/swaps/ISwapWrapper.d.ts +4 -4
- package/dist/swaps/ISwapWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.d.ts +4 -2
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.js +1 -1
- package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +1 -1
- package/dist/swaps/escrow_swaps/IEscrowSwap.js +1 -1
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.d.ts +9 -5
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.js +5 -4
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +6 -5
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +6 -5
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +4 -3
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +4 -3
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +18 -7
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +18 -7
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +3 -7
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +3 -7
- package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.d.ts +1 -1
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.js +1 -1
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +1 -1
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.d.ts +1 -1
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.js +1 -1
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +1 -1
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +1 -1
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +36 -10
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +36 -10
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +1 -1
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +7 -4
- package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +2 -2
- package/dist/swaps/trusted/ln/LnForGasSwap.js +2 -2
- package/dist/swaps/trusted/ln/LnForGasWrapper.d.ts +1 -1
- package/dist/swaps/trusted/ln/LnForGasWrapper.js +1 -1
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +2 -2
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +2 -2
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +1 -1
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +1 -1
- package/dist/types/CustomPriceFunction.d.ts +1 -1
- package/dist/types/PriceInfoType.d.ts +4 -4
- package/dist/types/PriceInfoType.js +3 -3
- package/dist/types/SwapExecutionAction.d.ts +17 -6
- package/dist/types/SwapWithSigner.d.ts +1 -1
- package/dist/types/fees/Fee.d.ts +1 -1
- package/dist/types/fees/FeeBreakdown.d.ts +1 -1
- package/dist/types/fees/PercentagePPM.d.ts +2 -2
- package/dist/types/fees/PercentagePPM.js +1 -1
- package/dist/types/lnurl/LNURLPay.d.ts +6 -6
- package/dist/types/lnurl/LNURLPay.js +2 -2
- package/dist/types/lnurl/LNURLWithdraw.d.ts +5 -5
- package/dist/types/lnurl/LNURLWithdraw.js +2 -2
- package/dist/types/wallets/LightningInvoiceCreateService.d.ts +4 -0
- package/dist/types/wallets/MinimalLightningNetworkWalletInterface.d.ts +1 -1
- package/dist/utils/SwapUtils.d.ts +2 -0
- package/dist/utils/SwapUtils.js +2 -0
- package/package.json +1 -1
- package/src/bitcoin/coinselect2/utils.ts +6 -0
- package/src/enums/FeeType.ts +1 -1
- package/src/index.ts +6 -0
- package/src/intermediaries/Intermediary.ts +4 -4
- package/src/intermediaries/IntermediaryDiscovery.ts +9 -7
- package/src/prices/RedundantSwapPrice.ts +2 -2
- package/src/prices/SingleSwapPrice.ts +1 -1
- package/src/prices/SwapPriceWithChain.ts +6 -7
- package/src/prices/abstract/IPriceProvider.ts +4 -4
- package/src/prices/abstract/ISwapPrice.ts +1 -1
- package/src/prices/providers/BinancePriceProvider.ts +1 -1
- package/src/prices/providers/CoinGeckoPriceProvider.ts +1 -1
- package/src/prices/providers/CoinPaprikaPriceProvider.ts +1 -1
- package/src/prices/providers/CustomPriceProvider.ts +1 -1
- package/src/prices/providers/KrakenPriceProvider.ts +1 -1
- package/src/prices/providers/OKXPriceProvider.ts +1 -1
- package/src/swapper/Swapper.ts +88 -13
- package/src/swapper/SwapperFactory.ts +29 -3
- package/src/swaps/IAddressSwap.ts +2 -2
- package/src/swaps/IBTCWalletSwap.ts +2 -2
- package/src/swaps/IClaimableSwap.ts +3 -3
- package/src/swaps/IClaimableSwapWrapper.ts +1 -1
- package/src/swaps/IRefundableSwap.ts +2 -2
- package/src/swaps/ISwap.ts +3 -3
- package/src/swaps/ISwapWithGasDrop.ts +2 -2
- package/src/swaps/ISwapWrapper.ts +4 -4
- package/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts +4 -2
- package/src/swaps/escrow_swaps/IEscrowSwap.ts +1 -1
- package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.ts +9 -5
- package/src/swaps/escrow_swaps/frombtc/IFromBTCWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +6 -5
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +4 -3
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +18 -7
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +3 -7
- package/src/swaps/escrow_swaps/tobtc/IToBTCWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.ts +1 -1
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +1 -1
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.ts +1 -1
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +1 -1
- package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +36 -10
- package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +7 -4
- package/src/swaps/trusted/ln/LnForGasSwap.ts +2 -2
- package/src/swaps/trusted/ln/LnForGasWrapper.ts +1 -1
- package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +2 -2
- package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +1 -1
- package/src/types/CustomPriceFunction.ts +1 -1
- package/src/types/PriceInfoType.ts +4 -4
- package/src/types/SwapExecutionAction.ts +19 -6
- package/src/types/SwapWithSigner.ts +1 -1
- package/src/types/fees/Fee.ts +1 -1
- package/src/types/fees/FeeBreakdown.ts +1 -1
- package/src/types/fees/PercentagePPM.ts +2 -2
- package/src/types/lnurl/LNURLPay.ts +6 -6
- package/src/types/lnurl/LNURLWithdraw.ts +5 -5
- package/src/types/wallets/LightningInvoiceCreateService.ts +4 -0
- package/src/types/wallets/MinimalLightningNetworkWalletInterface.ts +1 -1
- package/src/utils/SwapUtils.ts +2 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ISwapPrice } from "../prices/abstract/ISwapPrice";
|
|
3
|
-
import { BitcoinNetwork, BtcRelay, ChainData, ChainType, Messenger, RelaySynchronizer } from "@atomiqlabs/base";
|
|
3
|
+
import { BitcoinNetwork, BitcoinRpcWithAddressIndex, BtcBlock, BtcRelay, ChainData, ChainType, LightningNetworkApi, Messenger, RelaySynchronizer } from "@atomiqlabs/base";
|
|
4
4
|
import { ToBTCLNOptions, ToBTCLNWrapper } from "../swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper";
|
|
5
5
|
import { ToBTCOptions, ToBTCWrapper } from "../swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper";
|
|
6
6
|
import { FromBTCLNOptions, FromBTCLNWrapper } from "../swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper";
|
|
@@ -38,30 +38,100 @@ import { BtcToken, SCToken, Token } from "../types/Token";
|
|
|
38
38
|
import { LNURLWithdraw } from "../types/lnurl/LNURLWithdraw";
|
|
39
39
|
import { LNURLPay } from "../types/lnurl/LNURLPay";
|
|
40
40
|
import { NotNever } from "../utils/TypeUtils";
|
|
41
|
-
import { MempoolBitcoinBlock, MempoolBitcoinRpc } from "@atomiqlabs/btc-mempool";
|
|
42
41
|
import { LightningInvoiceCreateService } from "../types/wallets/LightningInvoiceCreateService";
|
|
43
42
|
/**
|
|
44
43
|
* Configuration options for the Swapper
|
|
45
44
|
* @category Core
|
|
46
45
|
*/
|
|
47
46
|
export type SwapperOptions = {
|
|
47
|
+
/**
|
|
48
|
+
* Manual override for the intermediary (LP) URLs for the SDK to use, by default these are fetched automatically
|
|
49
|
+
* from the registry
|
|
50
|
+
*/
|
|
48
51
|
intermediaryUrl?: string | string[];
|
|
52
|
+
/**
|
|
53
|
+
* Registry URL for where to look for active intermediary (LP) endpoint URLs
|
|
54
|
+
*/
|
|
49
55
|
registryUrl?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Bitcoin network to use for the swaps,
|
|
58
|
+
*/
|
|
50
59
|
bitcoinNetwork?: BitcoinNetwork;
|
|
60
|
+
/**
|
|
61
|
+
* Timeout (in milliseconds) for HTTP GET requests done by the SDK
|
|
62
|
+
*/
|
|
51
63
|
getRequestTimeout?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Timeout (in milliseconds) for HTTP POST requests done by the SDK
|
|
66
|
+
*/
|
|
52
67
|
postRequestTimeout?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Additional parameters to be sent to the intermediaries (LPs), when requesting quotes from them
|
|
70
|
+
*/
|
|
53
71
|
defaultAdditionalParameters?: {
|
|
54
72
|
[key: string]: any;
|
|
55
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Optional name prefix to use when creating a swap storage, you can use this to create separate storage
|
|
76
|
+
* instances that don't overlap.
|
|
77
|
+
*/
|
|
56
78
|
storagePrefix?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Sets the default intermediary (LP) to use for the trusted gas swaps, if not set the SDK uses a default one
|
|
81
|
+
*/
|
|
57
82
|
defaultTrustedIntermediaryUrl?: string;
|
|
58
|
-
|
|
83
|
+
/**
|
|
84
|
+
* A function callback to retrieve a specific named storage container for swap persistency. If not present, the
|
|
85
|
+
* default IndexedDB storage adapter is used. When you use the SDK in non-browser based environments you need to
|
|
86
|
+
* provide this callback such that the SDK is able to use a custom storage adapter.
|
|
87
|
+
*
|
|
88
|
+
* @param storageName Name of the container to retrieve
|
|
89
|
+
*/
|
|
90
|
+
swapStorage?: (storageName: string) => IUnifiedStorage<UnifiedSwapStorageIndexes, UnifiedSwapStorageCompositeIndexes>;
|
|
91
|
+
/**
|
|
92
|
+
* By setting this flag, the swapper doesn't schedule automatic tick timers. To make sure the swap states are
|
|
93
|
+
* properly updated (e.g. the expired swaps properly move to the expired state), you should call the
|
|
94
|
+
* {@link Swapper._syncSwaps} function periodically. This flag should be set when you run an environment that
|
|
95
|
+
* doesn't support long-running timers - e.g. serverless environments like Azure Function Apps or AWS Lambda
|
|
96
|
+
*/
|
|
59
97
|
noTimers?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* By setting this flag, the swapper doesn't subscribe to on-chain events. To make sure the swap states are
|
|
100
|
+
* properly updated you should call the {@link Swapper._syncSwaps} function periodically. This flag should be
|
|
101
|
+
* set when you run an environment that doesn't support long-running timers and websocket connections - e.g.
|
|
102
|
+
* serverless environments like Azure Function Apps or AWS Lambda
|
|
103
|
+
*/
|
|
60
104
|
noEvents?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* By setting this flag, the swap objects will not be cached in the SDK and instead will always be loaded from
|
|
107
|
+
* the persistent storage. By default, the SDK uses a `WeakRef` mapping of swaps, to ensure that when the same
|
|
108
|
+
* swap is loaded concurrently, it returns the same object reference to both, making the changes on the object
|
|
109
|
+
* atomic. This flag should be set to `true` when running in an environment where multiple instances of the SDK
|
|
110
|
+
* access the same swap database - e.g. serverless environments like Azure Function Apps or AWS Lambda
|
|
111
|
+
*/
|
|
61
112
|
noSwapCache?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Skip checking past swaps when the swapper is initiated with {@link Swapper.init}, you can call the
|
|
115
|
+
* {@link Swapper._syncSwaps} function later, to check the swaps. By default, the SDK checks the state
|
|
116
|
+
* of all the known swaps during init.
|
|
117
|
+
*/
|
|
62
118
|
dontCheckPastSwaps?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Skip fetching the LPs when the swapper is initiated with {@link Swapper.init}, this means the list of available
|
|
121
|
+
* tokens and swap limits won't be available immediately. LPs will be fetched automatically later, when a swap
|
|
122
|
+
* is requested
|
|
123
|
+
*/
|
|
63
124
|
dontFetchLPs?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* By setting this flag the SDK persists all created swaps. By default, the SDK only saves and persists swaps that
|
|
127
|
+
* are considered initiated, i.e. when `commit()`, `execute()` or `waitTillPayment` is called (or their respective
|
|
128
|
+
* txs... prefixed variations).
|
|
129
|
+
*/
|
|
64
130
|
saveUninitializedSwaps?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Automatically checks system time on initialize, if the system time drifts too far from the actual time
|
|
133
|
+
* (as checked from multiple server sources) it adjusts the `Date.now()` function to return proper actual time.
|
|
134
|
+
*/
|
|
65
135
|
automaticClockDriftCorrection?: boolean;
|
|
66
136
|
};
|
|
67
137
|
/**
|
|
@@ -86,8 +156,8 @@ type ChainSpecificData<T extends ChainType> = {
|
|
|
86
156
|
swapContract: T["Contract"];
|
|
87
157
|
spvVaultContract: T["SpvVaultContract"];
|
|
88
158
|
chainInterface: T["ChainInterface"];
|
|
89
|
-
btcRelay: BtcRelay<any, T["TX"],
|
|
90
|
-
synchronizer: RelaySynchronizer<any, T["TX"],
|
|
159
|
+
btcRelay: BtcRelay<any, T["TX"], BtcBlock, T["Signer"]>;
|
|
160
|
+
synchronizer: RelaySynchronizer<any, T["TX"], BtcBlock>;
|
|
91
161
|
unifiedChainEvents: UnifiedSwapEventListener<T>;
|
|
92
162
|
unifiedSwapStorage: UnifiedSwapStorage<T>;
|
|
93
163
|
reviver: (val: any) => ISwap<T>;
|
|
@@ -137,7 +207,7 @@ export declare class Swapper<T extends MultiChain> extends EventEmitter<{
|
|
|
137
207
|
* Bitcoin RPC for fetching bitcoin chain data
|
|
138
208
|
* @internal
|
|
139
209
|
*/
|
|
140
|
-
readonly _bitcoinRpc:
|
|
210
|
+
readonly _bitcoinRpc: BitcoinRpcWithAddressIndex<any>;
|
|
141
211
|
/**
|
|
142
212
|
* Bitcoin network specification
|
|
143
213
|
* @internal
|
|
@@ -173,7 +243,10 @@ export declare class Swapper<T extends MultiChain> extends EventEmitter<{
|
|
|
173
243
|
* Miscellaneous utility functions
|
|
174
244
|
*/
|
|
175
245
|
readonly Utils: SwapperUtils<T>;
|
|
176
|
-
|
|
246
|
+
/**
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
constructor(bitcoinRpc: BitcoinRpcWithAddressIndex<any>, lightningApi: LightningNetworkApi, bitcoinSynchronizer: (btcRelay: BtcRelay<any, any, any>) => RelaySynchronizer<any, any, any>, chainsData: CtorMultiChainData<T>, pricing: ISwapPrice<T>, tokens: WrapperCtorTokens<T>, messenger: Messenger, options?: SwapperOptions);
|
|
177
250
|
private _init;
|
|
178
251
|
private initPromise?;
|
|
179
252
|
private initialized;
|
package/dist/swapper/Swapper.js
CHANGED
|
@@ -33,7 +33,6 @@ const Logger_1 = require("../utils/Logger");
|
|
|
33
33
|
const LNURLWithdraw_1 = require("../types/lnurl/LNURLWithdraw");
|
|
34
34
|
const LNURLPay_1 = require("../types/lnurl/LNURLPay");
|
|
35
35
|
const RetryUtils_1 = require("../utils/RetryUtils");
|
|
36
|
-
const btc_mempool_1 = require("@atomiqlabs/btc-mempool");
|
|
37
36
|
const IEscrowSwap_1 = require("../swaps/escrow_swaps/IEscrowSwap");
|
|
38
37
|
const LightningInvoiceCreateService_1 = require("../types/wallets/LightningInvoiceCreateService");
|
|
39
38
|
/**
|
|
@@ -42,7 +41,10 @@ const LightningInvoiceCreateService_1 = require("../types/wallets/LightningInvoi
|
|
|
42
41
|
* @category Core
|
|
43
42
|
*/
|
|
44
43
|
class Swapper extends events_1.EventEmitter {
|
|
45
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
constructor(bitcoinRpc, lightningApi, bitcoinSynchronizer, chainsData, pricing, tokens, messenger, options) {
|
|
46
48
|
super();
|
|
47
49
|
this.logger = (0, Logger_1.getLogger)(this.constructor.name + ": ");
|
|
48
50
|
this.initialized = false;
|
|
@@ -99,7 +101,7 @@ class Swapper extends events_1.EventEmitter {
|
|
|
99
101
|
};
|
|
100
102
|
this._chains = (0, Utils_1.objectMap)(chainsData, (chainData, key) => {
|
|
101
103
|
const { swapContract, chainEvents, btcRelay, chainInterface, spvVaultContract, spvVaultWithdrawalDataConstructor } = chainData;
|
|
102
|
-
const synchronizer =
|
|
104
|
+
const synchronizer = bitcoinSynchronizer(btcRelay);
|
|
103
105
|
const storageHandler = swapStorage(storagePrefix + chainData.chainId);
|
|
104
106
|
const unifiedSwapStorage = new UnifiedSwapStorage_1.UnifiedSwapStorage(storageHandler, this.options.noSwapCache);
|
|
105
107
|
const unifiedChainEvents = new UnifiedSwapEventListener_1.UnifiedSwapEventListener(unifiedSwapStorage, chainEvents);
|
|
@@ -113,7 +115,7 @@ class Swapper extends events_1.EventEmitter {
|
|
|
113
115
|
postRequestTimeout: this.options.postRequestTimeout,
|
|
114
116
|
bitcoinNetwork: this._btcNetwork
|
|
115
117
|
});
|
|
116
|
-
wrappers[SwapType_1.SwapType.FROM_BTCLN] = new FromBTCLNWrapper_1.FromBTCLNWrapper(key, unifiedSwapStorage, unifiedChainEvents, chainInterface, swapContract, pricing, tokens, chainData.swapDataConstructor,
|
|
118
|
+
wrappers[SwapType_1.SwapType.FROM_BTCLN] = new FromBTCLNWrapper_1.FromBTCLNWrapper(key, unifiedSwapStorage, unifiedChainEvents, chainInterface, swapContract, pricing, tokens, chainData.swapDataConstructor, lightningApi, {
|
|
117
119
|
getRequestTimeout: this.options.getRequestTimeout,
|
|
118
120
|
postRequestTimeout: this.options.postRequestTimeout,
|
|
119
121
|
unsafeSkipLnNodeCheck: this.bitcoinNetwork === base_1.BitcoinNetwork.TESTNET4 || this.bitcoinNetwork === base_1.BitcoinNetwork.REGTEST
|
|
@@ -140,7 +142,7 @@ class Swapper extends events_1.EventEmitter {
|
|
|
140
142
|
});
|
|
141
143
|
}
|
|
142
144
|
if (swapContract.supportsInitWithoutClaimer) {
|
|
143
|
-
wrappers[SwapType_1.SwapType.FROM_BTCLN_AUTO] = new FromBTCLNAutoWrapper_1.FromBTCLNAutoWrapper(key, unifiedSwapStorage, unifiedChainEvents, chainInterface, swapContract, pricing, tokens, chainData.swapDataConstructor,
|
|
145
|
+
wrappers[SwapType_1.SwapType.FROM_BTCLN_AUTO] = new FromBTCLNAutoWrapper_1.FromBTCLNAutoWrapper(key, unifiedSwapStorage, unifiedChainEvents, chainInterface, swapContract, pricing, tokens, chainData.swapDataConstructor, lightningApi, this.messenger, {
|
|
144
146
|
getRequestTimeout: this.options.getRequestTimeout,
|
|
145
147
|
postRequestTimeout: this.options.postRequestTimeout,
|
|
146
148
|
unsafeSkipLnNodeCheck: this.bitcoinNetwork === base_1.BitcoinNetwork.TESTNET4 || this.bitcoinNetwork === base_1.BitcoinNetwork.REGTEST
|
|
@@ -38,11 +38,35 @@ type GetAllOptions<T extends readonly ChainInitializer<any, any, any>[]> = (T ex
|
|
|
38
38
|
* @category Core
|
|
39
39
|
*/
|
|
40
40
|
export type TypedSwapperOptions<T extends readonly ChainInitializer<any, any, any>[]> = {
|
|
41
|
+
/**
|
|
42
|
+
* A dictionary with chain-specific settings, like RPC URLs and others
|
|
43
|
+
*/
|
|
41
44
|
chains: GetAllOptions<T>;
|
|
42
|
-
|
|
45
|
+
/**
|
|
46
|
+
* A function callback to retrieve a specific named storage container for key-value persistency. If not present, the
|
|
47
|
+
* default browser Local Storage adapter is used. When you use the SDK in non-browser based environments you need
|
|
48
|
+
* to provide this callback such that the SDK is able to use a custom storage adapter.
|
|
49
|
+
*
|
|
50
|
+
* @param storageName Name of the container to retrieve
|
|
51
|
+
*/
|
|
52
|
+
chainStorageCtor?: <T extends StorageObject>(storageName: string) => IStorageManager<T>;
|
|
53
|
+
/**
|
|
54
|
+
* Maximum allowed pricing difference between intermediary (LP) returned rate and current market rate. In
|
|
55
|
+
* parts-per-million, e.g. 2% is written as `20000`.
|
|
56
|
+
*/
|
|
43
57
|
pricingFeeDifferencePPM?: bigint;
|
|
58
|
+
/**
|
|
59
|
+
* Optional pricing function to use instead of default pricing APIs. See {@link CustomPriceFunction} for details.
|
|
60
|
+
*/
|
|
44
61
|
getPriceFn?: CustomPriceFunction;
|
|
62
|
+
/**
|
|
63
|
+
* Mempool API instance or URLs to use, if not provided the defaults will be used for the specified bitcoin network
|
|
64
|
+
*/
|
|
45
65
|
mempoolApi?: MempoolApi | MempoolBitcoinRpc | string | string[];
|
|
66
|
+
/**
|
|
67
|
+
* Data propagation messenger instance to use for broadcasting data to watchtowers. By default, a Nostr-based
|
|
68
|
+
* messenger is used.
|
|
69
|
+
*/
|
|
46
70
|
messenger?: Messenger;
|
|
47
71
|
} & SwapperOptions;
|
|
48
72
|
/**
|
|
@@ -140,7 +140,7 @@ class SwapperFactory {
|
|
|
140
140
|
};
|
|
141
141
|
}), options.getPriceFn)) :
|
|
142
142
|
RedundantSwapPrice_1.RedundantSwapPrice.createFromTokenMap(options.pricingFeeDifferencePPM ?? 10000n, pricingAssets);
|
|
143
|
-
return new Swapper_1.Swapper(bitcoinRpc, chains, swapPricing, pricingAssets, options.messenger, options);
|
|
143
|
+
return new Swapper_1.Swapper(bitcoinRpc, bitcoinRpc, (btcRelay) => new btc_mempool_1.MempoolBtcRelaySynchronizer(btcRelay, bitcoinRpc), chains, swapPricing, pricingAssets, options.messenger, options);
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* Returns a new and already initialized swapper instance with the passed options. There is no need
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type guard to check if an object is an {@link IAddressSwap}
|
|
3
3
|
*
|
|
4
|
-
* @category Swaps
|
|
4
|
+
* @category Swaps/Types
|
|
5
5
|
*/
|
|
6
6
|
export declare function isIAddressSwap(obj: any): obj is IAddressSwap;
|
|
7
7
|
/**
|
|
8
8
|
* Interface for swaps which require a user to send funds to a specific address
|
|
9
9
|
*
|
|
10
|
-
* @category Swaps
|
|
10
|
+
* @category Swaps/Types
|
|
11
11
|
*/
|
|
12
12
|
export interface IAddressSwap {
|
|
13
13
|
/**
|
|
@@ -6,13 +6,13 @@ import { BtcToken } from "../types/Token";
|
|
|
6
6
|
/**
|
|
7
7
|
* Type guard to check if an object is an {@link IBTCWalletSwap}
|
|
8
8
|
*
|
|
9
|
-
* @category Swaps
|
|
9
|
+
* @category Swaps/Types
|
|
10
10
|
*/
|
|
11
11
|
export declare function isIBTCWalletSwap(obj: any): obj is IBTCWalletSwap;
|
|
12
12
|
/**
|
|
13
13
|
* Interface for swaps requiring Bitcoin wallet interaction
|
|
14
14
|
*
|
|
15
|
-
* @category Swaps
|
|
15
|
+
* @category Swaps/Types
|
|
16
16
|
*/
|
|
17
17
|
export interface IBTCWalletSwap {
|
|
18
18
|
/**
|
|
@@ -4,14 +4,14 @@ import { ISwapWrapper, SwapTypeDefinition } from "./ISwapWrapper";
|
|
|
4
4
|
/**
|
|
5
5
|
* Type guard to check if an object is an {@link IClaimableSwap}
|
|
6
6
|
*
|
|
7
|
-
* @category Swaps
|
|
7
|
+
* @category Swaps/Types
|
|
8
8
|
*/
|
|
9
9
|
export declare function isIClaimableSwap(obj: any): obj is IClaimableSwap;
|
|
10
10
|
/**
|
|
11
11
|
* Interface for swaps that can end up in a claimable state, requiring the user to claim the
|
|
12
12
|
* assets on the destination chain.
|
|
13
13
|
*
|
|
14
|
-
* @category Swaps
|
|
14
|
+
* @category Swaps/Types
|
|
15
15
|
*/
|
|
16
16
|
export interface IClaimableSwap<T extends ChainType = ChainType, D extends SwapTypeDefinition<T, ISwapWrapper<T, D>, IClaimableSwap<T, D, S>> = SwapTypeDefinition<T, ISwapWrapper<T, any>, IClaimableSwap<T, any, any>>, S extends number = number> extends ISwap<T, D, S> {
|
|
17
17
|
/**
|
|
@@ -24,7 +24,7 @@ export interface IClaimableSwap<T extends ChainType = ChainType, D extends SwapT
|
|
|
24
24
|
* function to wait till the claim transaction is observed, processed by the SDK and state of the swap
|
|
25
25
|
* properly updated.
|
|
26
26
|
*
|
|
27
|
-
* @param _signer Address of the signer to create the
|
|
27
|
+
* @param _signer Address of the signer to create the settlement (claim) transactions for
|
|
28
28
|
*/
|
|
29
29
|
txsClaim(_signer?: string | T["Signer"] | T["NativeSigner"]): Promise<T["TX"][]>;
|
|
30
30
|
/**
|
|
@@ -4,7 +4,7 @@ import { IClaimableSwap } from "./IClaimableSwap";
|
|
|
4
4
|
* Interface for a swap wrapper for swaps that can end up in a claimable state, requiring the user to claim the
|
|
5
5
|
* assets on the destination chain.
|
|
6
6
|
*
|
|
7
|
-
* @category Swaps
|
|
7
|
+
* @category Swaps/Abstract
|
|
8
8
|
*/
|
|
9
9
|
export interface IClaimableSwapWrapper<T extends ISwap & IClaimableSwap = ISwap & IClaimableSwap> {
|
|
10
10
|
/**
|
|
@@ -4,13 +4,13 @@ import { ISwapWrapper, SwapTypeDefinition } from "./ISwapWrapper";
|
|
|
4
4
|
/**
|
|
5
5
|
* Type guard to check if an object is an {@link IRefundableSwap}
|
|
6
6
|
*
|
|
7
|
-
* @category Swaps
|
|
7
|
+
* @category Swaps/Types
|
|
8
8
|
*/
|
|
9
9
|
export declare function isIRefundableSwap(obj: any): obj is IRefundableSwap;
|
|
10
10
|
/**
|
|
11
11
|
* Interface for swaps that can be refunded in case of failure
|
|
12
12
|
*
|
|
13
|
-
* @category Swaps
|
|
13
|
+
* @category Swaps/Types
|
|
14
14
|
*/
|
|
15
15
|
export interface IRefundableSwap<T extends ChainType = ChainType, D extends SwapTypeDefinition<T, ISwapWrapper<T, D>, IRefundableSwap<T, D, S>> = SwapTypeDefinition<T, ISwapWrapper<T, any>, IRefundableSwap<T, any, any>>, S extends number = number> extends ISwap<T, D, S> {
|
|
16
16
|
/**
|
package/dist/swaps/ISwap.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { PriceInfoType } from "../types/PriceInfoType";
|
|
|
15
15
|
/**
|
|
16
16
|
* Initialization data for creating a swap
|
|
17
17
|
*
|
|
18
|
-
* @category Swaps
|
|
18
|
+
* @category Swaps/Base
|
|
19
19
|
*/
|
|
20
20
|
export type ISwapInit = {
|
|
21
21
|
pricingInfo: PriceInfoType;
|
|
@@ -28,13 +28,13 @@ export type ISwapInit = {
|
|
|
28
28
|
/**
|
|
29
29
|
* Type guard to check if an object is an ISwapInit
|
|
30
30
|
*
|
|
31
|
-
* @category Swaps
|
|
31
|
+
* @category Swaps/Base
|
|
32
32
|
*/
|
|
33
33
|
export declare function isISwapInit(obj: any): obj is ISwapInit;
|
|
34
34
|
/**
|
|
35
35
|
* Base abstract class for all swap types
|
|
36
36
|
*
|
|
37
|
-
* @category Swaps
|
|
37
|
+
* @category Swaps/Base
|
|
38
38
|
*/
|
|
39
39
|
export declare abstract class ISwap<T extends ChainType = ChainType, D extends SwapTypeDefinition<T, ISwapWrapper<T, D>, ISwap<T, D, S>> = SwapTypeDefinition<T, ISwapWrapper<T, any>, ISwap<T, any, any>>, S extends number = number> {
|
|
40
40
|
/**
|
package/dist/swaps/ISwap.js
CHANGED
|
@@ -11,7 +11,7 @@ const PriceInfoType_1 = require("../types/PriceInfoType");
|
|
|
11
11
|
/**
|
|
12
12
|
* Type guard to check if an object is an ISwapInit
|
|
13
13
|
*
|
|
14
|
-
* @category Swaps
|
|
14
|
+
* @category Swaps/Base
|
|
15
15
|
*/
|
|
16
16
|
function isISwapInit(obj) {
|
|
17
17
|
return typeof obj === 'object' &&
|
|
@@ -27,7 +27,7 @@ exports.isISwapInit = isISwapInit;
|
|
|
27
27
|
/**
|
|
28
28
|
* Base abstract class for all swap types
|
|
29
29
|
*
|
|
30
|
-
* @category Swaps
|
|
30
|
+
* @category Swaps/Base
|
|
31
31
|
*/
|
|
32
32
|
class ISwap {
|
|
33
33
|
constructor(wrapper, swapInitOrObj) {
|
|
@@ -4,13 +4,13 @@ import { SCToken } from "../types/Token";
|
|
|
4
4
|
/**
|
|
5
5
|
* Type guard to check if a swap has gas drop functionality
|
|
6
6
|
*
|
|
7
|
-
* @category Swaps
|
|
7
|
+
* @category Swaps/Types
|
|
8
8
|
*/
|
|
9
9
|
export declare function isSwapWithGasDrop(swap: any): swap is ISwapWithGasDrop<any>;
|
|
10
10
|
/**
|
|
11
11
|
* Interface for swaps with gas drop functionality
|
|
12
12
|
*
|
|
13
|
-
* @category Swaps
|
|
13
|
+
* @category Swaps/Types
|
|
14
14
|
*/
|
|
15
15
|
export interface ISwapWithGasDrop<T extends ChainType> {
|
|
16
16
|
/**
|
|
@@ -4,7 +4,7 @@ exports.isSwapWithGasDrop = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Type guard to check if a swap has gas drop functionality
|
|
6
6
|
*
|
|
7
|
-
* @category Swaps
|
|
7
|
+
* @category Swaps/Types
|
|
8
8
|
*/
|
|
9
9
|
function isSwapWithGasDrop(swap) {
|
|
10
10
|
return swap != null && typeof (swap.getGasDropOutput) === "function";
|
|
@@ -13,7 +13,7 @@ import { PriceInfoType } from "../types/PriceInfoType";
|
|
|
13
13
|
/**
|
|
14
14
|
* Options for swap wrapper configuration
|
|
15
15
|
*
|
|
16
|
-
* @category Swaps
|
|
16
|
+
* @category Swaps/Base
|
|
17
17
|
*/
|
|
18
18
|
export type ISwapWrapperOptions = {
|
|
19
19
|
getRequestTimeout?: number;
|
|
@@ -22,7 +22,7 @@ export type ISwapWrapperOptions = {
|
|
|
22
22
|
/**
|
|
23
23
|
* Token configuration for wrapper constructors
|
|
24
24
|
*
|
|
25
|
-
* @category Swaps
|
|
25
|
+
* @category Swaps/Base
|
|
26
26
|
*/
|
|
27
27
|
export type WrapperCtorTokens<T extends MultiChain = MultiChain> = {
|
|
28
28
|
ticker: string;
|
|
@@ -38,7 +38,7 @@ export type WrapperCtorTokens<T extends MultiChain = MultiChain> = {
|
|
|
38
38
|
/**
|
|
39
39
|
* Type definition linking wrapper and swap types
|
|
40
40
|
*
|
|
41
|
-
* @category Swaps
|
|
41
|
+
* @category Swaps/Base
|
|
42
42
|
*/
|
|
43
43
|
export type SwapTypeDefinition<T extends ChainType, W extends ISwapWrapper<T, any>, S extends ISwap<T>> = {
|
|
44
44
|
Wrapper: W;
|
|
@@ -47,7 +47,7 @@ export type SwapTypeDefinition<T extends ChainType, W extends ISwapWrapper<T, an
|
|
|
47
47
|
/**
|
|
48
48
|
* Base abstract class for swap handler implementations
|
|
49
49
|
*
|
|
50
|
-
* @category Swaps
|
|
50
|
+
* @category Swaps/Base
|
|
51
51
|
*/
|
|
52
52
|
export declare abstract class ISwapWrapper<T extends ChainType, D extends SwapTypeDefinition<T, ISwapWrapper<T, D>, ISwap<T, D>>, O extends ISwapWrapperOptions = ISwapWrapperOptions> {
|
|
53
53
|
/**
|
|
@@ -7,7 +7,7 @@ const Logger_1 = require("../utils/Logger");
|
|
|
7
7
|
/**
|
|
8
8
|
* Base abstract class for swap handler implementations
|
|
9
9
|
*
|
|
10
|
-
* @category Swaps
|
|
10
|
+
* @category Swaps/Base
|
|
11
11
|
*/
|
|
12
12
|
class ISwapWrapper {
|
|
13
13
|
constructor(chainIdentifier, unifiedStorage, unifiedChainEvents, chain, prices, tokens, options, events) {
|
|
@@ -14,7 +14,7 @@ export type IEscrowSelfInitSwapDefinition<T extends ChainType, W extends IEscrow
|
|
|
14
14
|
* Base class for escrow-based swaps (i.e. swaps utilizing PrTLC and HTLC primitives) where the
|
|
15
15
|
* user needs to initiate the escrow on the smart chain side
|
|
16
16
|
*
|
|
17
|
-
* @category Swaps
|
|
17
|
+
* @category Swaps/Abstract
|
|
18
18
|
*/
|
|
19
19
|
export declare abstract class IEscrowSelfInitSwap<T extends ChainType = ChainType, D extends IEscrowSelfInitSwapDefinition<T, IEscrowSwapWrapper<T, D>, IEscrowSelfInitSwap<T, D, S>> = IEscrowSwapDefinition<T, IEscrowSwapWrapper<T, any>, IEscrowSelfInitSwap<T, any, any>>, S extends number = number> extends IEscrowSwap<T, D, S> {
|
|
20
20
|
/**
|
|
@@ -57,7 +57,9 @@ export declare abstract class IEscrowSelfInitSwap<T extends ChainType = ChainTyp
|
|
|
57
57
|
required: TokenAmount<T["ChainId"], SCToken<T["ChainId"]>, true>;
|
|
58
58
|
}>;
|
|
59
59
|
/**
|
|
60
|
-
* Returns transactions for initiating (committing) the escrow on the smart chain side
|
|
60
|
+
* Returns transactions for initiating (committing) the escrow on the smart chain side. After sending the
|
|
61
|
+
* transactions manually be sure to call the {@link waitTillCommited} function to wait till the initiation
|
|
62
|
+
* transaction is observed, processed by the SDK and state of the swap properly updated.
|
|
61
63
|
*
|
|
62
64
|
* @param skipChecks Skip checks like making sure init signature is still valid and swap wasn't commited yet
|
|
63
65
|
* (this is handled on swap creation, if you commit right after quoting, you can use `skipChecks=true`)
|
|
@@ -19,7 +19,7 @@ exports.isIEscrowSelfInitSwapInit = isIEscrowSelfInitSwapInit;
|
|
|
19
19
|
* Base class for escrow-based swaps (i.e. swaps utilizing PrTLC and HTLC primitives) where the
|
|
20
20
|
* user needs to initiate the escrow on the smart chain side
|
|
21
21
|
*
|
|
22
|
-
* @category Swaps
|
|
22
|
+
* @category Swaps/Abstract
|
|
23
23
|
*/
|
|
24
24
|
class IEscrowSelfInitSwap extends IEscrowSwap_1.IEscrowSwap {
|
|
25
25
|
constructor(wrapper, swapInitOrObj) {
|
|
@@ -11,7 +11,7 @@ export declare function isIEscrowSwapInit<T extends SwapData>(obj: any): obj is
|
|
|
11
11
|
/**
|
|
12
12
|
* Base class for escrow-based swaps (i.e. swaps utilizing PrTLC and HTLC primitives)
|
|
13
13
|
*
|
|
14
|
-
* @category Swaps
|
|
14
|
+
* @category Swaps/Abstract
|
|
15
15
|
*/
|
|
16
16
|
export declare abstract class IEscrowSwap<T extends ChainType = ChainType, D extends IEscrowSwapDefinition<T, IEscrowSwapWrapper<T, D>, IEscrowSwap<T, D, S>> = IEscrowSwapDefinition<T, IEscrowSwapWrapper<T, any>, IEscrowSwap<T, any, any>>, S extends number = number> extends ISwap<T, D, S> {
|
|
17
17
|
/**
|
|
@@ -14,7 +14,7 @@ exports.isIEscrowSwapInit = isIEscrowSwapInit;
|
|
|
14
14
|
/**
|
|
15
15
|
* Base class for escrow-based swaps (i.e. swaps utilizing PrTLC and HTLC primitives)
|
|
16
16
|
*
|
|
17
|
-
* @category Swaps
|
|
17
|
+
* @category Swaps/Abstract
|
|
18
18
|
*/
|
|
19
19
|
class IEscrowSwap extends ISwap_1.ISwap {
|
|
20
20
|
constructor(wrapper, swapInitOrObj) {
|
|
@@ -13,7 +13,7 @@ export type IEscrowSwapDefinition<T extends ChainType, W extends IEscrowSwapWrap
|
|
|
13
13
|
/**
|
|
14
14
|
* Base class for wrappers of escrow-based swaps (i.e. swaps utilizing PrTLC and HTLC primitives)
|
|
15
15
|
*
|
|
16
|
-
* @category Swaps
|
|
16
|
+
* @category Swaps/Abstract
|
|
17
17
|
*/
|
|
18
18
|
export declare abstract class IEscrowSwapWrapper<T extends ChainType, D extends IEscrowSwapDefinition<T, IEscrowSwapWrapper<T, D>, IEscrowSwap<T, D>>, O extends ISwapWrapperOptions = ISwapWrapperOptions> extends ISwapWrapper<T, D, O> {
|
|
19
19
|
readonly abstract TYPE: SwapType;
|
|
@@ -6,7 +6,7 @@ const base_1 = require("@atomiqlabs/base");
|
|
|
6
6
|
/**
|
|
7
7
|
* Base class for wrappers of escrow-based swaps (i.e. swaps utilizing PrTLC and HTLC primitives)
|
|
8
8
|
*
|
|
9
|
-
* @category Swaps
|
|
9
|
+
* @category Swaps/Abstract
|
|
10
10
|
*/
|
|
11
11
|
class IEscrowSwapWrapper extends ISwapWrapper_1.ISwapWrapper {
|
|
12
12
|
constructor(chainIdentifier, unifiedStorage, unifiedChainEvents, chain, contract, prices, tokens, swapDataDeserializer, options, events) {
|
|
@@ -17,7 +17,7 @@ export type IFromBTCLNDefinition<T extends ChainType, W extends IFromBTCLNWrappe
|
|
|
17
17
|
/**
|
|
18
18
|
* Base class for wrappers of escrow-based Lightning -> Smart chain swaps
|
|
19
19
|
*
|
|
20
|
-
* @category Swaps
|
|
20
|
+
* @category Swaps/Abstract
|
|
21
21
|
*/
|
|
22
22
|
export declare abstract class IFromBTCLNWrapper<T extends ChainType, D extends IFromBTCLNDefinition<T, IFromBTCLNWrapper<T, D>, IEscrowSwap<T, D>>, O extends ISwapWrapperOptions = ISwapWrapperOptions> extends IFromBTCWrapper<T, D, O> {
|
|
23
23
|
/**
|
|
@@ -11,7 +11,7 @@ const sha256_1 = require("@noble/hashes/sha256");
|
|
|
11
11
|
/**
|
|
12
12
|
* Base class for wrappers of escrow-based Lightning -> Smart chain swaps
|
|
13
13
|
*
|
|
14
|
-
* @category Swaps
|
|
14
|
+
* @category Swaps/Abstract
|
|
15
15
|
*/
|
|
16
16
|
class IFromBTCLNWrapper extends IFromBTCWrapper_1.IFromBTCWrapper {
|
|
17
17
|
/**
|
|
@@ -12,7 +12,7 @@ export type IFromBTCSelfInitDefinition<T extends ChainType, W extends IFromBTCWr
|
|
|
12
12
|
* Base class for legacy escrow-based Bitcoin (on-chain & lightning) -> Smart chain swaps,
|
|
13
13
|
* which require the user to manually initiate the escrow on the destination smart chain
|
|
14
14
|
*
|
|
15
|
-
* @category Swaps
|
|
15
|
+
* @category Swaps/Abstract
|
|
16
16
|
*/
|
|
17
17
|
export declare abstract class IFromBTCSelfInitSwap<T extends ChainType = ChainType, D extends IFromBTCSelfInitDefinition<T, IFromBTCWrapper<T, D>, IFromBTCSelfInitSwap<T, D, S>> = IFromBTCSelfInitDefinition<T, IFromBTCWrapper<T, any>, IFromBTCSelfInitSwap<T, any, any>>, S extends number = number> extends IEscrowSelfInitSwap<T, D, S> implements IAddressSwap, IClaimableSwap<T, D, S> {
|
|
18
18
|
/**
|
|
@@ -121,10 +121,11 @@ export declare abstract class IFromBTCSelfInitSwap<T extends ChainType = ChainTy
|
|
|
121
121
|
*/
|
|
122
122
|
getTotalDeposit(): TokenAmount<T["ChainId"], SCToken<T["ChainId"]>, true>;
|
|
123
123
|
/**
|
|
124
|
-
*
|
|
125
|
-
* into an escrow.
|
|
124
|
+
* Returns transactions for initiating (committing) the escrow on the destination smart chain side, pre-locking the
|
|
125
|
+
* tokens from the intermediary (LP) into an escrow.
|
|
126
126
|
*
|
|
127
|
-
* @
|
|
127
|
+
* @param skipChecks Skip checks like making sure init signature is still valid and swap wasn't commited
|
|
128
|
+
* yet (this is handled on swap creation, if you commit right after quoting, you can use skipChecks=true)
|
|
128
129
|
*
|
|
129
130
|
* @throws {Error} When in invalid state to commit the swap
|
|
130
131
|
*/
|
|
@@ -133,7 +134,10 @@ export declare abstract class IFromBTCSelfInitSwap<T extends ChainType = ChainTy
|
|
|
133
134
|
* Creates the escrow on the destination smart chain side, pre-locking the tokens from the intermediary (LP)
|
|
134
135
|
* into an escrow.
|
|
135
136
|
*
|
|
136
|
-
* @
|
|
137
|
+
* @param signer Signer to sign the transactions with, must be the same as used in the initialization
|
|
138
|
+
* @param abortSignal Abort signal
|
|
139
|
+
* @param skipChecks Skip checks like making sure init signature is still valid and swap wasn't commited
|
|
140
|
+
* yet (this is handled on swap creation, if you commit right after quoting, you can use skipChecks=true)
|
|
137
141
|
*
|
|
138
142
|
* @throws {Error} If invalid signer is provided that doesn't match the swap data
|
|
139
143
|
*/
|
|
@@ -10,7 +10,7 @@ const TokenAmount_1 = require("../../../types/TokenAmount");
|
|
|
10
10
|
* Base class for legacy escrow-based Bitcoin (on-chain & lightning) -> Smart chain swaps,
|
|
11
11
|
* which require the user to manually initiate the escrow on the destination smart chain
|
|
12
12
|
*
|
|
13
|
-
* @category Swaps
|
|
13
|
+
* @category Swaps/Abstract
|
|
14
14
|
*/
|
|
15
15
|
class IFromBTCSelfInitSwap extends IEscrowSelfInitSwap_1.IEscrowSelfInitSwap {
|
|
16
16
|
constructor(wrapper, initOrObj) {
|
|
@@ -157,10 +157,11 @@ class IFromBTCSelfInitSwap extends IEscrowSelfInitSwap_1.IEscrowSelfInitSwap {
|
|
|
157
157
|
//////////////////////////////
|
|
158
158
|
//// Commit
|
|
159
159
|
/**
|
|
160
|
-
*
|
|
161
|
-
* into an escrow.
|
|
160
|
+
* Returns transactions for initiating (committing) the escrow on the destination smart chain side, pre-locking the
|
|
161
|
+
* tokens from the intermediary (LP) into an escrow.
|
|
162
162
|
*
|
|
163
|
-
* @
|
|
163
|
+
* @param skipChecks Skip checks like making sure init signature is still valid and swap wasn't commited
|
|
164
|
+
* yet (this is handled on swap creation, if you commit right after quoting, you can use skipChecks=true)
|
|
164
165
|
*
|
|
165
166
|
* @throws {Error} When in invalid state to commit the swap
|
|
166
167
|
*/
|