@atomiqlabs/lp-lib 17.5.1 → 17.5.2
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/LICENSE +201 -201
- package/dist/fees/IBtcFeeEstimator.d.ts +3 -3
- package/dist/fees/IBtcFeeEstimator.js +2 -2
- package/dist/index.d.ts +43 -43
- package/dist/index.js +59 -59
- package/dist/info/InfoHandler.d.ts +17 -17
- package/dist/info/InfoHandler.js +61 -61
- package/dist/plugins/IPlugin.d.ts +158 -158
- package/dist/plugins/IPlugin.js +35 -35
- package/dist/plugins/PluginManager.d.ts +115 -115
- package/dist/plugins/PluginManager.js +304 -304
- package/dist/prices/BinanceSwapPrice.d.ts +29 -29
- package/dist/prices/BinanceSwapPrice.js +79 -79
- package/dist/prices/CoinGeckoSwapPrice.d.ts +33 -33
- package/dist/prices/CoinGeckoSwapPrice.js +51 -51
- package/dist/prices/ISwapPrice.d.ts +43 -43
- package/dist/prices/ISwapPrice.js +55 -55
- package/dist/prices/OKXSwapPrice.d.ts +29 -29
- package/dist/prices/OKXSwapPrice.js +79 -79
- package/dist/storage/IIntermediaryStorage.d.ts +18 -18
- package/dist/storage/IIntermediaryStorage.js +2 -2
- package/dist/storagemanager/IntermediaryStorageManager.d.ts +19 -19
- package/dist/storagemanager/IntermediaryStorageManager.js +111 -111
- package/dist/storagemanager/StorageManager.d.ts +13 -13
- package/dist/storagemanager/StorageManager.js +64 -64
- package/dist/swaps/SwapHandler.d.ts +178 -178
- package/dist/swaps/SwapHandler.js +225 -225
- package/dist/swaps/SwapHandlerSwap.d.ts +80 -80
- package/dist/swaps/SwapHandlerSwap.js +78 -78
- package/dist/swaps/assertions/AmountAssertions.d.ts +37 -37
- package/dist/swaps/assertions/AmountAssertions.js +83 -83
- package/dist/swaps/assertions/FromBtcAmountAssertions.d.ts +76 -76
- package/dist/swaps/assertions/FromBtcAmountAssertions.js +189 -189
- package/dist/swaps/assertions/LightningAssertions.d.ts +44 -44
- package/dist/swaps/assertions/LightningAssertions.js +86 -86
- package/dist/swaps/assertions/ToBtcAmountAssertions.d.ts +53 -53
- package/dist/swaps/assertions/ToBtcAmountAssertions.js +154 -154
- package/dist/swaps/escrow/EscrowHandler.d.ts +50 -50
- package/dist/swaps/escrow/EscrowHandler.js +151 -151
- package/dist/swaps/escrow/EscrowHandlerSwap.d.ts +35 -35
- package/dist/swaps/escrow/EscrowHandlerSwap.js +69 -69
- package/dist/swaps/escrow/FromBtcBaseSwap.d.ts +14 -14
- package/dist/swaps/escrow/FromBtcBaseSwap.js +32 -32
- package/dist/swaps/escrow/FromBtcBaseSwapHandler.d.ts +102 -102
- package/dist/swaps/escrow/FromBtcBaseSwapHandler.js +210 -210
- package/dist/swaps/escrow/ToBtcBaseSwap.d.ts +36 -36
- package/dist/swaps/escrow/ToBtcBaseSwap.js +67 -67
- package/dist/swaps/escrow/ToBtcBaseSwapHandler.d.ts +53 -53
- package/dist/swaps/escrow/ToBtcBaseSwapHandler.js +81 -81
- package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.d.ts +84 -84
- package/dist/swaps/escrow/frombtc_abstract/FromBtcAbs.js +329 -329
- package/dist/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.d.ts +22 -22
- package/dist/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.js +53 -53
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.d.ts +115 -115
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.js +719 -719
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +34 -34
- package/dist/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.js +94 -94
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.d.ts +119 -119
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.js +730 -730
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.d.ts +56 -56
- package/dist/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.js +123 -123
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.d.ts +170 -170
- package/dist/swaps/escrow/tobtc_abstract/ToBtcAbs.js +769 -769
- package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.d.ts +29 -29
- package/dist/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.js +67 -67
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.d.ts +178 -178
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.js +912 -912
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +25 -25
- package/dist/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.js +61 -61
- package/dist/swaps/spv_vault_swap/SpvVault.d.ts +45 -45
- package/dist/swaps/spv_vault_swap/SpvVault.js +148 -148
- package/dist/swaps/spv_vault_swap/SpvVaultSwap.d.ts +71 -71
- package/dist/swaps/spv_vault_swap/SpvVaultSwap.js +165 -165
- package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.d.ts +72 -72
- package/dist/swaps/spv_vault_swap/SpvVaultSwapHandler.js +710 -710
- package/dist/swaps/spv_vault_swap/SpvVaults.d.ts +70 -70
- package/dist/swaps/spv_vault_swap/SpvVaults.js +554 -554
- package/dist/swaps/spv_vault_swap/StickyAddress.d.ts +6 -6
- package/dist/swaps/spv_vault_swap/StickyAddress.js +19 -19
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.d.ts +52 -52
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrusted.js +677 -677
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.d.ts +53 -53
- package/dist/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.js +121 -121
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.d.ts +77 -77
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.js +518 -518
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +35 -35
- package/dist/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.js +84 -84
- package/dist/utils/BitcoinUtils.d.ts +4 -4
- package/dist/utils/BitcoinUtils.js +61 -61
- package/dist/utils/Utils.d.ts +32 -32
- package/dist/utils/Utils.js +130 -130
- package/dist/utils/paramcoders/IParamReader.d.ts +5 -5
- package/dist/utils/paramcoders/IParamReader.js +2 -2
- package/dist/utils/paramcoders/IParamWriter.d.ts +4 -4
- package/dist/utils/paramcoders/IParamWriter.js +2 -2
- package/dist/utils/paramcoders/LegacyParamEncoder.d.ts +10 -10
- package/dist/utils/paramcoders/LegacyParamEncoder.js +22 -22
- package/dist/utils/paramcoders/ParamDecoder.d.ts +25 -25
- package/dist/utils/paramcoders/ParamDecoder.js +222 -222
- package/dist/utils/paramcoders/ParamEncoder.d.ts +9 -9
- package/dist/utils/paramcoders/ParamEncoder.js +22 -22
- package/dist/utils/paramcoders/SchemaVerifier.d.ts +21 -21
- package/dist/utils/paramcoders/SchemaVerifier.js +84 -84
- package/dist/utils/paramcoders/server/ServerParamDecoder.d.ts +8 -8
- package/dist/utils/paramcoders/server/ServerParamDecoder.js +107 -107
- package/dist/utils/paramcoders/server/ServerParamEncoder.d.ts +11 -11
- package/dist/utils/paramcoders/server/ServerParamEncoder.js +65 -65
- package/dist/wallets/IBitcoinWallet.d.ts +155 -155
- package/dist/wallets/IBitcoinWallet.js +100 -100
- package/dist/wallets/ILightningWallet.d.ts +137 -137
- package/dist/wallets/ILightningWallet.js +37 -37
- package/dist/wallets/ISpvVaultSigner.d.ts +7 -7
- package/dist/wallets/ISpvVaultSigner.js +2 -2
- package/package.json +37 -37
- package/src/fees/IBtcFeeEstimator.ts +6 -6
- package/src/index.ts +54 -54
- package/src/info/InfoHandler.ts +106 -106
- package/src/plugins/IPlugin.ts +196 -196
- package/src/plugins/PluginManager.ts +389 -389
- package/src/prices/BinanceSwapPrice.ts +101 -101
- package/src/prices/CoinGeckoSwapPrice.ts +75 -75
- package/src/prices/ISwapPrice.ts +88 -88
- package/src/prices/OKXSwapPrice.ts +101 -101
- package/src/storage/IIntermediaryStorage.ts +19 -19
- package/src/storagemanager/IntermediaryStorageManager.ts +118 -118
- package/src/storagemanager/StorageManager.ts +78 -78
- package/src/swaps/SwapHandler.ts +337 -337
- package/src/swaps/SwapHandlerSwap.ts +143 -143
- package/src/swaps/assertions/AmountAssertions.ts +97 -97
- package/src/swaps/assertions/FromBtcAmountAssertions.ts +257 -257
- package/src/swaps/assertions/LightningAssertions.ts +103 -103
- package/src/swaps/assertions/ToBtcAmountAssertions.ts +209 -209
- package/src/swaps/escrow/EscrowHandler.ts +172 -172
- package/src/swaps/escrow/EscrowHandlerSwap.ts +86 -86
- package/src/swaps/escrow/FromBtcBaseSwap.ts +38 -38
- package/src/swaps/escrow/FromBtcBaseSwapHandler.ts +286 -286
- package/src/swaps/escrow/ToBtcBaseSwap.ts +85 -85
- package/src/swaps/escrow/ToBtcBaseSwapHandler.ts +129 -129
- package/src/swaps/escrow/frombtc_abstract/FromBtcAbs.ts +468 -468
- package/src/swaps/escrow/frombtc_abstract/FromBtcSwapAbs.ts +65 -65
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnAbs.ts +900 -900
- package/src/swaps/escrow/frombtcln_abstract/FromBtcLnSwapAbs.ts +145 -145
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAuto.ts +892 -892
- package/src/swaps/escrow/frombtcln_autoinit/FromBtcLnAutoSwap.ts +200 -200
- package/src/swaps/escrow/tobtc_abstract/ToBtcAbs.ts +947 -947
- package/src/swaps/escrow/tobtc_abstract/ToBtcSwapAbs.ts +112 -112
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnAbs.ts +1167 -1167
- package/src/swaps/escrow/tobtcln_abstract/ToBtcLnSwapAbs.ts +84 -84
- package/src/swaps/spv_vault_swap/SpvVault.ts +182 -182
- package/src/swaps/spv_vault_swap/SpvVaultSwap.ts +239 -239
- package/src/swaps/spv_vault_swap/SpvVaultSwapHandler.ts +897 -897
- package/src/swaps/spv_vault_swap/SpvVaults.ts +640 -640
- package/src/swaps/spv_vault_swap/StickyAddress.ts +20 -20
- package/src/swaps/trusted/frombtc_trusted/FromBtcTrusted.ts +782 -782
- package/src/swaps/trusted/frombtc_trusted/FromBtcTrustedSwap.ts +189 -189
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrusted.ts +622 -622
- package/src/swaps/trusted/frombtcln_trusted/FromBtcLnTrustedSwap.ts +125 -125
- package/src/utils/BitcoinUtils.ts +59 -59
- package/src/utils/Utils.ts +152 -152
- package/src/utils/paramcoders/IParamReader.ts +7 -7
- package/src/utils/paramcoders/IParamWriter.ts +8 -8
- package/src/utils/paramcoders/LegacyParamEncoder.ts +27 -27
- package/src/utils/paramcoders/ParamDecoder.ts +218 -218
- package/src/utils/paramcoders/ParamEncoder.ts +29 -29
- package/src/utils/paramcoders/SchemaVerifier.ts +96 -96
- package/src/utils/paramcoders/server/ServerParamDecoder.ts +118 -118
- package/src/utils/paramcoders/server/ServerParamEncoder.ts +75 -75
- package/src/wallets/IBitcoinWallet.ts +246 -246
- package/src/wallets/ILightningWallet.ts +201 -201
- package/src/wallets/ISpvVaultSigner.ts +10 -10
package/src/info/InfoHandler.ts
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import {Express} from "express";
|
|
2
|
-
import {MultichainData, SwapHandler, SwapHandlerInfoType, SwapHandlerType} from "../swaps/SwapHandler";
|
|
3
|
-
import * as express from "express";
|
|
4
|
-
|
|
5
|
-
const HEX_REGEX = /[0-9a-f]+/i;
|
|
6
|
-
|
|
7
|
-
type InfoHandlerResponseEnvelope = {
|
|
8
|
-
nonce: string,
|
|
9
|
-
services: {
|
|
10
|
-
[key in SwapHandlerType]?: SwapHandlerInfoType
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type InfoHandlerResponse = {
|
|
15
|
-
envelope: string,
|
|
16
|
-
chains: {
|
|
17
|
-
[chainIdentifier: string]: {
|
|
18
|
-
address: string,
|
|
19
|
-
signature: string,
|
|
20
|
-
contractVersion: string
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Handles info requests to POST /info returning information about fees, swap params, etc.
|
|
27
|
-
*/
|
|
28
|
-
export class InfoHandler {
|
|
29
|
-
|
|
30
|
-
readonly chainData: MultichainData;
|
|
31
|
-
readonly path: string;
|
|
32
|
-
|
|
33
|
-
readonly swapHandlers: SwapHandler[];
|
|
34
|
-
|
|
35
|
-
constructor(chainData: MultichainData, path: string, swapHandlers: SwapHandler[]) {
|
|
36
|
-
this.chainData = chainData;
|
|
37
|
-
this.path = path;
|
|
38
|
-
this.swapHandlers = swapHandlers;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Adds a listener to POST /info
|
|
43
|
-
*
|
|
44
|
-
* @param restServer
|
|
45
|
-
*/
|
|
46
|
-
startRestServer(restServer: Express) {
|
|
47
|
-
|
|
48
|
-
const infoHandler = async (req, res) => {
|
|
49
|
-
const reqParams = {...req.body, ...req.query};
|
|
50
|
-
|
|
51
|
-
if (
|
|
52
|
-
reqParams.nonce == null ||
|
|
53
|
-
typeof(reqParams.nonce) !== "string" ||
|
|
54
|
-
reqParams.nonce.length>64 ||
|
|
55
|
-
!HEX_REGEX.test(reqParams.nonce)
|
|
56
|
-
) {
|
|
57
|
-
res.status(400).json({
|
|
58
|
-
msg: "Invalid request body (nonce)"
|
|
59
|
-
});
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const env: InfoHandlerResponseEnvelope = {
|
|
64
|
-
nonce: reqParams.nonce,
|
|
65
|
-
services: {}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
for(let swapHandler of this.swapHandlers) {
|
|
69
|
-
env.services[swapHandler.type] = swapHandler.getInfo();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const envelope = JSON.stringify(env);
|
|
73
|
-
const envelopeBuffer = Buffer.from(envelope);
|
|
74
|
-
|
|
75
|
-
const chains: {
|
|
76
|
-
[chainIdentifier: string]: {
|
|
77
|
-
address: string,
|
|
78
|
-
signature: string,
|
|
79
|
-
contractVersion: string
|
|
80
|
-
}
|
|
81
|
-
} = {};
|
|
82
|
-
for(let chainIdentifier in this.chainData.chains) {
|
|
83
|
-
const singleChain = this.chainData.chains[chainIdentifier];
|
|
84
|
-
chains[chainIdentifier] = {
|
|
85
|
-
address: singleChain.signer.getAddress(),
|
|
86
|
-
signature: await singleChain.swapContract.getDataSignature(singleChain.signer, envelopeBuffer),
|
|
87
|
-
contractVersion: singleChain.contractVersion ?? "v1"
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const response: InfoHandlerResponse = {
|
|
92
|
-
envelope,
|
|
93
|
-
chains
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
res.status(200).json(response);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
restServer.use(this.path+"/info", express.json());
|
|
100
|
-
restServer.post(this.path+"/info", infoHandler);
|
|
101
|
-
restServer.get(this.path+"/info", infoHandler);
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
1
|
+
import {Express} from "express";
|
|
2
|
+
import {MultichainData, SwapHandler, SwapHandlerInfoType, SwapHandlerType} from "../swaps/SwapHandler";
|
|
3
|
+
import * as express from "express";
|
|
4
|
+
|
|
5
|
+
const HEX_REGEX = /[0-9a-f]+/i;
|
|
6
|
+
|
|
7
|
+
type InfoHandlerResponseEnvelope = {
|
|
8
|
+
nonce: string,
|
|
9
|
+
services: {
|
|
10
|
+
[key in SwapHandlerType]?: SwapHandlerInfoType
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type InfoHandlerResponse = {
|
|
15
|
+
envelope: string,
|
|
16
|
+
chains: {
|
|
17
|
+
[chainIdentifier: string]: {
|
|
18
|
+
address: string,
|
|
19
|
+
signature: string,
|
|
20
|
+
contractVersion: string
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Handles info requests to POST /info returning information about fees, swap params, etc.
|
|
27
|
+
*/
|
|
28
|
+
export class InfoHandler {
|
|
29
|
+
|
|
30
|
+
readonly chainData: MultichainData;
|
|
31
|
+
readonly path: string;
|
|
32
|
+
|
|
33
|
+
readonly swapHandlers: SwapHandler[];
|
|
34
|
+
|
|
35
|
+
constructor(chainData: MultichainData, path: string, swapHandlers: SwapHandler[]) {
|
|
36
|
+
this.chainData = chainData;
|
|
37
|
+
this.path = path;
|
|
38
|
+
this.swapHandlers = swapHandlers;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Adds a listener to POST /info
|
|
43
|
+
*
|
|
44
|
+
* @param restServer
|
|
45
|
+
*/
|
|
46
|
+
startRestServer(restServer: Express) {
|
|
47
|
+
|
|
48
|
+
const infoHandler = async (req, res) => {
|
|
49
|
+
const reqParams = {...req.body, ...req.query};
|
|
50
|
+
|
|
51
|
+
if (
|
|
52
|
+
reqParams.nonce == null ||
|
|
53
|
+
typeof(reqParams.nonce) !== "string" ||
|
|
54
|
+
reqParams.nonce.length>64 ||
|
|
55
|
+
!HEX_REGEX.test(reqParams.nonce)
|
|
56
|
+
) {
|
|
57
|
+
res.status(400).json({
|
|
58
|
+
msg: "Invalid request body (nonce)"
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const env: InfoHandlerResponseEnvelope = {
|
|
64
|
+
nonce: reqParams.nonce,
|
|
65
|
+
services: {}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
for(let swapHandler of this.swapHandlers) {
|
|
69
|
+
env.services[swapHandler.type] = swapHandler.getInfo();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const envelope = JSON.stringify(env);
|
|
73
|
+
const envelopeBuffer = Buffer.from(envelope);
|
|
74
|
+
|
|
75
|
+
const chains: {
|
|
76
|
+
[chainIdentifier: string]: {
|
|
77
|
+
address: string,
|
|
78
|
+
signature: string,
|
|
79
|
+
contractVersion: string
|
|
80
|
+
}
|
|
81
|
+
} = {};
|
|
82
|
+
for(let chainIdentifier in this.chainData.chains) {
|
|
83
|
+
const singleChain = this.chainData.chains[chainIdentifier];
|
|
84
|
+
chains[chainIdentifier] = {
|
|
85
|
+
address: singleChain.signer.getAddress(),
|
|
86
|
+
signature: await singleChain.swapContract.getDataSignature(singleChain.signer, envelopeBuffer),
|
|
87
|
+
contractVersion: singleChain.contractVersion ?? "v1"
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const response: InfoHandlerResponse = {
|
|
92
|
+
envelope,
|
|
93
|
+
chains
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
res.status(200).json(response);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
restServer.use(this.path+"/info", express.json());
|
|
100
|
+
restServer.post(this.path+"/info", infoHandler);
|
|
101
|
+
restServer.get(this.path+"/info", infoHandler);
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
}
|
package/src/plugins/IPlugin.ts
CHANGED
|
@@ -1,196 +1,196 @@
|
|
|
1
|
-
import {BitcoinRpc} from "@atomiqlabs/base";
|
|
2
|
-
import {
|
|
3
|
-
FromBtcLnAbs, FromBtcLnAutoSwap,
|
|
4
|
-
FromBtcLnRequestType, FromBtcLnSwapAbs, FromBtcLnTrustedSwap,
|
|
5
|
-
FromBtcRequestType, FromBtcSwapAbs, FromBtcTrustedRequestType, FromBtcTrustedSwap,
|
|
6
|
-
ISwapPrice, MultichainData, RequestData, SpvVaultPostQuote, SpvVaultSwap, SpvVaultSwapRequestType,
|
|
7
|
-
SwapHandler, SwapHandlerType,
|
|
8
|
-
ToBtcLnRequestType, ToBtcLnSwapAbs,
|
|
9
|
-
ToBtcRequestType, ToBtcSwapAbs
|
|
10
|
-
} from "..";
|
|
11
|
-
import {SwapHandlerSwap} from "../swaps/SwapHandlerSwap";
|
|
12
|
-
import {Command} from "@atomiqlabs/server-base";
|
|
13
|
-
import {FromBtcLnTrustedRequestType} from "../swaps/trusted/frombtcln_trusted/FromBtcLnTrusted";
|
|
14
|
-
import {IBitcoinWallet} from "../wallets/IBitcoinWallet";
|
|
15
|
-
import {ILightningWallet} from "../wallets/ILightningWallet";
|
|
16
|
-
import {SpvVault} from "../swaps/spv_vault_swap/SpvVault";
|
|
17
|
-
|
|
18
|
-
export type QuoteThrow = {
|
|
19
|
-
type: "throw",
|
|
20
|
-
message: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function isQuoteThrow(obj: any): obj is QuoteThrow {
|
|
24
|
-
return obj!=null && obj.type==="throw" && typeof(obj.message)==="string";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type QuoteSetFees = {
|
|
28
|
-
type: "fees"
|
|
29
|
-
baseFee?: bigint,
|
|
30
|
-
feePPM?: bigint,
|
|
31
|
-
securityDepositApyPPM?: bigint,
|
|
32
|
-
securityDepositBaseMultiplierPPM?: bigint
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export function isQuoteSetFees(obj: any): obj is QuoteSetFees {
|
|
36
|
-
return obj!=null &&
|
|
37
|
-
obj.type==="fees" &&
|
|
38
|
-
(obj.baseFee==null || typeof(obj.baseFee) === "bigint") &&
|
|
39
|
-
(obj.feePPM==null || typeof(obj.feePPM) === "bigint") &&
|
|
40
|
-
(obj.securityDepositApyPPM==null || typeof(obj.securityDepositApyPPM) === "bigint") &&
|
|
41
|
-
(obj.securityDepositBaseMultiplierPPM==null || typeof(obj.securityDepositBaseMultiplierPPM) === "bigint");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type QuoteAmountTooLow = {
|
|
45
|
-
type: "low",
|
|
46
|
-
data: { min: bigint, max: bigint }
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function isQuoteAmountTooLow(obj: any): obj is QuoteAmountTooLow {
|
|
50
|
-
return obj!=null && obj.type==="low" && obj.data!=null && typeof(obj.data)==="object" && typeof(obj.data.min)==="bigint" && typeof(obj.data.max)==="bigint";
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type QuoteAmountTooHigh = {
|
|
54
|
-
type: "high",
|
|
55
|
-
data: { min: bigint, max: bigint }
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function isQuoteAmountTooHigh(obj: any): obj is QuoteAmountTooHigh {
|
|
59
|
-
return obj!=null && obj.type==="high" && obj.data!=null && typeof(obj.data)==="object" && typeof(obj.data.min)==="bigint" && typeof(obj.data.max)==="bigint";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export type PluginQuote = {
|
|
63
|
-
type: "success",
|
|
64
|
-
amount: {input: boolean, amount: bigint},
|
|
65
|
-
swapFee: { inInputTokens: bigint, inOutputTokens: bigint }
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export function isPluginQuote(obj: any): obj is PluginQuote {
|
|
69
|
-
return obj!=null && obj.type==="success" &&
|
|
70
|
-
obj.amount!=null && typeof(obj.amount)==="object" && typeof(obj.amount.input)==="boolean" && typeof(obj.amount.amount)==="bigint" &&
|
|
71
|
-
obj.swapFee!=null && typeof(obj.swapFee)==="object" && typeof(obj.swapFee.inInputTokens)==="bigint" && typeof(obj.swapFee.inOutputTokens)==="bigint";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export type ToBtcPluginQuote = PluginQuote & {
|
|
75
|
-
networkFee: { inInputTokens: bigint, inOutputTokens: bigint }
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function isToBtcPluginQuote(obj: any): obj is ToBtcPluginQuote {
|
|
79
|
-
return obj!=null && obj.networkFee!=null && typeof(obj.networkFee)==="object" && typeof(obj.networkFee.inInputTokens)==="bigint" && typeof(obj.networkFee.inOutputTokens)==="bigint" &&
|
|
80
|
-
isPluginQuote(obj);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export interface IPlugin {
|
|
84
|
-
|
|
85
|
-
name: string;
|
|
86
|
-
author: string;
|
|
87
|
-
description: string;
|
|
88
|
-
|
|
89
|
-
//Needs to be called by implementation
|
|
90
|
-
onEnable(
|
|
91
|
-
chainsData: MultichainData,
|
|
92
|
-
|
|
93
|
-
bitcoinRpc: BitcoinRpc<any>,
|
|
94
|
-
bitcoinWallet: IBitcoinWallet,
|
|
95
|
-
lightningWallet: ILightningWallet,
|
|
96
|
-
|
|
97
|
-
swapPricing: ISwapPrice,
|
|
98
|
-
tokens: {
|
|
99
|
-
[chainId: string]: {
|
|
100
|
-
[ticker: string]: {
|
|
101
|
-
address: string,
|
|
102
|
-
decimals: number
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
directory: string
|
|
108
|
-
): Promise<void>;
|
|
109
|
-
onDisable(): Promise<void>;
|
|
110
|
-
|
|
111
|
-
//Called in the library
|
|
112
|
-
onServiceInitialize(service: SwapHandler<any>): Promise<void>;
|
|
113
|
-
|
|
114
|
-
onHttpServerStarted?(expressServer: any): Promise<void>;
|
|
115
|
-
|
|
116
|
-
onSwapStateChange?(swap: SwapHandlerSwap): Promise<void>;
|
|
117
|
-
onSwapCreate?(swap: SwapHandlerSwap): Promise<void>;
|
|
118
|
-
onSwapRemove?(swap: SwapHandlerSwap): Promise<void>;
|
|
119
|
-
|
|
120
|
-
onHandlePreFromBtcQuote?(
|
|
121
|
-
swapType: SwapHandlerType.FROM_BTCLN | SwapHandlerType.FROM_BTC | SwapHandlerType.FROM_BTCLN_TRUSTED | SwapHandlerType.FROM_BTC_TRUSTED | SwapHandlerType.FROM_BTC_SPV | SwapHandlerType.FROM_BTCLN_AUTO,
|
|
122
|
-
request: RequestData<FromBtcLnRequestType | FromBtcRequestType | FromBtcLnTrustedRequestType | FromBtcTrustedRequestType | SpvVaultSwapRequestType>,
|
|
123
|
-
requestedAmount: {input: boolean, amount: bigint, token: string},
|
|
124
|
-
chainIdentifier: string,
|
|
125
|
-
constraints: {minInBtc: bigint, maxInBtc: bigint},
|
|
126
|
-
fees: {baseFeeInBtc: bigint, feePPM: bigint},
|
|
127
|
-
gasTokenAmount?: {input: false, amount: bigint, token: string}
|
|
128
|
-
): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh>;
|
|
129
|
-
onHandlePostFromBtcQuote?(
|
|
130
|
-
swapType: SwapHandlerType.FROM_BTCLN | SwapHandlerType.FROM_BTC | SwapHandlerType.FROM_BTCLN_TRUSTED | SwapHandlerType.FROM_BTC_TRUSTED | SwapHandlerType.FROM_BTC_SPV | SwapHandlerType.FROM_BTCLN_AUTO,
|
|
131
|
-
request: RequestData<FromBtcLnRequestType | FromBtcRequestType | FromBtcLnTrustedRequestType | FromBtcTrustedRequestType | SpvVaultSwapRequestType>,
|
|
132
|
-
requestedAmount: {input: boolean, amount: bigint, token: string, pricePrefetch?: Promise<bigint>},
|
|
133
|
-
chainIdentifier: string,
|
|
134
|
-
constraints: {minInBtc: bigint, maxInBtc: bigint},
|
|
135
|
-
fees: {baseFeeInBtc: bigint, feePPM: bigint},
|
|
136
|
-
gasTokenAmount?: {input: false, amount: bigint, token: string, pricePrefetch?: Promise<bigint>}
|
|
137
|
-
): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh | PluginQuote>;
|
|
138
|
-
/**
|
|
139
|
-
* Triggered when the quote is about to get executed, this means:
|
|
140
|
-
* - FROM_BTCLN - lightning network payment received and the LP is about to sign an authorization allowing the user to settle
|
|
141
|
-
* - FROM_BTC - triggered on quote request, before the final authorization is given to the user
|
|
142
|
-
* - FROM_BTCLN_TRUSTED - triggered when the LP receives the funds on the source chain and before destination funds are sent
|
|
143
|
-
* - FROM_BTC_TRUSTED - triggered when the LP receives the funds on the source chain and before destination funds are sent
|
|
144
|
-
* - FROM_BTC_SPV - triggered before LP broadcasts the co-signed swap PSBT
|
|
145
|
-
* - FROM_BTCLN_AUTO - lightning network payment received and the LP is about to offer an HTLC to the user
|
|
146
|
-
*
|
|
147
|
-
* @param swapType
|
|
148
|
-
* @param swap
|
|
149
|
-
*/
|
|
150
|
-
onHandlePreFromBtcExecute?(
|
|
151
|
-
swapType: SwapHandlerType.FROM_BTCLN | SwapHandlerType.FROM_BTC | SwapHandlerType.FROM_BTCLN_TRUSTED | SwapHandlerType.FROM_BTC_TRUSTED | SwapHandlerType.FROM_BTC_SPV | SwapHandlerType.FROM_BTCLN_AUTO,
|
|
152
|
-
swap: FromBtcLnSwapAbs | FromBtcSwapAbs | FromBtcLnTrustedSwap | FromBtcTrustedSwap | SpvVaultSwap | FromBtcLnAutoSwap
|
|
153
|
-
): Promise<QuoteThrow | null>;
|
|
154
|
-
|
|
155
|
-
onHandlePreToBtcQuote?(
|
|
156
|
-
swapType: SwapHandlerType.TO_BTCLN | SwapHandlerType.TO_BTC,
|
|
157
|
-
request: RequestData<ToBtcLnRequestType | ToBtcRequestType>,
|
|
158
|
-
requestedAmount: {input: boolean, amount: bigint, token: string},
|
|
159
|
-
chainIdentifier: string,
|
|
160
|
-
constraints: {minInBtc: bigint, maxInBtc: bigint},
|
|
161
|
-
fees: {baseFeeInBtc: bigint, feePPM: bigint}
|
|
162
|
-
): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh>;
|
|
163
|
-
onHandlePostToBtcQuote?(
|
|
164
|
-
swapType: SwapHandlerType.TO_BTCLN | SwapHandlerType.TO_BTC,
|
|
165
|
-
request: RequestData<ToBtcLnRequestType | ToBtcRequestType>,
|
|
166
|
-
requestedAmount: {input: boolean, amount: bigint, token: string, pricePrefetch?: Promise<bigint>},
|
|
167
|
-
chainIdentifier: string,
|
|
168
|
-
constraints: {minInBtc: bigint, maxInBtc: bigint},
|
|
169
|
-
fees: {baseFeeInBtc: bigint, feePPM: bigint, networkFeeGetter: (amount: bigint) => Promise<bigint>}
|
|
170
|
-
): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh | ToBtcPluginQuote>;
|
|
171
|
-
onHandlePreToBtcExecute?(
|
|
172
|
-
swapType: SwapHandlerType.TO_BTCLN | SwapHandlerType.TO_BTC,
|
|
173
|
-
swap: ToBtcLnSwapAbs | ToBtcSwapAbs
|
|
174
|
-
): Promise<QuoteThrow | null>;
|
|
175
|
-
|
|
176
|
-
onHandlePostedFromBtcQuote?(
|
|
177
|
-
swapType: SwapHandlerType.FROM_BTC_SPV,
|
|
178
|
-
request: RequestData<SpvVaultPostQuote>,
|
|
179
|
-
swap: SpvVaultSwap
|
|
180
|
-
): Promise<QuoteThrow | null>;
|
|
181
|
-
|
|
182
|
-
onVaultSelection?(
|
|
183
|
-
chainIdentifier: string,
|
|
184
|
-
totalSats: bigint,
|
|
185
|
-
requestedAmount: {amount: bigint, token: string},
|
|
186
|
-
gasAmount: {amount: bigint, token: string}
|
|
187
|
-
): Promise<SpvVault | QuoteThrow | QuoteAmountTooHigh | QuoteAmountTooLow | null>;
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Returns whitelisted bitcoin txIds that are OK to spend even with 0-confs
|
|
191
|
-
*/
|
|
192
|
-
getWhitelistedTxIds?(): string[];
|
|
193
|
-
|
|
194
|
-
getCommands?(): Command<any>[];
|
|
195
|
-
|
|
196
|
-
}
|
|
1
|
+
import {BitcoinRpc} from "@atomiqlabs/base";
|
|
2
|
+
import {
|
|
3
|
+
FromBtcLnAbs, FromBtcLnAutoSwap,
|
|
4
|
+
FromBtcLnRequestType, FromBtcLnSwapAbs, FromBtcLnTrustedSwap,
|
|
5
|
+
FromBtcRequestType, FromBtcSwapAbs, FromBtcTrustedRequestType, FromBtcTrustedSwap,
|
|
6
|
+
ISwapPrice, MultichainData, RequestData, SpvVaultPostQuote, SpvVaultSwap, SpvVaultSwapRequestType,
|
|
7
|
+
SwapHandler, SwapHandlerType,
|
|
8
|
+
ToBtcLnRequestType, ToBtcLnSwapAbs,
|
|
9
|
+
ToBtcRequestType, ToBtcSwapAbs
|
|
10
|
+
} from "..";
|
|
11
|
+
import {SwapHandlerSwap} from "../swaps/SwapHandlerSwap";
|
|
12
|
+
import {Command} from "@atomiqlabs/server-base";
|
|
13
|
+
import {FromBtcLnTrustedRequestType} from "../swaps/trusted/frombtcln_trusted/FromBtcLnTrusted";
|
|
14
|
+
import {IBitcoinWallet} from "../wallets/IBitcoinWallet";
|
|
15
|
+
import {ILightningWallet} from "../wallets/ILightningWallet";
|
|
16
|
+
import {SpvVault} from "../swaps/spv_vault_swap/SpvVault";
|
|
17
|
+
|
|
18
|
+
export type QuoteThrow = {
|
|
19
|
+
type: "throw",
|
|
20
|
+
message: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isQuoteThrow(obj: any): obj is QuoteThrow {
|
|
24
|
+
return obj!=null && obj.type==="throw" && typeof(obj.message)==="string";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type QuoteSetFees = {
|
|
28
|
+
type: "fees"
|
|
29
|
+
baseFee?: bigint,
|
|
30
|
+
feePPM?: bigint,
|
|
31
|
+
securityDepositApyPPM?: bigint,
|
|
32
|
+
securityDepositBaseMultiplierPPM?: bigint
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function isQuoteSetFees(obj: any): obj is QuoteSetFees {
|
|
36
|
+
return obj!=null &&
|
|
37
|
+
obj.type==="fees" &&
|
|
38
|
+
(obj.baseFee==null || typeof(obj.baseFee) === "bigint") &&
|
|
39
|
+
(obj.feePPM==null || typeof(obj.feePPM) === "bigint") &&
|
|
40
|
+
(obj.securityDepositApyPPM==null || typeof(obj.securityDepositApyPPM) === "bigint") &&
|
|
41
|
+
(obj.securityDepositBaseMultiplierPPM==null || typeof(obj.securityDepositBaseMultiplierPPM) === "bigint");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type QuoteAmountTooLow = {
|
|
45
|
+
type: "low",
|
|
46
|
+
data: { min: bigint, max: bigint }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function isQuoteAmountTooLow(obj: any): obj is QuoteAmountTooLow {
|
|
50
|
+
return obj!=null && obj.type==="low" && obj.data!=null && typeof(obj.data)==="object" && typeof(obj.data.min)==="bigint" && typeof(obj.data.max)==="bigint";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type QuoteAmountTooHigh = {
|
|
54
|
+
type: "high",
|
|
55
|
+
data: { min: bigint, max: bigint }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function isQuoteAmountTooHigh(obj: any): obj is QuoteAmountTooHigh {
|
|
59
|
+
return obj!=null && obj.type==="high" && obj.data!=null && typeof(obj.data)==="object" && typeof(obj.data.min)==="bigint" && typeof(obj.data.max)==="bigint";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type PluginQuote = {
|
|
63
|
+
type: "success",
|
|
64
|
+
amount: {input: boolean, amount: bigint},
|
|
65
|
+
swapFee: { inInputTokens: bigint, inOutputTokens: bigint }
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export function isPluginQuote(obj: any): obj is PluginQuote {
|
|
69
|
+
return obj!=null && obj.type==="success" &&
|
|
70
|
+
obj.amount!=null && typeof(obj.amount)==="object" && typeof(obj.amount.input)==="boolean" && typeof(obj.amount.amount)==="bigint" &&
|
|
71
|
+
obj.swapFee!=null && typeof(obj.swapFee)==="object" && typeof(obj.swapFee.inInputTokens)==="bigint" && typeof(obj.swapFee.inOutputTokens)==="bigint";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type ToBtcPluginQuote = PluginQuote & {
|
|
75
|
+
networkFee: { inInputTokens: bigint, inOutputTokens: bigint }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function isToBtcPluginQuote(obj: any): obj is ToBtcPluginQuote {
|
|
79
|
+
return obj!=null && obj.networkFee!=null && typeof(obj.networkFee)==="object" && typeof(obj.networkFee.inInputTokens)==="bigint" && typeof(obj.networkFee.inOutputTokens)==="bigint" &&
|
|
80
|
+
isPluginQuote(obj);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface IPlugin {
|
|
84
|
+
|
|
85
|
+
name: string;
|
|
86
|
+
author: string;
|
|
87
|
+
description: string;
|
|
88
|
+
|
|
89
|
+
//Needs to be called by implementation
|
|
90
|
+
onEnable(
|
|
91
|
+
chainsData: MultichainData,
|
|
92
|
+
|
|
93
|
+
bitcoinRpc: BitcoinRpc<any>,
|
|
94
|
+
bitcoinWallet: IBitcoinWallet,
|
|
95
|
+
lightningWallet: ILightningWallet,
|
|
96
|
+
|
|
97
|
+
swapPricing: ISwapPrice,
|
|
98
|
+
tokens: {
|
|
99
|
+
[chainId: string]: {
|
|
100
|
+
[ticker: string]: {
|
|
101
|
+
address: string,
|
|
102
|
+
decimals: number
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
directory: string
|
|
108
|
+
): Promise<void>;
|
|
109
|
+
onDisable(): Promise<void>;
|
|
110
|
+
|
|
111
|
+
//Called in the library
|
|
112
|
+
onServiceInitialize(service: SwapHandler<any>): Promise<void>;
|
|
113
|
+
|
|
114
|
+
onHttpServerStarted?(expressServer: any): Promise<void>;
|
|
115
|
+
|
|
116
|
+
onSwapStateChange?(swap: SwapHandlerSwap): Promise<void>;
|
|
117
|
+
onSwapCreate?(swap: SwapHandlerSwap): Promise<void>;
|
|
118
|
+
onSwapRemove?(swap: SwapHandlerSwap): Promise<void>;
|
|
119
|
+
|
|
120
|
+
onHandlePreFromBtcQuote?(
|
|
121
|
+
swapType: SwapHandlerType.FROM_BTCLN | SwapHandlerType.FROM_BTC | SwapHandlerType.FROM_BTCLN_TRUSTED | SwapHandlerType.FROM_BTC_TRUSTED | SwapHandlerType.FROM_BTC_SPV | SwapHandlerType.FROM_BTCLN_AUTO,
|
|
122
|
+
request: RequestData<FromBtcLnRequestType | FromBtcRequestType | FromBtcLnTrustedRequestType | FromBtcTrustedRequestType | SpvVaultSwapRequestType>,
|
|
123
|
+
requestedAmount: {input: boolean, amount: bigint, token: string},
|
|
124
|
+
chainIdentifier: string,
|
|
125
|
+
constraints: {minInBtc: bigint, maxInBtc: bigint},
|
|
126
|
+
fees: {baseFeeInBtc: bigint, feePPM: bigint},
|
|
127
|
+
gasTokenAmount?: {input: false, amount: bigint, token: string}
|
|
128
|
+
): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh>;
|
|
129
|
+
onHandlePostFromBtcQuote?(
|
|
130
|
+
swapType: SwapHandlerType.FROM_BTCLN | SwapHandlerType.FROM_BTC | SwapHandlerType.FROM_BTCLN_TRUSTED | SwapHandlerType.FROM_BTC_TRUSTED | SwapHandlerType.FROM_BTC_SPV | SwapHandlerType.FROM_BTCLN_AUTO,
|
|
131
|
+
request: RequestData<FromBtcLnRequestType | FromBtcRequestType | FromBtcLnTrustedRequestType | FromBtcTrustedRequestType | SpvVaultSwapRequestType>,
|
|
132
|
+
requestedAmount: {input: boolean, amount: bigint, token: string, pricePrefetch?: Promise<bigint>},
|
|
133
|
+
chainIdentifier: string,
|
|
134
|
+
constraints: {minInBtc: bigint, maxInBtc: bigint},
|
|
135
|
+
fees: {baseFeeInBtc: bigint, feePPM: bigint},
|
|
136
|
+
gasTokenAmount?: {input: false, amount: bigint, token: string, pricePrefetch?: Promise<bigint>}
|
|
137
|
+
): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh | PluginQuote>;
|
|
138
|
+
/**
|
|
139
|
+
* Triggered when the quote is about to get executed, this means:
|
|
140
|
+
* - FROM_BTCLN - lightning network payment received and the LP is about to sign an authorization allowing the user to settle
|
|
141
|
+
* - FROM_BTC - triggered on quote request, before the final authorization is given to the user
|
|
142
|
+
* - FROM_BTCLN_TRUSTED - triggered when the LP receives the funds on the source chain and before destination funds are sent
|
|
143
|
+
* - FROM_BTC_TRUSTED - triggered when the LP receives the funds on the source chain and before destination funds are sent
|
|
144
|
+
* - FROM_BTC_SPV - triggered before LP broadcasts the co-signed swap PSBT
|
|
145
|
+
* - FROM_BTCLN_AUTO - lightning network payment received and the LP is about to offer an HTLC to the user
|
|
146
|
+
*
|
|
147
|
+
* @param swapType
|
|
148
|
+
* @param swap
|
|
149
|
+
*/
|
|
150
|
+
onHandlePreFromBtcExecute?(
|
|
151
|
+
swapType: SwapHandlerType.FROM_BTCLN | SwapHandlerType.FROM_BTC | SwapHandlerType.FROM_BTCLN_TRUSTED | SwapHandlerType.FROM_BTC_TRUSTED | SwapHandlerType.FROM_BTC_SPV | SwapHandlerType.FROM_BTCLN_AUTO,
|
|
152
|
+
swap: FromBtcLnSwapAbs | FromBtcSwapAbs | FromBtcLnTrustedSwap | FromBtcTrustedSwap | SpvVaultSwap | FromBtcLnAutoSwap
|
|
153
|
+
): Promise<QuoteThrow | null>;
|
|
154
|
+
|
|
155
|
+
onHandlePreToBtcQuote?(
|
|
156
|
+
swapType: SwapHandlerType.TO_BTCLN | SwapHandlerType.TO_BTC,
|
|
157
|
+
request: RequestData<ToBtcLnRequestType | ToBtcRequestType>,
|
|
158
|
+
requestedAmount: {input: boolean, amount: bigint, token: string},
|
|
159
|
+
chainIdentifier: string,
|
|
160
|
+
constraints: {minInBtc: bigint, maxInBtc: bigint},
|
|
161
|
+
fees: {baseFeeInBtc: bigint, feePPM: bigint}
|
|
162
|
+
): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh>;
|
|
163
|
+
onHandlePostToBtcQuote?(
|
|
164
|
+
swapType: SwapHandlerType.TO_BTCLN | SwapHandlerType.TO_BTC,
|
|
165
|
+
request: RequestData<ToBtcLnRequestType | ToBtcRequestType>,
|
|
166
|
+
requestedAmount: {input: boolean, amount: bigint, token: string, pricePrefetch?: Promise<bigint>},
|
|
167
|
+
chainIdentifier: string,
|
|
168
|
+
constraints: {minInBtc: bigint, maxInBtc: bigint},
|
|
169
|
+
fees: {baseFeeInBtc: bigint, feePPM: bigint, networkFeeGetter: (amount: bigint) => Promise<bigint>}
|
|
170
|
+
): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh | ToBtcPluginQuote>;
|
|
171
|
+
onHandlePreToBtcExecute?(
|
|
172
|
+
swapType: SwapHandlerType.TO_BTCLN | SwapHandlerType.TO_BTC,
|
|
173
|
+
swap: ToBtcLnSwapAbs | ToBtcSwapAbs
|
|
174
|
+
): Promise<QuoteThrow | null>;
|
|
175
|
+
|
|
176
|
+
onHandlePostedFromBtcQuote?(
|
|
177
|
+
swapType: SwapHandlerType.FROM_BTC_SPV,
|
|
178
|
+
request: RequestData<SpvVaultPostQuote>,
|
|
179
|
+
swap: SpvVaultSwap
|
|
180
|
+
): Promise<QuoteThrow | null>;
|
|
181
|
+
|
|
182
|
+
onVaultSelection?(
|
|
183
|
+
chainIdentifier: string,
|
|
184
|
+
totalSats: bigint,
|
|
185
|
+
requestedAmount: {amount: bigint, token: string},
|
|
186
|
+
gasAmount: {amount: bigint, token: string}
|
|
187
|
+
): Promise<SpvVault | QuoteThrow | QuoteAmountTooHigh | QuoteAmountTooLow | null>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Returns whitelisted bitcoin txIds that are OK to spend even with 0-confs
|
|
191
|
+
*/
|
|
192
|
+
getWhitelistedTxIds?(): string[];
|
|
193
|
+
|
|
194
|
+
getCommands?(): Command<any>[];
|
|
195
|
+
|
|
196
|
+
}
|