@nadohq/engine-client 0.14.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EngineBaseClient-DOOXIhnZ.d.ts +75 -0
- package/dist/EngineBaseClient-DOOXIhnZ.d.ts.map +1 -0
- package/dist/EngineBaseClient-L1ue7jBx.d.cts +75 -0
- package/dist/EngineBaseClient-L1ue7jBx.d.cts.map +1 -0
- package/dist/EngineBaseClient-Uc1D8ftx.cjs +150 -0
- package/dist/EngineBaseClient-Uc1D8ftx.cjs.map +1 -0
- package/dist/EngineBaseClient.cjs +3 -167
- package/dist/EngineBaseClient.d.cts +2 -75
- package/dist/EngineBaseClient.d.ts +2 -75
- package/dist/EngineBaseClient.js +112 -131
- package/dist/EngineBaseClient.js.map +1 -1
- package/dist/EngineClient.cjs +13 -38
- package/dist/EngineClient.cjs.map +1 -1
- package/dist/EngineClient.d.cts +8 -18
- package/dist/EngineClient.d.cts.map +1 -0
- package/dist/EngineClient.d.ts +8 -18
- package/dist/EngineClient.d.ts.map +1 -0
- package/dist/EngineClient.js +9 -11
- package/dist/EngineClient.js.map +1 -1
- package/dist/EngineExecuteBuilder-VLrEndhv.d.cts +105 -0
- package/dist/EngineExecuteBuilder-VLrEndhv.d.cts.map +1 -0
- package/dist/EngineExecuteBuilder-t8EQ5Rmp.d.ts +105 -0
- package/dist/EngineExecuteBuilder-t8EQ5Rmp.d.ts.map +1 -0
- package/dist/EngineExecuteBuilder.cjs +232 -277
- package/dist/EngineExecuteBuilder.cjs.map +1 -1
- package/dist/EngineExecuteBuilder.d.cts +2 -108
- package/dist/EngineExecuteBuilder.d.ts +2 -108
- package/dist/EngineExecuteBuilder.js +230 -256
- package/dist/EngineExecuteBuilder.js.map +1 -1
- package/dist/EngineExecuteClient-0EBoXRd7.d.ts +24 -0
- package/dist/EngineExecuteClient-0EBoXRd7.d.ts.map +1 -0
- package/dist/EngineExecuteClient-BGlNK5Le.d.cts +24 -0
- package/dist/EngineExecuteClient-BGlNK5Le.d.cts.map +1 -0
- package/dist/EngineExecuteClient.cjs +57 -110
- package/dist/EngineExecuteClient.cjs.map +1 -1
- package/dist/EngineExecuteClient.d.cts +2 -28
- package/dist/EngineExecuteClient.d.ts +2 -28
- package/dist/EngineExecuteClient.js +54 -83
- package/dist/EngineExecuteClient.js.map +1 -1
- package/dist/EngineQueryClient-C_7p1oRx.d.cts +147 -0
- package/dist/EngineQueryClient-C_7p1oRx.d.cts.map +1 -0
- package/dist/EngineQueryClient-DQwCRaYl.d.ts +147 -0
- package/dist/EngineQueryClient-DQwCRaYl.d.ts.map +1 -0
- package/dist/EngineQueryClient.cjs +354 -447
- package/dist/EngineQueryClient.cjs.map +1 -1
- package/dist/EngineQueryClient.d.cts +2 -149
- package/dist/EngineQueryClient.d.ts +2 -149
- package/dist/EngineQueryClient.js +351 -440
- package/dist/EngineQueryClient.js.map +1 -1
- package/dist/EngineServerFailureError-CDabRrF4.d.ts +11 -0
- package/dist/EngineServerFailureError-CDabRrF4.d.ts.map +1 -0
- package/dist/EngineServerFailureError-DpPY0--L.d.cts +11 -0
- package/dist/EngineServerFailureError-DpPY0--L.d.cts.map +1 -0
- package/dist/EngineWebClient-CEwqgd4t.d.ts +35 -0
- package/dist/EngineWebClient-CEwqgd4t.d.ts.map +1 -0
- package/dist/EngineWebClient-DajZqKAQ.d.cts +35 -0
- package/dist/EngineWebClient-DajZqKAQ.d.cts.map +1 -0
- package/dist/EngineWebClient.cjs +49 -86
- package/dist/EngineWebClient.cjs.map +1 -1
- package/dist/EngineWebClient.d.cts +2 -39
- package/dist/EngineWebClient.d.ts +2 -39
- package/dist/EngineWebClient.js +47 -60
- package/dist/EngineWebClient.js.map +1 -1
- package/dist/clientExecuteTypes-BlJOgCL_.d.cts +91 -0
- package/dist/clientExecuteTypes-BlJOgCL_.d.cts.map +1 -0
- package/dist/clientExecuteTypes-CJ08_c4q.d.ts +91 -0
- package/dist/clientExecuteTypes-CJ08_c4q.d.ts.map +1 -0
- package/dist/clientQueryTypes-DlTtS_mX.d.cts +221 -0
- package/dist/clientQueryTypes-DlTtS_mX.d.cts.map +1 -0
- package/dist/clientQueryTypes-DuRgEeBT.d.ts +221 -0
- package/dist/clientQueryTypes-DuRgEeBT.d.ts.map +1 -0
- package/dist/endpoints.cjs +19 -45
- package/dist/endpoints.cjs.map +1 -1
- package/dist/endpoints.d.cts +4 -2
- package/dist/endpoints.d.cts.map +1 -0
- package/dist/endpoints.d.ts +4 -2
- package/dist/endpoints.d.ts.map +1 -0
- package/dist/endpoints.js +16 -18
- package/dist/endpoints.js.map +1 -1
- package/dist/index-CmCelmEL.d.cts +1 -0
- package/dist/index-D0E78WnU.d.ts +1 -0
- package/dist/index.cjs +26 -31
- package/dist/index.d.cts +12 -20
- package/dist/index.d.ts +12 -20
- package/dist/index.js +8 -6
- package/dist/queryDataMappers-BguxA579.d.ts +21 -0
- package/dist/queryDataMappers-BguxA579.d.ts.map +1 -0
- package/dist/queryDataMappers-DO9yWdLo.d.cts +21 -0
- package/dist/queryDataMappers-DO9yWdLo.d.cts.map +1 -0
- package/dist/serverExecuteTypes-CgbHjnWM.d.ts +92 -0
- package/dist/serverExecuteTypes-CgbHjnWM.d.ts.map +1 -0
- package/dist/serverExecuteTypes-DejTR8Is.d.cts +92 -0
- package/dist/serverExecuteTypes-DejTR8Is.d.cts.map +1 -0
- package/dist/serverQueryModelTypes-85xnbU-a.d.cts +98 -0
- package/dist/serverQueryModelTypes-85xnbU-a.d.cts.map +1 -0
- package/dist/serverQueryModelTypes-CENoy5Hm.d.ts +98 -0
- package/dist/serverQueryModelTypes-CENoy5Hm.d.ts.map +1 -0
- package/dist/serverQueryTypes-B3vC8vxT.d.ts +301 -0
- package/dist/serverQueryTypes-B3vC8vxT.d.ts.map +1 -0
- package/dist/serverQueryTypes-Dva9R2tV.d.cts +301 -0
- package/dist/serverQueryTypes-Dva9R2tV.d.cts.map +1 -0
- package/dist/serverSubscriptionEventTypes-BMUrTkTg.d.cts +135 -0
- package/dist/serverSubscriptionEventTypes-BMUrTkTg.d.cts.map +1 -0
- package/dist/serverSubscriptionEventTypes-UCYAjmt7.d.ts +135 -0
- package/dist/serverSubscriptionEventTypes-UCYAjmt7.d.ts.map +1 -0
- package/dist/serverSubscriptionTypes-BSuYa6z_.d.cts +82 -0
- package/dist/serverSubscriptionTypes-BSuYa6z_.d.cts.map +1 -0
- package/dist/serverSubscriptionTypes-DoMWeKgY.d.ts +82 -0
- package/dist/serverSubscriptionTypes-DoMWeKgY.d.ts.map +1 -0
- package/dist/types/EngineServerFailureError.cjs +9 -33
- package/dist/types/EngineServerFailureError.cjs.map +1 -1
- package/dist/types/EngineServerFailureError.d.cts +2 -11
- package/dist/types/EngineServerFailureError.d.ts +2 -11
- package/dist/types/EngineServerFailureError.js +8 -8
- package/dist/types/EngineServerFailureError.js.map +1 -1
- package/dist/types/clientExecuteTypes.cjs +0 -19
- package/dist/types/clientExecuteTypes.d.cts +2 -91
- package/dist/types/clientExecuteTypes.d.ts +2 -91
- package/dist/types/clientExecuteTypes.js +1 -1
- package/dist/types/clientQueryTypes.cjs +0 -19
- package/dist/types/clientQueryTypes.d.cts +2 -219
- package/dist/types/clientQueryTypes.d.ts +2 -219
- package/dist/types/clientQueryTypes.js +1 -1
- package/dist/types/index.cjs +5 -39
- package/dist/types/index.d.cts +9 -10
- package/dist/types/index.d.ts +9 -10
- package/dist/types/index.js +3 -10
- package/dist/types/serverExecuteTypes.cjs +0 -19
- package/dist/types/serverExecuteTypes.d.cts +2 -93
- package/dist/types/serverExecuteTypes.d.ts +2 -93
- package/dist/types/serverExecuteTypes.js +1 -1
- package/dist/types/serverQueryModelTypes.cjs +0 -19
- package/dist/types/serverQueryModelTypes.d.cts +2 -96
- package/dist/types/serverQueryModelTypes.d.ts +2 -96
- package/dist/types/serverQueryModelTypes.js +1 -1
- package/dist/types/serverQueryTypes.cjs +12 -36
- package/dist/types/serverQueryTypes.cjs.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +2 -309
- package/dist/types/serverQueryTypes.d.ts +2 -309
- package/dist/types/serverQueryTypes.js +11 -11
- package/dist/types/serverQueryTypes.js.map +1 -1
- package/dist/types/serverSubscriptionEventTypes.cjs +0 -19
- package/dist/types/serverSubscriptionEventTypes.d.cts +2 -135
- package/dist/types/serverSubscriptionEventTypes.d.ts +2 -135
- package/dist/types/serverSubscriptionEventTypes.js +1 -1
- package/dist/types/serverSubscriptionTypes.cjs +0 -19
- package/dist/types/serverSubscriptionTypes.d.cts +2 -80
- package/dist/types/serverSubscriptionTypes.d.ts +2 -80
- package/dist/types/serverSubscriptionTypes.js +1 -1
- package/dist/utils/index.cjs +14 -25
- package/dist/utils/index.d.cts +2 -6
- package/dist/utils/index.d.ts +2 -6
- package/dist/utils/index.js +2 -3
- package/dist/utils/productEngineTypeMappers.cjs +16 -44
- package/dist/utils/productEngineTypeMappers.cjs.map +1 -1
- package/dist/utils/productEngineTypeMappers.d.cts +5 -3
- package/dist/utils/productEngineTypeMappers.d.cts.map +1 -0
- package/dist/utils/productEngineTypeMappers.d.ts +5 -3
- package/dist/utils/productEngineTypeMappers.d.ts.map +1 -0
- package/dist/utils/productEngineTypeMappers.js +12 -17
- package/dist/utils/productEngineTypeMappers.js.map +1 -1
- package/dist/utils/queryDataMappers.cjs +204 -292
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.d.cts +2 -20
- package/dist/utils/queryDataMappers.d.ts +2 -20
- package/dist/utils/queryDataMappers.js +190 -264
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +9 -9
- package/src/EngineQueryClient.ts +4 -0
- package/src/types/clientQueryTypes.ts +3 -0
- package/src/types/serverQueryTypes.ts +3 -0
- package/dist/EngineBaseClient.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/clientExecuteTypes.cjs.map +0 -1
- package/dist/types/clientExecuteTypes.js.map +0 -1
- package/dist/types/clientQueryTypes.cjs.map +0 -1
- package/dist/types/clientQueryTypes.js.map +0 -1
- package/dist/types/index.cjs.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/serverExecuteTypes.cjs.map +0 -1
- package/dist/types/serverExecuteTypes.js.map +0 -1
- package/dist/types/serverQueryModelTypes.cjs.map +0 -1
- package/dist/types/serverQueryModelTypes.js.map +0 -1
- package/dist/types/serverSubscriptionEventTypes.cjs.map +0 -1
- package/dist/types/serverSubscriptionEventTypes.js.map +0 -1
- package/dist/types/serverSubscriptionTypes.cjs.map +0 -1
- package/dist/types/serverSubscriptionTypes.js.map +0 -1
- package/dist/utils/index.cjs.map +0 -1
- package/dist/utils/index.js.map +0 -1
|
@@ -1,445 +1,356 @@
|
|
|
1
|
-
// src/EngineQueryClient.ts
|
|
2
|
-
import {
|
|
3
|
-
addDecimals,
|
|
4
|
-
encodeSignedOrder,
|
|
5
|
-
getOrderVerifyingAddress,
|
|
6
|
-
mapValues,
|
|
7
|
-
removeDecimals,
|
|
8
|
-
subaccountToHex,
|
|
9
|
-
toBigNumber,
|
|
10
|
-
toIntegerString
|
|
11
|
-
} from "@nadohq/shared";
|
|
12
1
|
import { EngineBaseClient } from "./EngineBaseClient.js";
|
|
13
2
|
import { mapProductEngineType } from "./utils/productEngineTypeMappers.js";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
mapEngineServerNlpLockedBalances,
|
|
18
|
-
mapEngineServerNlpPoolInfo,
|
|
19
|
-
mapEngineServerOrder,
|
|
20
|
-
mapEngineServerPerpProduct,
|
|
21
|
-
mapEngineServerSpotProduct,
|
|
22
|
-
mapEngineServerSymbols,
|
|
23
|
-
mapEngineServerTickLiquidity,
|
|
24
|
-
mapSubaccountSummary
|
|
25
|
-
} from "./utils/queryDataMappers.js";
|
|
3
|
+
import { mapEngineMarketPrice, mapEngineServerIsolatedPositions, mapEngineServerNlpLockedBalances, mapEngineServerNlpPoolInfo, mapEngineServerOrder, mapEngineServerPerpProduct, mapEngineServerSpotProduct, mapEngineServerSymbols, mapEngineServerTickLiquidity, mapSubaccountSummary } from "./utils/queryDataMappers.js";
|
|
4
|
+
import { addDecimals, encodeSignedOrder, getOrderVerifyingAddress, mapValues, removeDecimals, subaccountToHex, toBigNumber, toIntegerString } from "@nadohq/shared";
|
|
5
|
+
//#region src/EngineQueryClient.ts
|
|
26
6
|
var EngineQueryClient = class extends EngineBaseClient {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
async getMaxMintNlpAmount(params) {
|
|
373
|
-
const baseResponse = await this.query("max_nlp_mintable", {
|
|
374
|
-
sender: subaccountToHex({
|
|
375
|
-
subaccountOwner: params.subaccountOwner,
|
|
376
|
-
subaccountName: params.subaccountName
|
|
377
|
-
}),
|
|
378
|
-
spot_leverage: params.spotLeverage != null ? String(params.spotLeverage) : null
|
|
379
|
-
});
|
|
380
|
-
return toBigNumber(baseResponse.max_quote_amount);
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Retrieves the max amount of NLP that can be burned.
|
|
384
|
-
*
|
|
385
|
-
* @param params
|
|
386
|
-
*/
|
|
387
|
-
async getMaxBurnNlpAmount(params) {
|
|
388
|
-
const baseResponse = await this.query("max_nlp_burnable", {
|
|
389
|
-
sender: subaccountToHex({
|
|
390
|
-
subaccountOwner: params.subaccountOwner,
|
|
391
|
-
subaccountName: params.subaccountName
|
|
392
|
-
})
|
|
393
|
-
});
|
|
394
|
-
return toBigNumber(baseResponse.max_nlp_amount);
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Gets the currently linked signer for the subaccount
|
|
398
|
-
* @param params
|
|
399
|
-
* @returns
|
|
400
|
-
*/
|
|
401
|
-
async getLinkedSigner(params) {
|
|
402
|
-
const baseResponse = await this.query("linked_signer", {
|
|
403
|
-
subaccount: subaccountToHex({
|
|
404
|
-
subaccountOwner: params.subaccountOwner,
|
|
405
|
-
subaccountName: params.subaccountName
|
|
406
|
-
})
|
|
407
|
-
});
|
|
408
|
-
return {
|
|
409
|
-
signer: baseResponse.linked_signer
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Gets the insurance funds in USDT.
|
|
414
|
-
* @returns
|
|
415
|
-
*/
|
|
416
|
-
async getInsurance() {
|
|
417
|
-
const baseResponse = await this.query("insurance", {});
|
|
418
|
-
return toBigNumber(baseResponse.insurance);
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Retrieves the NLP locked and unlocked balances for a subaccount.
|
|
422
|
-
*
|
|
423
|
-
* @param params
|
|
424
|
-
*/
|
|
425
|
-
async getNlpLockedBalances(params) {
|
|
426
|
-
const baseResponse = await this.query("nlp_locked_balances", {
|
|
427
|
-
subaccount: subaccountToHex({
|
|
428
|
-
subaccountOwner: params.subaccountOwner,
|
|
429
|
-
subaccountName: params.subaccountName
|
|
430
|
-
})
|
|
431
|
-
});
|
|
432
|
-
return mapEngineServerNlpLockedBalances(baseResponse);
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Retrieves information about all NLP sub-pools
|
|
436
|
-
*/
|
|
437
|
-
async getNlpPoolInfo() {
|
|
438
|
-
const baseResponse = await this.query("nlp_pool_info", {});
|
|
439
|
-
return mapEngineServerNlpPoolInfo(baseResponse);
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
export {
|
|
443
|
-
EngineQueryClient
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves the set of contracts that the engine is interfacing with
|
|
9
|
+
*/
|
|
10
|
+
async getContracts() {
|
|
11
|
+
const baseResponse = await this.query("contracts", {});
|
|
12
|
+
return {
|
|
13
|
+
chainId: Number(baseResponse.chain_id),
|
|
14
|
+
endpointAddr: baseResponse.endpoint_addr
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves current engine status
|
|
19
|
+
*/
|
|
20
|
+
async getStatus() {
|
|
21
|
+
return this.query("status", {});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves a subaccount summary reflective of the state within the offchain engine. This adheres to the
|
|
25
|
+
* same return interface as the contract version
|
|
26
|
+
*
|
|
27
|
+
* @param params
|
|
28
|
+
*/
|
|
29
|
+
async getSubaccountSummary(params) {
|
|
30
|
+
const subaccount = subaccountToHex({
|
|
31
|
+
subaccountOwner: params.subaccountOwner,
|
|
32
|
+
subaccountName: params.subaccountName
|
|
33
|
+
});
|
|
34
|
+
return mapSubaccountSummary(await this.query("subaccount_info", { subaccount }));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a list of isolated positions
|
|
38
|
+
*
|
|
39
|
+
* @param params
|
|
40
|
+
*/
|
|
41
|
+
async getIsolatedPositions(params) {
|
|
42
|
+
const subaccount = subaccountToHex({
|
|
43
|
+
subaccountOwner: params.subaccountOwner,
|
|
44
|
+
subaccountName: params.subaccountName
|
|
45
|
+
});
|
|
46
|
+
return mapEngineServerIsolatedPositions(await this.query("isolated_positions", { subaccount }));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Retrieves an estimated subaccount summary with the applied transactions
|
|
50
|
+
*
|
|
51
|
+
* @param params
|
|
52
|
+
*/
|
|
53
|
+
async getEstimatedSubaccountSummary(params) {
|
|
54
|
+
const subaccount = subaccountToHex({
|
|
55
|
+
subaccountOwner: params.subaccountOwner,
|
|
56
|
+
subaccountName: params.subaccountName
|
|
57
|
+
});
|
|
58
|
+
const queryParams = {
|
|
59
|
+
subaccount,
|
|
60
|
+
txns: params.txs.map((tx) => {
|
|
61
|
+
switch (tx.type) {
|
|
62
|
+
case "apply_delta": return { apply_delta: {
|
|
63
|
+
product_id: tx.tx.productId,
|
|
64
|
+
subaccount,
|
|
65
|
+
amount_delta: toIntegerString(tx.tx.amountDelta),
|
|
66
|
+
v_quote_delta: toIntegerString(tx.tx.vQuoteDelta)
|
|
67
|
+
} };
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
return mapSubaccountSummary(await this.query("subaccount_info", {
|
|
72
|
+
subaccount: queryParams.subaccount,
|
|
73
|
+
txns: JSON.stringify(queryParams.txns),
|
|
74
|
+
pre_state: params.preState !== void 0 ? String(params.preState) : void 0
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves symbols and product info
|
|
79
|
+
*
|
|
80
|
+
* @param params
|
|
81
|
+
*/
|
|
82
|
+
async getSymbols(params) {
|
|
83
|
+
return mapEngineServerSymbols(await this.query("symbols", {
|
|
84
|
+
product_ids: params.productIds,
|
|
85
|
+
product_type: params.productType != null ? mapProductEngineType(params.productType) : void 0
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves all market states as per the offchain engine. Same return interface as contracts
|
|
90
|
+
*/
|
|
91
|
+
async getAllMarkets() {
|
|
92
|
+
const markets = [];
|
|
93
|
+
const baseResponse = await this.query("all_products", {});
|
|
94
|
+
baseResponse.spot_products.forEach((spotProduct) => {
|
|
95
|
+
markets.push(mapEngineServerSpotProduct(spotProduct));
|
|
96
|
+
});
|
|
97
|
+
baseResponse.perp_products.forEach((perpProduct) => {
|
|
98
|
+
markets.push(mapEngineServerPerpProduct(perpProduct));
|
|
99
|
+
});
|
|
100
|
+
return markets;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Retrieves all markets by chain id.
|
|
104
|
+
*/
|
|
105
|
+
async getEdgeAllMarkets() {
|
|
106
|
+
return mapValues((await this.query("edge_all_products", {})).edge_all_products, (allProducts) => {
|
|
107
|
+
const markets = [];
|
|
108
|
+
allProducts.spot_products.forEach((spotProduct) => {
|
|
109
|
+
markets.push(mapEngineServerSpotProduct(spotProduct));
|
|
110
|
+
});
|
|
111
|
+
allProducts.perp_products.forEach((perpProduct) => {
|
|
112
|
+
markets.push(mapEngineServerPerpProduct(perpProduct));
|
|
113
|
+
});
|
|
114
|
+
return markets;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Retrieves all health groups (linked spot & perp products) from the engine
|
|
119
|
+
*/
|
|
120
|
+
async getHealthGroups() {
|
|
121
|
+
return { healthGroups: (await this.query("health_groups", {})).health_groups.map(([spotProductId, perpProductId]) => {
|
|
122
|
+
return {
|
|
123
|
+
spotProductId,
|
|
124
|
+
perpProductId
|
|
125
|
+
};
|
|
126
|
+
}) };
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Retrieves an order from the offchain engine
|
|
130
|
+
*
|
|
131
|
+
* @param params
|
|
132
|
+
*/
|
|
133
|
+
async getOrder(params) {
|
|
134
|
+
return mapEngineServerOrder(await this.query("order", {
|
|
135
|
+
digest: params.digest,
|
|
136
|
+
product_id: params.productId
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Signs and validates with the engine that the order is valid to be submitted (i.e. does not violate health reqs)
|
|
141
|
+
*
|
|
142
|
+
* @param params
|
|
143
|
+
*/
|
|
144
|
+
async validateOrderParams(params) {
|
|
145
|
+
const signedOrder = {
|
|
146
|
+
order: params.order,
|
|
147
|
+
signature: await this.sign("place_order", getOrderVerifyingAddress(params.productId), params.chainId, params.order)
|
|
148
|
+
};
|
|
149
|
+
return this.validateSignedOrderParams({
|
|
150
|
+
signedOrder,
|
|
151
|
+
productId: params.productId
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Validates an existing signed order with the engine as a pre-check for health
|
|
156
|
+
*
|
|
157
|
+
* @param params
|
|
158
|
+
*/
|
|
159
|
+
async validateSignedOrderParams(params) {
|
|
160
|
+
const baseResponse = await this.query("validate_order", {
|
|
161
|
+
product_id: params.productId,
|
|
162
|
+
order: encodeSignedOrder(params.signedOrder)
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
productId: baseResponse.product_id,
|
|
166
|
+
valid: baseResponse.valid
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get all subaccount orders from the engine, per product ID
|
|
171
|
+
* @param params
|
|
172
|
+
*/
|
|
173
|
+
async getSubaccountOrders(params) {
|
|
174
|
+
return {
|
|
175
|
+
orders: (await this.query("subaccount_orders", {
|
|
176
|
+
sender: subaccountToHex({
|
|
177
|
+
subaccountOwner: params.subaccountOwner,
|
|
178
|
+
subaccountName: params.subaccountName
|
|
179
|
+
}),
|
|
180
|
+
product_id: params.productId
|
|
181
|
+
})).orders.map(mapEngineServerOrder),
|
|
182
|
+
productId: params.productId
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get all subaccount orders from the engine, for multiple products
|
|
187
|
+
* @param params
|
|
188
|
+
*/
|
|
189
|
+
async getSubaccountMultiProductOrders(params) {
|
|
190
|
+
return { productOrders: (await this.query("orders", {
|
|
191
|
+
sender: subaccountToHex({
|
|
192
|
+
subaccountOwner: params.subaccountOwner,
|
|
193
|
+
subaccountName: params.subaccountName
|
|
194
|
+
}),
|
|
195
|
+
product_ids: params.productIds
|
|
196
|
+
})).product_orders.map((orders) => {
|
|
197
|
+
return {
|
|
198
|
+
orders: orders.orders.map(mapEngineServerOrder),
|
|
199
|
+
productId: orders.product_id
|
|
200
|
+
};
|
|
201
|
+
}) };
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Gets maker & taker fee rates for order fees
|
|
205
|
+
* @param params
|
|
206
|
+
*/
|
|
207
|
+
async getSubaccountFeeRates(params) {
|
|
208
|
+
const baseResponse = await this.query("fee_rates", { sender: subaccountToHex({
|
|
209
|
+
subaccountOwner: params.subaccountOwner,
|
|
210
|
+
subaccountName: params.subaccountName
|
|
211
|
+
}) });
|
|
212
|
+
return {
|
|
213
|
+
healthCheckSequencerFee: toBigNumber(baseResponse.health_check_sequencer_fee),
|
|
214
|
+
liquidationSequencerFee: toBigNumber(baseResponse.liquidation_sequencer_fee),
|
|
215
|
+
takerSequencerFee: toBigNumber(baseResponse.taker_sequencer_fee),
|
|
216
|
+
orders: baseResponse.taker_fee_rates_x18.reduce((acc, takerRateX18, currIndex) => {
|
|
217
|
+
acc[currIndex] = {
|
|
218
|
+
taker: removeDecimals(takerRateX18),
|
|
219
|
+
maker: removeDecimals(baseResponse.maker_fee_rates_x18[currIndex])
|
|
220
|
+
};
|
|
221
|
+
return acc;
|
|
222
|
+
}, {}),
|
|
223
|
+
withdrawal: baseResponse.withdraw_sequencer_fees.reduce((acc, productFee, currIndex) => {
|
|
224
|
+
acc[currIndex] = toBigNumber(productFee);
|
|
225
|
+
return acc;
|
|
226
|
+
}, {}),
|
|
227
|
+
feeTier: baseResponse.fee_tier
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Gets "price ticks" for a given market, useful for constructing liquidity levels at each price
|
|
232
|
+
* @param params
|
|
233
|
+
*/
|
|
234
|
+
async getMarketLiquidity(params) {
|
|
235
|
+
const baseResponse = await this.query("market_liquidity", {
|
|
236
|
+
product_id: params.productId,
|
|
237
|
+
depth: params.depth
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
asks: baseResponse.asks.map(mapEngineServerTickLiquidity),
|
|
241
|
+
bids: baseResponse.bids.map(mapEngineServerTickLiquidity)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Retrieves the latest price for a given market
|
|
246
|
+
* @param params
|
|
247
|
+
*/
|
|
248
|
+
async getMarketPrice(params) {
|
|
249
|
+
return mapEngineMarketPrice(await this.query("market_price", { product_id: params.productId }));
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Retrieves the latest prices for provided markets
|
|
253
|
+
* @param params
|
|
254
|
+
*/
|
|
255
|
+
async getMarketPrices(params) {
|
|
256
|
+
return { marketPrices: (await this.query("market_prices", { product_ids: params.productIds })).market_prices.map(mapEngineMarketPrice) };
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Retrieves the estimated max order size for a product
|
|
260
|
+
* @param params
|
|
261
|
+
*/
|
|
262
|
+
async getMaxOrderSize(params) {
|
|
263
|
+
return toBigNumber((await this.query("max_order_size", {
|
|
264
|
+
direction: params.side,
|
|
265
|
+
price_x18: toIntegerString(addDecimals(params.price)),
|
|
266
|
+
avg_price_x18: params.avgPrice != null ? toIntegerString(addDecimals(params.avgPrice)) : null,
|
|
267
|
+
product_id: params.productId,
|
|
268
|
+
sender: subaccountToHex({
|
|
269
|
+
subaccountOwner: params.subaccountOwner,
|
|
270
|
+
subaccountName: params.subaccountName
|
|
271
|
+
}),
|
|
272
|
+
spot_leverage: params.spotLeverage != null ? String(params.spotLeverage) : null,
|
|
273
|
+
reduce_only: params.reduceOnly != null ? String(params.reduceOnly) : null,
|
|
274
|
+
isolated: params.isolated != null ? String(params.isolated) : null,
|
|
275
|
+
borrow_margin: params.isolated && params.isoBorrowMargin != null ? String(params.isoBorrowMargin) : null
|
|
276
|
+
})).max_order_size);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Retrieves the estimated max withdrawal size for a product
|
|
280
|
+
* @param params
|
|
281
|
+
*/
|
|
282
|
+
async getMaxWithdrawable(params) {
|
|
283
|
+
return toBigNumber((await this.query("max_withdrawable", {
|
|
284
|
+
product_id: params.productId,
|
|
285
|
+
sender: subaccountToHex({
|
|
286
|
+
subaccountOwner: params.subaccountOwner,
|
|
287
|
+
subaccountName: params.subaccountName
|
|
288
|
+
}),
|
|
289
|
+
spot_leverage: params.spotLeverage != null ? String(params.spotLeverage) : null
|
|
290
|
+
})).max_withdrawable);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Retrieves the estimated max quote amount for minting NLP.
|
|
294
|
+
*
|
|
295
|
+
* @param params
|
|
296
|
+
*/
|
|
297
|
+
async getMaxMintNlpAmount(params) {
|
|
298
|
+
return toBigNumber((await this.query("max_nlp_mintable", {
|
|
299
|
+
sender: subaccountToHex({
|
|
300
|
+
subaccountOwner: params.subaccountOwner,
|
|
301
|
+
subaccountName: params.subaccountName
|
|
302
|
+
}),
|
|
303
|
+
spot_leverage: params.spotLeverage != null ? String(params.spotLeverage) : null
|
|
304
|
+
})).max_quote_amount);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Retrieves the max amount of NLP that can be burned.
|
|
308
|
+
*
|
|
309
|
+
* @param params
|
|
310
|
+
*/
|
|
311
|
+
async getMaxBurnNlpAmount(params) {
|
|
312
|
+
return toBigNumber((await this.query("max_nlp_burnable", { sender: subaccountToHex({
|
|
313
|
+
subaccountOwner: params.subaccountOwner,
|
|
314
|
+
subaccountName: params.subaccountName
|
|
315
|
+
}) })).max_nlp_amount);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Gets the currently linked signer for the subaccount
|
|
319
|
+
* @param params
|
|
320
|
+
* @returns
|
|
321
|
+
*/
|
|
322
|
+
async getLinkedSigner(params) {
|
|
323
|
+
return { signer: (await this.query("linked_signer", { subaccount: subaccountToHex({
|
|
324
|
+
subaccountOwner: params.subaccountOwner,
|
|
325
|
+
subaccountName: params.subaccountName
|
|
326
|
+
}) })).linked_signer };
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Gets the insurance funds in USDT.
|
|
330
|
+
* @returns
|
|
331
|
+
*/
|
|
332
|
+
async getInsurance() {
|
|
333
|
+
return toBigNumber((await this.query("insurance", {})).insurance);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Retrieves the NLP locked and unlocked balances for a subaccount.
|
|
337
|
+
*
|
|
338
|
+
* @param params
|
|
339
|
+
*/
|
|
340
|
+
async getNlpLockedBalances(params) {
|
|
341
|
+
return mapEngineServerNlpLockedBalances(await this.query("nlp_locked_balances", { subaccount: subaccountToHex({
|
|
342
|
+
subaccountOwner: params.subaccountOwner,
|
|
343
|
+
subaccountName: params.subaccountName
|
|
344
|
+
}) }));
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Retrieves information about all NLP sub-pools
|
|
348
|
+
*/
|
|
349
|
+
async getNlpPoolInfo() {
|
|
350
|
+
return mapEngineServerNlpPoolInfo(await this.query("nlp_pool_info", {}));
|
|
351
|
+
}
|
|
444
352
|
};
|
|
353
|
+
//#endregion
|
|
354
|
+
export { EngineQueryClient };
|
|
355
|
+
|
|
445
356
|
//# sourceMappingURL=EngineQueryClient.js.map
|