@atomiqlabs/lp-lib 10.3.11

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.
Files changed (138) hide show
  1. package/LICENSE +201 -0
  2. package/dist/fees/IBtcFeeEstimator.d.ts +3 -0
  3. package/dist/fees/IBtcFeeEstimator.js +2 -0
  4. package/dist/fees/OneDollarFeeEstimator.d.ts +16 -0
  5. package/dist/fees/OneDollarFeeEstimator.js +71 -0
  6. package/dist/index.d.ts +33 -0
  7. package/dist/index.js +52 -0
  8. package/dist/info/InfoHandler.d.ts +17 -0
  9. package/dist/info/InfoHandler.js +70 -0
  10. package/dist/plugins/IPlugin.d.ts +118 -0
  11. package/dist/plugins/IPlugin.js +33 -0
  12. package/dist/plugins/PluginManager.d.ts +89 -0
  13. package/dist/plugins/PluginManager.js +263 -0
  14. package/dist/prices/BinanceSwapPrice.d.ts +27 -0
  15. package/dist/prices/BinanceSwapPrice.js +106 -0
  16. package/dist/prices/CoinGeckoSwapPrice.d.ts +31 -0
  17. package/dist/prices/CoinGeckoSwapPrice.js +76 -0
  18. package/dist/storage/IIntermediaryStorage.d.ts +15 -0
  19. package/dist/storage/IIntermediaryStorage.js +2 -0
  20. package/dist/storagemanager/IntermediaryStorageManager.d.ts +15 -0
  21. package/dist/storagemanager/IntermediaryStorageManager.js +113 -0
  22. package/dist/storagemanager/StorageManager.d.ts +12 -0
  23. package/dist/storagemanager/StorageManager.js +74 -0
  24. package/dist/swaps/FromBtcBaseSwap.d.ts +12 -0
  25. package/dist/swaps/FromBtcBaseSwap.js +16 -0
  26. package/dist/swaps/FromBtcBaseSwapHandler.d.ts +118 -0
  27. package/dist/swaps/FromBtcBaseSwapHandler.js +294 -0
  28. package/dist/swaps/FromBtcLnBaseSwapHandler.d.ts +25 -0
  29. package/dist/swaps/FromBtcLnBaseSwapHandler.js +55 -0
  30. package/dist/swaps/ISwapPrice.d.ts +44 -0
  31. package/dist/swaps/ISwapPrice.js +73 -0
  32. package/dist/swaps/SwapHandler.d.ts +186 -0
  33. package/dist/swaps/SwapHandler.js +292 -0
  34. package/dist/swaps/SwapHandlerSwap.d.ts +75 -0
  35. package/dist/swaps/SwapHandlerSwap.js +72 -0
  36. package/dist/swaps/ToBtcBaseSwap.d.ts +35 -0
  37. package/dist/swaps/ToBtcBaseSwap.js +61 -0
  38. package/dist/swaps/ToBtcBaseSwapHandler.d.ts +94 -0
  39. package/dist/swaps/ToBtcBaseSwapHandler.js +233 -0
  40. package/dist/swaps/frombtc_abstract/FromBtcAbs.d.ts +92 -0
  41. package/dist/swaps/frombtc_abstract/FromBtcAbs.js +386 -0
  42. package/dist/swaps/frombtc_abstract/FromBtcSwapAbs.d.ts +26 -0
  43. package/dist/swaps/frombtc_abstract/FromBtcSwapAbs.js +63 -0
  44. package/dist/swaps/frombtc_trusted/FromBtcTrusted.d.ts +55 -0
  45. package/dist/swaps/frombtc_trusted/FromBtcTrusted.js +586 -0
  46. package/dist/swaps/frombtc_trusted/FromBtcTrustedSwap.d.ts +43 -0
  47. package/dist/swaps/frombtc_trusted/FromBtcTrustedSwap.js +99 -0
  48. package/dist/swaps/frombtcln_abstract/FromBtcLnAbs.d.ts +105 -0
  49. package/dist/swaps/frombtcln_abstract/FromBtcLnAbs.js +731 -0
  50. package/dist/swaps/frombtcln_abstract/FromBtcLnSwapAbs.d.ts +29 -0
  51. package/dist/swaps/frombtcln_abstract/FromBtcLnSwapAbs.js +64 -0
  52. package/dist/swaps/frombtcln_trusted/FromBtcLnTrusted.d.ts +79 -0
  53. package/dist/swaps/frombtcln_trusted/FromBtcLnTrusted.js +514 -0
  54. package/dist/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.d.ts +28 -0
  55. package/dist/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.js +66 -0
  56. package/dist/swaps/tobtc_abstract/ToBtcAbs.d.ts +290 -0
  57. package/dist/swaps/tobtc_abstract/ToBtcAbs.js +1056 -0
  58. package/dist/swaps/tobtc_abstract/ToBtcSwapAbs.d.ts +29 -0
  59. package/dist/swaps/tobtc_abstract/ToBtcSwapAbs.js +70 -0
  60. package/dist/swaps/tobtcln_abstract/ToBtcLnAbs.d.ts +246 -0
  61. package/dist/swaps/tobtcln_abstract/ToBtcLnAbs.js +1169 -0
  62. package/dist/swaps/tobtcln_abstract/ToBtcLnSwapAbs.d.ts +27 -0
  63. package/dist/swaps/tobtcln_abstract/ToBtcLnSwapAbs.js +65 -0
  64. package/dist/utils/Utils.d.ts +32 -0
  65. package/dist/utils/Utils.js +109 -0
  66. package/dist/utils/coinselect2/accumulative.d.ts +6 -0
  67. package/dist/utils/coinselect2/accumulative.js +44 -0
  68. package/dist/utils/coinselect2/blackjack.d.ts +6 -0
  69. package/dist/utils/coinselect2/blackjack.js +41 -0
  70. package/dist/utils/coinselect2/index.d.ts +16 -0
  71. package/dist/utils/coinselect2/index.js +40 -0
  72. package/dist/utils/coinselect2/utils.d.ts +64 -0
  73. package/dist/utils/coinselect2/utils.js +121 -0
  74. package/dist/utils/paramcoders/IParamReader.d.ts +5 -0
  75. package/dist/utils/paramcoders/IParamReader.js +2 -0
  76. package/dist/utils/paramcoders/IParamWriter.d.ts +4 -0
  77. package/dist/utils/paramcoders/IParamWriter.js +2 -0
  78. package/dist/utils/paramcoders/LegacyParamEncoder.d.ts +10 -0
  79. package/dist/utils/paramcoders/LegacyParamEncoder.js +33 -0
  80. package/dist/utils/paramcoders/ParamDecoder.d.ts +25 -0
  81. package/dist/utils/paramcoders/ParamDecoder.js +234 -0
  82. package/dist/utils/paramcoders/ParamEncoder.d.ts +9 -0
  83. package/dist/utils/paramcoders/ParamEncoder.js +22 -0
  84. package/dist/utils/paramcoders/SchemaVerifier.d.ts +22 -0
  85. package/dist/utils/paramcoders/SchemaVerifier.js +85 -0
  86. package/dist/utils/paramcoders/server/ServerParamDecoder.d.ts +8 -0
  87. package/dist/utils/paramcoders/server/ServerParamDecoder.js +105 -0
  88. package/dist/utils/paramcoders/server/ServerParamEncoder.d.ts +11 -0
  89. package/dist/utils/paramcoders/server/ServerParamEncoder.js +76 -0
  90. package/package.json +43 -0
  91. package/src/fees/IBtcFeeEstimator.ts +7 -0
  92. package/src/fees/OneDollarFeeEstimator.ts +95 -0
  93. package/src/index.ts +46 -0
  94. package/src/info/InfoHandler.ts +106 -0
  95. package/src/plugins/IPlugin.ts +155 -0
  96. package/src/plugins/PluginManager.ts +310 -0
  97. package/src/prices/BinanceSwapPrice.ts +114 -0
  98. package/src/prices/CoinGeckoSwapPrice.ts +88 -0
  99. package/src/storage/IIntermediaryStorage.ts +21 -0
  100. package/src/storagemanager/IntermediaryStorageManager.ts +101 -0
  101. package/src/storagemanager/StorageManager.ts +68 -0
  102. package/src/swaps/FromBtcBaseSwap.ts +21 -0
  103. package/src/swaps/FromBtcBaseSwapHandler.ts +375 -0
  104. package/src/swaps/FromBtcLnBaseSwapHandler.ts +48 -0
  105. package/src/swaps/ISwapPrice.ts +94 -0
  106. package/src/swaps/SwapHandler.ts +404 -0
  107. package/src/swaps/SwapHandlerSwap.ts +133 -0
  108. package/src/swaps/ToBtcBaseSwap.ts +76 -0
  109. package/src/swaps/ToBtcBaseSwapHandler.ts +309 -0
  110. package/src/swaps/frombtc_abstract/FromBtcAbs.ts +484 -0
  111. package/src/swaps/frombtc_abstract/FromBtcSwapAbs.ts +77 -0
  112. package/src/swaps/frombtc_trusted/FromBtcTrusted.ts +661 -0
  113. package/src/swaps/frombtc_trusted/FromBtcTrustedSwap.ts +158 -0
  114. package/src/swaps/frombtcln_abstract/FromBtcLnAbs.ts +864 -0
  115. package/src/swaps/frombtcln_abstract/FromBtcLnSwapAbs.ts +82 -0
  116. package/src/swaps/frombtcln_trusted/FromBtcLnTrusted.ts +592 -0
  117. package/src/swaps/frombtcln_trusted/FromBtcLnTrustedSwap.ts +90 -0
  118. package/src/swaps/tobtc_abstract/ToBtcAbs.ts +1249 -0
  119. package/src/swaps/tobtc_abstract/ToBtcSwapAbs.ts +112 -0
  120. package/src/swaps/tobtcln_abstract/ToBtcLnAbs.ts +1422 -0
  121. package/src/swaps/tobtcln_abstract/ToBtcLnSwapAbs.ts +87 -0
  122. package/src/utils/Utils.ts +108 -0
  123. package/src/utils/coinselect2/accumulative.js +32 -0
  124. package/src/utils/coinselect2/accumulative.ts +58 -0
  125. package/src/utils/coinselect2/blackjack.js +29 -0
  126. package/src/utils/coinselect2/blackjack.ts +54 -0
  127. package/src/utils/coinselect2/index.js +16 -0
  128. package/src/utils/coinselect2/index.ts +50 -0
  129. package/src/utils/coinselect2/utils.js +110 -0
  130. package/src/utils/coinselect2/utils.ts +183 -0
  131. package/src/utils/paramcoders/IParamReader.ts +8 -0
  132. package/src/utils/paramcoders/IParamWriter.ts +8 -0
  133. package/src/utils/paramcoders/LegacyParamEncoder.ts +28 -0
  134. package/src/utils/paramcoders/ParamDecoder.ts +219 -0
  135. package/src/utils/paramcoders/ParamEncoder.ts +30 -0
  136. package/src/utils/paramcoders/SchemaVerifier.ts +97 -0
  137. package/src/utils/paramcoders/server/ServerParamDecoder.ts +115 -0
  138. package/src/utils/paramcoders/server/ServerParamEncoder.ts +76 -0
@@ -0,0 +1,95 @@
1
+ import {IBtcFeeEstimator} from "./IBtcFeeEstimator";
2
+ import {getLogger} from "../utils/Utils";
3
+ const dynamicImport = new Function('specifier', 'return import(specifier)');
4
+ const importPromise = dynamicImport('one-dollar-fee-estimator-failover');
5
+
6
+ const logger = getLogger("OneDollarFeeEstimator: ")
7
+
8
+ export class OneDollarFeeEstimator implements IBtcFeeEstimator {
9
+
10
+ estimator: any;
11
+
12
+ receivedFee: [number, number, number, number];
13
+ iterations: number = 0;
14
+
15
+ host: string;
16
+ port: number;
17
+ username: string;
18
+ password: string;
19
+
20
+ addFee: number;
21
+ feeMultiplier: number;
22
+
23
+ startFeeEstimator() {
24
+ logger.info("startFeeEstimator(): starting fee estimator worker");
25
+
26
+ importPromise.then(({FeeEstimator}) => {
27
+ this.estimator = new FeeEstimator({
28
+ mode: 'bundles', // 'txs' | 'bundles' - optional, default 'txs'
29
+ refresh: 30, // optional, default 30 - interval in seconds, setting too low can cause unexpected errors
30
+ rpcOptions: {
31
+ host: this.host,
32
+ port: this.port,
33
+ username: this.username,
34
+ password: this.password
35
+ }
36
+ });
37
+
38
+ this.estimator.on('error', (err) => {
39
+ logger.error("on(error): fee estimator error", err);
40
+ if(err.message.startsWith("FeeEstimator worker stopped")) {
41
+ logger.info("on(error): restarting fee estimator worker");
42
+ this.receivedFee = null;
43
+ this.iterations = 0;
44
+ this.startFeeEstimator();
45
+ }
46
+ });
47
+
48
+ // receive live fee rate updates from the FeeEstimator
49
+ this.estimator.on('fees', (fees) => {
50
+ this.receivedFee = fees;
51
+ this.iterations++;
52
+ });
53
+ });
54
+ }
55
+
56
+ constructor(
57
+ host: string,
58
+ port: number,
59
+ username: string,
60
+ password: string,
61
+ addFee?: number,
62
+ feeMultiplier?: number
63
+ ) {
64
+ this.host = host;
65
+ this.port = port;
66
+ this.username = username;
67
+ this.password = password;
68
+ this.addFee = addFee;
69
+ this.feeMultiplier = feeMultiplier;
70
+ this.startFeeEstimator();
71
+
72
+ process.on('exit', () => {
73
+ logger.info("process(exit): process exiting, stopping estimator");
74
+ if(this.estimator!=null) this.estimator.stop();
75
+ });
76
+
77
+ process.on('SIGINT', () => {
78
+ logger.info("process(SIGINT): process exiting, stopping estimator");
79
+ if(this.estimator!=null) this.estimator.stop();
80
+ process.exit();
81
+ });
82
+ }
83
+
84
+ getFee(): number {
85
+ let fee = this.receivedFee[3];
86
+ if(this.feeMultiplier!=null) fee *= this.feeMultiplier;
87
+ if(this.addFee!=null) fee += this.addFee;
88
+ return fee;
89
+ }
90
+
91
+ estimateFee(): Promise<number | null> {
92
+ return Promise.resolve(this.iterations<=1 ? null : this.getFee());
93
+ }
94
+
95
+ }
package/src/index.ts ADDED
@@ -0,0 +1,46 @@
1
+ import * as bitcoin from "bitcoinjs-lib";
2
+ import * as tinySecpk256Interface from "@bitcoinerlab/secp256k1";
3
+ bitcoin.initEccLib(tinySecpk256Interface);
4
+
5
+ export * from "./info/InfoHandler";
6
+
7
+ export * from "./prices/CoinGeckoSwapPrice";
8
+ export * from "./prices/BinanceSwapPrice";
9
+
10
+ export * from "./storage/IIntermediaryStorage";
11
+
12
+ export * from "./storagemanager/StorageManager";
13
+ export * from "./storagemanager/IntermediaryStorageManager";
14
+
15
+ export * from "./swaps/frombtc_abstract/FromBtcAbs";
16
+ export * from "./swaps/frombtc_abstract/FromBtcSwapAbs";
17
+ export * from "./swaps/frombtcln_abstract/FromBtcLnAbs";
18
+ export * from "./swaps/frombtcln_abstract/FromBtcLnSwapAbs";
19
+ export * from "./swaps/tobtc_abstract/ToBtcAbs";
20
+ export * from "./swaps/tobtc_abstract/ToBtcSwapAbs";
21
+ export * from "./swaps/tobtcln_abstract/ToBtcLnAbs";
22
+ export * from "./swaps/tobtcln_abstract/ToBtcLnSwapAbs";
23
+
24
+ export * from "./swaps/frombtc_trusted/FromBtcTrusted";
25
+ export * from "./swaps/frombtc_trusted/FromBtcTrustedSwap";
26
+ export * from "./swaps/frombtcln_trusted/FromBtcLnTrusted";
27
+ export * from "./swaps/frombtcln_trusted/FromBtcLnTrustedSwap";
28
+
29
+ export * from "./swaps/ISwapPrice";
30
+ export * from "./swaps/SwapHandler";
31
+ export * from "./swaps/SwapHandlerSwap";
32
+
33
+ export * from "./plugins/PluginManager";
34
+ export * from "./plugins/IPlugin";
35
+
36
+ export * from "./fees/IBtcFeeEstimator";
37
+ export * from "./fees/OneDollarFeeEstimator";
38
+
39
+ export * from "./utils/paramcoders/IParamReader";
40
+ export * from "./utils/paramcoders/IParamWriter";
41
+ export * from "./utils/paramcoders/LegacyParamEncoder";
42
+ export * from "./utils/paramcoders/ParamDecoder";
43
+ export * from "./utils/paramcoders/ParamEncoder";
44
+ export * from "./utils/paramcoders/SchemaVerifier";
45
+ export * from "./utils/paramcoders/server/ServerParamDecoder";
46
+ export * from "./utils/paramcoders/server/ServerParamEncoder";
@@ -0,0 +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
+ address: string,
17
+ signature: string,
18
+ chains: {
19
+ [chainIdentifier: string]: {
20
+ address: string,
21
+ signature: string
22
+ }
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Handles info requests to POST /info returning information about fees, swap params, etc.
28
+ */
29
+ export class InfoHandler {
30
+
31
+ readonly chainData: MultichainData;
32
+ readonly path: string;
33
+
34
+ readonly swapHandlers: SwapHandler[];
35
+
36
+ constructor(chainData: MultichainData, path: string, swapHandlers: SwapHandler[]) {
37
+ this.chainData = chainData;
38
+ this.path = path;
39
+ this.swapHandlers = swapHandlers;
40
+ }
41
+
42
+ /**
43
+ * Adds a listener to POST /info
44
+ *
45
+ * @param restServer
46
+ */
47
+ startRestServer(restServer: Express) {
48
+
49
+ restServer.use(this.path+"/info", express.json());
50
+ restServer.post(this.path+"/info", async (req, res) => {
51
+ if (
52
+ req.body == null ||
53
+
54
+ req.body.nonce == null ||
55
+ typeof(req.body.nonce) !== "string" ||
56
+ req.body.nonce.length>64 ||
57
+ !HEX_REGEX.test(req.body.nonce)
58
+ ) {
59
+ res.status(400).json({
60
+ msg: "Invalid request body (nonce)"
61
+ });
62
+ return;
63
+ }
64
+
65
+ const env: InfoHandlerResponseEnvelope = {
66
+ nonce: req.body.nonce,
67
+ services: {}
68
+ };
69
+
70
+ for(let swapHandler of this.swapHandlers) {
71
+ env.services[swapHandler.type] = swapHandler.getInfo();
72
+ }
73
+
74
+ const envelope = JSON.stringify(env);
75
+ const envelopeBuffer = Buffer.from(envelope);
76
+
77
+ const chains: {
78
+ [chainIdentifier: string]: {
79
+ address: string,
80
+ signature: string
81
+ }
82
+ } = {};
83
+ for(let chainIdentifier in this.chainData.chains) {
84
+ const singleChain = this.chainData.chains[chainIdentifier];
85
+ chains[chainIdentifier] = {
86
+ address: singleChain.signer.getAddress(),
87
+ signature: await singleChain.swapContract.getDataSignature(singleChain.signer, envelopeBuffer)
88
+ };
89
+ }
90
+
91
+ const defaults = chains[this.chainData.default];
92
+
93
+ const response: InfoHandlerResponse = {
94
+ envelope,
95
+ address: defaults.address,
96
+ signature: defaults.signature,
97
+ chains
98
+ };
99
+
100
+ res.status(200).json(response);
101
+ });
102
+
103
+ }
104
+
105
+
106
+ }
@@ -0,0 +1,155 @@
1
+ import {BitcoinRpc, SwapData} from "@atomiqlabs/base";
2
+ import {
3
+ FromBtcLnRequestType,
4
+ FromBtcRequestType,
5
+ ISwapPrice, MultichainData, RequestData,
6
+ SwapHandler,
7
+ ToBtcLnRequestType,
8
+ ToBtcRequestType
9
+ } from "..";
10
+ import {SwapHandlerSwap} from "../swaps/SwapHandlerSwap";
11
+ import {AuthenticatedLnd} from "lightning";
12
+ import * as BN from "bn.js";
13
+ import {Command} from "@atomiqlabs/server-base";
14
+ import {FromBtcLnTrustedRequestType} from "../swaps/frombtcln_trusted/FromBtcLnTrusted";
15
+
16
+ export type QuoteThrow = {
17
+ type: "throw",
18
+ message: string
19
+ }
20
+
21
+ export function isQuoteThrow(obj: any): obj is QuoteThrow {
22
+ return obj.type==="throw" && typeof(obj.message)==="string";
23
+ }
24
+
25
+ export type QuoteSetFees = {
26
+ type: "fees"
27
+ baseFee?: BN,
28
+ feePPM?: BN
29
+ };
30
+
31
+ export function isQuoteSetFees(obj: any): obj is QuoteSetFees {
32
+ return obj.type==="fees" &&
33
+ (obj.baseFee==null || BN.isBN(obj.baseFee)) &&
34
+ (obj.feePPM==null || BN.isBN(obj.feePPM));
35
+ }
36
+
37
+ export type QuoteAmountTooLow = {
38
+ type: "low",
39
+ data: { min: BN, max: BN }
40
+ }
41
+
42
+ export function isQuoteAmountTooLow(obj: any): obj is QuoteAmountTooLow {
43
+ return obj.type==="low" && typeof(obj.data)==="object" && BN.isBN(obj.data.min) && BN.isBN(obj.data.max);
44
+ }
45
+
46
+ export type QuoteAmountTooHigh = {
47
+ type: "high",
48
+ data: { min: BN, max: BN }
49
+ }
50
+
51
+ export function isQuoteAmountTooHigh(obj: any): obj is QuoteAmountTooHigh {
52
+ return obj.type==="high" && typeof(obj.data)==="object" && BN.isBN(obj.data.min) && BN.isBN(obj.data.max);
53
+ }
54
+
55
+ export type PluginQuote = {
56
+ type: "success",
57
+ amount: {input: boolean, amount: BN},
58
+ swapFee: { inInputTokens: BN, inOutputTokens: BN }
59
+ };
60
+
61
+ export function isPluginQuote(obj: any): obj is PluginQuote {
62
+ return obj.type==="success" &&
63
+ typeof(obj.amount)==="object" && typeof(obj.amount.input)==="boolean" && BN.isBN(obj.amount.amount) &&
64
+ typeof(obj.swapFee)==="object" && BN.isBN(obj.swapFee.inInputTokens) && BN.isBN(obj.swapFee.inOutputTokens);
65
+ }
66
+
67
+ export type ToBtcPluginQuote = PluginQuote & {
68
+ networkFee: { inInputTokens: BN, inOutputTokens: BN }
69
+ }
70
+
71
+ export function isToBtcPluginQuote(obj: any): obj is ToBtcPluginQuote {
72
+ return typeof(obj.networkFee)==="object" && BN.isBN(obj.networkFee.inInputTokens) && BN.isBN(obj.networkFee.inOutputTokens) &&
73
+ isPluginQuote(obj);
74
+ }
75
+
76
+ export interface IPlugin {
77
+
78
+ name: string;
79
+ author: string;
80
+ description: string;
81
+
82
+ //Needs to be called by implementation
83
+ onEnable(
84
+ chainsData: MultichainData,
85
+
86
+ bitcoinRpc: BitcoinRpc<any>,
87
+ lnd: AuthenticatedLnd,
88
+
89
+ swapPricing: ISwapPrice,
90
+ tokens: {
91
+ [ticker: string]: {
92
+ [chainId: string]: {
93
+ address: string,
94
+ decimals: number
95
+ }
96
+ }
97
+ },
98
+
99
+ directory: string
100
+ ): Promise<void>;
101
+ onDisable(): Promise<void>;
102
+
103
+ //Called in the library
104
+ onServiceInitialize(service: SwapHandler<any>): Promise<void>;
105
+
106
+ onHttpServerStarted?(expressServer: any): Promise<void>;
107
+
108
+ onSwapStateChange?(swap: SwapHandlerSwap): Promise<void>;
109
+ onSwapCreate?(swap: SwapHandlerSwap): Promise<void>;
110
+ onSwapRemove?(swap: SwapHandlerSwap): Promise<void>;
111
+
112
+ onHandlePreFromBtcQuote?(
113
+ request: RequestData<FromBtcLnRequestType | FromBtcRequestType | FromBtcLnTrustedRequestType>,
114
+ requestedAmount: {input: boolean, amount: BN},
115
+ chainIdentifier: string,
116
+ token: string,
117
+ constraints: {minInBtc: BN, maxInBtc: BN},
118
+ fees: {baseFeeInBtc: BN, feePPM: BN}
119
+ ): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh>;
120
+ onHandlePostFromBtcQuote?(
121
+ request: RequestData<FromBtcLnRequestType | FromBtcRequestType | FromBtcLnTrustedRequestType>,
122
+ requestedAmount: {input: boolean, amount: BN},
123
+ chainIdentifier: string,
124
+ token: string,
125
+ constraints: {minInBtc: BN, maxInBtc: BN},
126
+ fees: {baseFeeInBtc: BN, feePPM: BN},
127
+ pricePrefetchPromise?: Promise<BN> | null
128
+ ): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh | PluginQuote>;
129
+
130
+ onHandlePreToBtcQuote?(
131
+ request: RequestData<ToBtcLnRequestType | ToBtcRequestType>,
132
+ requestedAmount: {input: boolean, amount: BN},
133
+ chainIdentifier: string,
134
+ token: string,
135
+ constraints: {minInBtc: BN, maxInBtc: BN},
136
+ fees: {baseFeeInBtc: BN, feePPM: BN}
137
+ ): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh>;
138
+ onHandlePostToBtcQuote?(
139
+ request: RequestData<ToBtcLnRequestType | ToBtcRequestType>,
140
+ requestedAmount: {input: boolean, amount: BN},
141
+ chainIdentifier: string,
142
+ token: string,
143
+ constraints: {minInBtc: BN, maxInBtc: BN},
144
+ fees: {baseFeeInBtc: BN, feePPM: BN, networkFeeGetter: (amount: BN) => Promise<BN>},
145
+ pricePrefetchPromise?: Promise<BN> | null
146
+ ): Promise<QuoteThrow | QuoteSetFees | QuoteAmountTooLow | QuoteAmountTooHigh | ToBtcPluginQuote>;
147
+
148
+ /**
149
+ * Returns whitelisted bitcoin txIds that are OK to spend even with 0-confs
150
+ */
151
+ getWhitelistedTxIds?(): string[];
152
+
153
+ getCommands?(): Command<any>[];
154
+
155
+ }