@grvt/client 1.5.1 → 1.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.
- package/interfaces/codegen/data.interface.d.ts +40 -1
- package/interfaces/codegen/schema-maps/api_bulk_orders_request.d.ts +2 -0
- package/interfaces/codegen/schema-maps/api_bulk_orders_request.js +21 -0
- package/interfaces/codegen/schema-maps/api_bulk_orders_response.d.ts +2 -0
- package/interfaces/codegen/schema-maps/api_bulk_orders_response.js +16 -0
- package/interfaces/codegen/schema-maps/api_detailed_aggregated_account_summary_response.d.ts +2 -0
- package/interfaces/codegen/schema-maps/api_detailed_aggregated_account_summary_response.js +13 -0
- package/interfaces/codegen/schema-maps/api_get_user_vault_reward_point_response.d.ts +2 -0
- package/interfaces/codegen/schema-maps/api_get_user_vault_reward_point_response.js +16 -0
- package/interfaces/codegen/schema-maps/api_list_aggregated_account_summary_response.js +3 -3
- package/interfaces/codegen/schema-maps/api_list_epoch_user_vault_reward_point_response.d.ts +2 -0
- package/interfaces/codegen/schema-maps/api_list_epoch_user_vault_reward_point_response.js +13 -0
- package/interfaces/codegen/schema-maps/detailed_aggregated_account_summary.d.ts +2 -0
- package/interfaces/codegen/schema-maps/detailed_aggregated_account_summary.js +22 -0
- package/interfaces/codegen/schema-maps/epoch_user_vault_reward_point.d.ts +2 -0
- package/interfaces/codegen/schema-maps/epoch_user_vault_reward_point.js +18 -0
- package/interfaces/codegen/schema-maps/query_vault_investor_history_request.js +8 -2
- package/interfaces/codegen/schema-maps/snap_vault_summary.js +4 -2
- package/package.json +1 -1
- package/ws/ws.d.ts +3 -4
- package/ws/ws.js +27 -54
|
@@ -285,6 +285,17 @@ export interface IApiBatchQueryVaultRiskMetricRequest {
|
|
|
285
285
|
export interface IApiBatchQueryVaultRiskMetricResponse {
|
|
286
286
|
result?: IVaultRiskMetric[];
|
|
287
287
|
}
|
|
288
|
+
export interface IApiBulkOrdersRequest {
|
|
289
|
+
sub_account_id?: string;
|
|
290
|
+
orders?: IOrder[];
|
|
291
|
+
order_i_ds?: string[];
|
|
292
|
+
client_order_i_ds?: string[];
|
|
293
|
+
time_to_live_ms?: string;
|
|
294
|
+
}
|
|
295
|
+
export interface IApiBulkOrdersResponse {
|
|
296
|
+
orders?: IOrder[];
|
|
297
|
+
cancel_acks?: IAck[];
|
|
298
|
+
}
|
|
288
299
|
export interface IApiCancelAllOrdersRequest {
|
|
289
300
|
sub_account_id?: string;
|
|
290
301
|
kind?: EKind[];
|
|
@@ -357,6 +368,9 @@ export interface IApiDepositHistoryResponse {
|
|
|
357
368
|
result?: IDepositHistory[];
|
|
358
369
|
next?: string;
|
|
359
370
|
}
|
|
371
|
+
export interface IApiDetailedAggregatedAccountSummaryResponse {
|
|
372
|
+
result?: IDetailedAggregatedAccountSummary;
|
|
373
|
+
}
|
|
360
374
|
export interface IApiDropClientWsRequest {
|
|
361
375
|
main_account_id?: string;
|
|
362
376
|
}
|
|
@@ -575,6 +589,11 @@ export interface IApiGetUserEcosystemPointRequest {
|
|
|
575
589
|
export interface IApiGetUserEcosystemPointResponse {
|
|
576
590
|
points?: IEcosystemPoint[];
|
|
577
591
|
}
|
|
592
|
+
export interface IApiGetUserVaultRewardPointResponse {
|
|
593
|
+
ecosystem_point?: string;
|
|
594
|
+
trader_point?: string;
|
|
595
|
+
lp_point?: string;
|
|
596
|
+
}
|
|
578
597
|
export interface IApiGetVerifiedEcosystemLeaderboardRequest {
|
|
579
598
|
calculate_from?: string;
|
|
580
599
|
completed_kyc_before?: string;
|
|
@@ -589,7 +608,10 @@ export interface IApiListAggregatedAccountSummaryRequest {
|
|
|
589
608
|
main_account_ids?: string[];
|
|
590
609
|
}
|
|
591
610
|
export interface IApiListAggregatedAccountSummaryResponse {
|
|
592
|
-
account_summaries?:
|
|
611
|
+
account_summaries?: IApiDetailedAggregatedAccountSummaryResponse[];
|
|
612
|
+
}
|
|
613
|
+
export interface IApiListEpochUserVaultRewardPointResponse {
|
|
614
|
+
result?: IEpochUserVaultRewardPoint[];
|
|
593
615
|
}
|
|
594
616
|
export interface IApiMiniTickerRequest {
|
|
595
617
|
instrument?: string;
|
|
@@ -1139,6 +1161,13 @@ export interface IDepositHistory {
|
|
|
1139
1161
|
confirmed_time?: string;
|
|
1140
1162
|
from_address?: string;
|
|
1141
1163
|
}
|
|
1164
|
+
export interface IDetailedAggregatedAccountSummary {
|
|
1165
|
+
main_account_id?: string;
|
|
1166
|
+
total_equity?: string;
|
|
1167
|
+
spot_balances?: ISpotBalance[];
|
|
1168
|
+
vault_investments?: IVaultInvestment[];
|
|
1169
|
+
funding_account_balance?: string;
|
|
1170
|
+
}
|
|
1142
1171
|
export interface IECNToBrokerFeed {
|
|
1143
1172
|
order_id?: string;
|
|
1144
1173
|
client_order_id?: string;
|
|
@@ -1222,6 +1251,12 @@ export interface IEpochLPPoint {
|
|
|
1222
1251
|
liquidity_score?: string;
|
|
1223
1252
|
vault_liquidity_score?: string;
|
|
1224
1253
|
}
|
|
1254
|
+
export interface IEpochUserVaultRewardPoint {
|
|
1255
|
+
epoch?: number;
|
|
1256
|
+
ecosystem_point?: string;
|
|
1257
|
+
trader_point?: string;
|
|
1258
|
+
lp_point?: string;
|
|
1259
|
+
}
|
|
1225
1260
|
export interface IError {
|
|
1226
1261
|
code?: number;
|
|
1227
1262
|
message?: string;
|
|
@@ -1553,6 +1588,9 @@ export interface IQueryTradingPerformanceTrendResponse {
|
|
|
1553
1588
|
export interface IQueryVaultInvestorHistoryRequest {
|
|
1554
1589
|
main_account_id?: string;
|
|
1555
1590
|
vault_id?: string;
|
|
1591
|
+
types?: EVaultInvestorAction[];
|
|
1592
|
+
start_time?: string;
|
|
1593
|
+
end_time?: string;
|
|
1556
1594
|
}
|
|
1557
1595
|
export interface IQueryVaultInvestorHistoryResponse {
|
|
1558
1596
|
result?: IVaultInvestorHistory[];
|
|
@@ -1617,6 +1655,7 @@ export interface ISnapVaultSummary {
|
|
|
1617
1655
|
lp_infos?: ILpInfoEntry[];
|
|
1618
1656
|
total_lp_token_supply?: string;
|
|
1619
1657
|
share_price?: string;
|
|
1658
|
+
reward_sharing_ratio_centi_beeps?: number;
|
|
1620
1659
|
}
|
|
1621
1660
|
export interface ISpotBalance {
|
|
1622
1661
|
currency?: string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_BULK_ORDERS_REQUEST_MAP = void 0;
|
|
4
|
+
const order_1 = require("./order");
|
|
5
|
+
// Schema map for the 'API_BULK_ORDERS_REQUEST' struct.
|
|
6
|
+
exports.API_BULK_ORDERS_REQUEST_MAP = Object.freeze({
|
|
7
|
+
FULL_TO_LITE: {
|
|
8
|
+
sub_account_id: 'sa',
|
|
9
|
+
orders: ['o', [order_1.ORDER_MAP.FULL_TO_LITE]],
|
|
10
|
+
order_i_ds: 'oi',
|
|
11
|
+
client_order_i_ds: 'co',
|
|
12
|
+
time_to_live_ms: 'tt'
|
|
13
|
+
},
|
|
14
|
+
LITE_TO_FULL: {
|
|
15
|
+
sa: 'sub_account_id',
|
|
16
|
+
o: ['orders', [order_1.ORDER_MAP.LITE_TO_FULL]],
|
|
17
|
+
oi: 'order_i_ds',
|
|
18
|
+
co: 'client_order_i_ds',
|
|
19
|
+
tt: 'time_to_live_ms'
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_BULK_ORDERS_RESPONSE_MAP = void 0;
|
|
4
|
+
const order_1 = require("./order");
|
|
5
|
+
const ack_1 = require("./ack");
|
|
6
|
+
// Schema map for the 'API_BULK_ORDERS_RESPONSE' struct.
|
|
7
|
+
exports.API_BULK_ORDERS_RESPONSE_MAP = Object.freeze({
|
|
8
|
+
FULL_TO_LITE: {
|
|
9
|
+
orders: ['o', [order_1.ORDER_MAP.FULL_TO_LITE]],
|
|
10
|
+
cancel_acks: ['ca', [ack_1.ACK_MAP.FULL_TO_LITE]]
|
|
11
|
+
},
|
|
12
|
+
LITE_TO_FULL: {
|
|
13
|
+
o: ['orders', [order_1.ORDER_MAP.LITE_TO_FULL]],
|
|
14
|
+
ca: ['cancel_acks', [ack_1.ACK_MAP.LITE_TO_FULL]]
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_DETAILED_AGGREGATED_ACCOUNT_SUMMARY_RESPONSE_MAP = void 0;
|
|
4
|
+
const detailed_aggregated_account_summary_1 = require("./detailed_aggregated_account_summary");
|
|
5
|
+
// Schema map for the 'API_DETAILED_AGGREGATED_ACCOUNT_SUMMARY_RESPONSE' struct.
|
|
6
|
+
exports.API_DETAILED_AGGREGATED_ACCOUNT_SUMMARY_RESPONSE_MAP = Object.freeze({
|
|
7
|
+
FULL_TO_LITE: {
|
|
8
|
+
result: ['r', detailed_aggregated_account_summary_1.DETAILED_AGGREGATED_ACCOUNT_SUMMARY_MAP.FULL_TO_LITE]
|
|
9
|
+
},
|
|
10
|
+
LITE_TO_FULL: {
|
|
11
|
+
r: ['result', detailed_aggregated_account_summary_1.DETAILED_AGGREGATED_ACCOUNT_SUMMARY_MAP.LITE_TO_FULL]
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_GET_USER_VAULT_REWARD_POINT_RESPONSE_MAP = void 0;
|
|
4
|
+
// Schema map for the 'API_GET_USER_VAULT_REWARD_POINT_RESPONSE' struct.
|
|
5
|
+
exports.API_GET_USER_VAULT_REWARD_POINT_RESPONSE_MAP = Object.freeze({
|
|
6
|
+
FULL_TO_LITE: {
|
|
7
|
+
ecosystem_point: 'ep',
|
|
8
|
+
trader_point: 'tp',
|
|
9
|
+
lp_point: 'lp'
|
|
10
|
+
},
|
|
11
|
+
LITE_TO_FULL: {
|
|
12
|
+
ep: 'ecosystem_point',
|
|
13
|
+
tp: 'trader_point',
|
|
14
|
+
lp: 'lp_point'
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.API_LIST_AGGREGATED_ACCOUNT_SUMMARY_RESPONSE_MAP = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_detailed_aggregated_account_summary_response_1 = require("./api_detailed_aggregated_account_summary_response");
|
|
5
5
|
// Schema map for the 'API_LIST_AGGREGATED_ACCOUNT_SUMMARY_RESPONSE' struct.
|
|
6
6
|
exports.API_LIST_AGGREGATED_ACCOUNT_SUMMARY_RESPONSE_MAP = Object.freeze({
|
|
7
7
|
FULL_TO_LITE: {
|
|
8
|
-
account_summaries: ['as', [
|
|
8
|
+
account_summaries: ['as', [api_detailed_aggregated_account_summary_response_1.API_DETAILED_AGGREGATED_ACCOUNT_SUMMARY_RESPONSE_MAP.FULL_TO_LITE]]
|
|
9
9
|
},
|
|
10
10
|
LITE_TO_FULL: {
|
|
11
|
-
as: ['account_summaries', [
|
|
11
|
+
as: ['account_summaries', [api_detailed_aggregated_account_summary_response_1.API_DETAILED_AGGREGATED_ACCOUNT_SUMMARY_RESPONSE_MAP.LITE_TO_FULL]]
|
|
12
12
|
}
|
|
13
13
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.API_LIST_EPOCH_USER_VAULT_REWARD_POINT_RESPONSE_MAP = void 0;
|
|
4
|
+
const epoch_user_vault_reward_point_1 = require("./epoch_user_vault_reward_point");
|
|
5
|
+
// Schema map for the 'API_LIST_EPOCH_USER_VAULT_REWARD_POINT_RESPONSE' struct.
|
|
6
|
+
exports.API_LIST_EPOCH_USER_VAULT_REWARD_POINT_RESPONSE_MAP = Object.freeze({
|
|
7
|
+
FULL_TO_LITE: {
|
|
8
|
+
result: ['r', [epoch_user_vault_reward_point_1.EPOCH_USER_VAULT_REWARD_POINT_MAP.FULL_TO_LITE]]
|
|
9
|
+
},
|
|
10
|
+
LITE_TO_FULL: {
|
|
11
|
+
r: ['result', [epoch_user_vault_reward_point_1.EPOCH_USER_VAULT_REWARD_POINT_MAP.LITE_TO_FULL]]
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DETAILED_AGGREGATED_ACCOUNT_SUMMARY_MAP = void 0;
|
|
4
|
+
const api_spot_balance_1 = require("./api_spot_balance");
|
|
5
|
+
const vault_investment_1 = require("./vault_investment");
|
|
6
|
+
// Schema map for the 'DETAILED_AGGREGATED_ACCOUNT_SUMMARY' struct.
|
|
7
|
+
exports.DETAILED_AGGREGATED_ACCOUNT_SUMMARY_MAP = Object.freeze({
|
|
8
|
+
FULL_TO_LITE: {
|
|
9
|
+
main_account_id: 'ma',
|
|
10
|
+
total_equity: 'te',
|
|
11
|
+
spot_balances: ['sb', [api_spot_balance_1.SPOT_BALANCE_MAP.FULL_TO_LITE]],
|
|
12
|
+
vault_investments: ['vi', [vault_investment_1.VAULT_INVESTMENT_MAP.FULL_TO_LITE]],
|
|
13
|
+
funding_account_balance: 'fa'
|
|
14
|
+
},
|
|
15
|
+
LITE_TO_FULL: {
|
|
16
|
+
ma: 'main_account_id',
|
|
17
|
+
te: 'total_equity',
|
|
18
|
+
sb: ['spot_balances', [api_spot_balance_1.SPOT_BALANCE_MAP.LITE_TO_FULL]],
|
|
19
|
+
vi: ['vault_investments', [vault_investment_1.VAULT_INVESTMENT_MAP.LITE_TO_FULL]],
|
|
20
|
+
fa: 'funding_account_balance'
|
|
21
|
+
}
|
|
22
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EPOCH_USER_VAULT_REWARD_POINT_MAP = void 0;
|
|
4
|
+
// Schema map for the 'EPOCH_USER_VAULT_REWARD_POINT' struct.
|
|
5
|
+
exports.EPOCH_USER_VAULT_REWARD_POINT_MAP = Object.freeze({
|
|
6
|
+
FULL_TO_LITE: {
|
|
7
|
+
epoch: 'e',
|
|
8
|
+
ecosystem_point: 'ep',
|
|
9
|
+
trader_point: 'tp',
|
|
10
|
+
lp_point: 'lp'
|
|
11
|
+
},
|
|
12
|
+
LITE_TO_FULL: {
|
|
13
|
+
e: 'epoch',
|
|
14
|
+
ep: 'ecosystem_point',
|
|
15
|
+
tp: 'trader_point',
|
|
16
|
+
lp: 'lp_point'
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -5,10 +5,16 @@ exports.QUERY_VAULT_INVESTOR_HISTORY_REQUEST_MAP = void 0;
|
|
|
5
5
|
exports.QUERY_VAULT_INVESTOR_HISTORY_REQUEST_MAP = Object.freeze({
|
|
6
6
|
FULL_TO_LITE: {
|
|
7
7
|
main_account_id: 'ma',
|
|
8
|
-
vault_id: 'vi'
|
|
8
|
+
vault_id: 'vi',
|
|
9
|
+
types: 't',
|
|
10
|
+
start_time: 'st',
|
|
11
|
+
end_time: 'et'
|
|
9
12
|
},
|
|
10
13
|
LITE_TO_FULL: {
|
|
11
14
|
ma: 'main_account_id',
|
|
12
|
-
vi: 'vault_id'
|
|
15
|
+
vi: 'vault_id',
|
|
16
|
+
t: 'types',
|
|
17
|
+
st: 'start_time',
|
|
18
|
+
et: 'end_time'
|
|
13
19
|
}
|
|
14
20
|
});
|
|
@@ -10,7 +10,8 @@ exports.SNAP_VAULT_SUMMARY_MAP = Object.freeze({
|
|
|
10
10
|
vault_id: 'vi',
|
|
11
11
|
lp_infos: ['li', [lp_info_entry_1.LP_INFO_ENTRY_MAP.FULL_TO_LITE]],
|
|
12
12
|
total_lp_token_supply: 'tl',
|
|
13
|
-
share_price: 'sp'
|
|
13
|
+
share_price: 'sp',
|
|
14
|
+
reward_sharing_ratio_centi_beeps: 'rs'
|
|
14
15
|
},
|
|
15
16
|
LITE_TO_FULL: {
|
|
16
17
|
et: 'event_time',
|
|
@@ -18,6 +19,7 @@ exports.SNAP_VAULT_SUMMARY_MAP = Object.freeze({
|
|
|
18
19
|
vi: 'vault_id',
|
|
19
20
|
li: ['lp_infos', [lp_info_entry_1.LP_INFO_ENTRY_MAP.LITE_TO_FULL]],
|
|
20
21
|
tl: 'total_lp_token_supply',
|
|
21
|
-
sp: 'share_price'
|
|
22
|
+
sp: 'share_price',
|
|
23
|
+
rs: 'reward_sharing_ratio_centi_beeps'
|
|
22
24
|
}
|
|
23
25
|
});
|
package/package.json
CHANGED
package/ws/ws.d.ts
CHANGED
|
@@ -27,14 +27,13 @@ export declare class WS {
|
|
|
27
27
|
private _bindWebSocketListeners;
|
|
28
28
|
/**
|
|
29
29
|
* Only use for TDG
|
|
30
|
-
* Use for TEntities of
|
|
30
|
+
* Use for TEntities of DEPOSIT | TRANSFER | WITHDRAWAL streams
|
|
31
31
|
*/
|
|
32
|
-
private
|
|
32
|
+
private _getHistoryConsumers;
|
|
33
33
|
/**
|
|
34
34
|
* Use for MDG/TDG
|
|
35
|
-
* Use for TEntityHasInstrument
|
|
36
35
|
*/
|
|
37
|
-
private
|
|
36
|
+
private _getSelectorConsumers;
|
|
38
37
|
private _parseStream;
|
|
39
38
|
private _messageLiteToFull;
|
|
40
39
|
private _sendMessage;
|
package/ws/ws.js
CHANGED
|
@@ -149,7 +149,7 @@ class WS {
|
|
|
149
149
|
reconnect();
|
|
150
150
|
});
|
|
151
151
|
currentWs.addEventListener('message', (e) => {
|
|
152
|
-
var _a, _b, _c, _d, _e, _f
|
|
152
|
+
var _a, _b, _c, _d, _e, _f;
|
|
153
153
|
// only keep the latest ws
|
|
154
154
|
if (currentWs !== this.__ws) {
|
|
155
155
|
this._close(currentWs);
|
|
@@ -183,12 +183,13 @@ class WS {
|
|
|
183
183
|
return;
|
|
184
184
|
}
|
|
185
185
|
const stream = message.s = (_f = (_e = message.s) === null || _e === void 0 ? void 0 : _e.replace) === null || _f === void 0 ? void 0 : _f.call(_e, `${this._version}.`, '');
|
|
186
|
+
const selector = typeof message.s1 === 'string' ? message.s1 : '';
|
|
186
187
|
const result = this._messageLiteToFull(message);
|
|
187
188
|
// no entity found
|
|
188
|
-
if (!result) {
|
|
189
|
+
if (!selector || !result) {
|
|
189
190
|
// if no entity found and not a subscription message
|
|
190
|
-
if (
|
|
191
|
-
console.warn('Error:
|
|
191
|
+
if (typeof message.s1 === 'string') {
|
|
192
|
+
console.warn('Error: not found selector', message);
|
|
192
193
|
}
|
|
193
194
|
return;
|
|
194
195
|
}
|
|
@@ -196,13 +197,16 @@ class WS {
|
|
|
196
197
|
console.warn('Error: cannot parse stream or feed from message', message);
|
|
197
198
|
return;
|
|
198
199
|
}
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
const consumers = (() => {
|
|
201
|
+
switch (stream) {
|
|
202
|
+
case interfaces_1.EStream.DEPOSIT:
|
|
203
|
+
case interfaces_1.EStream.TRANSFER:
|
|
204
|
+
case interfaces_1.EStream.WITHDRAWAL:
|
|
205
|
+
return this._getHistoryConsumers({ stream, result });
|
|
206
|
+
default:
|
|
207
|
+
return this._getSelectorConsumers({ stream, selector });
|
|
208
|
+
}
|
|
209
|
+
})();
|
|
206
210
|
if (!(consumers === null || consumers === void 0 ? void 0 : consumers.length)) {
|
|
207
211
|
// There are delay in sending unsubscribe message so clients might receive messages after unsubscribing
|
|
208
212
|
// console.log('TODO: send unsubscribe with by message:', message, result)
|
|
@@ -244,9 +248,9 @@ class WS {
|
|
|
244
248
|
}
|
|
245
249
|
/**
|
|
246
250
|
* Only use for TDG
|
|
247
|
-
* Use for TEntities of
|
|
251
|
+
* Use for TEntities of DEPOSIT | TRANSFER | WITHDRAWAL streams
|
|
248
252
|
*/
|
|
249
|
-
|
|
253
|
+
_getHistoryConsumers({ result, stream }) {
|
|
250
254
|
return Object.entries(this._pairs).reduce((acc, [key, value]) => {
|
|
251
255
|
if (!key.startsWith(`${stream}__`)) {
|
|
252
256
|
return acc;
|
|
@@ -262,10 +266,6 @@ class WS {
|
|
|
262
266
|
].filter(Boolean).join('-');
|
|
263
267
|
const withdrawalFromAccountId = omitZeroStr(result.from_account_id);
|
|
264
268
|
switch (stream) {
|
|
265
|
-
case interfaces_1.EStream.GROUP:
|
|
266
|
-
return [...acc, ...Object.values(value)];
|
|
267
|
-
case interfaces_1.EStream.STATE:
|
|
268
|
-
return [...acc, ...Object.values(value)];
|
|
269
269
|
case interfaces_1.EStream.DEPOSIT:
|
|
270
270
|
if (depositDestinationAccountId && key.endsWith(depositDestinationAccountId)) {
|
|
271
271
|
return [...acc, ...Object.values(value)];
|
|
@@ -287,45 +287,18 @@ class WS {
|
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
289
289
|
* Use for MDG/TDG
|
|
290
|
-
* Use for TEntityHasInstrument
|
|
291
290
|
*/
|
|
292
|
-
|
|
291
|
+
_getSelectorConsumers({ stream, selector }) {
|
|
292
|
+
const selectorPrimary = selector.split('@')[0];
|
|
293
293
|
return Object.entries(this._pairs).reduce((acc, [key, value]) => {
|
|
294
|
-
|
|
295
|
-
|
|
294
|
+
const pairPrefix = `${stream}__${selectorPrimary}`;
|
|
295
|
+
const isKeyMatch = key.includes('@')
|
|
296
|
+
? key.startsWith(pairPrefix)
|
|
297
|
+
: key === pairPrefix;
|
|
298
|
+
if (!isKeyMatch) {
|
|
296
299
|
return acc;
|
|
297
300
|
}
|
|
298
|
-
|
|
299
|
-
interfaces_1.EStream.ORDER,
|
|
300
|
-
// EStream.STATE,
|
|
301
|
-
interfaces_1.EStream.POSITION,
|
|
302
|
-
interfaces_1.EStream.FILL
|
|
303
|
-
// EStream.DEPOSIT,
|
|
304
|
-
// EStream.TRANSFER,
|
|
305
|
-
// EStream.WITHDRAWAL
|
|
306
|
-
].includes(stream);
|
|
307
|
-
// no sub account id handling
|
|
308
|
-
if (!hasSubAccountId) {
|
|
309
|
-
return key.startsWith(`${stream}__${instrument}`)
|
|
310
|
-
? [...acc, ...Object.values(value)]
|
|
311
|
-
: acc;
|
|
312
|
-
}
|
|
313
|
-
// has sub account id handling
|
|
314
|
-
const subAccountId = String((_a = result.sub_account_id) !== null && _a !== void 0 ? _a : '');
|
|
315
|
-
// const subAccountId = String((result as IPositions).sub_account_id)
|
|
316
|
-
// const subAccountId = String((result as IFill).sub_account_id)
|
|
317
|
-
const feed = (_b = this._parseStream({
|
|
318
|
-
stream: stream,
|
|
319
|
-
params: {
|
|
320
|
-
sub_account_id: omitZeroStr(subAccountId),
|
|
321
|
-
instrument
|
|
322
|
-
}
|
|
323
|
-
})) === null || _b === void 0 ? void 0 : _b.feed;
|
|
324
|
-
const tdgFeedPrefix = (_d = (_c = feed === null || feed === void 0 ? void 0 : feed[0]) === null || _c === void 0 ? void 0 : _c.split('@')) === null || _d === void 0 ? void 0 : _d[0];
|
|
325
|
-
if (tdgFeedPrefix && key.startsWith(`${stream}__${tdgFeedPrefix}`)) {
|
|
326
|
-
return [...acc, ...Object.values(value)];
|
|
327
|
-
}
|
|
328
|
-
return acc;
|
|
301
|
+
return [...acc, ...Object.values(value)];
|
|
329
302
|
}, []);
|
|
330
303
|
}
|
|
331
304
|
_parseStream(options) {
|
|
@@ -707,7 +680,7 @@ class WS {
|
|
|
707
680
|
const onPaired = (e) => {
|
|
708
681
|
var _a, _b, _c;
|
|
709
682
|
const message = utils_1.JsonUtils.parse(e.data);
|
|
710
|
-
if (!(message === null || message === void 0 ? void 0 : message.s) || !((_a = message === null || message === void 0 ? void 0 : message.s1) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
683
|
+
if (!(message === null || message === void 0 ? void 0 : message.s) || !((_a = message === null || message === void 0 ? void 0 : message.s1) === null || _a === void 0 ? void 0 : _a.length) || typeof message.s1 === 'string') {
|
|
711
684
|
return;
|
|
712
685
|
}
|
|
713
686
|
const responseStream = (_c = (_b = message.s) === null || _b === void 0 ? void 0 : _b.replace) === null || _c === void 0 ? void 0 : _c.call(_b, `${this._version}.`, '');
|
|
@@ -790,7 +763,7 @@ class WS {
|
|
|
790
763
|
const onPaired = (e) => {
|
|
791
764
|
var _a, _b, _c;
|
|
792
765
|
const message = utils_1.JsonUtils.parse(e.data);
|
|
793
|
-
if (!(message === null || message === void 0 ? void 0 : message.s) || !((_a = message === null || message === void 0 ? void 0 : message.s1) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
766
|
+
if (!(message === null || message === void 0 ? void 0 : message.s) || !((_a = message === null || message === void 0 ? void 0 : message.s1) === null || _a === void 0 ? void 0 : _a.length) || typeof message.s1 === 'string') {
|
|
794
767
|
return;
|
|
795
768
|
}
|
|
796
769
|
const responseStream = (_c = (_b = message.s) === null || _b === void 0 ? void 0 : _b.replace) === null || _c === void 0 ? void 0 : _c.call(_b, `${this._version}.`, '');
|