@volare.finance/nestjs.plugins 1.0.3 → 1.0.5
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/binance/binance.service.d.ts +24 -1
- package/dist/binance/binance.service.js +5 -23
- package/dist/binance/binance.service.js.map +1 -1
- package/dist/coingecko/coingecko.config.d.ts +2 -0
- package/dist/coingecko/coingecko.service.d.ts +1 -0
- package/dist/coingecko/coingecko.service.js +11 -8
- package/dist/coingecko/coingecko.service.js.map +1 -1
- package/dist/lbank/lbank.service.d.ts +1 -0
- package/dist/lbank/lbank.service.js +19 -22
- package/dist/lbank/lbank.service.js.map +1 -1
- package/dist/mexc/mexc.service.d.ts +21 -1
- package/dist/mexc/mexc.service.js +7 -26
- package/dist/mexc/mexc.service.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { BinanceConfig } from './binance.config';
|
|
7
7
|
export declare class BinanceService {
|
|
8
8
|
private readonly constant;
|
|
9
|
+
private readonly instance;
|
|
9
10
|
constructor(constant: BinanceConfig);
|
|
10
11
|
/**
|
|
11
12
|
* Market Data - Current Average Price
|
|
@@ -21,7 +22,29 @@ export declare class BinanceService {
|
|
|
21
22
|
* @param symbol e.g. BTCUSDT
|
|
22
23
|
* @see https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics
|
|
23
24
|
*/
|
|
24
|
-
tickerPrice24H(symbol: string): Promise<
|
|
25
|
+
tickerPrice24H(symbol: string): Promise<{
|
|
26
|
+
symbol: string;
|
|
27
|
+
priceChange: string;
|
|
28
|
+
priceChangePercent: string;
|
|
29
|
+
weightedAvgPrice: string;
|
|
30
|
+
prevClosePrice: string;
|
|
31
|
+
lastPrice: string;
|
|
32
|
+
lastQty: string;
|
|
33
|
+
bidPrice: string;
|
|
34
|
+
bidQty: string;
|
|
35
|
+
askPrice: string;
|
|
36
|
+
askQty: string;
|
|
37
|
+
openPrice: string;
|
|
38
|
+
highPrice: string;
|
|
39
|
+
lowPrice: string;
|
|
40
|
+
volume: string;
|
|
41
|
+
quoteVolume: string;
|
|
42
|
+
openTime: number;
|
|
43
|
+
closeTime: number;
|
|
44
|
+
firstId: number;
|
|
45
|
+
lastId: number;
|
|
46
|
+
count: number;
|
|
47
|
+
}>;
|
|
25
48
|
/**
|
|
26
49
|
* Market Data - Kline/Candlestick Data
|
|
27
50
|
* @param symbol e.g. BTCUSDT
|
|
@@ -12,7 +12,7 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
12
12
|
let BinanceService = class BinanceService {
|
|
13
13
|
constructor(constant) {
|
|
14
14
|
this.constant = constant;
|
|
15
|
-
|
|
15
|
+
this.instance = axios_1.default.create({ baseURL: this.constant.binance.url });
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Market Data - Current Average Price
|
|
@@ -25,11 +25,7 @@ let BinanceService = class BinanceService {
|
|
|
25
25
|
if (!((_a = this.constant.binance) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
26
26
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
27
27
|
}
|
|
28
|
-
return (yield (
|
|
29
|
-
method: 'GET',
|
|
30
|
-
url: this.constant.binance.url + '/api/v3/avgPrice',
|
|
31
|
-
params: { symbol },
|
|
32
|
-
})).data;
|
|
28
|
+
return (yield this.instance.get('/api/v3/avgPrice', { params: { symbol } })).data;
|
|
33
29
|
});
|
|
34
30
|
}
|
|
35
31
|
/**
|
|
@@ -43,13 +39,7 @@ let BinanceService = class BinanceService {
|
|
|
43
39
|
if (!((_a = this.constant.binance) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
44
40
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
45
41
|
}
|
|
46
|
-
return (yield (
|
|
47
|
-
method: 'GET',
|
|
48
|
-
url: this.constant.binance.url + '/api/v3/ticker/24hr',
|
|
49
|
-
params: {
|
|
50
|
-
symbol,
|
|
51
|
-
},
|
|
52
|
-
})).data;
|
|
42
|
+
return (yield this.instance.get('/api/v3/ticker/24hr', { params: { symbol } })).data;
|
|
53
43
|
});
|
|
54
44
|
}
|
|
55
45
|
/**
|
|
@@ -67,11 +57,7 @@ let BinanceService = class BinanceService {
|
|
|
67
57
|
if (!((_a = this.constant.binance) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
68
58
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
69
59
|
}
|
|
70
|
-
return (yield (
|
|
71
|
-
method: 'GET',
|
|
72
|
-
url: this.constant.binance.url + '/api/v3/klines',
|
|
73
|
-
params: { symbol, interval, startTime, endTime, limit },
|
|
74
|
-
})).data;
|
|
60
|
+
return (yield this.instance.get('/api/v3/klines', { params: { symbol, interval, startTime, endTime, limit } })).data;
|
|
75
61
|
});
|
|
76
62
|
}
|
|
77
63
|
/**
|
|
@@ -86,11 +72,7 @@ let BinanceService = class BinanceService {
|
|
|
86
72
|
if (!((_a = this.constant.binance) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
87
73
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
88
74
|
}
|
|
89
|
-
return (yield (
|
|
90
|
-
method: 'GET',
|
|
91
|
-
url: this.constant.binance.url + '/api/v3/depth',
|
|
92
|
-
params: { symbol, limit },
|
|
93
|
-
})).data;
|
|
75
|
+
return (yield this.instance.get('/api/v3/depth', { params: { symbol, limit } })).data;
|
|
94
76
|
});
|
|
95
77
|
}
|
|
96
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binance.service.js","sourceRoot":"","sources":["../../src/binance/binance.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"binance.service.js","sourceRoot":"","sources":["../../src/binance/binance.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;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E,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;;KACtH;IAED;;;;;OAKG;IACG,SAAS,CAAC,MAAc,EAAE,KAAc;;;YAC5C,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,0CAAE,OAAO,CAAA,EAAE;gBACnC,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;;KACvF;CACF,CAAA;AAvFY,cAAc;IAD1B,IAAA,mBAAU,GAAE;IAIE,mBAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;GAH3B,cAAc,CAuF1B;AAvFY,wCAAc"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { CoinGeckoConfig } from './coingecko.config';
|
|
7
7
|
export declare class CoinGeckoService {
|
|
8
8
|
private readonly constant;
|
|
9
|
+
private readonly instance;
|
|
9
10
|
constructor(constant: CoinGeckoConfig);
|
|
10
11
|
/**
|
|
11
12
|
* supported coins price, market cap, volume, and market related data
|
|
@@ -12,7 +12,11 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
12
12
|
let CoinGeckoService = class CoinGeckoService {
|
|
13
13
|
constructor(constant) {
|
|
14
14
|
this.constant = constant;
|
|
15
|
-
|
|
15
|
+
const config = { baseURL: this.constant.coingecko.url };
|
|
16
|
+
if (this.constant.coingecko.apiKey) {
|
|
17
|
+
config.params = { [this.constant.coingecko.isPro ? 'x_cg_pro_api_key' : 'x_cg_api_key']: this.constant.coingecko.apiKey };
|
|
18
|
+
}
|
|
19
|
+
this.instance = axios_1.default.create(config);
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* supported coins price, market cap, volume, and market related data
|
|
@@ -26,13 +30,12 @@ let CoinGeckoService = class CoinGeckoService {
|
|
|
26
30
|
if (!((_a = this.constant.coingecko) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
27
31
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
28
32
|
}
|
|
29
|
-
const response = yield (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return response.data[0];
|
|
33
|
+
const response = yield this.instance.get('/api/v3/coins/markets', { params: { ids, vs_currency } });
|
|
34
|
+
if (response.status === common_1.HttpStatus.OK) {
|
|
35
|
+
if (response.data.length) {
|
|
36
|
+
return response.data[0];
|
|
37
|
+
}
|
|
38
|
+
throw new common_1.HttpException('No Data', common_1.HttpStatus.NOT_FOUND);
|
|
36
39
|
}
|
|
37
40
|
throw new common_1.HttpException(response.statusText, response.status);
|
|
38
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coingecko.service.js","sourceRoot":"","sources":["../../src/coingecko/coingecko.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"coingecko.service.js","sourceRoot":"","sources":["../../src/coingecko/coingecko.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,0DAAkE;AAI3D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAG3B,YAA0D,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;QACjF,MAAM,MAAM,GAAwB,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS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gBAAgB,CA4D5B;AA5DY,4CAAgB"}
|
|
@@ -12,7 +12,7 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
12
12
|
let LBankService = class LBankService {
|
|
13
13
|
constructor(constant) {
|
|
14
14
|
this.constant = constant;
|
|
15
|
-
|
|
15
|
+
this.instance = axios_1.default.create({ baseURL: this.constant.lbank.url });
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Common - Query current Market Data (new)
|
|
@@ -25,13 +25,12 @@ let LBankService = class LBankService {
|
|
|
25
25
|
if (!((_a = this.constant.lbank) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
26
26
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
27
27
|
}
|
|
28
|
-
const response = yield (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return response.data.data[0];
|
|
28
|
+
const response = yield this.instance.get('/v2/ticker/24hr.do', { params: { symbol } });
|
|
29
|
+
if (response.status === common_1.HttpStatus.OK) {
|
|
30
|
+
if (((_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === 'true' && ((_d = (_c = response.data) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.length) > 0) {
|
|
31
|
+
return response.data.data[0];
|
|
32
|
+
}
|
|
33
|
+
throw new common_1.HttpException(response.data.result, common_1.HttpStatus.BAD_REQUEST);
|
|
35
34
|
}
|
|
36
35
|
throw new common_1.HttpException(response.statusText, response.status);
|
|
37
36
|
});
|
|
@@ -50,13 +49,12 @@ let LBankService = class LBankService {
|
|
|
50
49
|
if (!((_a = this.constant.lbank) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
51
50
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
52
51
|
}
|
|
53
|
-
const response = yield (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return response.data.data;
|
|
52
|
+
const response = yield this.instance.get('/v2/kline.do', { params: { symbol, type, time, size } });
|
|
53
|
+
if (response.status === common_1.HttpStatus.OK) {
|
|
54
|
+
if (((_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === 'true') {
|
|
55
|
+
return response.data.data;
|
|
56
|
+
}
|
|
57
|
+
throw new common_1.HttpException(response.data.result, common_1.HttpStatus.BAD_REQUEST);
|
|
60
58
|
}
|
|
61
59
|
throw new common_1.HttpException(response.statusText, response.status);
|
|
62
60
|
});
|
|
@@ -73,13 +71,12 @@ let LBankService = class LBankService {
|
|
|
73
71
|
if (!((_a = this.constant.lbank) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
74
72
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
75
73
|
}
|
|
76
|
-
const response = yield (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return response.data.data;
|
|
74
|
+
const response = yield this.instance.get('/v2/depth.do', { params: { symbol, size } });
|
|
75
|
+
if (response.status === common_1.HttpStatus.OK) {
|
|
76
|
+
if (((_b = response.data) === null || _b === void 0 ? void 0 : _b.result) === 'true') {
|
|
77
|
+
return response.data.data;
|
|
78
|
+
}
|
|
79
|
+
throw new common_1.HttpException(response.data.result, common_1.HttpStatus.BAD_REQUEST);
|
|
83
80
|
}
|
|
84
81
|
throw new common_1.HttpException(response.statusText, response.status);
|
|
85
82
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lbank.service.js","sourceRoot":"","sources":["../../src/lbank/lbank.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"lbank.service.js","sourceRoot":"","sources":["../../src/lbank/lbank.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,0DAA6C;AAItC,IA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gBACD,MAAM,IAAI,sBAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aACvE;YACD,MAAM,IAAI,sBAAa,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;;KAC/D;CACF,CAAA;AA3EY,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGE,mBAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;GAFzB,YAAY,CA2ExB;AA3EY,oCAAY"}
|
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
import { MexcConfig } from './mexc.config';
|
|
7
7
|
export declare class MexcService {
|
|
8
8
|
private readonly constant;
|
|
9
|
+
private readonly instance;
|
|
9
10
|
constructor(constant: MexcConfig);
|
|
10
11
|
/**
|
|
11
12
|
* Market Data - Ticker Information
|
|
12
13
|
* @param symbol e.g. BTC_USDC
|
|
13
14
|
* @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#ticker-information
|
|
15
|
+
* @deprecated
|
|
14
16
|
*/
|
|
15
17
|
marketTicker(symbol: string): Promise<any>;
|
|
16
18
|
/**
|
|
@@ -27,7 +29,25 @@ export declare class MexcService {
|
|
|
27
29
|
* @param symbol e.g. BTCUSDT
|
|
28
30
|
* @see https://mexcdevelop.github.io/apidocs/spot_v3_en/#24hr-ticker-price-change-statistics
|
|
29
31
|
*/
|
|
30
|
-
tickerPrice24H(symbol: string): Promise<
|
|
32
|
+
tickerPrice24H(symbol: string): Promise<{
|
|
33
|
+
symbol: string;
|
|
34
|
+
priceChange: string;
|
|
35
|
+
priceChangePercent: string;
|
|
36
|
+
prevClosePrice: string;
|
|
37
|
+
lastPrice: string;
|
|
38
|
+
bidPrice: string;
|
|
39
|
+
bidQty: string;
|
|
40
|
+
askPrice: string;
|
|
41
|
+
askQty: string;
|
|
42
|
+
openPrice: string;
|
|
43
|
+
highPrice: string;
|
|
44
|
+
lowPrice: string;
|
|
45
|
+
volume: string;
|
|
46
|
+
quoteVolume: string;
|
|
47
|
+
openTime: number;
|
|
48
|
+
closeTime: number;
|
|
49
|
+
count: number;
|
|
50
|
+
}>;
|
|
31
51
|
/**
|
|
32
52
|
* Market Data - Kline/Candlestick Data
|
|
33
53
|
* @param symbol e.g. BTCUSDT
|
|
@@ -12,12 +12,13 @@ const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
|
12
12
|
let MexcService = class MexcService {
|
|
13
13
|
constructor(constant) {
|
|
14
14
|
this.constant = constant;
|
|
15
|
-
|
|
15
|
+
this.instance = axios_1.default.create({ baseURL: this.constant.mexc.url });
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Market Data - Ticker Information
|
|
19
19
|
* @param symbol e.g. BTC_USDC
|
|
20
20
|
* @see https://mexcdevelop.github.io/apidocs/spot_v2_en/#ticker-information
|
|
21
|
+
* @deprecated
|
|
21
22
|
*/
|
|
22
23
|
marketTicker(symbol) {
|
|
23
24
|
var _a;
|
|
@@ -25,11 +26,7 @@ let MexcService = class MexcService {
|
|
|
25
26
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
26
27
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
27
28
|
}
|
|
28
|
-
return (yield (
|
|
29
|
-
method: 'GET',
|
|
30
|
-
url: this.constant.mexc.url + '/open/api/v2/market/ticker',
|
|
31
|
-
params: { symbol },
|
|
32
|
-
})).data;
|
|
29
|
+
return (yield this.instance.get('/open/api/v2/market/ticker', { params: { symbol } })).data;
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
32
|
// ----- v3 -----
|
|
@@ -44,11 +41,7 @@ let MexcService = class MexcService {
|
|
|
44
41
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
45
42
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
46
43
|
}
|
|
47
|
-
return (yield (
|
|
48
|
-
method: 'GET',
|
|
49
|
-
url: this.constant.mexc.url + '/api/v3/avgPrice',
|
|
50
|
-
params: { symbol },
|
|
51
|
-
})).data;
|
|
44
|
+
return (yield this.instance.get('/api/v3/avgPrice', { params: { symbol } })).data;
|
|
52
45
|
});
|
|
53
46
|
}
|
|
54
47
|
/**
|
|
@@ -62,11 +55,7 @@ let MexcService = class MexcService {
|
|
|
62
55
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
63
56
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
64
57
|
}
|
|
65
|
-
return (yield (
|
|
66
|
-
method: 'GET',
|
|
67
|
-
url: this.constant.mexc.url + '/api/v3/ticker/24hr',
|
|
68
|
-
params: { symbol },
|
|
69
|
-
})).data;
|
|
58
|
+
return (yield this.instance.get('/api/v3/ticker/24hr', { params: { symbol } })).data;
|
|
70
59
|
});
|
|
71
60
|
}
|
|
72
61
|
/**
|
|
@@ -84,11 +73,7 @@ let MexcService = class MexcService {
|
|
|
84
73
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
85
74
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
86
75
|
}
|
|
87
|
-
return (yield (
|
|
88
|
-
method: 'GET',
|
|
89
|
-
url: this.constant.mexc.url + '/api/v3/klines',
|
|
90
|
-
params: { symbol, interval, startTime, endTime, limit },
|
|
91
|
-
})).data;
|
|
76
|
+
return (yield this.instance.get('/api/v3/klines', { params: { symbol, interval, startTime, endTime, limit } })).data;
|
|
92
77
|
});
|
|
93
78
|
}
|
|
94
79
|
/**
|
|
@@ -103,11 +88,7 @@ let MexcService = class MexcService {
|
|
|
103
88
|
if (!((_a = this.constant.mexc) === null || _a === void 0 ? void 0 : _a.enabled)) {
|
|
104
89
|
throw new common_1.HttpException('This feature is not supported', common_1.HttpStatus.BAD_REQUEST);
|
|
105
90
|
}
|
|
106
|
-
return (yield (
|
|
107
|
-
method: 'GET',
|
|
108
|
-
url: this.constant.mexc.url + '/api/v3/depth',
|
|
109
|
-
params: { symbol, limit },
|
|
110
|
-
})).data;
|
|
91
|
+
return (yield this.instance.get('/api/v3/depth', { params: { symbol, limit } })).data;
|
|
111
92
|
});
|
|
112
93
|
}
|
|
113
94
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mexc.service.js","sourceRoot":"","sources":["../../src/mexc/mexc.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,
|
|
1
|
+
{"version":3,"file":"mexc.service.js","sourceRoot":"","sources":["../../src/mexc/mexc.service.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;AAEH,2CAA+E;AAC/E,0DAA6C;AAItC,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEtB,YAAqD,QAAoB;QAApB,aAAQ,GAAR,QAAQ,CAAY;QACvE,IAAI,CAAC,QAAQ,GAAG,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACpE,CAAC;IAED;;;;;OAKG;IACG,YAAY,CAAC,MAAc;;;YAC/B,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,0CAAE,OAAO,CAAA,EAAE;gBAChC,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,WAAW,CAAC,CAAC;aAClF;YACD,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,4BAA4B,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;;KAC7F;IAED,iBAAiB;IAEjB;;;;OAIG;IACG,mBAAmB,CAAC,MAAc;;;YACtC,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,QAAQ,CAAC,IAA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