@atomiqlabs/sdk 8.1.7 → 8.3.1
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/wallet/BitcoinWallet.d.ts +41 -5
- package/dist/bitcoin/wallet/BitcoinWallet.js +36 -1
- package/dist/bitcoin/wallet/IBitcoinWallet.d.ts +52 -2
- package/dist/bitcoin/wallet/IBitcoinWallet.js +2 -1
- package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.d.ts +42 -7
- package/dist/bitcoin/wallet/SingleAddressBitcoinWallet.js +36 -1
- package/dist/enums/FeeType.d.ts +7 -0
- package/dist/enums/FeeType.js +7 -0
- package/dist/enums/SwapAmountType.d.ts +7 -0
- package/dist/enums/SwapAmountType.js +7 -0
- package/dist/enums/SwapDirection.d.ts +7 -0
- package/dist/enums/SwapDirection.js +7 -0
- package/dist/enums/SwapType.d.ts +62 -1
- package/dist/enums/SwapType.js +62 -1
- package/dist/errors/IntermediaryError.d.ts +4 -0
- package/dist/errors/IntermediaryError.js +1 -0
- package/dist/errors/RequestError.d.ts +15 -1
- package/dist/errors/RequestError.js +8 -0
- package/dist/errors/UserError.d.ts +1 -0
- package/dist/errors/UserError.js +1 -0
- package/dist/index.d.ts +4 -5
- package/dist/index.js +3 -4
- package/dist/intermediaries/Intermediary.d.ts +57 -10
- package/dist/intermediaries/Intermediary.js +37 -10
- package/dist/intermediaries/IntermediaryDiscovery.d.ts +55 -22
- package/dist/intermediaries/IntermediaryDiscovery.js +35 -22
- package/dist/prices/RedundantSwapPrice.d.ts +24 -3
- package/dist/prices/RedundantSwapPrice.js +21 -1
- package/dist/prices/SingleSwapPrice.d.ts +9 -6
- package/dist/prices/SingleSwapPrice.js +10 -7
- package/dist/prices/SwapPriceWithChain.d.ts +54 -16
- package/dist/prices/SwapPriceWithChain.js +58 -20
- package/dist/prices/abstract/ISwapPrice.d.ts +94 -45
- package/dist/prices/abstract/ISwapPrice.js +103 -55
- package/dist/prices/providers/BinancePriceProvider.d.ts +7 -0
- package/dist/prices/providers/BinancePriceProvider.js +7 -0
- package/dist/prices/providers/CoinGeckoPriceProvider.d.ts +6 -0
- package/dist/prices/providers/CoinGeckoPriceProvider.js +6 -0
- package/dist/prices/providers/CoinPaprikaPriceProvider.d.ts +6 -0
- package/dist/prices/providers/CoinPaprikaPriceProvider.js +6 -0
- package/dist/prices/providers/CustomPriceProvider.d.ts +11 -0
- package/dist/prices/providers/CustomPriceProvider.js +11 -0
- package/dist/prices/providers/KrakenPriceProvider.d.ts +9 -0
- package/dist/prices/providers/KrakenPriceProvider.js +9 -0
- package/dist/prices/providers/OKXPriceProvider.d.ts +6 -0
- package/dist/prices/providers/OKXPriceProvider.js +6 -0
- package/dist/prices/providers/abstract/ExchangePriceProvider.d.ts +3 -0
- package/dist/prices/providers/abstract/ExchangePriceProvider.js +3 -0
- package/dist/storage/IUnifiedStorage.d.ts +19 -7
- package/dist/storage/UnifiedSwapStorage.d.ts +33 -3
- package/dist/storage/UnifiedSwapStorage.js +29 -1
- package/dist/storage-browser/IndexedDBUnifiedStorage.d.ts +31 -7
- package/dist/storage-browser/IndexedDBUnifiedStorage.js +29 -6
- package/dist/storage-browser/LocalStorageManager.d.ts +25 -1
- package/dist/storage-browser/LocalStorageManager.js +25 -1
- package/dist/swapper/Swapper.d.ts +303 -222
- package/dist/swapper/Swapper.js +376 -344
- package/dist/swapper/SwapperFactory.d.ts +41 -17
- package/dist/swapper/SwapperFactory.js +23 -2
- package/dist/swapper/SwapperUtils.d.ts +75 -28
- package/dist/swapper/SwapperUtils.js +107 -60
- package/dist/swapper/SwapperWithChain.d.ts +286 -91
- package/dist/swapper/SwapperWithChain.js +218 -64
- package/dist/swapper/SwapperWithSigner.d.ts +229 -80
- package/dist/swapper/SwapperWithSigner.js +190 -44
- package/dist/swaps/IAddressSwap.d.ts +10 -1
- package/dist/swaps/IAddressSwap.js +2 -1
- package/dist/swaps/IBTCWalletSwap.d.ts +24 -6
- package/dist/swaps/IBTCWalletSwap.js +2 -1
- package/dist/swaps/IClaimableSwap.d.ts +36 -4
- package/dist/swaps/IClaimableSwap.js +2 -1
- package/dist/swaps/IClaimableSwapWrapper.d.ts +11 -1
- package/dist/swaps/IRefundableSwap.d.ts +29 -3
- package/dist/swaps/IRefundableSwap.js +2 -1
- package/dist/swaps/ISwap.d.ts +159 -21
- package/dist/swaps/ISwap.js +90 -33
- package/dist/swaps/ISwapWithGasDrop.d.ts +6 -0
- package/dist/swaps/ISwapWithGasDrop.js +1 -0
- package/dist/swaps/ISwapWrapper.d.ts +157 -48
- package/dist/swaps/ISwapWrapper.js +130 -72
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.d.ts +49 -6
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.js +22 -12
- package/dist/swaps/escrow_swaps/IEscrowSwap.d.ts +65 -12
- package/dist/swaps/escrow_swaps/IEscrowSwap.js +38 -19
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.d.ts +39 -9
- package/dist/swaps/escrow_swaps/IEscrowSwapWrapper.js +30 -21
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.d.ts +31 -15
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.js +33 -18
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.d.ts +94 -29
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.js +90 -27
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.d.ts +22 -9
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCWrapper.js +24 -11
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.d.ts +275 -58
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +516 -239
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +76 -25
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +131 -49
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +311 -51
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +542 -193
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.d.ts +87 -26
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.js +147 -58
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.d.ts +209 -53
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +449 -242
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.d.ts +77 -23
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.js +116 -46
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.d.ts +197 -56
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +326 -189
- package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.d.ts +30 -5
- package/dist/swaps/escrow_swaps/tobtc/IToBTCWrapper.js +44 -19
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.d.ts +60 -19
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.js +74 -31
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.d.ts +76 -50
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.js +106 -101
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.d.ts +36 -13
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.js +65 -19
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.d.ts +46 -17
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.js +82 -27
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.d.ts +328 -92
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +460 -219
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +76 -24
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +244 -124
- package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +146 -18
- package/dist/swaps/trusted/ln/LnForGasSwap.js +173 -43
- package/dist/swaps/trusted/ln/LnForGasWrapper.d.ts +29 -10
- package/dist/swaps/trusted/ln/LnForGasWrapper.js +30 -11
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.d.ts +200 -47
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +230 -78
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.d.ts +34 -12
- package/dist/swaps/trusted/onchain/OnchainForGasWrapper.js +33 -14
- package/dist/types/AmountData.d.ts +2 -1
- package/dist/types/CustomPriceFunction.d.ts +7 -1
- package/dist/types/SwapExecutionAction.d.ts +74 -4
- package/dist/types/SwapWithSigner.d.ts +4 -1
- package/dist/types/SwapWithSigner.js +5 -2
- package/dist/types/Token.d.ts +11 -5
- package/dist/types/Token.js +6 -3
- package/dist/types/TokenAmount.d.ts +3 -0
- package/dist/types/TokenAmount.js +2 -0
- package/dist/types/fees/Fee.d.ts +2 -1
- package/dist/types/fees/FeeBreakdown.d.ts +2 -1
- package/dist/types/fees/PercentagePPM.d.ts +2 -0
- package/dist/types/fees/PercentagePPM.js +1 -0
- package/dist/types/lnurl/LNURLPay.d.ts +14 -6
- package/dist/types/lnurl/LNURLPay.js +6 -2
- package/dist/types/lnurl/LNURLWithdraw.d.ts +12 -5
- package/dist/types/lnurl/LNURLWithdraw.js +6 -2
- package/dist/types/wallets/LightningInvoiceCreateService.d.ts +20 -0
- package/dist/types/wallets/LightningInvoiceCreateService.js +15 -0
- package/dist/types/wallets/MinimalBitcoinWalletInterface.d.ts +3 -1
- package/dist/types/wallets/MinimalLightningNetworkWalletInterface.d.ts +3 -1
- package/dist/utils/BitcoinUtils.d.ts +1 -0
- package/dist/utils/BitcoinUtils.js +5 -1
- package/dist/utils/SwapUtils.d.ts +56 -1
- package/dist/utils/SwapUtils.js +53 -1
- package/dist/utils/TokenUtils.d.ts +10 -2
- package/dist/utils/TokenUtils.js +12 -4
- package/package.json +3 -3
- package/src/bitcoin/wallet/BitcoinWallet.ts +41 -5
- package/src/bitcoin/wallet/IBitcoinWallet.ts +57 -2
- package/src/bitcoin/wallet/SingleAddressBitcoinWallet.ts +42 -6
- package/src/enums/FeeType.ts +7 -0
- package/src/enums/SwapAmountType.ts +7 -0
- package/src/enums/SwapDirection.ts +7 -0
- package/src/enums/SwapType.ts +62 -2
- package/src/errors/IntermediaryError.ts +4 -0
- package/src/errors/RequestError.ts +15 -1
- package/src/errors/UserError.ts +1 -0
- package/src/index.ts +6 -5
- package/src/intermediaries/Intermediary.ts +57 -10
- package/src/intermediaries/IntermediaryDiscovery.ts +60 -27
- package/src/prices/RedundantSwapPrice.ts +24 -4
- package/src/prices/SingleSwapPrice.ts +10 -7
- package/src/prices/SwapPriceWithChain.ts +59 -21
- package/src/prices/abstract/ISwapPrice.ts +114 -65
- package/src/prices/providers/BinancePriceProvider.ts +7 -0
- package/src/prices/providers/CoinGeckoPriceProvider.ts +6 -0
- package/src/prices/providers/CoinPaprikaPriceProvider.ts +6 -0
- package/src/prices/providers/CustomPriceProvider.ts +11 -0
- package/src/prices/providers/KrakenPriceProvider.ts +9 -0
- package/src/prices/providers/OKXPriceProvider.ts +6 -0
- package/src/prices/providers/abstract/ExchangePriceProvider.ts +3 -0
- package/src/storage/IUnifiedStorage.ts +19 -7
- package/src/storage/UnifiedSwapStorage.ts +33 -3
- package/src/storage-browser/IndexedDBUnifiedStorage.ts +31 -8
- package/src/storage-browser/LocalStorageManager.ts +25 -1
- package/src/swapper/Swapper.ts +513 -379
- package/src/swapper/SwapperFactory.ts +44 -21
- package/src/swapper/SwapperUtils.ts +107 -60
- package/src/swapper/SwapperWithChain.ts +320 -81
- package/src/swapper/SwapperWithSigner.ts +263 -56
- package/src/swaps/IAddressSwap.ts +11 -1
- package/src/swaps/IBTCWalletSwap.ts +24 -8
- package/src/swaps/IClaimableSwap.ts +39 -4
- package/src/swaps/IClaimableSwapWrapper.ts +11 -2
- package/src/swaps/IRefundableSwap.ts +32 -3
- package/src/swaps/ISwap.ts +221 -82
- package/src/swaps/ISwapWithGasDrop.ts +6 -0
- package/src/swaps/ISwapWrapper.ts +212 -94
- package/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts +62 -18
- package/src/swaps/escrow_swaps/IEscrowSwap.ts +83 -37
- package/src/swaps/escrow_swaps/IEscrowSwapWrapper.ts +61 -30
- package/src/swaps/escrow_swaps/frombtc/IFromBTCLNWrapper.ts +37 -19
- package/src/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.ts +120 -51
- package/src/swaps/escrow_swaps/frombtc/IFromBTCWrapper.ts +24 -11
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +559 -256
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +155 -61
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +590 -226
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +177 -74
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +470 -243
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +141 -59
- package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +352 -193
- package/src/swaps/escrow_swaps/tobtc/IToBTCWrapper.ts +48 -23
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.ts +86 -39
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +110 -110
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.ts +88 -33
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +101 -31
- package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +534 -263
- package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +289 -148
- package/src/swaps/trusted/ln/LnForGasSwap.ts +184 -45
- package/src/swaps/trusted/ln/LnForGasWrapper.ts +34 -15
- package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +260 -86
- package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +41 -19
- package/src/types/AmountData.ts +2 -1
- package/src/types/CustomPriceFunction.ts +7 -1
- package/src/types/SwapExecutionAction.ts +84 -5
- package/src/types/SwapWithSigner.ts +7 -3
- package/src/types/Token.ts +12 -5
- package/src/types/TokenAmount.ts +3 -0
- package/src/types/fees/Fee.ts +2 -1
- package/src/types/fees/FeeBreakdown.ts +2 -1
- package/src/types/fees/PercentagePPM.ts +2 -0
- package/src/types/lnurl/LNURLPay.ts +14 -6
- package/src/types/lnurl/LNURLWithdraw.ts +12 -5
- package/src/types/wallets/LightningInvoiceCreateService.ts +26 -0
- package/src/types/wallets/MinimalBitcoinWalletInterface.ts +3 -1
- package/src/types/wallets/MinimalLightningNetworkWalletInterface.ts +3 -1
- package/src/utils/BitcoinUtils.ts +5 -0
- package/src/utils/SwapUtils.ts +61 -1
- package/src/utils/TokenUtils.ts +12 -4
- package/dist/bitcoin/BitcoinRpcWithAddressIndex.d.ts +0 -68
- package/dist/bitcoin/BitcoinRpcWithAddressIndex.js +0 -2
- package/dist/bitcoin/LightningNetworkApi.d.ts +0 -12
- package/dist/bitcoin/LightningNetworkApi.js +0 -2
- package/dist/bitcoin/mempool/MempoolApi.d.ts +0 -350
- package/dist/bitcoin/mempool/MempoolApi.js +0 -311
- package/dist/bitcoin/mempool/MempoolBitcoinBlock.d.ts +0 -44
- package/dist/bitcoin/mempool/MempoolBitcoinBlock.js +0 -48
- package/dist/bitcoin/mempool/MempoolBitcoinRpc.d.ts +0 -119
- package/dist/bitcoin/mempool/MempoolBitcoinRpc.js +0 -361
- package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.d.ts +0 -22
- package/dist/bitcoin/mempool/synchronizer/MempoolBtcRelaySynchronizer.js +0 -105
- package/dist/errors/PaymentAuthError.d.ts +0 -11
- package/dist/errors/PaymentAuthError.js +0 -23
- package/src/errors/PaymentAuthError.ts +0 -26
package/dist/swaps/ISwap.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { LoggerType } from "../utils/Logger";
|
|
|
14
14
|
import { PriceInfoType } from "../types/PriceInfoType";
|
|
15
15
|
/**
|
|
16
16
|
* Initialization data for creating a swap
|
|
17
|
+
*
|
|
17
18
|
* @category Swaps
|
|
18
19
|
*/
|
|
19
20
|
export type ISwapInit = {
|
|
@@ -26,56 +27,132 @@ export type ISwapInit = {
|
|
|
26
27
|
};
|
|
27
28
|
/**
|
|
28
29
|
* Type guard to check if an object is an ISwapInit
|
|
30
|
+
*
|
|
29
31
|
* @category Swaps
|
|
30
32
|
*/
|
|
31
33
|
export declare function isISwapInit(obj: any): obj is ISwapInit;
|
|
32
34
|
/**
|
|
33
35
|
* Base abstract class for all swap types
|
|
36
|
+
*
|
|
34
37
|
* @category Swaps
|
|
35
38
|
*/
|
|
36
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
|
+
/**
|
|
41
|
+
* Swap type
|
|
42
|
+
*/
|
|
37
43
|
protected readonly abstract TYPE: SwapType;
|
|
44
|
+
/**
|
|
45
|
+
* Swap logger
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
38
48
|
protected readonly abstract logger: LoggerType;
|
|
49
|
+
/**
|
|
50
|
+
* Current newest defined version of the swap
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
39
53
|
protected readonly currentVersion: number;
|
|
54
|
+
/**
|
|
55
|
+
* Wrapper instance holding this swap
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
40
58
|
protected readonly wrapper: D["Wrapper"];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
59
|
+
/**
|
|
60
|
+
* The current version of the swap
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
45
63
|
protected version: number;
|
|
64
|
+
/**
|
|
65
|
+
* Whether a swap was initialized, a swap is considered initialize on first interaction with it, i.e.
|
|
66
|
+
* calling commit() on a Smart chain -> Bitcoin swaps, calling waitForPayment() or similar on the other
|
|
67
|
+
* direction. Not initiated swaps are not saved to the persistent storage by default (see
|
|
68
|
+
* {@link SwapperOptions.saveUninitializedSwaps})
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
46
71
|
protected initiated: boolean;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Expiration of the swap quote
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
protected expiry: number;
|
|
77
|
+
/**
|
|
78
|
+
* Pricing information of the swap
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
protected pricingInfo?: PriceInfoType;
|
|
82
|
+
/**
|
|
83
|
+
* Swap fee in the non-bitcoin token
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
50
86
|
protected swapFee: bigint;
|
|
87
|
+
/**
|
|
88
|
+
* Swap fee in bitcoin satoshis
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
51
91
|
protected swapFeeBtc: bigint;
|
|
92
|
+
/**
|
|
93
|
+
* Swap state
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
_state: S;
|
|
52
97
|
/**
|
|
53
98
|
* Random nonce to differentiate the swap from others with the same identifier hash (i.e. when quoting the same swap
|
|
54
99
|
* from multiple LPs)
|
|
100
|
+
* @internal
|
|
55
101
|
*/
|
|
56
|
-
|
|
102
|
+
_randomNonce: string;
|
|
57
103
|
/**
|
|
58
|
-
* Event emitter emitting "swapState" event when swap's state changes
|
|
104
|
+
* Event emitter emitting `"swapState"` event when swap's state changes
|
|
59
105
|
*/
|
|
60
|
-
events: EventEmitter<{
|
|
106
|
+
readonly events: EventEmitter<{
|
|
61
107
|
swapState: [D["Swap"]];
|
|
62
108
|
}>;
|
|
109
|
+
/**
|
|
110
|
+
* URL of the intermediary (LP) used for this swap, already has the swap service specific path appended
|
|
111
|
+
*/
|
|
112
|
+
readonly url?: string;
|
|
113
|
+
/**
|
|
114
|
+
* Smart chain identifier string corresponding to this swap
|
|
115
|
+
*/
|
|
116
|
+
readonly chainIdentifier: T["ChainId"];
|
|
117
|
+
/**
|
|
118
|
+
* Whether a swap is an exact input swap
|
|
119
|
+
*/
|
|
120
|
+
readonly exactIn: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* A UNIX milliseconds timestamps of when this swap was created
|
|
123
|
+
*/
|
|
124
|
+
createdAt: number;
|
|
63
125
|
protected constructor(wrapper: D["Wrapper"], obj: any);
|
|
64
126
|
protected constructor(wrapper: D["Wrapper"], swapInit: ISwapInit);
|
|
127
|
+
/**
|
|
128
|
+
* Called when swap is deserialized to potentially update the version of the data for the swap
|
|
129
|
+
*
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
65
132
|
protected abstract upgradeVersion(): void;
|
|
66
133
|
/**
|
|
67
134
|
* Waits till the swap reaches a specific state
|
|
68
135
|
*
|
|
69
136
|
* @param targetState The state to wait for
|
|
70
137
|
* @param type Whether to wait for the state exactly or also to a state with a higher number
|
|
71
|
-
* @param abortSignal
|
|
72
|
-
* @
|
|
138
|
+
* @param abortSignal Abort signal
|
|
139
|
+
* @internal
|
|
73
140
|
*/
|
|
74
141
|
protected waitTillState(targetState: S, type?: "eq" | "gte" | "neq", abortSignal?: AbortSignal): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Returns a list of steps or transactions required to finish and settle the swap
|
|
144
|
+
*
|
|
145
|
+
* @param options Additional options for executing the swap
|
|
146
|
+
*/
|
|
75
147
|
abstract txsExecute(options?: any): Promise<SwapExecutionAction<T>[]>;
|
|
148
|
+
/**
|
|
149
|
+
* This attempts to populate missing fields in the pricing info based on the swap amounts
|
|
150
|
+
*
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
76
153
|
protected tryRecomputeSwapPrice(): void;
|
|
77
154
|
/**
|
|
78
|
-
* Re-fetches & revalidates the price data
|
|
155
|
+
* Re-fetches & revalidates the price data based on the current market prices
|
|
79
156
|
*/
|
|
80
157
|
refreshPriceData(): Promise<void>;
|
|
81
158
|
/**
|
|
@@ -90,22 +167,58 @@ export declare abstract class ISwap<T extends ChainType = ChainType, D extends S
|
|
|
90
167
|
swapPrice: number;
|
|
91
168
|
difference: PercentagePPM;
|
|
92
169
|
};
|
|
93
|
-
abstract _getEscrowHash(): string | null;
|
|
94
170
|
/**
|
|
171
|
+
* Asserts a given signer is the initiator of this swap
|
|
172
|
+
*
|
|
95
173
|
* @param signer Signer to check with this swap's initiator
|
|
96
174
|
* @throws {Error} When signer's address doesn't match with the swap's initiator one
|
|
175
|
+
* @internal
|
|
97
176
|
*/
|
|
98
177
|
protected checkSigner(signer: T["Signer"] | string): void;
|
|
178
|
+
/**
|
|
179
|
+
* Returns an escrow hash of the swap
|
|
180
|
+
*
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
abstract _getEscrowHash(): string | null;
|
|
184
|
+
/**
|
|
185
|
+
* Checks if the swap's quote is expired for good (i.e. the swap strictly cannot be initiated anymore)
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
abstract _verifyQuoteDefinitelyExpired(): Promise<boolean>;
|
|
99
189
|
/**
|
|
100
190
|
* Checks if the swap's quote is still valid
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
abstract _verifyQuoteValid(): Promise<boolean>;
|
|
194
|
+
/**
|
|
195
|
+
* Returns the intiator address of the swap - address that created this swap
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
abstract _getInitiator(): string;
|
|
199
|
+
/**
|
|
200
|
+
* Sets this swap as initiated
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
_setInitiated(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Returns source address of the swap
|
|
101
206
|
*/
|
|
102
|
-
abstract verifyQuoteValid(): Promise<boolean>;
|
|
103
207
|
abstract getInputAddress(): string | null;
|
|
208
|
+
/**
|
|
209
|
+
* Returns destination address of the swap
|
|
210
|
+
*/
|
|
104
211
|
abstract getOutputAddress(): string | null;
|
|
212
|
+
/**
|
|
213
|
+
* Returns swap input transaction ID on the source chain
|
|
214
|
+
*/
|
|
105
215
|
abstract getInputTxId(): string | null;
|
|
216
|
+
/**
|
|
217
|
+
* Returns swap output transaction ID on the destination chain
|
|
218
|
+
*/
|
|
106
219
|
abstract getOutputTxId(): string | null;
|
|
107
220
|
/**
|
|
108
|
-
* Returns the ID of the swap, as used in the storage
|
|
221
|
+
* Returns the ID of the swap, as used in the storage
|
|
109
222
|
*/
|
|
110
223
|
abstract getId(): string;
|
|
111
224
|
/**
|
|
@@ -134,11 +247,12 @@ export declare abstract class ISwap<T extends ChainType = ChainType, D extends S
|
|
|
134
247
|
*/
|
|
135
248
|
abstract isFailed(): boolean;
|
|
136
249
|
/**
|
|
137
|
-
*
|
|
250
|
+
* Whether a swap was initialized, a swap is considered initialized on first interaction with it, i.e.
|
|
251
|
+
* calling commit() on a Smart chain -> Bitcoin swaps, calling waitForPayment() or similar on the other
|
|
252
|
+
* direction. Not initiated swaps are not saved to the persistent storage by default (see
|
|
253
|
+
* {@link SwapperOptions.saveUninitializedSwaps})
|
|
138
254
|
*/
|
|
139
|
-
abstract _getInitiator(): string;
|
|
140
255
|
isInitiated(): boolean;
|
|
141
|
-
_setInitiated(): void;
|
|
142
256
|
/**
|
|
143
257
|
* Returns quote expiry in UNIX millis
|
|
144
258
|
*/
|
|
@@ -172,7 +286,7 @@ export declare abstract class ISwap<T extends ChainType = ChainType, D extends S
|
|
|
172
286
|
*/
|
|
173
287
|
abstract getInputToken(): Token<T["ChainId"]>;
|
|
174
288
|
/**
|
|
175
|
-
* Returns input amount
|
|
289
|
+
* Returns input amount of the swap without the fees (swap fee, network fee)
|
|
176
290
|
*/
|
|
177
291
|
abstract getInputWithoutFee(): TokenAmount;
|
|
178
292
|
/**
|
|
@@ -184,9 +298,29 @@ export declare abstract class ISwap<T extends ChainType = ChainType, D extends S
|
|
|
184
298
|
* Returns the breakdown of all the fees paid
|
|
185
299
|
*/
|
|
186
300
|
abstract getFeeBreakdown(): FeeBreakdown<T["ChainId"]>;
|
|
187
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Saves the swap data to the underlying storage, or removes it if it is in a quote expired state
|
|
303
|
+
*
|
|
304
|
+
* @internal
|
|
305
|
+
*/
|
|
188
306
|
_save(): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* Saves the swap data and also emits a swap state change
|
|
309
|
+
*
|
|
310
|
+
* @param state Optional state to set before the swap is saved an event emitted
|
|
311
|
+
*
|
|
312
|
+
* @internal
|
|
313
|
+
*/
|
|
189
314
|
_saveAndEmit(state?: S): Promise<void>;
|
|
315
|
+
/**
|
|
316
|
+
* Serializes the swap to a JSON stringifiable representation (i.e. no bigints, buffers etc.)
|
|
317
|
+
*/
|
|
318
|
+
serialize(): any;
|
|
319
|
+
/**
|
|
320
|
+
* Emits a `swapState` event with the current swap
|
|
321
|
+
*
|
|
322
|
+
* @internal
|
|
323
|
+
*/
|
|
190
324
|
_emitEvent(): void;
|
|
191
325
|
/**
|
|
192
326
|
* Synchronizes swap state from chain and/or LP node, usually ran on startup
|
|
@@ -194,6 +328,8 @@ export declare abstract class ISwap<T extends ChainType = ChainType, D extends S
|
|
|
194
328
|
* @param save whether to save the new swap state or not
|
|
195
329
|
*
|
|
196
330
|
* @returns {boolean} true if the swap changed, false if the swap hasn't changed
|
|
331
|
+
*
|
|
332
|
+
* @internal
|
|
197
333
|
*/
|
|
198
334
|
abstract _sync(save?: boolean): Promise<boolean>;
|
|
199
335
|
/**
|
|
@@ -202,6 +338,8 @@ export declare abstract class ISwap<T extends ChainType = ChainType, D extends S
|
|
|
202
338
|
* @param save whether to save the new swap state or not
|
|
203
339
|
*
|
|
204
340
|
* @returns {boolean} true if the swap changed, false if the swap hasn't changed
|
|
341
|
+
*
|
|
342
|
+
* @internal
|
|
205
343
|
*/
|
|
206
344
|
abstract _tick(save?: boolean): Promise<boolean>;
|
|
207
345
|
}
|
package/dist/swaps/ISwap.js
CHANGED
|
@@ -10,6 +10,7 @@ const Token_1 = require("../types/Token");
|
|
|
10
10
|
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
15
|
*/
|
|
15
16
|
function isISwapInit(obj) {
|
|
@@ -25,15 +26,31 @@ function isISwapInit(obj) {
|
|
|
25
26
|
exports.isISwapInit = isISwapInit;
|
|
26
27
|
/**
|
|
27
28
|
* Base abstract class for all swap types
|
|
29
|
+
*
|
|
28
30
|
* @category Swaps
|
|
29
31
|
*/
|
|
30
32
|
class ISwap {
|
|
31
33
|
constructor(wrapper, swapInitOrObj) {
|
|
34
|
+
/**
|
|
35
|
+
* Current newest defined version of the swap
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
32
38
|
this.currentVersion = 1;
|
|
39
|
+
/**
|
|
40
|
+
* Whether a swap was initialized, a swap is considered initialize on first interaction with it, i.e.
|
|
41
|
+
* calling commit() on a Smart chain -> Bitcoin swaps, calling waitForPayment() or similar on the other
|
|
42
|
+
* direction. Not initiated swaps are not saved to the persistent storage by default (see
|
|
43
|
+
* {@link SwapperOptions.saveUninitializedSwaps})
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
33
46
|
this.initiated = false;
|
|
34
|
-
this.state = 0;
|
|
35
47
|
/**
|
|
36
|
-
*
|
|
48
|
+
* Swap state
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
this._state = 0;
|
|
52
|
+
/**
|
|
53
|
+
* Event emitter emitting `"swapState"` event when swap's state changes
|
|
37
54
|
*/
|
|
38
55
|
this.events = new events_1.EventEmitter();
|
|
39
56
|
this.chainIdentifier = wrapper.chainIdentifier;
|
|
@@ -47,12 +64,12 @@ class ISwap {
|
|
|
47
64
|
this.exactIn = swapInitOrObj.exactIn;
|
|
48
65
|
this.version = this.currentVersion;
|
|
49
66
|
this.createdAt = Date.now();
|
|
50
|
-
this.
|
|
67
|
+
this._randomNonce = (0, Utils_1.randomBytes)(16).toString("hex");
|
|
51
68
|
}
|
|
52
69
|
else {
|
|
53
70
|
this.expiry = swapInitOrObj.expiry;
|
|
54
71
|
this.url = swapInitOrObj.url;
|
|
55
|
-
this.
|
|
72
|
+
this._state = swapInitOrObj.state;
|
|
56
73
|
if (swapInitOrObj._isValid != null && swapInitOrObj._differencePPM != null && swapInitOrObj._satsBaseFee != null &&
|
|
57
74
|
swapInitOrObj._feePPM != null && swapInitOrObj._swapPriceUSatPerToken != null) {
|
|
58
75
|
this.pricingInfo = {
|
|
@@ -71,7 +88,7 @@ class ISwap {
|
|
|
71
88
|
this.initiated = swapInitOrObj.initiated;
|
|
72
89
|
this.exactIn = swapInitOrObj.exactIn;
|
|
73
90
|
this.createdAt = swapInitOrObj.createdAt ?? swapInitOrObj.expiry;
|
|
74
|
-
this.
|
|
91
|
+
this._randomNonce = swapInitOrObj.randomNonce;
|
|
75
92
|
}
|
|
76
93
|
if (this.version !== this.currentVersion) {
|
|
77
94
|
this.upgradeVersion();
|
|
@@ -84,14 +101,14 @@ class ISwap {
|
|
|
84
101
|
*
|
|
85
102
|
* @param targetState The state to wait for
|
|
86
103
|
* @param type Whether to wait for the state exactly or also to a state with a higher number
|
|
87
|
-
* @param abortSignal
|
|
88
|
-
* @
|
|
104
|
+
* @param abortSignal Abort signal
|
|
105
|
+
* @internal
|
|
89
106
|
*/
|
|
90
107
|
waitTillState(targetState, type = "eq", abortSignal) {
|
|
91
108
|
return new Promise((resolve, reject) => {
|
|
92
109
|
let listener;
|
|
93
110
|
listener = (swap) => {
|
|
94
|
-
if (type === "eq" ? swap.
|
|
111
|
+
if (type === "eq" ? swap._state === targetState : type === "gte" ? swap._state >= targetState : swap._state != targetState) {
|
|
95
112
|
resolve();
|
|
96
113
|
this.events.removeListener("swapState", listener);
|
|
97
114
|
}
|
|
@@ -106,6 +123,11 @@ class ISwap {
|
|
|
106
123
|
}
|
|
107
124
|
//////////////////////////////
|
|
108
125
|
//// Pricing
|
|
126
|
+
/**
|
|
127
|
+
* This attempts to populate missing fields in the pricing info based on the swap amounts
|
|
128
|
+
*
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
109
131
|
tryRecomputeSwapPrice() {
|
|
110
132
|
if (this.pricingInfo == null)
|
|
111
133
|
return;
|
|
@@ -116,17 +138,17 @@ class ISwap {
|
|
|
116
138
|
if (input.isUnknown || output.isUnknown)
|
|
117
139
|
return;
|
|
118
140
|
if ((0, Token_1.isSCToken)(input.token) && this.getDirection() === SwapDirection_1.SwapDirection.TO_BTC) {
|
|
119
|
-
this.pricingInfo = this.wrapper.
|
|
141
|
+
this.pricingInfo = this.wrapper._prices.recomputePriceInfoSend(this.chainIdentifier, output.rawAmount, this.pricingInfo.satsBaseFee, this.pricingInfo.feePPM, input.rawAmount, input.token.address);
|
|
120
142
|
this.pricingInfo.realPriceUsdPerBitcoin = priceUsdPerBtc;
|
|
121
143
|
}
|
|
122
144
|
else if ((0, Token_1.isSCToken)(output.token) && this.getDirection() === SwapDirection_1.SwapDirection.FROM_BTC) {
|
|
123
|
-
this.pricingInfo = this.wrapper.
|
|
145
|
+
this.pricingInfo = this.wrapper._prices.recomputePriceInfoReceive(this.chainIdentifier, input.rawAmount, this.pricingInfo.satsBaseFee, this.pricingInfo.feePPM, output.rawAmount, output.token.address);
|
|
124
146
|
this.pricingInfo.realPriceUsdPerBitcoin = priceUsdPerBtc;
|
|
125
147
|
}
|
|
126
148
|
}
|
|
127
149
|
}
|
|
128
150
|
/**
|
|
129
|
-
* Re-fetches & revalidates the price data
|
|
151
|
+
* Re-fetches & revalidates the price data based on the current market prices
|
|
130
152
|
*/
|
|
131
153
|
async refreshPriceData() {
|
|
132
154
|
if (this.pricingInfo == null)
|
|
@@ -137,11 +159,11 @@ class ISwap {
|
|
|
137
159
|
if (input.isUnknown || output.isUnknown)
|
|
138
160
|
return;
|
|
139
161
|
if ((0, Token_1.isSCToken)(input.token) && this.getDirection() === SwapDirection_1.SwapDirection.TO_BTC) {
|
|
140
|
-
this.pricingInfo = await this.wrapper.
|
|
162
|
+
this.pricingInfo = await this.wrapper._prices.isValidAmountSend(this.chainIdentifier, output.rawAmount, this.pricingInfo.satsBaseFee, this.pricingInfo.feePPM, input.rawAmount, input.token.address);
|
|
141
163
|
this.pricingInfo.realPriceUsdPerBitcoin = priceUsdPerBtc;
|
|
142
164
|
}
|
|
143
165
|
else if ((0, Token_1.isSCToken)(output.token) && this.getDirection() === SwapDirection_1.SwapDirection.FROM_BTC) {
|
|
144
|
-
this.pricingInfo = await this.wrapper.
|
|
166
|
+
this.pricingInfo = await this.wrapper._prices.isValidAmountReceive(this.chainIdentifier, input.rawAmount, this.pricingInfo.satsBaseFee, this.pricingInfo.feePPM, output.rawAmount, output.token.address);
|
|
145
167
|
this.pricingInfo.realPriceUsdPerBitcoin = priceUsdPerBtc;
|
|
146
168
|
}
|
|
147
169
|
}
|
|
@@ -173,20 +195,35 @@ class ISwap {
|
|
|
173
195
|
difference: (0, PercentagePPM_1.ppmToPercentage)(this.pricingInfo.differencePPM)
|
|
174
196
|
};
|
|
175
197
|
}
|
|
198
|
+
//////////////////////////////
|
|
199
|
+
//// Getters & utils
|
|
176
200
|
/**
|
|
201
|
+
* Asserts a given signer is the initiator of this swap
|
|
202
|
+
*
|
|
177
203
|
* @param signer Signer to check with this swap's initiator
|
|
178
204
|
* @throws {Error} When signer's address doesn't match with the swap's initiator one
|
|
205
|
+
* @internal
|
|
179
206
|
*/
|
|
180
207
|
checkSigner(signer) {
|
|
181
208
|
if ((typeof (signer) === "string" ? signer : signer.getAddress()) !== this._getInitiator())
|
|
182
209
|
throw new Error("Invalid signer provided!");
|
|
183
210
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Sets this swap as initiated
|
|
213
|
+
* @internal
|
|
214
|
+
*/
|
|
187
215
|
_setInitiated() {
|
|
188
216
|
this.initiated = true;
|
|
189
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Whether a swap was initialized, a swap is considered initialized on first interaction with it, i.e.
|
|
220
|
+
* calling commit() on a Smart chain -> Bitcoin swaps, calling waitForPayment() or similar on the other
|
|
221
|
+
* direction. Not initiated swaps are not saved to the persistent storage by default (see
|
|
222
|
+
* {@link SwapperOptions.saveUninitializedSwaps})
|
|
223
|
+
*/
|
|
224
|
+
isInitiated() {
|
|
225
|
+
return this.initiated;
|
|
226
|
+
}
|
|
190
227
|
/**
|
|
191
228
|
* Returns quote expiry in UNIX millis
|
|
192
229
|
*/
|
|
@@ -209,10 +246,39 @@ class ISwap {
|
|
|
209
246
|
* Returns the current state of the swap
|
|
210
247
|
*/
|
|
211
248
|
getState() {
|
|
212
|
-
return this.
|
|
249
|
+
return this._state;
|
|
213
250
|
}
|
|
214
251
|
//////////////////////////////
|
|
215
252
|
//// Storage
|
|
253
|
+
/**
|
|
254
|
+
* Saves the swap data to the underlying storage, or removes it if it is in a quote expired state
|
|
255
|
+
*
|
|
256
|
+
* @internal
|
|
257
|
+
*/
|
|
258
|
+
_save() {
|
|
259
|
+
if (this.isQuoteExpired()) {
|
|
260
|
+
return this.wrapper._removeSwapData(this);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
return this.wrapper._saveSwapData(this);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Saves the swap data and also emits a swap state change
|
|
268
|
+
*
|
|
269
|
+
* @param state Optional state to set before the swap is saved an event emitted
|
|
270
|
+
*
|
|
271
|
+
* @internal
|
|
272
|
+
*/
|
|
273
|
+
async _saveAndEmit(state) {
|
|
274
|
+
if (state != null)
|
|
275
|
+
this._state = state;
|
|
276
|
+
await this._save();
|
|
277
|
+
this._emitEvent();
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Serializes the swap to a JSON stringifiable representation (i.e. no bigints, buffers etc.)
|
|
281
|
+
*/
|
|
216
282
|
serialize() {
|
|
217
283
|
if (this.pricingInfo == null)
|
|
218
284
|
return {};
|
|
@@ -228,7 +294,7 @@ class ISwap {
|
|
|
228
294
|
_realPriceUSatPerToken: this.pricingInfo.realPriceUSatPerToken == null ? null : this.pricingInfo.realPriceUSatPerToken.toString(10),
|
|
229
295
|
_realPriceUsdPerBitcoin: this.pricingInfo.realPriceUsdPerBitcoin,
|
|
230
296
|
_swapPriceUSatPerToken: this.pricingInfo.swapPriceUSatPerToken == null ? null : this.pricingInfo.swapPriceUSatPerToken.toString(10),
|
|
231
|
-
state: this.
|
|
297
|
+
state: this._state,
|
|
232
298
|
url: this.url,
|
|
233
299
|
swapFee: this.swapFee == null ? null : this.swapFee.toString(10),
|
|
234
300
|
swapFeeBtc: this.swapFeeBtc == null ? null : this.swapFeeBtc.toString(10),
|
|
@@ -237,25 +303,16 @@ class ISwap {
|
|
|
237
303
|
initiated: this.initiated,
|
|
238
304
|
exactIn: this.exactIn,
|
|
239
305
|
createdAt: this.createdAt,
|
|
240
|
-
randomNonce: this.
|
|
306
|
+
randomNonce: this._randomNonce
|
|
241
307
|
};
|
|
242
308
|
}
|
|
243
|
-
_save() {
|
|
244
|
-
if (this.isQuoteExpired()) {
|
|
245
|
-
return this.wrapper.removeSwapData(this);
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
return this.wrapper.saveSwapData(this);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
async _saveAndEmit(state) {
|
|
252
|
-
if (state != null)
|
|
253
|
-
this.state = state;
|
|
254
|
-
await this._save();
|
|
255
|
-
this._emitEvent();
|
|
256
|
-
}
|
|
257
309
|
//////////////////////////////
|
|
258
310
|
//// Events
|
|
311
|
+
/**
|
|
312
|
+
* Emits a `swapState` event with the current swap
|
|
313
|
+
*
|
|
314
|
+
* @internal
|
|
315
|
+
*/
|
|
259
316
|
_emitEvent() {
|
|
260
317
|
this.wrapper.events.emit("swapState", this);
|
|
261
318
|
this.events.emit("swapState", this);
|
|
@@ -3,13 +3,19 @@ import { TokenAmount } from "../types/TokenAmount";
|
|
|
3
3
|
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
8
|
*/
|
|
8
9
|
export declare function isSwapWithGasDrop(swap: any): swap is ISwapWithGasDrop<any>;
|
|
9
10
|
/**
|
|
10
11
|
* Interface for swaps with gas drop functionality
|
|
12
|
+
*
|
|
11
13
|
* @category Swaps
|
|
12
14
|
*/
|
|
13
15
|
export interface ISwapWithGasDrop<T extends ChainType> {
|
|
16
|
+
/**
|
|
17
|
+
* Returns the output of the "gas drop", additional native token received by the user on
|
|
18
|
+
* the destination chain
|
|
19
|
+
*/
|
|
14
20
|
getGasDropOutput(): TokenAmount<T["ChainId"], SCToken<T["ChainId"]>>;
|
|
15
21
|
}
|