@nadohq/engine-client 0.1.0-alpha.5 → 0.1.0-alpha.51
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/EngineBaseClient.d.cts +1 -1
- package/dist/EngineBaseClient.d.ts +1 -1
- package/dist/EngineExecuteBuilder.cjs +9 -6
- package/dist/EngineExecuteBuilder.cjs.map +1 -1
- package/dist/EngineExecuteBuilder.js +9 -6
- package/dist/EngineExecuteBuilder.js.map +1 -1
- package/dist/EngineExecuteClient.cjs +6 -6
- package/dist/EngineExecuteClient.cjs.map +1 -1
- package/dist/EngineExecuteClient.d.cts +1 -1
- package/dist/EngineExecuteClient.d.ts +1 -1
- package/dist/EngineExecuteClient.js +6 -6
- package/dist/EngineExecuteClient.js.map +1 -1
- package/dist/EngineQueryClient.cjs +48 -4
- package/dist/EngineQueryClient.cjs.map +1 -1
- package/dist/EngineQueryClient.d.cts +18 -2
- package/dist/EngineQueryClient.d.ts +18 -2
- package/dist/EngineQueryClient.js +50 -4
- package/dist/EngineQueryClient.js.map +1 -1
- package/dist/endpoints.cjs +6 -6
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.js +6 -6
- package/dist/endpoints.js.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/clientExecuteTypes.cjs.map +1 -1
- package/dist/types/clientExecuteTypes.d.cts +8 -1
- package/dist/types/clientExecuteTypes.d.ts +8 -1
- package/dist/types/clientQueryTypes.cjs.map +1 -1
- package/dist/types/clientQueryTypes.d.cts +38 -5
- package/dist/types/clientQueryTypes.d.ts +38 -5
- package/dist/types/index.cjs +10 -10
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +6 -6
- package/dist/types/index.d.ts +6 -6
- package/dist/types/index.js +5 -5
- package/dist/types/index.js.map +1 -1
- package/dist/types/serverExecuteTypes.cjs.map +1 -1
- package/dist/types/serverExecuteTypes.d.cts +8 -1
- package/dist/types/serverExecuteTypes.d.ts +8 -1
- package/dist/types/serverQueryModelTypes.cjs.map +1 -1
- package/dist/types/serverQueryModelTypes.d.cts +24 -1
- package/dist/types/serverQueryModelTypes.d.ts +24 -1
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +48 -22
- package/dist/types/serverQueryTypes.d.ts +48 -22
- package/dist/types/serverSubscriptionEventTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionEventTypes.d.cts +86 -22
- package/dist/types/serverSubscriptionEventTypes.d.ts +86 -22
- package/dist/types/serverSubscriptionTypes.cjs.map +1 -1
- package/dist/types/serverSubscriptionTypes.d.cts +21 -4
- package/dist/types/serverSubscriptionTypes.d.ts +21 -4
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/queryDataMappers.cjs +67 -19
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.d.cts +7 -5
- package/dist/utils/queryDataMappers.d.ts +7 -5
- package/dist/utils/queryDataMappers.js +65 -19
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +8 -4
- package/src/EngineExecuteBuilder.ts +9 -6
- package/src/EngineExecuteClient.ts +7 -7
- package/src/EngineQueryClient.ts +63 -1
- package/src/endpoints.ts +6 -6
- package/src/index.ts +2 -2
- package/src/types/clientExecuteTypes.ts +9 -2
- package/src/types/clientQueryTypes.ts +49 -4
- package/src/types/index.ts +5 -5
- package/src/types/serverExecuteTypes.ts +9 -2
- package/src/types/serverQueryModelTypes.ts +25 -0
- package/src/types/serverQueryTypes.ts +65 -25
- package/src/types/serverSubscriptionEventTypes.ts +122 -21
- package/src/types/serverSubscriptionTypes.ts +23 -3
- package/src/utils/queryDataMappers.ts +86 -20
|
@@ -3,21 +3,23 @@ import '@nadohq/shared';
|
|
|
3
3
|
import './serverQueryModelTypes.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Reasons that can trigger position change events.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type PositionChangeReason = 'deposit_collateral' | 'match_orders' | 'withdraw_collateral' | 'transfer_quote' | 'settle_pnl' | 'mint_nlp' | 'burn_nlp' | 'liquidate_subaccount';
|
|
9
|
+
/**
|
|
10
|
+
* Possible reasons for order updates.
|
|
11
|
+
*/
|
|
12
|
+
type OrderUpdateReason = 'cancelled' | 'filled' | 'placed';
|
|
13
|
+
type EngineServerSubscriptionEventType = 'trade' | 'best_bid_offer' | 'book_depth' | 'fill' | 'position_change' | 'order_update' | 'liquidation' | 'latest_candlestick' | 'funding_payment';
|
|
14
|
+
interface EngineServerSubscriptionBaseEvent<T extends EngineServerSubscriptionEventType = EngineServerSubscriptionEventType> {
|
|
15
|
+
type: T;
|
|
10
16
|
product_id: number;
|
|
11
|
-
digest: string;
|
|
12
|
-
amount: string;
|
|
13
|
-
reason: string;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Event from subscribing to a `trade` stream.
|
|
17
20
|
*/
|
|
18
|
-
interface EngineServerSubscriptionTradeEvent {
|
|
21
|
+
interface EngineServerSubscriptionTradeEvent extends EngineServerSubscriptionBaseEvent<'trade'> {
|
|
19
22
|
timestamp: string;
|
|
20
|
-
product_id: number;
|
|
21
23
|
price: string;
|
|
22
24
|
taker_qty: string;
|
|
23
25
|
maker_qty: string;
|
|
@@ -26,46 +28,108 @@ interface EngineServerSubscriptionTradeEvent {
|
|
|
26
28
|
/**
|
|
27
29
|
* Event from subscribing to a `best_bid_offer` stream.
|
|
28
30
|
*/
|
|
29
|
-
interface EngineServerSubscriptionBestBidOfferEvent {
|
|
31
|
+
interface EngineServerSubscriptionBestBidOfferEvent extends EngineServerSubscriptionBaseEvent<'best_bid_offer'> {
|
|
30
32
|
timestamp: string;
|
|
31
|
-
product_id: number;
|
|
32
33
|
bid_price: string;
|
|
33
34
|
bid_qty: string;
|
|
34
35
|
ask_price: string;
|
|
35
36
|
ask_qty: string;
|
|
36
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Event from subscribing to a `book_depth` stream.
|
|
40
|
+
*/
|
|
41
|
+
interface EngineServerSubscriptionBookDepthEvent extends EngineServerSubscriptionBaseEvent<'book_depth'> {
|
|
42
|
+
last_max_timestamp: string;
|
|
43
|
+
min_timestamp: string;
|
|
44
|
+
max_timestamp: string;
|
|
45
|
+
bids: EngineServerPriceTickLiquidity[];
|
|
46
|
+
asks: EngineServerPriceTickLiquidity[];
|
|
47
|
+
}
|
|
37
48
|
/**
|
|
38
49
|
* Event from subscribing to a `fill` stream.
|
|
39
50
|
*/
|
|
40
|
-
interface EngineServerSubscriptionFillEvent {
|
|
51
|
+
interface EngineServerSubscriptionFillEvent extends EngineServerSubscriptionBaseEvent<'fill'> {
|
|
41
52
|
timestamp: string;
|
|
42
|
-
product_id: number;
|
|
43
53
|
subaccount: string;
|
|
44
54
|
order_digest: string;
|
|
45
55
|
filled_qty: string;
|
|
46
56
|
remaining_qty: string;
|
|
57
|
+
original_qty: string;
|
|
47
58
|
price: string;
|
|
48
59
|
is_taker: boolean;
|
|
60
|
+
is_bid: boolean;
|
|
61
|
+
fee: string;
|
|
62
|
+
submission_idx: string;
|
|
63
|
+
appendix: string;
|
|
49
64
|
}
|
|
50
65
|
/**
|
|
51
66
|
* Event from subscribing to a `position_change` stream.
|
|
52
67
|
*/
|
|
53
|
-
interface EngineServerSubscriptionPositionChangeEvent {
|
|
68
|
+
interface EngineServerSubscriptionPositionChangeEvent extends EngineServerSubscriptionBaseEvent<'position_change'> {
|
|
54
69
|
timestamp: string;
|
|
55
|
-
product_id: number;
|
|
56
70
|
subaccount: string;
|
|
57
71
|
amount: string;
|
|
72
|
+
/** Zero for everything except perps */
|
|
58
73
|
v_quote_amount: string;
|
|
74
|
+
reason: PositionChangeReason;
|
|
75
|
+
/**
|
|
76
|
+
* True if the position change was for an isolated position
|
|
77
|
+
*/
|
|
78
|
+
isolated: boolean;
|
|
59
79
|
}
|
|
60
80
|
/**
|
|
61
|
-
* Event from subscribing to
|
|
81
|
+
* Event from subscribing to an `order_update` stream.
|
|
62
82
|
*/
|
|
63
|
-
interface
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
interface EngineServerSubscriptionOrderUpdateEvent extends EngineServerSubscriptionBaseEvent<'order_update'> {
|
|
84
|
+
timestamp: string;
|
|
85
|
+
digest: string;
|
|
86
|
+
amount: string;
|
|
87
|
+
reason: OrderUpdateReason;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Event from subscribing to a `liquidation` stream.
|
|
91
|
+
*/
|
|
92
|
+
interface EngineServerSubscriptionLiquidationEvent extends EngineServerSubscriptionBaseEvent<'liquidation'> {
|
|
93
|
+
timestamp: string;
|
|
94
|
+
/** Single element for regular liquidations, two elements for spread liquidations [spotId, perpId] */
|
|
95
|
+
product_ids: number[];
|
|
96
|
+
liquidator: string;
|
|
97
|
+
liquidatee: string;
|
|
98
|
+
/** Amount liquidated (positive for long, negative for short) */
|
|
99
|
+
amount: string;
|
|
100
|
+
/** Price at which liquidation occurred */
|
|
101
|
+
price: string;
|
|
69
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Event from subscribing to a `latest_candlestick` stream.
|
|
105
|
+
*/
|
|
106
|
+
interface EngineServerSubscriptionLatestCandlestickEvent extends EngineServerSubscriptionBaseEvent<'latest_candlestick'> {
|
|
107
|
+
timestamp: string;
|
|
108
|
+
granularity: number;
|
|
109
|
+
open_x18: string;
|
|
110
|
+
high_x18: string;
|
|
111
|
+
low_x18: string;
|
|
112
|
+
close_x18: string;
|
|
113
|
+
volume: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Event from subscribing to a `funding_payment` stream.
|
|
117
|
+
*/
|
|
118
|
+
interface EngineServerSubscriptionFundingPaymentEvent extends EngineServerSubscriptionBaseEvent<'funding_payment'> {
|
|
119
|
+
timestamp: string;
|
|
120
|
+
/** Funding payment amount (positive = receive, negative = pay) */
|
|
121
|
+
payment_amount: string;
|
|
122
|
+
/** Open interest at time of funding */
|
|
123
|
+
open_interest: string;
|
|
124
|
+
/** Current cumulative funding values */
|
|
125
|
+
cumulative_funding_long_x18: string;
|
|
126
|
+
cumulative_funding_short_x18: string;
|
|
127
|
+
/** Time delta over which the funding payment was calculated */
|
|
128
|
+
dt: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Union type for all engine server subscription events.
|
|
132
|
+
*/
|
|
133
|
+
type EngineServerSubscriptionEvent = EngineServerSubscriptionTradeEvent | EngineServerSubscriptionBestBidOfferEvent | EngineServerSubscriptionBookDepthEvent | EngineServerSubscriptionFillEvent | EngineServerSubscriptionPositionChangeEvent | EngineServerSubscriptionOrderUpdateEvent | EngineServerSubscriptionLiquidationEvent | EngineServerSubscriptionLatestCandlestickEvent | EngineServerSubscriptionFundingPaymentEvent;
|
|
70
134
|
|
|
71
|
-
export type { EngineServerSubscriptionBestBidOfferEvent, EngineServerSubscriptionBookDepthEvent, EngineServerSubscriptionFillEvent, EngineServerSubscriptionOrderUpdateEvent, EngineServerSubscriptionPositionChangeEvent, EngineServerSubscriptionTradeEvent };
|
|
135
|
+
export type { EngineServerSubscriptionBaseEvent, EngineServerSubscriptionBestBidOfferEvent, EngineServerSubscriptionBookDepthEvent, EngineServerSubscriptionEvent, EngineServerSubscriptionEventType, EngineServerSubscriptionFillEvent, EngineServerSubscriptionFundingPaymentEvent, EngineServerSubscriptionLatestCandlestickEvent, EngineServerSubscriptionLiquidationEvent, EngineServerSubscriptionOrderUpdateEvent, EngineServerSubscriptionPositionChangeEvent, EngineServerSubscriptionTradeEvent, OrderUpdateReason, PositionChangeReason };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/serverSubscriptionTypes.ts"],"sourcesContent":["export interface EngineServerOrderUpdateStreamParams {\n product_id
|
|
1
|
+
{"version":3,"sources":["../../src/types/serverSubscriptionTypes.ts"],"sourcesContent":["export interface EngineServerOrderUpdateStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n subaccount: string;\n}\n\nexport interface EngineServerTradeStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerBestBidOfferStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerFillStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n subaccount: string;\n}\n\nexport interface EngineServerPositionChangeStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n subaccount: string;\n}\n\nexport interface EngineServerBookDepthStreamParams {\n product_id: number;\n}\n\nexport interface EngineServerLatestCandlestickStreamParams {\n product_id: number;\n granularity: number;\n}\n\nexport interface EngineServerLiquidationStreamParams {\n /** when not provided, subscribes to all products */\n product_id?: number;\n}\n\nexport interface EngineServerFundingPaymentStreamParams {\n product_id: number;\n}\n\n/**\n * Available subscription streams\n */\nexport interface EngineServerSubscriptionStreamParamsByType {\n order_update: EngineServerOrderUpdateStreamParams;\n trade: EngineServerTradeStreamParams;\n best_bid_offer: EngineServerBestBidOfferStreamParams;\n fill: EngineServerFillStreamParams;\n position_change: EngineServerPositionChangeStreamParams;\n book_depth: EngineServerBookDepthStreamParams;\n liquidation: EngineServerLiquidationStreamParams;\n latest_candlestick: EngineServerLatestCandlestickStreamParams;\n funding_payment: EngineServerFundingPaymentStreamParams;\n}\n\nexport type EngineServerSubscriptionStreamParamsType =\n keyof EngineServerSubscriptionStreamParamsByType;\n\n/**\n * Describes a stream that can be subscribed to.\n */\nexport type EngineServerSubscriptionStream<\n TStreamType extends EngineServerSubscriptionStreamParamsType,\n> = {\n type: TStreamType;\n} & EngineServerSubscriptionStreamParamsByType[TStreamType];\n\n/**\n * Params to provide to a `subscribe` / `unsubscribe` action.\n */\nexport interface EngineServerSubscriptionParams {\n stream: EngineServerSubscriptionStream<EngineServerSubscriptionStreamParamsType>;\n}\n\n/**\n * Available actions on the subscription API.\n */\nexport interface EngineServerSubscriptionRequestByType {\n subscribe: EngineServerSubscriptionParams;\n unsubscribe: EngineServerSubscriptionParams;\n list: Record<string, never>;\n}\n\nexport type EngineServerSubscriptionRequestType =\n keyof EngineServerSubscriptionRequestByType;\n\n/**\n * Top level request to send to the server.\n */\nexport type EngineServerSubscriptionRequest<\n TRequestType extends EngineServerSubscriptionRequestType,\n> = {\n id: number;\n method: TRequestType;\n} & EngineServerSubscriptionRequestByType[TRequestType];\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface EngineServerOrderUpdateStreamParams {
|
|
2
|
-
|
|
2
|
+
/** when not provided, subscribes to all products */
|
|
3
|
+
product_id?: number;
|
|
3
4
|
subaccount: string;
|
|
4
5
|
}
|
|
5
6
|
interface EngineServerTradeStreamParams {
|
|
@@ -9,16 +10,29 @@ interface EngineServerBestBidOfferStreamParams {
|
|
|
9
10
|
product_id: number;
|
|
10
11
|
}
|
|
11
12
|
interface EngineServerFillStreamParams {
|
|
12
|
-
|
|
13
|
+
/** when not provided, subscribes to all products */
|
|
14
|
+
product_id?: number;
|
|
13
15
|
subaccount: string;
|
|
14
16
|
}
|
|
15
17
|
interface EngineServerPositionChangeStreamParams {
|
|
16
|
-
|
|
18
|
+
/** when not provided, subscribes to all products */
|
|
19
|
+
product_id?: number;
|
|
17
20
|
subaccount: string;
|
|
18
21
|
}
|
|
19
22
|
interface EngineServerBookDepthStreamParams {
|
|
20
23
|
product_id: number;
|
|
21
24
|
}
|
|
25
|
+
interface EngineServerLatestCandlestickStreamParams {
|
|
26
|
+
product_id: number;
|
|
27
|
+
granularity: number;
|
|
28
|
+
}
|
|
29
|
+
interface EngineServerLiquidationStreamParams {
|
|
30
|
+
/** when not provided, subscribes to all products */
|
|
31
|
+
product_id?: number;
|
|
32
|
+
}
|
|
33
|
+
interface EngineServerFundingPaymentStreamParams {
|
|
34
|
+
product_id: number;
|
|
35
|
+
}
|
|
22
36
|
/**
|
|
23
37
|
* Available subscription streams
|
|
24
38
|
*/
|
|
@@ -29,6 +43,9 @@ interface EngineServerSubscriptionStreamParamsByType {
|
|
|
29
43
|
fill: EngineServerFillStreamParams;
|
|
30
44
|
position_change: EngineServerPositionChangeStreamParams;
|
|
31
45
|
book_depth: EngineServerBookDepthStreamParams;
|
|
46
|
+
liquidation: EngineServerLiquidationStreamParams;
|
|
47
|
+
latest_candlestick: EngineServerLatestCandlestickStreamParams;
|
|
48
|
+
funding_payment: EngineServerFundingPaymentStreamParams;
|
|
32
49
|
}
|
|
33
50
|
type EngineServerSubscriptionStreamParamsType = keyof EngineServerSubscriptionStreamParamsByType;
|
|
34
51
|
/**
|
|
@@ -60,4 +77,4 @@ type EngineServerSubscriptionRequest<TRequestType extends EngineServerSubscripti
|
|
|
60
77
|
method: TRequestType;
|
|
61
78
|
} & EngineServerSubscriptionRequestByType[TRequestType];
|
|
62
79
|
|
|
63
|
-
export type { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams };
|
|
80
|
+
export type { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerFundingPaymentStreamParams, EngineServerLatestCandlestickStreamParams, EngineServerLiquidationStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface EngineServerOrderUpdateStreamParams {
|
|
2
|
-
|
|
2
|
+
/** when not provided, subscribes to all products */
|
|
3
|
+
product_id?: number;
|
|
3
4
|
subaccount: string;
|
|
4
5
|
}
|
|
5
6
|
interface EngineServerTradeStreamParams {
|
|
@@ -9,16 +10,29 @@ interface EngineServerBestBidOfferStreamParams {
|
|
|
9
10
|
product_id: number;
|
|
10
11
|
}
|
|
11
12
|
interface EngineServerFillStreamParams {
|
|
12
|
-
|
|
13
|
+
/** when not provided, subscribes to all products */
|
|
14
|
+
product_id?: number;
|
|
13
15
|
subaccount: string;
|
|
14
16
|
}
|
|
15
17
|
interface EngineServerPositionChangeStreamParams {
|
|
16
|
-
|
|
18
|
+
/** when not provided, subscribes to all products */
|
|
19
|
+
product_id?: number;
|
|
17
20
|
subaccount: string;
|
|
18
21
|
}
|
|
19
22
|
interface EngineServerBookDepthStreamParams {
|
|
20
23
|
product_id: number;
|
|
21
24
|
}
|
|
25
|
+
interface EngineServerLatestCandlestickStreamParams {
|
|
26
|
+
product_id: number;
|
|
27
|
+
granularity: number;
|
|
28
|
+
}
|
|
29
|
+
interface EngineServerLiquidationStreamParams {
|
|
30
|
+
/** when not provided, subscribes to all products */
|
|
31
|
+
product_id?: number;
|
|
32
|
+
}
|
|
33
|
+
interface EngineServerFundingPaymentStreamParams {
|
|
34
|
+
product_id: number;
|
|
35
|
+
}
|
|
22
36
|
/**
|
|
23
37
|
* Available subscription streams
|
|
24
38
|
*/
|
|
@@ -29,6 +43,9 @@ interface EngineServerSubscriptionStreamParamsByType {
|
|
|
29
43
|
fill: EngineServerFillStreamParams;
|
|
30
44
|
position_change: EngineServerPositionChangeStreamParams;
|
|
31
45
|
book_depth: EngineServerBookDepthStreamParams;
|
|
46
|
+
liquidation: EngineServerLiquidationStreamParams;
|
|
47
|
+
latest_candlestick: EngineServerLatestCandlestickStreamParams;
|
|
48
|
+
funding_payment: EngineServerFundingPaymentStreamParams;
|
|
32
49
|
}
|
|
33
50
|
type EngineServerSubscriptionStreamParamsType = keyof EngineServerSubscriptionStreamParamsByType;
|
|
34
51
|
/**
|
|
@@ -60,4 +77,4 @@ type EngineServerSubscriptionRequest<TRequestType extends EngineServerSubscripti
|
|
|
60
77
|
method: TRequestType;
|
|
61
78
|
} & EngineServerSubscriptionRequestByType[TRequestType];
|
|
62
79
|
|
|
63
|
-
export type { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams };
|
|
80
|
+
export type { EngineServerBestBidOfferStreamParams, EngineServerBookDepthStreamParams, EngineServerFillStreamParams, EngineServerFundingPaymentStreamParams, EngineServerLatestCandlestickStreamParams, EngineServerLiquidationStreamParams, EngineServerOrderUpdateStreamParams, EngineServerPositionChangeStreamParams, EngineServerSubscriptionParams, EngineServerSubscriptionRequest, EngineServerSubscriptionRequestByType, EngineServerSubscriptionRequestType, EngineServerSubscriptionStream, EngineServerSubscriptionStreamParamsByType, EngineServerSubscriptionStreamParamsType, EngineServerTradeStreamParams };
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.cjs';
|
|
1
|
+
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerNlpPoolInfo, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.cjs';
|
|
2
2
|
import '@nadohq/shared';
|
|
3
|
-
import '../types/clientQueryTypes.cjs';
|
|
4
3
|
import '../types/serverQueryTypes.cjs';
|
|
5
4
|
import '../types/serverQueryModelTypes.cjs';
|
|
5
|
+
import '../types/clientQueryTypes.cjs';
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.js';
|
|
1
|
+
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerNlpPoolInfo, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from './queryDataMappers.js';
|
|
2
2
|
import '@nadohq/shared';
|
|
3
|
-
import '../types/clientQueryTypes.js';
|
|
4
3
|
import '../types/serverQueryTypes.js';
|
|
5
4
|
import '../types/serverQueryModelTypes.js';
|
|
5
|
+
import '../types/clientQueryTypes.js';
|
|
@@ -23,6 +23,8 @@ __export(queryDataMappers_exports, {
|
|
|
23
23
|
mapEngineMarketPrice: () => mapEngineMarketPrice,
|
|
24
24
|
mapEngineServerBalanceHealthContributions: () => mapEngineServerBalanceHealthContributions,
|
|
25
25
|
mapEngineServerIsolatedPositions: () => mapEngineServerIsolatedPositions,
|
|
26
|
+
mapEngineServerNlpLockedBalances: () => mapEngineServerNlpLockedBalances,
|
|
27
|
+
mapEngineServerNlpPoolInfo: () => mapEngineServerNlpPoolInfo,
|
|
26
28
|
mapEngineServerOrder: () => mapEngineServerOrder,
|
|
27
29
|
mapEngineServerPerpProduct: () => mapEngineServerPerpProduct,
|
|
28
30
|
mapEngineServerSpotProduct: () => mapEngineServerSpotProduct,
|
|
@@ -131,9 +133,24 @@ function mapEngineServerBalanceHealthContributions(healthContributionsForBalance
|
|
|
131
133
|
};
|
|
132
134
|
}
|
|
133
135
|
function mapSubaccountSummary(baseResponse) {
|
|
136
|
+
return {
|
|
137
|
+
exists: baseResponse.exists,
|
|
138
|
+
...mapSubaccountSummaryState(
|
|
139
|
+
baseResponse,
|
|
140
|
+
baseResponse.spot_products,
|
|
141
|
+
baseResponse.perp_products
|
|
142
|
+
),
|
|
143
|
+
preState: baseResponse.pre_state ? mapSubaccountSummaryState(
|
|
144
|
+
baseResponse.pre_state,
|
|
145
|
+
baseResponse.spot_products,
|
|
146
|
+
baseResponse.perp_products
|
|
147
|
+
) : void 0
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function mapSubaccountSummaryState(state, spotProducts, perpProducts) {
|
|
134
151
|
const balances = [];
|
|
135
|
-
|
|
136
|
-
const product =
|
|
152
|
+
state.spot_balances.forEach((spotBalance) => {
|
|
153
|
+
const product = spotProducts.find(
|
|
137
154
|
(product2) => product2.product_id === spotBalance.product_id
|
|
138
155
|
);
|
|
139
156
|
if (!product) {
|
|
@@ -142,13 +159,13 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
142
159
|
balances.push({
|
|
143
160
|
amount: (0, import_shared.toBigDecimal)(spotBalance.balance.amount),
|
|
144
161
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
145
|
-
|
|
162
|
+
state.health_contributions[spotBalance.product_id]
|
|
146
163
|
),
|
|
147
164
|
...mapEngineServerSpotProduct(product).product
|
|
148
165
|
});
|
|
149
166
|
});
|
|
150
|
-
|
|
151
|
-
const product =
|
|
167
|
+
state.perp_balances.forEach((perpBalance) => {
|
|
168
|
+
const product = perpProducts.find(
|
|
152
169
|
(product2) => product2.product_id === perpBalance.product_id
|
|
153
170
|
);
|
|
154
171
|
if (!product) {
|
|
@@ -158,29 +175,28 @@ function mapSubaccountSummary(baseResponse) {
|
|
|
158
175
|
amount: (0, import_shared.toBigDecimal)(perpBalance.balance.amount),
|
|
159
176
|
vQuoteBalance: (0, import_shared.toBigDecimal)(perpBalance.balance.v_quote_balance),
|
|
160
177
|
healthContributions: mapEngineServerBalanceHealthContributions(
|
|
161
|
-
|
|
178
|
+
state.health_contributions[perpBalance.product_id]
|
|
162
179
|
),
|
|
163
180
|
...mapEngineServerPerpProduct(product).product
|
|
164
181
|
});
|
|
165
182
|
});
|
|
166
183
|
return {
|
|
167
184
|
balances,
|
|
168
|
-
exists: baseResponse.exists,
|
|
169
185
|
health: {
|
|
170
186
|
initial: {
|
|
171
|
-
health: (0, import_shared.toBigDecimal)(
|
|
172
|
-
assets: (0, import_shared.toBigDecimal)(
|
|
173
|
-
liabilities: (0, import_shared.toBigDecimal)(
|
|
187
|
+
health: (0, import_shared.toBigDecimal)(state.healths[0].health),
|
|
188
|
+
assets: (0, import_shared.toBigDecimal)(state.healths[0].assets),
|
|
189
|
+
liabilities: (0, import_shared.toBigDecimal)(state.healths[0].liabilities)
|
|
174
190
|
},
|
|
175
191
|
maintenance: {
|
|
176
|
-
health: (0, import_shared.toBigDecimal)(
|
|
177
|
-
assets: (0, import_shared.toBigDecimal)(
|
|
178
|
-
liabilities: (0, import_shared.toBigDecimal)(
|
|
192
|
+
health: (0, import_shared.toBigDecimal)(state.healths[1].health),
|
|
193
|
+
assets: (0, import_shared.toBigDecimal)(state.healths[1].assets),
|
|
194
|
+
liabilities: (0, import_shared.toBigDecimal)(state.healths[1].liabilities)
|
|
179
195
|
},
|
|
180
196
|
unweighted: {
|
|
181
|
-
health: (0, import_shared.toBigDecimal)(
|
|
182
|
-
assets: (0, import_shared.toBigDecimal)(
|
|
183
|
-
liabilities: (0, import_shared.toBigDecimal)(
|
|
197
|
+
health: (0, import_shared.toBigDecimal)(state.healths[2].health),
|
|
198
|
+
assets: (0, import_shared.toBigDecimal)(state.healths[2].assets),
|
|
199
|
+
liabilities: (0, import_shared.toBigDecimal)(state.healths[2].liabilities)
|
|
184
200
|
}
|
|
185
201
|
}
|
|
186
202
|
};
|
|
@@ -236,8 +252,6 @@ function mapEngineServerSymbol(engineServerSymbol) {
|
|
|
236
252
|
priceIncrement: (0, import_shared.removeDecimals)(engineServerSymbol.price_increment_x18),
|
|
237
253
|
sizeIncrement: (0, import_shared.toBigDecimal)(engineServerSymbol.size_increment),
|
|
238
254
|
minSize: (0, import_shared.toBigDecimal)(engineServerSymbol.min_size),
|
|
239
|
-
minDepth: (0, import_shared.removeDecimals)(engineServerSymbol.min_depth_x18),
|
|
240
|
-
maxSpreadRate: (0, import_shared.removeDecimals)(engineServerSymbol.max_spread_rate_x18),
|
|
241
255
|
makerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.maker_fee_rate_x18),
|
|
242
256
|
takerFeeRate: (0, import_shared.removeDecimals)(engineServerSymbol.taker_fee_rate_x18),
|
|
243
257
|
longWeightInitial: (0, import_shared.removeDecimals)(
|
|
@@ -245,7 +259,9 @@ function mapEngineServerSymbol(engineServerSymbol) {
|
|
|
245
259
|
),
|
|
246
260
|
longWeightMaintenance: (0, import_shared.removeDecimals)(
|
|
247
261
|
engineServerSymbol.long_weight_maintenance_x18
|
|
248
|
-
)
|
|
262
|
+
),
|
|
263
|
+
maxOpenInterest: (0, import_shared.removeDecimals)(engineServerSymbol.max_open_interest_x18),
|
|
264
|
+
isolatedOnly: engineServerSymbol.isolated_only
|
|
249
265
|
};
|
|
250
266
|
}
|
|
251
267
|
function mapEngineMarketPrice(baseResponse) {
|
|
@@ -255,11 +271,43 @@ function mapEngineMarketPrice(baseResponse) {
|
|
|
255
271
|
productId: baseResponse.product_id
|
|
256
272
|
};
|
|
257
273
|
}
|
|
274
|
+
function mapEngineServerNlpLockedBalances(baseResponse) {
|
|
275
|
+
const lockedBalances = baseResponse.locked_balances.map((lockedBalance) => ({
|
|
276
|
+
productId: lockedBalance.balance.product_id,
|
|
277
|
+
balance: (0, import_shared.toBigDecimal)(lockedBalance.balance.balance.amount),
|
|
278
|
+
unlockedAt: lockedBalance.unlocked_at
|
|
279
|
+
}));
|
|
280
|
+
return {
|
|
281
|
+
lockedBalances,
|
|
282
|
+
balanceLocked: {
|
|
283
|
+
productId: baseResponse.balance_locked.product_id,
|
|
284
|
+
balance: (0, import_shared.toBigDecimal)(baseResponse.balance_locked.balance.amount)
|
|
285
|
+
},
|
|
286
|
+
balanceUnlocked: {
|
|
287
|
+
productId: baseResponse.balance_unlocked.product_id,
|
|
288
|
+
balance: (0, import_shared.toBigDecimal)(baseResponse.balance_unlocked.balance.amount)
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function mapEngineServerNlpPoolInfo(baseResponse) {
|
|
293
|
+
return {
|
|
294
|
+
nlpPools: baseResponse.nlp_pools.map((pool) => ({
|
|
295
|
+
poolId: pool.pool_id,
|
|
296
|
+
subaccountHex: pool.subaccount,
|
|
297
|
+
ownerAddress: pool.owner,
|
|
298
|
+
balanceWeight: (0, import_shared.removeDecimals)(pool.balance_weight_x18),
|
|
299
|
+
subaccountInfo: mapSubaccountSummary(pool.subaccount_info),
|
|
300
|
+
openOrders: pool.open_orders.map(mapEngineServerOrder)
|
|
301
|
+
}))
|
|
302
|
+
};
|
|
303
|
+
}
|
|
258
304
|
// Annotate the CommonJS export names for ESM import in node:
|
|
259
305
|
0 && (module.exports = {
|
|
260
306
|
mapEngineMarketPrice,
|
|
261
307
|
mapEngineServerBalanceHealthContributions,
|
|
262
308
|
mapEngineServerIsolatedPositions,
|
|
309
|
+
mapEngineServerNlpLockedBalances,
|
|
310
|
+
mapEngineServerNlpPoolInfo,
|
|
263
311
|
mapEngineServerOrder,
|
|
264
312
|
mapEngineServerPerpProduct,
|
|
265
313
|
mapEngineServerSpotProduct,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineSubaccountSummaryResponse,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n const balances: GetEngineSubaccountSummaryResponse['balances'] = [];\n\n baseResponse.spot_balances.forEach((spotBalance) => {\n const product = baseResponse.spot_products.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n baseResponse.perp_balances.forEach((perpBalance) => {\n const product = baseResponse.perp_products.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n baseResponse.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances: balances,\n exists: baseResponse.exists,\n health: {\n initial: {\n health: toBigDecimal(baseResponse.healths[0].health),\n assets: toBigDecimal(baseResponse.healths[0].assets),\n liabilities: toBigDecimal(baseResponse.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(baseResponse.healths[1].health),\n assets: toBigDecimal(baseResponse.healths[1].assets),\n liabilities: toBigDecimal(baseResponse.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(baseResponse.healths[2].health),\n assets: toBigDecimal(baseResponse.healths[2].assets),\n liabilities: toBigDecimal(baseResponse.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n minDepth: removeDecimals(engineServerSymbol.min_depth_x18),\n maxSpreadRate: removeDecimals(engineServerSymbol.max_spread_rate_x18),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAYO;AAmBP,sCAA2C;AAEpC,SAAS,6BACd,MAC0B;AAC1B,SAAO;AAAA,IACL,WAAO,8BAAe,KAAK,CAAC,CAAC;AAAA,IAC7B,eAAW,4BAAa,KAAK,CAAC,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,qBACd,OACa;AACb,QAAM,iBAAa,iCAAkB,MAAM,MAAM;AACjD,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,YAAY,OAAO,MAAM,UAAU;AAAA,IACnC,OAAO,MAAM;AAAA,IACb,WAAO,8BAAe,MAAM,SAAS;AAAA,IACrC,WAAW,MAAM;AAAA,IACjB,iBAAiB,WAAW;AAAA,IAC5B,gBAAgB,WAAW;AAAA,IAC3B,iBAAa,4BAAa,MAAM,MAAM;AAAA,IACtC,oBAAgB,4BAAa,MAAM,eAAe;AAAA,IAClD,eAAe,MAAM;AAAA,IACrB,cAAU,mCAAoB,MAAM,QAAQ;AAAA,EAC9C;AACF;AAEO,SAAS,2BACd,SACY;AACZ,SAAO;AAAA,IACL,MAAM,gCAAkB;AAAA,IACxB,WAAW,QAAQ;AAAA,IACnB,aAAS,4BAAa,QAAQ,UAAU,QAAQ;AAAA,IAChD,oBAAgB,8BAAe,QAAQ,UAAU,mBAAmB;AAA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AAc,8BAAe,mBAAmB,kBAAkB;AAAA,IAClE,kBAAc,8BAAe,mBAAmB,kBAAkB;AAAA,IAClE,uBAAmB;AAAA,MACjB,mBAAmB;AAAA,IACrB;AAAA,IACA,2BAAuB;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAAA,EACF;AACF;AAEO,SAAS,qBACd,cACmB;AACnB,SAAO;AAAA,IACL,SAAK,8BAAe,aAAa,OAAO;AAAA,IACxC,SAAK,8BAAe,aAAa,OAAO;AAAA,IACxC,WAAW,aAAa;AAAA,EAC1B;AACF;","names":["product"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/queryDataMappers.ts"],"sourcesContent":["import {\n BalanceHealthContributions,\n calcTotalBorrowed,\n calcTotalDeposited,\n mapValues,\n PerpMarket,\n ProductEngineType,\n removeDecimals,\n SpotMarket,\n subaccountFromHex,\n toBigDecimal,\n unpackOrderAppendix,\n} from '@nadohq/shared';\nimport {\n EngineMarketPrice,\n EngineNlpLockedBalance,\n EngineOrder,\n EnginePriceTickLiquidity,\n EngineServerIsolatedPositionsResponse,\n EngineServerMarketPrice,\n EngineServerNlpLockedBalancesResponse,\n EngineServerNlpPoolInfoResponse,\n EngineServerOrderResponse,\n EngineServerPerpProduct,\n EngineServerPriceTickLiquidity,\n EngineServerSpotProduct,\n EngineServerSubaccountInfoResponse,\n EngineServerSubaccountInfoState,\n EngineServerSymbol,\n EngineServerSymbolsResponse,\n EngineSymbol,\n EngineSymbolsResponse,\n GetEngineIsolatedPositionsResponse,\n GetEngineNlpLockedBalancesResponse,\n GetEngineNlpPoolInfoResponse,\n GetEngineSubaccountSummaryResponse,\n SubaccountSummaryState,\n} from '../types';\nimport { mapEngineServerProductType } from './productEngineTypeMappers';\n\nexport function mapEngineServerTickLiquidity(\n tick: EngineServerPriceTickLiquidity,\n): EnginePriceTickLiquidity {\n return {\n price: removeDecimals(tick[0]),\n liquidity: toBigDecimal(tick[1]),\n };\n}\n\nexport function mapEngineServerOrder(\n order: EngineServerOrderResponse,\n): EngineOrder {\n const subaccount = subaccountFromHex(order.sender);\n return {\n digest: order.digest,\n expiration: Number(order.expiration),\n nonce: order.nonce,\n price: removeDecimals(order.price_x18),\n productId: order.product_id,\n subaccountOwner: subaccount.subaccountOwner,\n subaccountName: subaccount.subaccountName,\n totalAmount: toBigDecimal(order.amount),\n unfilledAmount: toBigDecimal(order.unfilled_amount),\n placementTime: order.placed_at,\n appendix: unpackOrderAppendix(order.appendix),\n };\n}\n\nexport function mapEngineServerSpotProduct(\n product: EngineServerSpotProduct,\n): SpotMarket {\n return {\n type: ProductEngineType.SPOT,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.SPOT,\n totalBorrowed: calcTotalBorrowed(\n product.state.total_borrows_normalized,\n product.state.cumulative_borrows_multiplier_x18,\n ),\n totalDeposited: calcTotalDeposited(\n product.state.total_deposits_normalized,\n product.state.cumulative_deposits_multiplier_x18,\n ),\n oraclePrice: removeDecimals(product.oracle_price_x18),\n interestFloor: removeDecimals(product.config.interest_floor_x18),\n interestInflectionUtil: removeDecimals(\n product.config.interest_inflection_util_x18,\n ),\n interestLargeCap: removeDecimals(product.config.interest_large_cap_x18),\n interestSmallCap: removeDecimals(product.config.interest_small_cap_x18),\n minDepositRate: removeDecimals(product.config.min_deposit_rate_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n tokenAddr: product.config.token,\n },\n };\n}\n\nexport function mapEngineServerPerpProduct(\n product: EngineServerPerpProduct,\n): PerpMarket {\n return {\n type: ProductEngineType.PERP,\n productId: product.product_id,\n minSize: toBigDecimal(product.book_info.min_size),\n priceIncrement: removeDecimals(product.book_info.price_increment_x18),\n sizeIncrement: toBigDecimal(product.book_info.size_increment),\n product: {\n productId: product.product_id,\n type: ProductEngineType.PERP,\n oraclePrice: removeDecimals(product.oracle_price_x18),\n longWeightInitial: removeDecimals(product.risk.long_weight_initial_x18),\n longWeightMaintenance: removeDecimals(\n product.risk.long_weight_maintenance_x18,\n ),\n shortWeightInitial: removeDecimals(product.risk.short_weight_initial_x18),\n shortWeightMaintenance: removeDecimals(\n product.risk.short_weight_maintenance_x18,\n ),\n openInterest: toBigDecimal(product.state.open_interest),\n cumulativeFundingLong: removeDecimals(\n product.state.cumulative_funding_long_x18,\n ),\n cumulativeFundingShort: removeDecimals(\n product.state.cumulative_funding_short_x18,\n ),\n },\n };\n}\n\nexport function mapEngineServerBalanceHealthContributions(\n healthContributionsForBalance: string[],\n): BalanceHealthContributions {\n return {\n initial: toBigDecimal(healthContributionsForBalance[0]),\n maintenance: toBigDecimal(healthContributionsForBalance[1]),\n unweighted: toBigDecimal(healthContributionsForBalance[2]),\n };\n}\n\nexport function mapSubaccountSummary(\n baseResponse: EngineServerSubaccountInfoResponse,\n): GetEngineSubaccountSummaryResponse {\n return {\n exists: baseResponse.exists,\n ...mapSubaccountSummaryState(\n baseResponse,\n baseResponse.spot_products,\n baseResponse.perp_products,\n ),\n preState: baseResponse.pre_state\n ? mapSubaccountSummaryState(\n baseResponse.pre_state,\n baseResponse.spot_products,\n baseResponse.perp_products,\n )\n : undefined,\n };\n}\n\nfunction mapSubaccountSummaryState(\n state: EngineServerSubaccountInfoState,\n spotProducts: EngineServerSubaccountInfoResponse['spot_products'],\n perpProducts: EngineServerSubaccountInfoResponse['perp_products'],\n): SubaccountSummaryState {\n const balances: SubaccountSummaryState['balances'] = [];\n\n state.spot_balances.forEach((spotBalance) => {\n const product = spotProducts.find(\n (product) => product.product_id === spotBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${spotBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(spotBalance.balance.amount),\n healthContributions: mapEngineServerBalanceHealthContributions(\n state.health_contributions[spotBalance.product_id],\n ),\n ...mapEngineServerSpotProduct(product).product,\n });\n });\n\n state.perp_balances.forEach((perpBalance) => {\n const product = perpProducts.find(\n (product) => product.product_id === perpBalance.product_id,\n );\n if (!product) {\n throw Error(`Could not find product ${perpBalance.product_id}`);\n }\n\n balances.push({\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n healthContributions: mapEngineServerBalanceHealthContributions(\n state.health_contributions[perpBalance.product_id],\n ),\n ...mapEngineServerPerpProduct(product).product,\n });\n });\n\n return {\n balances,\n health: {\n initial: {\n health: toBigDecimal(state.healths[0].health),\n assets: toBigDecimal(state.healths[0].assets),\n liabilities: toBigDecimal(state.healths[0].liabilities),\n },\n maintenance: {\n health: toBigDecimal(state.healths[1].health),\n assets: toBigDecimal(state.healths[1].assets),\n liabilities: toBigDecimal(state.healths[1].liabilities),\n },\n unweighted: {\n health: toBigDecimal(state.healths[2].health),\n assets: toBigDecimal(state.healths[2].assets),\n liabilities: toBigDecimal(state.healths[2].liabilities),\n },\n },\n };\n}\n\nexport function mapEngineServerIsolatedPositions(\n baseResponse: EngineServerIsolatedPositionsResponse,\n): GetEngineIsolatedPositionsResponse {\n return baseResponse.isolated_positions.map((position) => {\n const perpBalance = position.base_balance;\n const quoteBalance = position.quote_balance;\n\n return {\n subaccount: subaccountFromHex(position.subaccount),\n healths: {\n initial: toBigDecimal(position.healths[0].health),\n maintenance: toBigDecimal(position.healths[1].health),\n unweighted: toBigDecimal(position.healths[2].health),\n },\n baseBalance: {\n amount: toBigDecimal(perpBalance.balance.amount),\n vQuoteBalance: toBigDecimal(perpBalance.balance.v_quote_balance),\n // Health contributions === healths for an isolated position\n healthContributions: {\n initial: toBigDecimal(position.base_healths[0]),\n maintenance: toBigDecimal(position.base_healths[1]),\n unweighted: toBigDecimal(position.base_healths[2]),\n },\n ...mapEngineServerPerpProduct(position.base_product).product,\n },\n quoteBalance: {\n amount: toBigDecimal(quoteBalance.balance.amount),\n healthContributions: {\n initial: toBigDecimal(position.quote_healths[0]),\n maintenance: toBigDecimal(position.quote_healths[1]),\n unweighted: toBigDecimal(position.quote_healths[2]),\n },\n ...mapEngineServerSpotProduct(position.quote_product).product,\n },\n };\n });\n}\n\nexport function mapEngineServerSymbols(\n baseResponse: EngineServerSymbolsResponse,\n): EngineSymbolsResponse {\n const symbols: Record<string, EngineSymbol> = mapValues(\n baseResponse.symbols,\n mapEngineServerSymbol,\n );\n\n return {\n symbols,\n };\n}\n\nexport function mapEngineServerSymbol(\n engineServerSymbol: EngineServerSymbol,\n): EngineSymbol {\n return {\n type: mapEngineServerProductType(engineServerSymbol.type),\n productId: engineServerSymbol.product_id,\n symbol: engineServerSymbol.symbol,\n priceIncrement: removeDecimals(engineServerSymbol.price_increment_x18),\n sizeIncrement: toBigDecimal(engineServerSymbol.size_increment),\n minSize: toBigDecimal(engineServerSymbol.min_size),\n makerFeeRate: removeDecimals(engineServerSymbol.maker_fee_rate_x18),\n takerFeeRate: removeDecimals(engineServerSymbol.taker_fee_rate_x18),\n longWeightInitial: removeDecimals(\n engineServerSymbol.long_weight_initial_x18,\n ),\n longWeightMaintenance: removeDecimals(\n engineServerSymbol.long_weight_maintenance_x18,\n ),\n maxOpenInterest: removeDecimals(engineServerSymbol.max_open_interest_x18),\n isolatedOnly: engineServerSymbol.isolated_only,\n };\n}\n\nexport function mapEngineMarketPrice(\n baseResponse: EngineServerMarketPrice,\n): EngineMarketPrice {\n return {\n ask: removeDecimals(baseResponse.ask_x18),\n bid: removeDecimals(baseResponse.bid_x18),\n productId: baseResponse.product_id,\n };\n}\n\nexport function mapEngineServerNlpLockedBalances(\n baseResponse: EngineServerNlpLockedBalancesResponse,\n): GetEngineNlpLockedBalancesResponse {\n const lockedBalances: EngineNlpLockedBalance[] =\n baseResponse.locked_balances.map((lockedBalance) => ({\n productId: lockedBalance.balance.product_id,\n balance: toBigDecimal(lockedBalance.balance.balance.amount),\n unlockedAt: lockedBalance.unlocked_at,\n }));\n\n return {\n lockedBalances,\n balanceLocked: {\n productId: baseResponse.balance_locked.product_id,\n balance: toBigDecimal(baseResponse.balance_locked.balance.amount),\n },\n balanceUnlocked: {\n productId: baseResponse.balance_unlocked.product_id,\n balance: toBigDecimal(baseResponse.balance_unlocked.balance.amount),\n },\n };\n}\n\nexport function mapEngineServerNlpPoolInfo(\n baseResponse: EngineServerNlpPoolInfoResponse,\n): GetEngineNlpPoolInfoResponse {\n return {\n nlpPools: baseResponse.nlp_pools.map((pool) => ({\n poolId: pool.pool_id,\n subaccountHex: pool.subaccount,\n ownerAddress: pool.owner,\n balanceWeight: removeDecimals(pool.balance_weight_x18),\n subaccountInfo: mapSubaccountSummary(pool.subaccount_info),\n openOrders: pool.open_orders.map(mapEngineServerOrder),\n })),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAYO;AA0BP,sCAA2C;AAEpC,SAAS,6BACd,MAC0B;AAC1B,SAAO;AAAA,IACL,WAAO,8BAAe,KAAK,CAAC,CAAC;AAAA,IAC7B,eAAW,4BAAa,KAAK,CAAC,CAAC;AAAA,EACjC;AACF;AAEO,SAAS,qBACd,OACa;AACb,QAAM,iBAAa,iCAAkB,MAAM,MAAM;AACjD,SAAO;AAAA,IACL,QAAQ,MAAM;AAAA,IACd,YAAY,OAAO,MAAM,UAAU;AAAA,IACnC,OAAO,MAAM;AAAA,IACb,WAAO,8BAAe,MAAM,SAAS;AAAA,IACrC,WAAW,MAAM;AAAA,IACjB,iBAAiB,WAAW;AAAA,IAC5B,gBAAgB,WAAW;AAAA,IAC3B,iBAAa,4BAAa,MAAM,MAAM;AAAA,IACtC,oBAAgB,4BAAa,MAAM,eAAe;AAAA,IAClD,e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AiB,QAAQ,MAAM;AAAA,IACpE;AAAA,EACF;AACF;AAEO,SAAS,2BACd,cAC8B;AAC9B,SAAO;AAAA,IACL,UAAU,aAAa,UAAU,IAAI,CAAC,UAAU;AAAA,MAC9C,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,cAAc,KAAK;AAAA,MACnB,mBAAe,8BAAe,KAAK,kBAAkB;AAAA,MACrD,gBAAgB,qBAAqB,KAAK,eAAe;AAAA,MACzD,YAAY,KAAK,YAAY,IAAI,oBAAoB;AAAA,IACvD,EAAE;AAAA,EACJ;AACF;","names":["product"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { BalanceHealthContributions, PerpMarket, SpotMarket } from '@nadohq/shared';
|
|
2
|
+
import { EngineServerMarketPrice, EngineServerIsolatedPositionsResponse, EngineServerNlpLockedBalancesResponse, EngineServerNlpPoolInfoResponse, EngineServerOrderResponse, EngineServerSymbol, EngineServerSymbolsResponse, EngineServerPriceTickLiquidity, EngineServerSubaccountInfoResponse } from '../types/serverQueryTypes.cjs';
|
|
3
|
+
import { EngineMarketPrice, GetEngineIsolatedPositionsResponse, GetEngineNlpLockedBalancesResponse, GetEngineNlpPoolInfoResponse, EngineOrder, EngineSymbol, EngineSymbolsResponse, EnginePriceTickLiquidity, GetEngineSubaccountSummaryResponse } from '../types/clientQueryTypes.cjs';
|
|
4
|
+
import { EngineServerPerpProduct, EngineServerSpotProduct } from '../types/serverQueryModelTypes.cjs';
|
|
5
5
|
|
|
6
6
|
declare function mapEngineServerTickLiquidity(tick: EngineServerPriceTickLiquidity): EnginePriceTickLiquidity;
|
|
7
7
|
declare function mapEngineServerOrder(order: EngineServerOrderResponse): EngineOrder;
|
|
@@ -13,5 +13,7 @@ declare function mapEngineServerIsolatedPositions(baseResponse: EngineServerIsol
|
|
|
13
13
|
declare function mapEngineServerSymbols(baseResponse: EngineServerSymbolsResponse): EngineSymbolsResponse;
|
|
14
14
|
declare function mapEngineServerSymbol(engineServerSymbol: EngineServerSymbol): EngineSymbol;
|
|
15
15
|
declare function mapEngineMarketPrice(baseResponse: EngineServerMarketPrice): EngineMarketPrice;
|
|
16
|
+
declare function mapEngineServerNlpLockedBalances(baseResponse: EngineServerNlpLockedBalancesResponse): GetEngineNlpLockedBalancesResponse;
|
|
17
|
+
declare function mapEngineServerNlpPoolInfo(baseResponse: EngineServerNlpPoolInfoResponse): GetEngineNlpPoolInfoResponse;
|
|
16
18
|
|
|
17
|
-
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary };
|
|
19
|
+
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerNlpPoolInfo, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { BalanceHealthContributions, PerpMarket, SpotMarket } from '@nadohq/shared';
|
|
2
|
+
import { EngineServerMarketPrice, EngineServerIsolatedPositionsResponse, EngineServerNlpLockedBalancesResponse, EngineServerNlpPoolInfoResponse, EngineServerOrderResponse, EngineServerSymbol, EngineServerSymbolsResponse, EngineServerPriceTickLiquidity, EngineServerSubaccountInfoResponse } from '../types/serverQueryTypes.js';
|
|
3
|
+
import { EngineMarketPrice, GetEngineIsolatedPositionsResponse, GetEngineNlpLockedBalancesResponse, GetEngineNlpPoolInfoResponse, EngineOrder, EngineSymbol, EngineSymbolsResponse, EnginePriceTickLiquidity, GetEngineSubaccountSummaryResponse } from '../types/clientQueryTypes.js';
|
|
4
|
+
import { EngineServerPerpProduct, EngineServerSpotProduct } from '../types/serverQueryModelTypes.js';
|
|
5
5
|
|
|
6
6
|
declare function mapEngineServerTickLiquidity(tick: EngineServerPriceTickLiquidity): EnginePriceTickLiquidity;
|
|
7
7
|
declare function mapEngineServerOrder(order: EngineServerOrderResponse): EngineOrder;
|
|
@@ -13,5 +13,7 @@ declare function mapEngineServerIsolatedPositions(baseResponse: EngineServerIsol
|
|
|
13
13
|
declare function mapEngineServerSymbols(baseResponse: EngineServerSymbolsResponse): EngineSymbolsResponse;
|
|
14
14
|
declare function mapEngineServerSymbol(engineServerSymbol: EngineServerSymbol): EngineSymbol;
|
|
15
15
|
declare function mapEngineMarketPrice(baseResponse: EngineServerMarketPrice): EngineMarketPrice;
|
|
16
|
+
declare function mapEngineServerNlpLockedBalances(baseResponse: EngineServerNlpLockedBalancesResponse): GetEngineNlpLockedBalancesResponse;
|
|
17
|
+
declare function mapEngineServerNlpPoolInfo(baseResponse: EngineServerNlpPoolInfoResponse): GetEngineNlpPoolInfoResponse;
|
|
16
18
|
|
|
17
|
-
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary };
|
|
19
|
+
export { mapEngineMarketPrice, mapEngineServerBalanceHealthContributions, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerNlpPoolInfo, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbol, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary };
|