@atomiqlabs/lp-lib 17.5.1 → 17.5.3

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.
@@ -23,7 +23,7 @@ export declare class CoinGeckoSwapPrice extends ISwapPrice<{
23
23
  decimals: number;
24
24
  }>);
25
25
  /**
26
- * Returns coin price in mSat
26
+ * Returns coin price in uSat (sats-per-token * 1_000_000)
27
27
  *
28
28
  * @param coin
29
29
  */
@@ -10,7 +10,7 @@ class CoinGeckoSwapPrice extends ISwapPrice_1.ISwapPrice {
10
10
  this.url = url || "https://api.coingecko.com/api/v3";
11
11
  }
12
12
  /**
13
- * Returns coin price in mSat
13
+ * Returns coin price in uSat (sats-per-token * 1_000_000)
14
14
  *
15
15
  * @param coin
16
16
  */
@@ -18,7 +18,7 @@ class CoinGeckoSwapPrice extends ISwapPrice_1.ISwapPrice {
18
18
  const coinId = coin.coinId;
19
19
  if (coinId.startsWith("$fixed-")) {
20
20
  const amt = parseFloat(coinId.substring(7));
21
- return BigInt(Math.floor(amt * 1000));
21
+ return BigInt(Math.floor(amt * 1000000));
22
22
  }
23
23
  const cachedValue = this.cache[coinId];
24
24
  if (cachedValue != null && cachedValue.expiry > Date.now()) {
@@ -40,7 +40,7 @@ class CoinGeckoSwapPrice extends ISwapPrice_1.ISwapPrice {
40
40
  }
41
41
  let jsonBody = await response.json();
42
42
  const amt = jsonBody[coinId].sats;
43
- const result = BigInt(Math.floor(amt * 1000));
43
+ const result = BigInt(Math.floor(amt * 1000000));
44
44
  this.cache[coinId] = {
45
45
  price: result,
46
46
  expiry: Date.now() + CACHE_DURATION
@@ -13,7 +13,7 @@ export declare abstract class ISwapPrice<T extends {
13
13
  protected coinsMap: ISwapPriceCoinsMap<T>;
14
14
  protected constructor(coinsMap: ISwapPriceCoinsMap<T>);
15
15
  /**
16
- * Returns coin price in mSat
16
+ * Returns coin price in uSat (sats-per-token * 1_000_000)
17
17
  *
18
18
  * @param tokenData
19
19
  */
@@ -8,7 +8,7 @@ import { ToBtcBaseConfig, ToBtcBaseSwapHandler } from "../ToBtcBaseSwapHandler";
8
8
  import { ILightningWallet, ParsedPaymentRequest } from "../../../wallets/ILightningWallet";
9
9
  import { LightningAssertions } from "../../assertions/LightningAssertions";
10
10
  export type ToBtcLnConfig = ToBtcBaseConfig & {
11
- routingFeeMultiplier: bigint;
11
+ routingFeeMultiplier: bigint | number;
12
12
  minSendCltv: bigint;
13
13
  allowProbeFailedSwaps: boolean;
14
14
  allowShortExpiry: boolean;
@@ -497,7 +497,9 @@ class ToBtcLnAbs extends ToBtcBaseSwapHandler_1.ToBtcBaseSwapHandler {
497
497
  " fee mtokens: " + probeOrRouteResp.feeMtokens.toString(10));
498
498
  }
499
499
  const safeFeeTokens = (probeOrRouteResp.feeMtokens + 999n) / 1000n;
500
- let actualRoutingFee = safeFeeTokens * this.config.routingFeeMultiplier;
500
+ let actualRoutingFee = safeFeeTokens
501
+ * BigInt(Math.floor(Number(this.config.routingFeeMultiplier) * 1000000))
502
+ / 1000000n;
501
503
  const minRoutingFee = (amountBD * this.config.minLnRoutingFeePPM / 1000000n) + this.config.minLnBaseFee;
502
504
  if (actualRoutingFee < minRoutingFee) {
503
505
  actualRoutingFee = minRoutingFee;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/lp-lib",
3
- "version": "17.5.1",
3
+ "version": "17.5.3",
4
4
  "description": "Main functionality implementation for atomiq LP node",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -27,7 +27,7 @@ export class CoinGeckoSwapPrice extends ISwapPrice<{coinId: string, decimals: nu
27
27
  }
28
28
 
29
29
  /**
30
- * Returns coin price in mSat
30
+ * Returns coin price in uSat (sats-per-token * 1_000_000)
31
31
  *
32
32
  * @param coin
33
33
  */
@@ -35,7 +35,7 @@ export class CoinGeckoSwapPrice extends ISwapPrice<{coinId: string, decimals: nu
35
35
  const coinId = coin.coinId;
36
36
  if(coinId.startsWith("$fixed-")) {
37
37
  const amt: number = parseFloat(coinId.substring(7));
38
- return BigInt(Math.floor(amt*1000));
38
+ return BigInt(Math.floor(amt*1000000));
39
39
  }
40
40
 
41
41
  const cachedValue = this.cache[coinId];
@@ -62,7 +62,7 @@ export class CoinGeckoSwapPrice extends ISwapPrice<{coinId: string, decimals: nu
62
62
 
63
63
  const amt: number = jsonBody[coinId].sats;
64
64
 
65
- const result = BigInt(Math.floor(amt*1000));
65
+ const result = BigInt(Math.floor(amt*1000000));
66
66
 
67
67
  this.cache[coinId] = {
68
68
  price: result,
@@ -13,7 +13,7 @@ export abstract class ISwapPrice<T extends {decimals: number} = {decimals: numbe
13
13
  }
14
14
 
15
15
  /**
16
- * Returns coin price in mSat
16
+ * Returns coin price in uSat (sats-per-token * 1_000_000)
17
17
  *
18
18
  * @param tokenData
19
19
  */
@@ -32,7 +32,7 @@ import {isQuoteThrow} from "../../../plugins/IPlugin";
32
32
  import {ToBtcSwapState} from "../tobtc_abstract/ToBtcSwapAbs";
33
33
 
34
34
  export type ToBtcLnConfig = ToBtcBaseConfig & {
35
- routingFeeMultiplier: bigint,
35
+ routingFeeMultiplier: bigint | number,
36
36
 
37
37
  minSendCltv: bigint,
38
38
 
@@ -625,7 +625,9 @@ export class ToBtcLnAbs extends ToBtcBaseSwapHandler<ToBtcLnSwapAbs, ToBtcLnSwap
625
625
 
626
626
  const safeFeeTokens = (probeOrRouteResp.feeMtokens + 999n) / 1000n;
627
627
 
628
- let actualRoutingFee: bigint = safeFeeTokens * this.config.routingFeeMultiplier;
628
+ let actualRoutingFee: bigint = safeFeeTokens
629
+ * BigInt(Math.floor(Number(this.config.routingFeeMultiplier) * 1_000_000))
630
+ / 1_000_000n;
629
631
 
630
632
  const minRoutingFee: bigint = (amountBD * this.config.minLnRoutingFeePPM / 1000000n) + this.config.minLnBaseFee;
631
633
  if(actualRoutingFee < minRoutingFee) {