@atomiqlabs/lp-lib 12.0.2 → 12.1.0
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/plugins/IPlugin.d.ts +2 -0
- package/dist/plugins/IPlugin.js +3 -1
- package/dist/swaps/FromBtcBaseSwapHandler.d.ts +9 -1
- package/dist/swaps/FromBtcBaseSwapHandler.js +17 -4
- package/dist/swaps/frombtc_abstract/FromBtcAbs.js +6 -2
- package/dist/swaps/frombtcln_abstract/FromBtcLnAbs.js +6 -2
- package/package.json +1 -1
- package/src/plugins/IPlugin.ts +6 -2
- package/src/swaps/FromBtcBaseSwapHandler.ts +28 -5
- package/src/swaps/frombtc_abstract/FromBtcAbs.ts +7 -2
- package/src/swaps/frombtcln_abstract/FromBtcLnAbs.ts +7 -2
|
@@ -14,6 +14,8 @@ export type QuoteSetFees = {
|
|
|
14
14
|
type: "fees";
|
|
15
15
|
baseFee?: bigint;
|
|
16
16
|
feePPM?: bigint;
|
|
17
|
+
securityDepositApyPPM?: bigint;
|
|
18
|
+
securityDepositBaseMultiplierPPM?: bigint;
|
|
17
19
|
};
|
|
18
20
|
export declare function isQuoteSetFees(obj: any): obj is QuoteSetFees;
|
|
19
21
|
export type QuoteAmountTooLow = {
|
package/dist/plugins/IPlugin.js
CHANGED
|
@@ -8,7 +8,9 @@ exports.isQuoteThrow = isQuoteThrow;
|
|
|
8
8
|
function isQuoteSetFees(obj) {
|
|
9
9
|
return obj.type === "fees" &&
|
|
10
10
|
(obj.baseFee == null || typeof (obj.baseFee) === "bigint") &&
|
|
11
|
-
(obj.feePPM == null || typeof (obj.feePPM) === "bigint")
|
|
11
|
+
(obj.feePPM == null || typeof (obj.feePPM) === "bigint") &&
|
|
12
|
+
(obj.securityDepositApyPPM == null || typeof (obj.securityDepositApyPPM) === "bigint") &&
|
|
13
|
+
(obj.securityDepositBaseMultiplierPPM == null || typeof (obj.securityDepositBaseMultiplierPPM) === "bigint");
|
|
12
14
|
}
|
|
13
15
|
exports.isQuoteSetFees = isQuoteSetFees;
|
|
14
16
|
function isQuoteAmountTooLow(obj) {
|
|
@@ -74,6 +74,8 @@ export declare abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<S
|
|
|
74
74
|
}, useToken: string): Promise<{
|
|
75
75
|
baseFee: bigint;
|
|
76
76
|
feePPM: bigint;
|
|
77
|
+
securityDepositApyPPM?: bigint;
|
|
78
|
+
securityDepositBaseMultiplierPPM?: bigint;
|
|
77
79
|
}>;
|
|
78
80
|
/**
|
|
79
81
|
* Checks minimums/maximums, calculates the fee & total amount
|
|
@@ -97,6 +99,8 @@ export declare abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<S
|
|
|
97
99
|
swapFee: bigint;
|
|
98
100
|
swapFeeInToken: bigint;
|
|
99
101
|
totalInToken: bigint;
|
|
102
|
+
securityDepositApyPPM?: bigint;
|
|
103
|
+
securityDepositBaseMultiplierPPM?: bigint;
|
|
100
104
|
}>;
|
|
101
105
|
/**
|
|
102
106
|
* Signs the created swap
|
|
@@ -125,8 +129,12 @@ export declare abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<S
|
|
|
125
129
|
* @param baseSecurityDepositPromise
|
|
126
130
|
* @param depositToken
|
|
127
131
|
* @param depositTokenPricePrefetchPromise
|
|
132
|
+
* @param securityDepositData
|
|
128
133
|
* @param signal
|
|
129
134
|
* @param metadata
|
|
130
135
|
*/
|
|
131
|
-
protected getSecurityDeposit(chainIdentifier: string, amountBD: bigint, swapFee: bigint, expiryTimeout: bigint, baseSecurityDepositPromise: Promise<bigint>, depositToken: string, depositTokenPricePrefetchPromise: Promise<bigint>,
|
|
136
|
+
protected getSecurityDeposit(chainIdentifier: string, amountBD: bigint, swapFee: bigint, expiryTimeout: bigint, baseSecurityDepositPromise: Promise<bigint>, depositToken: string, depositTokenPricePrefetchPromise: Promise<bigint>, securityDepositData: {
|
|
137
|
+
securityDepositApyPPM?: bigint;
|
|
138
|
+
securityDepositBaseMultiplierPPM?: bigint;
|
|
139
|
+
}, signal: AbortSignal, metadata: any): Promise<bigint>;
|
|
132
140
|
}
|
|
@@ -155,7 +155,9 @@ class FromBtcBaseSwapHandler extends SwapHandler_1.SwapHandler {
|
|
|
155
155
|
if ((0, IPlugin_1.isQuoteSetFees)(res)) {
|
|
156
156
|
return {
|
|
157
157
|
baseFee: res.baseFee || this.config.baseFee,
|
|
158
|
-
feePPM: res.feePPM || this.config.feePPM
|
|
158
|
+
feePPM: res.feePPM || this.config.feePPM,
|
|
159
|
+
securityDepositApyPPM: res.securityDepositApyPPM,
|
|
160
|
+
securityDepositBaseMultiplierPPM: res.securityDepositBaseMultiplierPPM
|
|
159
161
|
};
|
|
160
162
|
}
|
|
161
163
|
}
|
|
@@ -179,6 +181,8 @@ class FromBtcBaseSwapHandler extends SwapHandler_1.SwapHandler {
|
|
|
179
181
|
*/
|
|
180
182
|
async checkFromBtcAmount(request, requestedAmount, fees, useToken, signal, pricePrefetchPromise = Promise.resolve(null)) {
|
|
181
183
|
const chainIdentifier = request.chainIdentifier;
|
|
184
|
+
let securityDepositApyPPM;
|
|
185
|
+
let securityDepositBaseMultiplierPPM;
|
|
182
186
|
const res = await PluginManager_1.PluginManager.onHandlePostFromBtcQuote(request, requestedAmount, chainIdentifier, useToken, { minInBtc: this.config.min, maxInBtc: this.config.max }, { baseFeeInBtc: fees.baseFee, feePPM: fees.feePPM }, pricePrefetchPromise);
|
|
183
187
|
signal.throwIfAborted();
|
|
184
188
|
if (res != null) {
|
|
@@ -188,6 +192,10 @@ class FromBtcBaseSwapHandler extends SwapHandler_1.SwapHandler {
|
|
|
188
192
|
fees.baseFee = res.baseFee;
|
|
189
193
|
if (res.feePPM != null)
|
|
190
194
|
fees.feePPM = res.feePPM;
|
|
195
|
+
if (res.securityDepositApyPPM != null)
|
|
196
|
+
securityDepositApyPPM = res.securityDepositApyPPM;
|
|
197
|
+
if (res.securityDepositBaseMultiplierPPM != null)
|
|
198
|
+
securityDepositBaseMultiplierPPM = res.securityDepositBaseMultiplierPPM;
|
|
191
199
|
}
|
|
192
200
|
if ((0, IPlugin_1.isPluginQuote)(res)) {
|
|
193
201
|
if (!requestedAmount.input) {
|
|
@@ -251,7 +259,9 @@ class FromBtcBaseSwapHandler extends SwapHandler_1.SwapHandler {
|
|
|
251
259
|
amountBD,
|
|
252
260
|
swapFee,
|
|
253
261
|
swapFeeInToken,
|
|
254
|
-
totalInToken
|
|
262
|
+
totalInToken,
|
|
263
|
+
securityDepositApyPPM,
|
|
264
|
+
securityDepositBaseMultiplierPPM
|
|
255
265
|
};
|
|
256
266
|
}
|
|
257
267
|
/**
|
|
@@ -292,16 +302,19 @@ class FromBtcBaseSwapHandler extends SwapHandler_1.SwapHandler {
|
|
|
292
302
|
* @param baseSecurityDepositPromise
|
|
293
303
|
* @param depositToken
|
|
294
304
|
* @param depositTokenPricePrefetchPromise
|
|
305
|
+
* @param securityDepositData
|
|
295
306
|
* @param signal
|
|
296
307
|
* @param metadata
|
|
297
308
|
*/
|
|
298
|
-
async getSecurityDeposit(chainIdentifier, amountBD, swapFee, expiryTimeout, baseSecurityDepositPromise, depositToken, depositTokenPricePrefetchPromise, signal, metadata) {
|
|
309
|
+
async getSecurityDeposit(chainIdentifier, amountBD, swapFee, expiryTimeout, baseSecurityDepositPromise, depositToken, depositTokenPricePrefetchPromise, securityDepositData, signal, metadata) {
|
|
299
310
|
let baseSD = await baseSecurityDepositPromise;
|
|
311
|
+
if (securityDepositData.securityDepositBaseMultiplierPPM != null)
|
|
312
|
+
baseSD = baseSD * securityDepositData.securityDepositBaseMultiplierPPM / 1000000n;
|
|
300
313
|
signal.throwIfAborted();
|
|
301
314
|
metadata.times.refundFeeFetched = Date.now();
|
|
302
315
|
const swapValueInDepositToken = await this.swapPricing.getFromBtcSwapAmount(amountBD - swapFee, depositToken, chainIdentifier, true, depositTokenPricePrefetchPromise);
|
|
303
316
|
signal.throwIfAborted();
|
|
304
|
-
const apyPPM = BigInt(Math.floor(this.config.securityDepositAPY * 1000000));
|
|
317
|
+
const apyPPM = securityDepositData.securityDepositApyPPM ?? BigInt(Math.floor(this.config.securityDepositAPY * 1000000));
|
|
305
318
|
const variableSD = swapValueInDepositToken * apyPPM * expiryTimeout / 1000000n / secondsInYear;
|
|
306
319
|
this.logger.debug("getSecurityDeposit(): base security deposit: " + baseSD.toString(10) +
|
|
307
320
|
" deposit token: " + depositToken +
|
|
@@ -239,8 +239,12 @@ class FromBtcAbs extends FromBtcBaseSwapHandler_1.FromBtcBaseSwapHandler {
|
|
|
239
239
|
abortController.signal.throwIfAborted();
|
|
240
240
|
const baseSDPromise = this.getBaseSecurityDepositPrefetch(chainIdentifier, dummySwapData, depositToken, gasTokenPricePrefetchPromise, depositTokenPricePrefetchPromise, abortController);
|
|
241
241
|
//Check valid amount specified (min/max)
|
|
242
|
-
const { amountBD, swapFee, swapFeeInToken, totalInToken } = await this.checkFromBtcAmount(request, requestedAmount, fees, useToken, abortController.signal, pricePrefetchPromise);
|
|
242
|
+
const { amountBD, swapFee, swapFeeInToken, totalInToken, securityDepositApyPPM, securityDepositBaseMultiplierPPM } = await this.checkFromBtcAmount(request, requestedAmount, fees, useToken, abortController.signal, pricePrefetchPromise);
|
|
243
243
|
metadata.times.priceCalculated = Date.now();
|
|
244
|
+
if (securityDepositApyPPM != null)
|
|
245
|
+
fees.securityDepositApyPPM = securityDepositApyPPM;
|
|
246
|
+
if (securityDepositBaseMultiplierPPM != null)
|
|
247
|
+
fees.securityDepositBaseMultiplierPPM = securityDepositBaseMultiplierPPM;
|
|
244
248
|
//Check if we have enough funds to honor the request
|
|
245
249
|
await this.checkBalance(totalInToken, balancePrefetch, abortController.signal);
|
|
246
250
|
metadata.times.balanceChecked = Date.now();
|
|
@@ -253,7 +257,7 @@ class FromBtcAbs extends FromBtcBaseSwapHandler_1.FromBtcBaseSwapHandler {
|
|
|
253
257
|
const expiryTimeout = this.config.swapTsCsvDelta;
|
|
254
258
|
const expiry = currentTimestamp + expiryTimeout;
|
|
255
259
|
//Calculate security deposit
|
|
256
|
-
const totalSecurityDeposit = await this.getSecurityDeposit(chainIdentifier, amountBD, swapFee, expiryTimeout, baseSDPromise, depositToken, depositTokenPricePrefetchPromise, abortController.signal, metadata);
|
|
260
|
+
const totalSecurityDeposit = await this.getSecurityDeposit(chainIdentifier, amountBD, swapFee, expiryTimeout, baseSDPromise, depositToken, depositTokenPricePrefetchPromise, fees, abortController.signal, metadata);
|
|
257
261
|
metadata.times.securityDepositCalculated = Date.now();
|
|
258
262
|
//Calculate claimer bounty
|
|
259
263
|
const totalClaimerBounty = await this.getClaimerBounty(req, expiry, abortController.signal);
|
|
@@ -488,8 +488,12 @@ class FromBtcLnAbs extends FromBtcLnBaseSwapHandler_1.FromBtcLnBaseSwapHandler {
|
|
|
488
488
|
//Asynchronously send the node's public key to the client
|
|
489
489
|
this.sendPublicKeyAsync(responseStream);
|
|
490
490
|
//Check valid amount specified (min/max)
|
|
491
|
-
const { amountBD, swapFee, swapFeeInToken, totalInToken } = await this.checkFromBtcAmount(request, requestedAmount, fees, useToken, abortController.signal, pricePrefetchPromise);
|
|
491
|
+
const { amountBD, swapFee, swapFeeInToken, totalInToken, securityDepositApyPPM, securityDepositBaseMultiplierPPM } = await this.checkFromBtcAmount(request, requestedAmount, fees, useToken, abortController.signal, pricePrefetchPromise);
|
|
492
492
|
metadata.times.priceCalculated = Date.now();
|
|
493
|
+
if (securityDepositApyPPM != null)
|
|
494
|
+
fees.securityDepositApyPPM = securityDepositApyPPM;
|
|
495
|
+
if (securityDepositBaseMultiplierPPM != null)
|
|
496
|
+
fees.securityDepositBaseMultiplierPPM = securityDepositBaseMultiplierPPM;
|
|
493
497
|
//Check if we have enough funds to honor the request
|
|
494
498
|
await this.checkBalance(totalInToken, balancePrefetch, abortController.signal);
|
|
495
499
|
await this.checkInboundLiquidity(amountBD, channelsPrefetch, abortController.signal);
|
|
@@ -510,7 +514,7 @@ class FromBtcLnAbs extends FromBtcLnBaseSwapHandler_1.FromBtcLnBaseSwapHandler {
|
|
|
510
514
|
metadata.invoiceResponse = { ...hodlInvoice };
|
|
511
515
|
//Pre-compute the security deposit
|
|
512
516
|
const expiryTimeout = (this.config.minCltv * this.config.bitcoinBlocktime / this.config.safetyFactor) - this.config.gracePeriod;
|
|
513
|
-
const totalSecurityDeposit = await this.getSecurityDeposit(chainIdentifier, amountBD, swapFee, expiryTimeout, baseSDPromise, depositToken, depositTokenPricePrefetchPromise, abortController.signal, metadata);
|
|
517
|
+
const totalSecurityDeposit = await this.getSecurityDeposit(chainIdentifier, amountBD, swapFee, expiryTimeout, baseSDPromise, depositToken, depositTokenPricePrefetchPromise, fees, abortController.signal, metadata);
|
|
514
518
|
metadata.times.securityDepositCalculated = Date.now();
|
|
515
519
|
const createdSwap = new FromBtcLnSwapAbs_1.FromBtcLnSwapAbs(chainIdentifier, hodlInvoice.request, parsedBody.paymentHash, hodlInvoice.mtokens, swapFee, swapFeeInToken, parsedBody.address, useToken, totalInToken, swapContract.getHashForHtlc(Buffer.from(parsedBody.paymentHash, "hex")).toString("hex"), totalSecurityDeposit, depositToken);
|
|
516
520
|
metadata.times.swapCreated = Date.now();
|
package/package.json
CHANGED
package/src/plugins/IPlugin.ts
CHANGED
|
@@ -25,13 +25,17 @@ export function isQuoteThrow(obj: any): obj is QuoteThrow {
|
|
|
25
25
|
export type QuoteSetFees = {
|
|
26
26
|
type: "fees"
|
|
27
27
|
baseFee?: bigint,
|
|
28
|
-
feePPM?: bigint
|
|
28
|
+
feePPM?: bigint,
|
|
29
|
+
securityDepositApyPPM?: bigint,
|
|
30
|
+
securityDepositBaseMultiplierPPM?: bigint
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
export function isQuoteSetFees(obj: any): obj is QuoteSetFees {
|
|
32
34
|
return obj.type==="fees" &&
|
|
33
35
|
(obj.baseFee==null || typeof(obj.baseFee) === "bigint") &&
|
|
34
|
-
(obj.feePPM==null || typeof(obj.feePPM) === "bigint")
|
|
36
|
+
(obj.feePPM==null || typeof(obj.feePPM) === "bigint") &&
|
|
37
|
+
(obj.securityDepositApyPPM==null || typeof(obj.securityDepositApyPPM) === "bigint") &&
|
|
38
|
+
(obj.securityDepositBaseMultiplierPPM==null || typeof(obj.securityDepositBaseMultiplierPPM) === "bigint");
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
export type QuoteAmountTooLow = {
|
|
@@ -174,7 +174,12 @@ export abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<SwapData,
|
|
|
174
174
|
request: RequestData<FromBtcLnRequestType | FromBtcRequestType | FromBtcLnTrustedRequestType>,
|
|
175
175
|
requestedAmount: {input: boolean, amount: bigint},
|
|
176
176
|
useToken: string
|
|
177
|
-
): Promise<{
|
|
177
|
+
): Promise<{
|
|
178
|
+
baseFee: bigint,
|
|
179
|
+
feePPM: bigint,
|
|
180
|
+
securityDepositApyPPM?: bigint,
|
|
181
|
+
securityDepositBaseMultiplierPPM?: bigint,
|
|
182
|
+
}> {
|
|
178
183
|
const res = await PluginManager.onHandlePreFromBtcQuote(
|
|
179
184
|
request,
|
|
180
185
|
requestedAmount,
|
|
@@ -188,7 +193,9 @@ export abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<SwapData,
|
|
|
188
193
|
if(isQuoteSetFees(res)) {
|
|
189
194
|
return {
|
|
190
195
|
baseFee: res.baseFee || this.config.baseFee,
|
|
191
|
-
feePPM: res.feePPM || this.config.feePPM
|
|
196
|
+
feePPM: res.feePPM || this.config.feePPM,
|
|
197
|
+
securityDepositApyPPM: res.securityDepositApyPPM,
|
|
198
|
+
securityDepositBaseMultiplierPPM: res.securityDepositBaseMultiplierPPM
|
|
192
199
|
}
|
|
193
200
|
}
|
|
194
201
|
}
|
|
@@ -221,10 +228,15 @@ export abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<SwapData,
|
|
|
221
228
|
amountBD: bigint,
|
|
222
229
|
swapFee: bigint, //Swap fee in BTC
|
|
223
230
|
swapFeeInToken: bigint, //Swap fee in token on top of what should be paid out to the user
|
|
224
|
-
totalInToken: bigint //Total to be paid out to the user
|
|
231
|
+
totalInToken: bigint, //Total to be paid out to the user
|
|
232
|
+
securityDepositApyPPM?: bigint,
|
|
233
|
+
securityDepositBaseMultiplierPPM?: bigint
|
|
225
234
|
}> {
|
|
226
235
|
const chainIdentifier = request.chainIdentifier;
|
|
227
236
|
|
|
237
|
+
let securityDepositApyPPM: bigint;
|
|
238
|
+
let securityDepositBaseMultiplierPPM: bigint;
|
|
239
|
+
|
|
228
240
|
const res = await PluginManager.onHandlePostFromBtcQuote(
|
|
229
241
|
request,
|
|
230
242
|
requestedAmount,
|
|
@@ -240,6 +252,8 @@ export abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<SwapData,
|
|
|
240
252
|
if(isQuoteSetFees(res)) {
|
|
241
253
|
if(res.baseFee!=null) fees.baseFee = res.baseFee;
|
|
242
254
|
if(res.feePPM!=null) fees.feePPM = res.feePPM;
|
|
255
|
+
if(res.securityDepositApyPPM!=null) securityDepositApyPPM = res.securityDepositApyPPM;
|
|
256
|
+
if(res.securityDepositBaseMultiplierPPM!=null) securityDepositBaseMultiplierPPM = res.securityDepositBaseMultiplierPPM;
|
|
243
257
|
}
|
|
244
258
|
if(isPluginQuote(res)) {
|
|
245
259
|
if(!requestedAmount.input) {
|
|
@@ -310,7 +324,9 @@ export abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<SwapData,
|
|
|
310
324
|
amountBD,
|
|
311
325
|
swapFee,
|
|
312
326
|
swapFeeInToken,
|
|
313
|
-
totalInToken
|
|
327
|
+
totalInToken,
|
|
328
|
+
securityDepositApyPPM,
|
|
329
|
+
securityDepositBaseMultiplierPPM
|
|
314
330
|
}
|
|
315
331
|
}
|
|
316
332
|
|
|
@@ -373,6 +389,7 @@ export abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<SwapData,
|
|
|
373
389
|
* @param baseSecurityDepositPromise
|
|
374
390
|
* @param depositToken
|
|
375
391
|
* @param depositTokenPricePrefetchPromise
|
|
392
|
+
* @param securityDepositData
|
|
376
393
|
* @param signal
|
|
377
394
|
* @param metadata
|
|
378
395
|
*/
|
|
@@ -384,10 +401,16 @@ export abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<SwapData,
|
|
|
384
401
|
baseSecurityDepositPromise: Promise<bigint>,
|
|
385
402
|
depositToken: string,
|
|
386
403
|
depositTokenPricePrefetchPromise: Promise<bigint>,
|
|
404
|
+
securityDepositData: {
|
|
405
|
+
securityDepositApyPPM?: bigint,
|
|
406
|
+
securityDepositBaseMultiplierPPM?: bigint,
|
|
407
|
+
},
|
|
387
408
|
signal: AbortSignal,
|
|
388
409
|
metadata: any
|
|
389
410
|
): Promise<bigint> {
|
|
390
411
|
let baseSD: bigint = await baseSecurityDepositPromise;
|
|
412
|
+
if(securityDepositData.securityDepositBaseMultiplierPPM!=null)
|
|
413
|
+
baseSD = baseSD * securityDepositData.securityDepositBaseMultiplierPPM / 1_000_000n;
|
|
391
414
|
|
|
392
415
|
signal.throwIfAborted();
|
|
393
416
|
|
|
@@ -403,7 +426,7 @@ export abstract class FromBtcBaseSwapHandler<V extends SwapHandlerSwap<SwapData,
|
|
|
403
426
|
|
|
404
427
|
signal.throwIfAborted();
|
|
405
428
|
|
|
406
|
-
const apyPPM = BigInt(Math.floor(this.config.securityDepositAPY*1000000));
|
|
429
|
+
const apyPPM = securityDepositData.securityDepositApyPPM ?? BigInt(Math.floor(this.config.securityDepositAPY*1000000));
|
|
407
430
|
const variableSD = swapValueInDepositToken * apyPPM * expiryTimeout / 1000000n / secondsInYear;
|
|
408
431
|
|
|
409
432
|
this.logger.debug(
|
|
@@ -333,10 +333,15 @@ export class FromBtcAbs extends FromBtcBaseSwapHandler<FromBtcSwapAbs, FromBtcSw
|
|
|
333
333
|
amountBD,
|
|
334
334
|
swapFee,
|
|
335
335
|
swapFeeInToken,
|
|
336
|
-
totalInToken
|
|
336
|
+
totalInToken,
|
|
337
|
+
securityDepositApyPPM,
|
|
338
|
+
securityDepositBaseMultiplierPPM
|
|
337
339
|
} = await this.checkFromBtcAmount(request, requestedAmount, fees, useToken, abortController.signal, pricePrefetchPromise);
|
|
338
340
|
metadata.times.priceCalculated = Date.now();
|
|
339
341
|
|
|
342
|
+
if(securityDepositApyPPM!=null) fees.securityDepositApyPPM = securityDepositApyPPM;
|
|
343
|
+
if(securityDepositBaseMultiplierPPM!=null) fees.securityDepositBaseMultiplierPPM = securityDepositBaseMultiplierPPM;
|
|
344
|
+
|
|
340
345
|
//Check if we have enough funds to honor the request
|
|
341
346
|
await this.checkBalance(totalInToken, balancePrefetch, abortController.signal);
|
|
342
347
|
metadata.times.balanceChecked = Date.now();
|
|
@@ -354,7 +359,7 @@ export class FromBtcAbs extends FromBtcBaseSwapHandler<FromBtcSwapAbs, FromBtcSw
|
|
|
354
359
|
//Calculate security deposit
|
|
355
360
|
const totalSecurityDeposit = await this.getSecurityDeposit(
|
|
356
361
|
chainIdentifier, amountBD, swapFee, expiryTimeout,
|
|
357
|
-
baseSDPromise, depositToken, depositTokenPricePrefetchPromise,
|
|
362
|
+
baseSDPromise, depositToken, depositTokenPricePrefetchPromise, fees,
|
|
358
363
|
abortController.signal, metadata
|
|
359
364
|
);
|
|
360
365
|
metadata.times.securityDepositCalculated = Date.now();
|
|
@@ -624,10 +624,15 @@ export class FromBtcLnAbs extends FromBtcLnBaseSwapHandler<FromBtcLnSwapAbs, Fro
|
|
|
624
624
|
amountBD,
|
|
625
625
|
swapFee,
|
|
626
626
|
swapFeeInToken,
|
|
627
|
-
totalInToken
|
|
627
|
+
totalInToken,
|
|
628
|
+
securityDepositApyPPM,
|
|
629
|
+
securityDepositBaseMultiplierPPM
|
|
628
630
|
} = await this.checkFromBtcAmount(request, requestedAmount, fees, useToken, abortController.signal, pricePrefetchPromise);
|
|
629
631
|
metadata.times.priceCalculated = Date.now();
|
|
630
632
|
|
|
633
|
+
if(securityDepositApyPPM!=null) fees.securityDepositApyPPM = securityDepositApyPPM;
|
|
634
|
+
if(securityDepositBaseMultiplierPPM!=null) fees.securityDepositBaseMultiplierPPM = securityDepositBaseMultiplierPPM;
|
|
635
|
+
|
|
631
636
|
//Check if we have enough funds to honor the request
|
|
632
637
|
await this.checkBalance(totalInToken, balancePrefetch, abortController.signal)
|
|
633
638
|
await this.checkInboundLiquidity(amountBD, channelsPrefetch, abortController.signal);
|
|
@@ -653,7 +658,7 @@ export class FromBtcLnAbs extends FromBtcLnBaseSwapHandler<FromBtcLnSwapAbs, Fro
|
|
|
653
658
|
const expiryTimeout = (this.config.minCltv * this.config.bitcoinBlocktime / this.config.safetyFactor) - this.config.gracePeriod;
|
|
654
659
|
const totalSecurityDeposit = await this.getSecurityDeposit(
|
|
655
660
|
chainIdentifier, amountBD, swapFee, expiryTimeout,
|
|
656
|
-
baseSDPromise, depositToken, depositTokenPricePrefetchPromise,
|
|
661
|
+
baseSDPromise, depositToken, depositTokenPricePrefetchPromise, fees,
|
|
657
662
|
abortController.signal, metadata
|
|
658
663
|
);
|
|
659
664
|
metadata.times.securityDepositCalculated = Date.now();
|