@atomiqlabs/lp-lib 16.0.11 → 16.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.
@@ -1,4 +1,4 @@
1
- import { ISwapPrice } from "./ISwapPrice";
1
+ import { ISwapPrice, ISwapPriceCoinsMap } from "./ISwapPrice";
2
2
  export type BinancePriceData = {
3
3
  [pair: string]: {
4
4
  [chainId: string]: {
@@ -18,7 +18,10 @@ export declare class BinanceSwapPrice extends ISwapPrice<{
18
18
  expiry: number;
19
19
  };
20
20
  };
21
- constructor(url: string, coins: BinancePriceData);
21
+ constructor(url: string, coins: ISwapPriceCoinsMap<{
22
+ pair: string;
23
+ decimals: number;
24
+ }>);
22
25
  fetchPrice(pair: string): Promise<number>;
23
26
  getPrice(tokenData: {
24
27
  pair: string;
@@ -5,20 +5,7 @@ const ISwapPrice_1 = require("./ISwapPrice");
5
5
  const CACHE_DURATION = 15000;
6
6
  class BinanceSwapPrice extends ISwapPrice_1.ISwapPrice {
7
7
  constructor(url, coins) {
8
- const coinsMap = {};
9
- for (let pair in coins) {
10
- const chains = coins[pair];
11
- for (let chainId in chains) {
12
- const tokenData = chains[chainId];
13
- if (coinsMap[chainId] == null)
14
- coinsMap[chainId] = {};
15
- coinsMap[chainId][tokenData.address] = {
16
- pair,
17
- decimals: tokenData.decimals
18
- };
19
- }
20
- }
21
- super(coinsMap);
8
+ super(coins);
22
9
  this.cache = {};
23
10
  this.url = url || "https://api.binance.com/api/v3";
24
11
  }
@@ -1,4 +1,4 @@
1
- import { ISwapPrice } from "./ISwapPrice";
1
+ import { ISwapPrice, ISwapPriceCoinsMap } from "./ISwapPrice";
2
2
  export type CoinGeckoPriceData = {
3
3
  [coinId: string]: {
4
4
  [chainId: string]: {
@@ -18,7 +18,10 @@ export declare class CoinGeckoSwapPrice extends ISwapPrice<{
18
18
  expiry: number;
19
19
  };
20
20
  };
21
- constructor(url: string, coins: CoinGeckoPriceData);
21
+ constructor(url: string, coins: ISwapPriceCoinsMap<{
22
+ coinId: string;
23
+ decimals: number;
24
+ }>);
22
25
  /**
23
26
  * Returns coin price in mSat
24
27
  *
@@ -5,20 +5,7 @@ const ISwapPrice_1 = require("./ISwapPrice");
5
5
  const CACHE_DURATION = 15000;
6
6
  class CoinGeckoSwapPrice extends ISwapPrice_1.ISwapPrice {
7
7
  constructor(url, coins) {
8
- const coinsMap = {};
9
- for (let coinId in coins) {
10
- const chains = coins[coinId];
11
- for (let chainId in chains) {
12
- const tokenData = chains[chainId];
13
- if (coinsMap[chainId] == null)
14
- coinsMap[chainId] = {};
15
- coinsMap[chainId][tokenData.address] = {
16
- coinId,
17
- decimals: tokenData.decimals
18
- };
19
- }
20
- }
21
- super(coinsMap);
8
+ super(coins);
22
9
  this.cache = {};
23
10
  this.url = url || "https://api.coingecko.com/api/v3";
24
11
  }
@@ -1,4 +1,4 @@
1
- import { ISwapPrice } from "./ISwapPrice";
1
+ import { ISwapPrice, ISwapPriceCoinsMap } from "./ISwapPrice";
2
2
  export type OKXPriceData = {
3
3
  [pair: string]: {
4
4
  [chainId: string]: {
@@ -18,7 +18,10 @@ export declare class OKXSwapPrice extends ISwapPrice<{
18
18
  expiry: number;
19
19
  };
20
20
  };
21
- constructor(url: string, coins: OKXPriceData);
21
+ constructor(url: string, coins: ISwapPriceCoinsMap<{
22
+ pair: string;
23
+ decimals: number;
24
+ }>);
22
25
  fetchPrice(pair: string): Promise<number>;
23
26
  getPrice(tokenData: {
24
27
  pair: string;
@@ -5,20 +5,7 @@ const ISwapPrice_1 = require("./ISwapPrice");
5
5
  const CACHE_DURATION = 15000;
6
6
  class OKXSwapPrice extends ISwapPrice_1.ISwapPrice {
7
7
  constructor(url, coins) {
8
- const coinsMap = {};
9
- for (let pair in coins) {
10
- const chains = coins[pair];
11
- for (let chainId in chains) {
12
- const tokenData = chains[chainId];
13
- if (coinsMap[chainId] == null)
14
- coinsMap[chainId] = {};
15
- coinsMap[chainId][tokenData.address] = {
16
- pair,
17
- decimals: tokenData.decimals
18
- };
19
- }
20
- }
21
- super(coinsMap);
8
+ super(coins);
22
9
  this.cache = {};
23
10
  this.url = url || "https://www.okx.com/api/v5";
24
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomiqlabs/lp-lib",
3
- "version": "16.0.11",
3
+ "version": "16.1.0",
4
4
  "description": "Main functionality implementation for atomiq LP node",
5
5
  "main": "./dist/index.js",
6
6
  "types:": "./dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import {ISwapPrice} from "./ISwapPrice";
1
+ import {ISwapPrice, ISwapPriceCoinsMap} from "./ISwapPrice";
2
2
 
3
3
  const CACHE_DURATION = 15000;
4
4
 
@@ -21,20 +21,8 @@ export class BinanceSwapPrice extends ISwapPrice<{ pair: string, decimals: numbe
21
21
  }
22
22
  } = {};
23
23
 
24
- constructor(url: string, coins: BinancePriceData) {
25
- const coinsMap = {};
26
- for(let pair in coins) {
27
- const chains = coins[pair];
28
- for(let chainId in chains) {
29
- const tokenData = chains[chainId];
30
- if(coinsMap[chainId]==null) coinsMap[chainId] = {};
31
- coinsMap[chainId][tokenData.address] = {
32
- pair,
33
- decimals: tokenData.decimals
34
- }
35
- }
36
- }
37
- super(coinsMap);
24
+ constructor(url: string, coins: ISwapPriceCoinsMap<{pair: string, decimals: number}>) {
25
+ super(coins);
38
26
  this.url = url || "https://api.binance.com/api/v3";
39
27
  }
40
28
 
@@ -1,4 +1,4 @@
1
- import {ISwapPrice} from "./ISwapPrice";
1
+ import {ISwapPrice, ISwapPriceCoinsMap} from "./ISwapPrice";
2
2
 
3
3
  const CACHE_DURATION = 15000;
4
4
 
@@ -21,20 +21,8 @@ export class CoinGeckoSwapPrice extends ISwapPrice<{coinId: string, decimals: nu
21
21
  }
22
22
  } = {};
23
23
 
24
- constructor(url: string, coins: CoinGeckoPriceData) {
25
- const coinsMap = {};
26
- for(let coinId in coins) {
27
- const chains = coins[coinId];
28
- for(let chainId in chains) {
29
- const tokenData = chains[chainId];
30
- if(coinsMap[chainId]==null) coinsMap[chainId] = {};
31
- coinsMap[chainId][tokenData.address] = {
32
- coinId,
33
- decimals: tokenData.decimals
34
- };
35
- }
36
- }
37
- super(coinsMap);
24
+ constructor(url: string, coins: ISwapPriceCoinsMap<{coinId: string, decimals: number}>) {
25
+ super(coins);
38
26
  this.url = url || "https://api.coingecko.com/api/v3";
39
27
  }
40
28
 
@@ -1,4 +1,4 @@
1
- import {ISwapPrice} from "./ISwapPrice";
1
+ import {ISwapPrice, ISwapPriceCoinsMap} from "./ISwapPrice";
2
2
 
3
3
  const CACHE_DURATION = 15000;
4
4
 
@@ -21,20 +21,8 @@ export class OKXSwapPrice extends ISwapPrice<{ pair: string, decimals: number }>
21
21
  }
22
22
  } = {};
23
23
 
24
- constructor(url: string, coins: OKXPriceData) {
25
- const coinsMap = {};
26
- for(let pair in coins) {
27
- const chains = coins[pair];
28
- for(let chainId in chains) {
29
- const tokenData = chains[chainId];
30
- if(coinsMap[chainId]==null) coinsMap[chainId] = {};
31
- coinsMap[chainId][tokenData.address] = {
32
- pair,
33
- decimals: tokenData.decimals
34
- }
35
- }
36
- }
37
- super(coinsMap);
24
+ constructor(url: string, coins: ISwapPriceCoinsMap<{pair: string, decimals: number}>) {
25
+ super(coins);
38
26
  this.url = url || "https://www.okx.com/api/v5";
39
27
  }
40
28