@atomiqlabs/sdk 8.1.8 → 8.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bitcoin/coinselect2/utils.d.ts +6 -0
- 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 +8 -1
- package/dist/enums/FeeType.js +8 -1
- 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 +5 -5
- package/dist/index.js +7 -6
- package/dist/intermediaries/Intermediary.d.ts +61 -14
- package/dist/intermediaries/Intermediary.js +38 -11
- package/dist/intermediaries/IntermediaryDiscovery.d.ts +62 -29
- package/dist/intermediaries/IntermediaryDiscovery.js +39 -24
- package/dist/prices/RedundantSwapPrice.d.ts +26 -5
- package/dist/prices/RedundantSwapPrice.js +22 -2
- package/dist/prices/SingleSwapPrice.d.ts +10 -7
- package/dist/prices/SingleSwapPrice.js +11 -8
- package/dist/prices/SwapPriceWithChain.d.ts +56 -19
- package/dist/prices/SwapPriceWithChain.js +62 -25
- package/dist/prices/abstract/IPriceProvider.d.ts +4 -4
- package/dist/prices/abstract/IPriceProvider.js +1 -1
- package/dist/prices/abstract/ISwapPrice.d.ts +95 -46
- package/dist/prices/abstract/ISwapPrice.js +104 -56
- package/dist/prices/providers/BinancePriceProvider.d.ts +8 -1
- package/dist/prices/providers/BinancePriceProvider.js +8 -1
- package/dist/prices/providers/CoinGeckoPriceProvider.d.ts +7 -1
- package/dist/prices/providers/CoinGeckoPriceProvider.js +7 -1
- package/dist/prices/providers/CoinPaprikaPriceProvider.d.ts +7 -1
- package/dist/prices/providers/CoinPaprikaPriceProvider.js +7 -1
- package/dist/prices/providers/CustomPriceProvider.d.ts +12 -1
- package/dist/prices/providers/CustomPriceProvider.js +12 -1
- package/dist/prices/providers/KrakenPriceProvider.d.ts +10 -1
- package/dist/prices/providers/KrakenPriceProvider.js +10 -1
- package/dist/prices/providers/OKXPriceProvider.d.ts +7 -1
- package/dist/prices/providers/OKXPriceProvider.js +7 -1
- 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 +380 -226
- package/dist/swapper/Swapper.js +383 -349
- package/dist/swapper/SwapperFactory.d.ts +66 -18
- package/dist/swapper/SwapperFactory.js +24 -3
- 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 +12 -3
- package/dist/swaps/IAddressSwap.js +3 -2
- package/dist/swaps/IBTCWalletSwap.d.ts +26 -8
- package/dist/swaps/IBTCWalletSwap.js +3 -2
- package/dist/swaps/IClaimableSwap.d.ts +38 -6
- package/dist/swaps/IClaimableSwap.js +3 -2
- package/dist/swaps/IClaimableSwapWrapper.d.ts +11 -1
- package/dist/swaps/IRefundableSwap.d.ts +31 -5
- package/dist/swaps/IRefundableSwap.js +3 -2
- package/dist/swaps/ISwap.d.ts +162 -24
- package/dist/swaps/ISwap.js +92 -35
- package/dist/swaps/ISwapWithGasDrop.d.ts +8 -2
- package/dist/swaps/ISwapWithGasDrop.js +2 -1
- package/dist/swaps/ISwapWrapper.d.ts +161 -52
- package/dist/swaps/ISwapWrapper.js +131 -73
- package/dist/swaps/escrow_swaps/IEscrowSelfInitSwap.d.ts +51 -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 +97 -28
- package/dist/swaps/escrow_swaps/frombtc/IFromBTCSelfInitSwap.js +91 -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 +278 -60
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.js +519 -241
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.d.ts +77 -26
- package/dist/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.js +132 -50
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.d.ts +313 -52
- package/dist/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.js +544 -194
- 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 +222 -55
- package/dist/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.js +462 -244
- 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 +195 -58
- package/dist/swaps/escrow_swaps/tobtc/IToBTCSwap.js +324 -191
- 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 +61 -20
- package/dist/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.js +75 -32
- 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 +37 -14
- package/dist/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.js +66 -20
- 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 +350 -88
- package/dist/swaps/spv_swaps/SpvFromBTCSwap.js +482 -215
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.d.ts +76 -24
- package/dist/swaps/spv_swaps/SpvFromBTCWrapper.js +247 -124
- package/dist/swaps/trusted/ln/LnForGasSwap.d.ts +148 -20
- package/dist/swaps/trusted/ln/LnForGasSwap.js +175 -45
- 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 +202 -49
- package/dist/swaps/trusted/onchain/OnchainForGasSwap.js +232 -80
- 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 +8 -2
- package/dist/types/PriceInfoType.d.ts +4 -4
- package/dist/types/PriceInfoType.js +3 -3
- package/dist/types/SwapExecutionAction.d.ts +85 -4
- package/dist/types/SwapWithSigner.d.ts +5 -2
- 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 +3 -2
- package/dist/types/fees/FeeBreakdown.d.ts +3 -2
- package/dist/types/fees/PercentagePPM.d.ts +4 -2
- package/dist/types/fees/PercentagePPM.js +2 -1
- package/dist/types/lnurl/LNURLPay.d.ts +20 -12
- package/dist/types/lnurl/LNURLPay.js +8 -4
- package/dist/types/lnurl/LNURLWithdraw.d.ts +17 -10
- package/dist/types/lnurl/LNURLWithdraw.js +8 -4
- package/dist/types/wallets/LightningInvoiceCreateService.d.ts +24 -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 +4 -2
- package/dist/utils/BitcoinUtils.d.ts +1 -0
- package/dist/utils/BitcoinUtils.js +5 -1
- package/dist/utils/SwapUtils.d.ts +58 -1
- package/dist/utils/SwapUtils.js +55 -1
- package/dist/utils/TokenUtils.d.ts +10 -2
- package/dist/utils/TokenUtils.js +12 -4
- package/package.json +3 -3
- package/src/bitcoin/coinselect2/utils.ts +6 -0
- 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 +8 -1
- 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 +12 -5
- package/src/intermediaries/Intermediary.ts +61 -14
- package/src/intermediaries/IntermediaryDiscovery.ts +69 -34
- package/src/prices/RedundantSwapPrice.ts +26 -6
- package/src/prices/SingleSwapPrice.ts +11 -8
- package/src/prices/SwapPriceWithChain.ts +63 -26
- package/src/prices/abstract/IPriceProvider.ts +4 -4
- package/src/prices/abstract/ISwapPrice.ts +115 -66
- package/src/prices/providers/BinancePriceProvider.ts +8 -1
- package/src/prices/providers/CoinGeckoPriceProvider.ts +7 -1
- package/src/prices/providers/CoinPaprikaPriceProvider.ts +7 -1
- package/src/prices/providers/CustomPriceProvider.ts +12 -1
- package/src/prices/providers/KrakenPriceProvider.ts +10 -1
- package/src/prices/providers/OKXPriceProvider.ts +7 -1
- 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 +599 -390
- package/src/swapper/SwapperFactory.ts +73 -24
- 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 +13 -3
- package/src/swaps/IBTCWalletSwap.ts +26 -10
- package/src/swaps/IClaimableSwap.ts +41 -6
- package/src/swaps/IClaimableSwapWrapper.ts +11 -2
- package/src/swaps/IRefundableSwap.ts +34 -5
- package/src/swaps/ISwap.ts +224 -85
- package/src/swaps/ISwapWithGasDrop.ts +8 -2
- package/src/swaps/ISwapWrapper.ts +216 -98
- package/src/swaps/escrow_swaps/IEscrowSelfInitSwap.ts +64 -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 +123 -50
- package/src/swaps/escrow_swaps/frombtc/IFromBTCWrapper.ts +24 -11
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNSwap.ts +562 -258
- package/src/swaps/escrow_swaps/frombtc/ln/FromBTCLNWrapper.ts +156 -62
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoSwap.ts +592 -227
- package/src/swaps/escrow_swaps/frombtc/ln_auto/FromBTCLNAutoWrapper.ts +177 -74
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCSwap.ts +483 -245
- package/src/swaps/escrow_swaps/frombtc/onchain/FromBTCWrapper.ts +141 -59
- package/src/swaps/escrow_swaps/tobtc/IToBTCSwap.ts +350 -195
- package/src/swaps/escrow_swaps/tobtc/IToBTCWrapper.ts +48 -23
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNSwap.ts +87 -40
- package/src/swaps/escrow_swaps/tobtc/ln/ToBTCLNWrapper.ts +110 -110
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCSwap.ts +89 -34
- package/src/swaps/escrow_swaps/tobtc/onchain/ToBTCWrapper.ts +101 -31
- package/src/swaps/spv_swaps/SpvFromBTCSwap.ts +556 -259
- package/src/swaps/spv_swaps/SpvFromBTCWrapper.ts +292 -148
- package/src/swaps/trusted/ln/LnForGasSwap.ts +186 -47
- package/src/swaps/trusted/ln/LnForGasWrapper.ts +34 -15
- package/src/swaps/trusted/onchain/OnchainForGasSwap.ts +262 -88
- package/src/swaps/trusted/onchain/OnchainForGasWrapper.ts +41 -19
- package/src/types/AmountData.ts +2 -1
- package/src/types/CustomPriceFunction.ts +8 -2
- package/src/types/PriceInfoType.ts +4 -4
- package/src/types/SwapExecutionAction.ts +97 -5
- package/src/types/SwapWithSigner.ts +8 -4
- package/src/types/Token.ts +12 -5
- package/src/types/TokenAmount.ts +3 -0
- package/src/types/fees/Fee.ts +3 -2
- package/src/types/fees/FeeBreakdown.ts +3 -2
- package/src/types/fees/PercentagePPM.ts +4 -2
- package/src/types/lnurl/LNURLPay.ts +20 -12
- package/src/types/lnurl/LNURLWithdraw.ts +17 -10
- package/src/types/wallets/LightningInvoiceCreateService.ts +30 -0
- package/src/types/wallets/MinimalBitcoinWalletInterface.ts +3 -1
- package/src/types/wallets/MinimalLightningNetworkWalletInterface.ts +4 -2
- package/src/utils/BitcoinUtils.ts +5 -0
- package/src/utils/SwapUtils.ts +63 -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
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ChainType,
|
|
5
5
|
ClaimEvent,
|
|
6
6
|
InitializeEvent, LightningNetworkApi, Messenger,
|
|
7
|
-
RefundEvent
|
|
7
|
+
RefundEvent, SwapCommitState, SwapCommitStateType
|
|
8
8
|
} from "@atomiqlabs/base";
|
|
9
9
|
import {Intermediary} from "../../../../intermediaries/Intermediary";
|
|
10
10
|
import {Buffer} from "buffer";
|
|
@@ -34,6 +34,7 @@ import {AmountData} from "../../../../types/AmountData";
|
|
|
34
34
|
import {LNURLWithdrawParamsWithUrl} from "../../../../types/lnurl/LNURLWithdraw";
|
|
35
35
|
import {tryWithRetries} from "../../../../utils/RetryUtils";
|
|
36
36
|
import {AllOptional} from "../../../../utils/TypeUtils";
|
|
37
|
+
import {sha256} from "@noble/hashes/sha2";
|
|
37
38
|
|
|
38
39
|
export type FromBTCLNAutoOptions = {
|
|
39
40
|
descriptionHash?: Buffer,
|
|
@@ -51,15 +52,52 @@ export type FromBTCLNAutoWrapperOptions = ISwapWrapperOptions & {
|
|
|
51
52
|
|
|
52
53
|
export type FromBTCLNAutoDefinition<T extends ChainType> = IFromBTCLNDefinition<T, FromBTCLNAutoWrapper<T>, FromBTCLNAutoSwap<T>>;
|
|
53
54
|
|
|
55
|
+
/**
|
|
56
|
+
* New escrow based (HTLC) swaps for Bitcoin Lightning -> Smart chain swaps not requiring manual settlement on
|
|
57
|
+
* the destination by the user, and instead letting the LP initiate the escrow. Permissionless watchtower network
|
|
58
|
+
* handles the claiming of HTLC, with the swap secret broadcasted over Nostr. Also adds a possibility for the user
|
|
59
|
+
* to receive a native token on the destination chain as part of the swap (a "gas drop" feature).
|
|
60
|
+
*
|
|
61
|
+
* @category Swaps/Lightning → Smart chain
|
|
62
|
+
*/
|
|
54
63
|
export class FromBTCLNAutoWrapper<
|
|
55
64
|
T extends ChainType
|
|
56
65
|
> extends IFromBTCLNWrapper<T, FromBTCLNAutoDefinition<T>, FromBTCLNAutoWrapperOptions> implements IClaimableSwapWrapper<FromBTCLNAutoSwap<T>> {
|
|
57
66
|
|
|
58
|
-
public readonly
|
|
59
|
-
public readonly TYPE = SwapType.FROM_BTCLN_AUTO;
|
|
60
|
-
public readonly swapDeserializer = FromBTCLNAutoSwap;
|
|
67
|
+
public readonly TYPE: SwapType.FROM_BTCLN_AUTO = SwapType.FROM_BTCLN_AUTO;
|
|
61
68
|
|
|
62
|
-
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
protected readonly tickSwapState = [
|
|
73
|
+
FromBTCLNAutoSwapState.PR_CREATED,
|
|
74
|
+
FromBTCLNAutoSwapState.QUOTE_SOFT_EXPIRED,
|
|
75
|
+
FromBTCLNAutoSwapState.PR_PAID,
|
|
76
|
+
FromBTCLNAutoSwapState.CLAIM_COMMITED
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
readonly _pendingSwapStates = [
|
|
83
|
+
FromBTCLNAutoSwapState.PR_CREATED,
|
|
84
|
+
FromBTCLNAutoSwapState.QUOTE_SOFT_EXPIRED,
|
|
85
|
+
FromBTCLNAutoSwapState.PR_PAID,
|
|
86
|
+
FromBTCLNAutoSwapState.CLAIM_COMMITED,
|
|
87
|
+
FromBTCLNAutoSwapState.EXPIRED
|
|
88
|
+
];
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
readonly _claimableSwapStates = [FromBTCLNAutoSwapState.CLAIM_COMMITED];
|
|
93
|
+
/**
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
readonly _swapDeserializer = FromBTCLNAutoSwap;
|
|
97
|
+
/**
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
readonly _messenger: Messenger;
|
|
63
101
|
|
|
64
102
|
/**
|
|
65
103
|
* @param chainIdentifier
|
|
@@ -98,26 +136,16 @@ export class FromBTCLNAutoWrapper<
|
|
|
98
136
|
},
|
|
99
137
|
events
|
|
100
138
|
);
|
|
101
|
-
this.
|
|
139
|
+
this._messenger = messenger;
|
|
102
140
|
}
|
|
103
141
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
FromBTCLNAutoSwapState.CLAIM_COMMITED,
|
|
109
|
-
FromBTCLNAutoSwapState.EXPIRED
|
|
110
|
-
];
|
|
111
|
-
public readonly tickSwapState = [
|
|
112
|
-
FromBTCLNAutoSwapState.PR_CREATED,
|
|
113
|
-
FromBTCLNAutoSwapState.QUOTE_SOFT_EXPIRED,
|
|
114
|
-
FromBTCLNAutoSwapState.PR_PAID,
|
|
115
|
-
FromBTCLNAutoSwapState.CLAIM_COMMITED
|
|
116
|
-
];
|
|
117
|
-
|
|
142
|
+
/**
|
|
143
|
+
* @inheritDoc
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
118
146
|
protected async processEventInitialize(swap: FromBTCLNAutoSwap<T>, event: InitializeEvent<T["Data"]>): Promise<boolean> {
|
|
119
|
-
if(swap.
|
|
120
|
-
if(swap.
|
|
147
|
+
if(swap._state===FromBTCLNAutoSwapState.PR_PAID || swap._state===FromBTCLNAutoSwapState.PR_CREATED || swap._state===FromBTCLNAutoSwapState.QUOTE_SOFT_EXPIRED) {
|
|
148
|
+
if(swap._data==null) {
|
|
121
149
|
//Obtain data from the initialize event
|
|
122
150
|
const eventData = await event.swapData();
|
|
123
151
|
if(eventData==null) {
|
|
@@ -138,8 +166,8 @@ export class FromBTCLNAutoWrapper<
|
|
|
138
166
|
return false;
|
|
139
167
|
}
|
|
140
168
|
|
|
141
|
-
swap.
|
|
142
|
-
swap.
|
|
169
|
+
swap._commitTxId = event.meta?.txId;
|
|
170
|
+
swap._state = FromBTCLNAutoSwapState.CLAIM_COMMITED;
|
|
143
171
|
swap._broadcastSecret().catch(e => {
|
|
144
172
|
this.logger.error("processEventInitialize("+swap.getId()+"): Error when broadcasting swap secret: ", e);
|
|
145
173
|
});
|
|
@@ -148,19 +176,28 @@ export class FromBTCLNAutoWrapper<
|
|
|
148
176
|
return false;
|
|
149
177
|
}
|
|
150
178
|
|
|
179
|
+
/**
|
|
180
|
+
* @inheritDoc
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
151
183
|
protected processEventClaim(swap: FromBTCLNAutoSwap<T>, event: ClaimEvent<T["Data"]>): Promise<boolean> {
|
|
152
|
-
if(swap.
|
|
153
|
-
swap.
|
|
154
|
-
swap.
|
|
184
|
+
if(swap._state!==FromBTCLNAutoSwapState.FAILED && swap._state!==FromBTCLNAutoSwapState.CLAIM_CLAIMED) {
|
|
185
|
+
swap._claimTxId = event.meta?.txId;
|
|
186
|
+
swap._state = FromBTCLNAutoSwapState.CLAIM_CLAIMED;
|
|
187
|
+
swap._setSwapSecret(event.result);
|
|
155
188
|
return Promise.resolve(true);
|
|
156
189
|
}
|
|
157
190
|
return Promise.resolve(false);
|
|
158
191
|
}
|
|
159
192
|
|
|
193
|
+
/**
|
|
194
|
+
* @inheritDoc
|
|
195
|
+
* @internal
|
|
196
|
+
*/
|
|
160
197
|
protected processEventRefund(swap: FromBTCLNAutoSwap<T>, event: RefundEvent<T["Data"]>): Promise<boolean> {
|
|
161
|
-
if(swap.
|
|
162
|
-
swap.
|
|
163
|
-
swap.
|
|
198
|
+
if(swap._state!==FromBTCLNAutoSwapState.CLAIM_CLAIMED && swap._state!==FromBTCLNAutoSwapState.FAILED) {
|
|
199
|
+
swap._refundTxId ??= event.meta?.txId;
|
|
200
|
+
swap._state = FromBTCLNAutoSwapState.FAILED;
|
|
164
201
|
return Promise.resolve(true);
|
|
165
202
|
}
|
|
166
203
|
return Promise.resolve(false);
|
|
@@ -174,6 +211,7 @@ export class FromBTCLNAutoWrapper<
|
|
|
174
211
|
* @param amountData
|
|
175
212
|
* @param options Options as passed to the swap creation function
|
|
176
213
|
* @param abortController
|
|
214
|
+
*
|
|
177
215
|
* @private
|
|
178
216
|
*/
|
|
179
217
|
private async preFetchClaimerBounty(
|
|
@@ -185,15 +223,15 @@ export class FromBTCLNAutoWrapper<
|
|
|
185
223
|
if(options.unsafeZeroWatchtowerFee) return 0n;
|
|
186
224
|
|
|
187
225
|
const dummyAmount = BigInt(Math.floor(Math.random()* 0x1000000));
|
|
188
|
-
const dummySwapData = await this.
|
|
189
|
-
ChainSwapType.HTLC, this.
|
|
190
|
-
dummyAmount, this.
|
|
226
|
+
const dummySwapData = await this._contract.createSwapData(
|
|
227
|
+
ChainSwapType.HTLC, this._chain.randomAddress(), signer, amountData.token,
|
|
228
|
+
dummyAmount, this._contract.getHashForHtlc(randomBytes(32)).toString("hex"),
|
|
191
229
|
this.getRandomSequence(), BigInt(Math.floor(Date.now()/1000)), false, true,
|
|
192
230
|
BigInt(Math.floor(Math.random() * 0x10000)), BigInt(Math.floor(Math.random() * 0x10000))
|
|
193
231
|
);
|
|
194
232
|
|
|
195
233
|
try {
|
|
196
|
-
const result = await this.
|
|
234
|
+
const result = await this._contract.getClaimFee(this._chain.randomAddress(), dummySwapData);
|
|
197
235
|
return result * BigInt(Math.floor(options.feeSafetyFactor*1000000)) / 1_000_000n
|
|
198
236
|
} catch (e) {
|
|
199
237
|
abortController.abort(e);
|
|
@@ -210,8 +248,10 @@ export class FromBTCLNAutoWrapper<
|
|
|
210
248
|
* @param decodedPr Decoded bolt11 lightning network invoice
|
|
211
249
|
* @param paymentHash Expected payment hash of the bolt11 lightning network invoice
|
|
212
250
|
* @param claimerBounty Claimer bounty as request by the user
|
|
213
|
-
*
|
|
251
|
+
*
|
|
214
252
|
* @throws {IntermediaryError} in case the response is invalid
|
|
253
|
+
*
|
|
254
|
+
* @private
|
|
215
255
|
*/
|
|
216
256
|
private verifyReturnedData(
|
|
217
257
|
resp: FromBTCLNAutoResponseType,
|
|
@@ -247,18 +287,21 @@ export class FromBTCLNAutoWrapper<
|
|
|
247
287
|
}
|
|
248
288
|
|
|
249
289
|
/**
|
|
250
|
-
* Returns a newly created swap
|
|
290
|
+
* Returns a newly created Lightning -> Smart chain swap using the HTLC based escrow swap protocol,
|
|
291
|
+
* where watchtowers handle the automatic settlement of the swap on the destination chain. Also allows
|
|
292
|
+
* specifying additional "gas drop" native token that the receipient receives on the destination chain
|
|
293
|
+
* in the `options` argument. The user has to pay a bolt11 invoice on the input lightning network side.
|
|
251
294
|
*
|
|
252
|
-
* @param
|
|
253
|
-
* @param amountData
|
|
254
|
-
* @param lps
|
|
255
|
-
* @param options
|
|
256
|
-
* @param additionalParams
|
|
257
|
-
* @param abortSignal
|
|
258
|
-
* @param preFetches
|
|
295
|
+
* @param recipient Recipient's address on the destination chain
|
|
296
|
+
* @param amountData Amount, token and exact input/output data for to swap
|
|
297
|
+
* @param lps An array of intermediaries (LPs) to get the quotes from
|
|
298
|
+
* @param options Optional additional quote options
|
|
299
|
+
* @param additionalParams Optional additional parameters sent to the LP when creating the swap
|
|
300
|
+
* @param abortSignal Abort signal
|
|
301
|
+
* @param preFetches Optional pre-fetches for speeding up the quoting process (mainly used internally)
|
|
259
302
|
*/
|
|
260
303
|
create(
|
|
261
|
-
|
|
304
|
+
recipient: string,
|
|
262
305
|
amountData: AmountData,
|
|
263
306
|
lps: Intermediary[],
|
|
264
307
|
options?: FromBTCLNAutoOptions,
|
|
@@ -275,7 +318,7 @@ export class FromBTCLNAutoWrapper<
|
|
|
275
318
|
intermediary: Intermediary
|
|
276
319
|
}[] {
|
|
277
320
|
const _options = {
|
|
278
|
-
unsafeSkipLnNodeCheck: options?.unsafeSkipLnNodeCheck ?? this.
|
|
321
|
+
unsafeSkipLnNodeCheck: options?.unsafeSkipLnNodeCheck ?? this._options.unsafeSkipLnNodeCheck,
|
|
279
322
|
gasAmount: options?.gasAmount ?? 0n,
|
|
280
323
|
feeSafetyFactor: options?.feeSafetyFactor ?? 1.25, //No need to add much of a margin, since the claim should happen rather soon
|
|
281
324
|
unsafeZeroWatchtowerFee: options?.unsafeZeroWatchtowerFee ?? false,
|
|
@@ -288,15 +331,15 @@ export class FromBTCLNAutoWrapper<
|
|
|
288
331
|
throw new UserError("Invalid description hash length");
|
|
289
332
|
|
|
290
333
|
const {secret, paymentHash} = this.getSecretAndHash();
|
|
291
|
-
const claimHash = this.
|
|
334
|
+
const claimHash = this._contract.getHashForHtlc(paymentHash);
|
|
292
335
|
|
|
293
|
-
const nativeTokenAddress = this.
|
|
336
|
+
const nativeTokenAddress = this._chain.getNativeCurrencyAddress();
|
|
294
337
|
|
|
295
338
|
const _abortController = extendAbortController(abortSignal);
|
|
296
339
|
const _preFetches = {
|
|
297
340
|
pricePrefetchPromise: preFetches?.pricePrefetchPromise ?? this.preFetchPrice(amountData, _abortController.signal),
|
|
298
341
|
usdPricePrefetchPromise: preFetches?.usdPricePrefetchPromise ?? this.preFetchUsdPrice(_abortController.signal),
|
|
299
|
-
claimerBountyPrefetch: preFetches?.claimerBountyPrefetch ?? this.preFetchClaimerBounty(
|
|
342
|
+
claimerBountyPrefetch: preFetches?.claimerBountyPrefetch ?? this.preFetchClaimerBounty(recipient, amountData, _options, _abortController),
|
|
300
343
|
gasTokenPricePrefetchPromise: _options.gasAmount!==0n || !_options.unsafeZeroWatchtowerFee ?
|
|
301
344
|
(preFetches.gasTokenPricePrefetchPromise ??= this.preFetchPrice({token: nativeTokenAddress}, _abortController.signal)) :
|
|
302
345
|
undefined
|
|
@@ -318,16 +361,16 @@ export class FromBTCLNAutoWrapper<
|
|
|
318
361
|
{
|
|
319
362
|
paymentHash,
|
|
320
363
|
amount: amountData.amount,
|
|
321
|
-
claimer:
|
|
364
|
+
claimer: recipient,
|
|
322
365
|
token: amountData.token.toString(),
|
|
323
366
|
descriptionHash: _options.descriptionHash,
|
|
324
367
|
exactOut: !amountData.exactIn,
|
|
325
368
|
additionalParams,
|
|
326
|
-
gasToken: this.
|
|
369
|
+
gasToken: this._chain.getNativeCurrencyAddress(),
|
|
327
370
|
gasAmount: _options.gasAmount,
|
|
328
371
|
claimerBounty: throwIfUndefined(_preFetches.claimerBountyPrefetch)
|
|
329
372
|
},
|
|
330
|
-
this.
|
|
373
|
+
this._options.postRequestTimeout, abortController.signal, retryCount>0 ? false : undefined
|
|
331
374
|
);
|
|
332
375
|
|
|
333
376
|
return {
|
|
@@ -377,8 +420,8 @@ export class FromBTCLNAutoWrapper<
|
|
|
377
420
|
|
|
378
421
|
gasPricingInfo,
|
|
379
422
|
|
|
380
|
-
initialSwapData: await this.
|
|
381
|
-
ChainSwapType.HTLC, lp.getAddress(this.chainIdentifier),
|
|
423
|
+
initialSwapData: await this._contract.createSwapData(
|
|
424
|
+
ChainSwapType.HTLC, lp.getAddress(this.chainIdentifier), recipient, amountData.token,
|
|
382
425
|
resp.total, claimHash.toString("hex"),
|
|
383
426
|
this.getRandomSequence(), BigInt(Math.floor(Date.now()/1000)), false, true,
|
|
384
427
|
_options.gasAmount + resp.claimerBounty, resp.claimerBounty, nativeTokenAddress
|
|
@@ -401,18 +444,23 @@ export class FromBTCLNAutoWrapper<
|
|
|
401
444
|
}
|
|
402
445
|
|
|
403
446
|
/**
|
|
404
|
-
* Returns a newly created
|
|
447
|
+
* Returns a newly created Lightning -> Smart chain swap using the HTLC based escrow swap protocol,
|
|
448
|
+
* where watchtowers handle the automatic settlement of the swap on the destination chain. Also allows
|
|
449
|
+
* specifying additional "gas drop" native token that the receipient receives on the destination chain
|
|
450
|
+
* in the `options` argument. The swap is created with an LNURL-withdraw link which will be used to pay
|
|
451
|
+
* the generated bolt11 invoice automatically when {@link FromBTCLNSwap.waitForPayment} is called on the
|
|
452
|
+
* swap.
|
|
405
453
|
*
|
|
406
|
-
* @param
|
|
407
|
-
* @param lnurl
|
|
408
|
-
* @param amountData
|
|
409
|
-
* @param lps
|
|
410
|
-
* @param options
|
|
411
|
-
* @param additionalParams
|
|
412
|
-
* @param abortSignal
|
|
454
|
+
* @param recipient Recipient's address on the destination chain
|
|
455
|
+
* @param lnurl LNURL-withdraw link to pull the funds from
|
|
456
|
+
* @param amountData Amount, token and exact input/output data for to swap
|
|
457
|
+
* @param lps An array of intermediaries (LPs) to get the quotes from
|
|
458
|
+
* @param options Optional additional quote options
|
|
459
|
+
* @param additionalParams Optional additional parameters sent to the LP when creating the swap
|
|
460
|
+
* @param abortSignal Abort signal
|
|
413
461
|
*/
|
|
414
462
|
async createViaLNURL(
|
|
415
|
-
|
|
463
|
+
recipient: string,
|
|
416
464
|
lnurl: string | LNURLWithdrawParamsWithUrl,
|
|
417
465
|
amountData: AmountData,
|
|
418
466
|
lps: Intermediary[],
|
|
@@ -424,7 +472,7 @@ export class FromBTCLNAutoWrapper<
|
|
|
424
472
|
intermediary: Intermediary
|
|
425
473
|
}[]> {
|
|
426
474
|
const _options = {
|
|
427
|
-
unsafeSkipLnNodeCheck: options?.unsafeSkipLnNodeCheck ?? this.
|
|
475
|
+
unsafeSkipLnNodeCheck: options?.unsafeSkipLnNodeCheck ?? this._options.unsafeSkipLnNodeCheck,
|
|
428
476
|
gasAmount: options?.gasAmount ?? 0n,
|
|
429
477
|
feeSafetyFactor: options?.feeSafetyFactor ?? 1.25, //No need to add much of a margin, since the claim should happen rather soon
|
|
430
478
|
unsafeZeroWatchtowerFee: options?.unsafeZeroWatchtowerFee ?? false,
|
|
@@ -436,14 +484,14 @@ export class FromBTCLNAutoWrapper<
|
|
|
436
484
|
pricePrefetchPromise: this.preFetchPrice(amountData, abortController.signal),
|
|
437
485
|
usdPricePrefetchPromise: this.preFetchUsdPrice(abortController.signal),
|
|
438
486
|
gasTokenPricePrefetchPromise: _options.gasAmount!==0n || !_options.unsafeZeroWatchtowerFee ?
|
|
439
|
-
this.preFetchPrice({token: this.
|
|
487
|
+
this.preFetchPrice({token: this._chain.getNativeCurrencyAddress()}, abortController.signal) :
|
|
440
488
|
undefined,
|
|
441
|
-
claimerBountyPrefetch: this.preFetchClaimerBounty(
|
|
489
|
+
claimerBountyPrefetch: this.preFetchClaimerBounty(recipient, amountData, _options, abortController)
|
|
442
490
|
};
|
|
443
491
|
|
|
444
492
|
try {
|
|
445
493
|
const exactOutAmountPromise: Promise<bigint | undefined> | undefined = !amountData.exactIn ? preFetches.pricePrefetchPromise.then(price =>
|
|
446
|
-
this.
|
|
494
|
+
this._prices.getToBtcSwapAmount(this.chainIdentifier, amountData.amount, amountData.token, abortController.signal, price)
|
|
447
495
|
).catch(e => {
|
|
448
496
|
abortController.abort(e);
|
|
449
497
|
return undefined;
|
|
@@ -465,12 +513,14 @@ export class FromBTCLNAutoWrapper<
|
|
|
465
513
|
if((amount * 105n / 100n) > max) throw new UserError("Amount more than LNURL-withdraw maximum");
|
|
466
514
|
}
|
|
467
515
|
|
|
468
|
-
return this.create(
|
|
516
|
+
return this.create(recipient, amountData, lps, _options, additionalParams, abortSignal, preFetches).map(data => {
|
|
469
517
|
return {
|
|
470
518
|
quote: data.quote.then(quote => {
|
|
471
|
-
quote.
|
|
472
|
-
|
|
473
|
-
|
|
519
|
+
quote._setLNURLData(
|
|
520
|
+
withdrawRequest.url,
|
|
521
|
+
withdrawRequest.k1,
|
|
522
|
+
withdrawRequest.callback
|
|
523
|
+
);
|
|
474
524
|
|
|
475
525
|
const amountIn = quote.getInput().rawAmount!;
|
|
476
526
|
if(amountIn < min) throw new UserError("Amount less than LNURL-withdraw minimum");
|
|
@@ -487,6 +537,10 @@ export class FromBTCLNAutoWrapper<
|
|
|
487
537
|
}
|
|
488
538
|
}
|
|
489
539
|
|
|
540
|
+
/**
|
|
541
|
+
* @inheritDoc
|
|
542
|
+
* @internal
|
|
543
|
+
*/
|
|
490
544
|
protected async _checkPastSwaps(pastSwaps: FromBTCLNAutoSwap<T>[]): Promise<{
|
|
491
545
|
changedSwaps: FromBTCLNAutoSwap<T>[];
|
|
492
546
|
removeSwaps: FromBTCLNAutoSwap<T>[]
|
|
@@ -494,7 +548,7 @@ export class FromBTCLNAutoWrapper<
|
|
|
494
548
|
const changedSwapSet: Set<FromBTCLNAutoSwap<T>> = new Set();
|
|
495
549
|
|
|
496
550
|
const swapExpiredStatus: {[id: string]: boolean} = {};
|
|
497
|
-
const checkStatusSwaps: (FromBTCLNAutoSwap<T> & {
|
|
551
|
+
const checkStatusSwaps: (FromBTCLNAutoSwap<T> & {_data: T["Data"]})[] = [];
|
|
498
552
|
|
|
499
553
|
await Promise.all(pastSwaps.map(async (pastSwap) => {
|
|
500
554
|
if(pastSwap._shouldCheckIntermediary()) {
|
|
@@ -511,13 +565,13 @@ export class FromBTCLNAutoWrapper<
|
|
|
511
565
|
//Check expiry
|
|
512
566
|
swapExpiredStatus[pastSwap.getId()] = await pastSwap._verifyQuoteDefinitelyExpired();
|
|
513
567
|
}
|
|
514
|
-
if(pastSwap.
|
|
568
|
+
if(pastSwap._shouldFetchOnchainState()) {
|
|
515
569
|
//Add to swaps for which status should be checked
|
|
516
|
-
if(pastSwap.
|
|
570
|
+
if(pastSwap._data!=null) checkStatusSwaps.push(pastSwap as FromBTCLNAutoSwap<T> & {_data: T["Data"]});
|
|
517
571
|
}
|
|
518
572
|
}));
|
|
519
573
|
|
|
520
|
-
const swapStatuses = await this.
|
|
574
|
+
const swapStatuses = await this._contract.getCommitStatuses(checkStatusSwaps.map(val => ({signer: val._getInitiator(), swapData: val._data})));
|
|
521
575
|
|
|
522
576
|
for(let pastSwap of checkStatusSwaps) {
|
|
523
577
|
const shouldSave = await pastSwap._sync(
|
|
@@ -545,4 +599,53 @@ export class FromBTCLNAutoWrapper<
|
|
|
545
599
|
};
|
|
546
600
|
}
|
|
547
601
|
|
|
602
|
+
/**
|
|
603
|
+
* @inheritDoc
|
|
604
|
+
*/
|
|
605
|
+
async recoverFromSwapDataAndState(
|
|
606
|
+
init: {data: T["Data"], getInitTxId: () => Promise<string>, getTxBlock: () => Promise<{blockTime: number, blockHeight: number}>},
|
|
607
|
+
state: SwapCommitState,
|
|
608
|
+
lp?: Intermediary
|
|
609
|
+
): Promise<FromBTCLNAutoSwap<T> | null> {
|
|
610
|
+
const data = init.data;
|
|
611
|
+
|
|
612
|
+
let paymentHash = data.getHTLCHashHint();
|
|
613
|
+
let secret: string | undefined;
|
|
614
|
+
if(state.type===SwapCommitStateType.PAID) {
|
|
615
|
+
secret = await state.getClaimResult();
|
|
616
|
+
paymentHash = Buffer.from(sha256(Buffer.from(secret, "hex"))).toString("hex");
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
const swapInit: FromBTCLNAutoSwapInit<T["Data"]> = {
|
|
620
|
+
pricingInfo: {
|
|
621
|
+
isValid: true,
|
|
622
|
+
satsBaseFee: 0n,
|
|
623
|
+
swapPriceUSatPerToken: 100_000_000_000_000n,
|
|
624
|
+
realPriceUSatPerToken: 100_000_000_000_000n,
|
|
625
|
+
differencePPM: 0n,
|
|
626
|
+
feePPM: 0n,
|
|
627
|
+
},
|
|
628
|
+
url: lp?.url,
|
|
629
|
+
expiry: 0,
|
|
630
|
+
swapFee: 0n,
|
|
631
|
+
swapFeeBtc: 0n,
|
|
632
|
+
gasSwapFee: 0n,
|
|
633
|
+
gasSwapFeeBtc: 0n,
|
|
634
|
+
initialSwapData: data,
|
|
635
|
+
data,
|
|
636
|
+
pr: paymentHash ?? undefined,
|
|
637
|
+
secret,
|
|
638
|
+
exactIn: false
|
|
639
|
+
}
|
|
640
|
+
const swap = new FromBTCLNAutoSwap(this, swapInit);
|
|
641
|
+
swap._commitTxId = await init.getInitTxId();
|
|
642
|
+
const blockData = await init.getTxBlock();
|
|
643
|
+
swap.createdAt = blockData.blockTime * 1000;
|
|
644
|
+
swap._setInitiated();
|
|
645
|
+
swap._state = FromBTCLNAutoSwapState.CLAIM_COMMITED;
|
|
646
|
+
await swap._sync(false, false, state);
|
|
647
|
+
await swap._save();
|
|
648
|
+
return swap;
|
|
649
|
+
}
|
|
650
|
+
|
|
548
651
|
}
|