@typus/typus-perp-sdk 1.0.40-fix-history-3 → 1.0.40-fix-history-6
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.
|
@@ -20,6 +20,7 @@ export interface Event {
|
|
|
20
20
|
realized_pnl: number | undefined;
|
|
21
21
|
timestamp: string;
|
|
22
22
|
tx_digest: string;
|
|
23
|
+
dov_index: string | undefined;
|
|
23
24
|
}
|
|
24
25
|
export declare function parseUserHistory(raw_events: any): Promise<Event[]>;
|
|
25
26
|
export declare function getGraphQLEvents(module: string, sender: string, beforeCursor?: string | null): Promise<any>;
|
package/dist/src/user/history.js
CHANGED
|
@@ -119,7 +119,9 @@ function parseUserHistory(raw_events) {
|
|
|
119
119
|
else if (json.reduce_only && json.is_stop_order) {
|
|
120
120
|
order_type = "Stop Loss";
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
if (json.linked_position_id != undefined) {
|
|
123
|
+
related = events.find(function (e) { return e.position_id == json.linked_position_id && e.market == market; });
|
|
124
|
+
}
|
|
123
125
|
var e = {
|
|
124
126
|
action: "Place Order",
|
|
125
127
|
typeName: name,
|
|
@@ -137,6 +139,7 @@ function parseUserHistory(raw_events) {
|
|
|
137
139
|
realized_pnl: undefined,
|
|
138
140
|
timestamp: timestamp,
|
|
139
141
|
tx_digest: tx_digest,
|
|
142
|
+
dov_index: json.dov_index,
|
|
140
143
|
};
|
|
141
144
|
events.push(e);
|
|
142
145
|
break;
|
|
@@ -148,7 +151,7 @@ function parseUserHistory(raw_events) {
|
|
|
148
151
|
var price = json.filled_price;
|
|
149
152
|
var action;
|
|
150
153
|
var related;
|
|
151
|
-
if (json.linked_position_id) {
|
|
154
|
+
if (json.linked_position_id != undefined) {
|
|
152
155
|
action = "Order Filled (Close Position)";
|
|
153
156
|
related = events.findLast(function (e) { return e.position_id === json.linked_position_id && e.market === market; });
|
|
154
157
|
// the "Place Order" is emit after Order Filled if filled immediately
|
|
@@ -178,6 +181,7 @@ function parseUserHistory(raw_events) {
|
|
|
178
181
|
realized_pnl: realized_pnl,
|
|
179
182
|
timestamp: timestamp,
|
|
180
183
|
tx_digest: tx_digest,
|
|
184
|
+
dov_index: related === null || related === void 0 ? void 0 : related.dov_index,
|
|
181
185
|
};
|
|
182
186
|
events.push(e);
|
|
183
187
|
break;
|
|
@@ -213,6 +217,7 @@ function parseUserHistory(raw_events) {
|
|
|
213
217
|
realized_pnl: undefined,
|
|
214
218
|
timestamp: timestamp,
|
|
215
219
|
tx_digest: tx_digest,
|
|
220
|
+
dov_index: related === null || related === void 0 ? void 0 : related.dov_index,
|
|
216
221
|
};
|
|
217
222
|
events.push(e);
|
|
218
223
|
break;
|
|
@@ -246,6 +251,7 @@ function parseUserHistory(raw_events) {
|
|
|
246
251
|
realized_pnl: undefined,
|
|
247
252
|
timestamp: timestamp,
|
|
248
253
|
tx_digest: tx_digest,
|
|
254
|
+
dov_index: related === null || related === void 0 ? void 0 : related.dov_index,
|
|
249
255
|
};
|
|
250
256
|
events.push(e);
|
|
251
257
|
break;
|
|
@@ -271,6 +277,7 @@ function parseUserHistory(raw_events) {
|
|
|
271
277
|
realized_pnl: -Number(json.fee_amount_usd) / Math.pow(10, 9),
|
|
272
278
|
timestamp: timestamp,
|
|
273
279
|
tx_digest: tx_digest,
|
|
280
|
+
dov_index: undefined,
|
|
274
281
|
};
|
|
275
282
|
events.push(e);
|
|
276
283
|
break;
|
|
@@ -341,6 +348,7 @@ function getLiquidateFromSentio(userAddress, startTimestamp, events) {
|
|
|
341
348
|
realized_pnl: -collateral * Number(x.collateral_price),
|
|
342
349
|
timestamp: x.timestamp,
|
|
343
350
|
tx_digest: x.transaction_hash,
|
|
351
|
+
dov_index: undefined,
|
|
344
352
|
};
|
|
345
353
|
return txHistory;
|
|
346
354
|
});
|
|
@@ -350,6 +358,7 @@ function getLiquidateFromSentio(userAddress, startTimestamp, events) {
|
|
|
350
358
|
// console.log(related);
|
|
351
359
|
if (related) {
|
|
352
360
|
x.side = related.side;
|
|
361
|
+
x.dov_index = related.dov_index;
|
|
353
362
|
}
|
|
354
363
|
return x;
|
|
355
364
|
});
|
|
@@ -388,6 +397,7 @@ function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
|
|
|
388
397
|
realized_pnl: x.realized_pnl,
|
|
389
398
|
timestamp: x.timestamp,
|
|
390
399
|
tx_digest: x.transaction_hash,
|
|
400
|
+
dov_index: undefined,
|
|
391
401
|
};
|
|
392
402
|
return txHistory;
|
|
393
403
|
});
|
|
@@ -399,6 +409,7 @@ function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
|
|
|
399
409
|
if (related) {
|
|
400
410
|
x.order_type = related.order_type;
|
|
401
411
|
x.collateral = related.collateral;
|
|
412
|
+
x.dov_index = related.dov_index;
|
|
402
413
|
}
|
|
403
414
|
else {
|
|
404
415
|
x.order_type = "Market";
|
|
@@ -440,6 +451,7 @@ function getRealizeOptionFromSentio(userAddress, startTimestamp, events) {
|
|
|
440
451
|
realized_pnl: Number(x.user_remaining_in_usd),
|
|
441
452
|
timestamp: x.timestamp,
|
|
442
453
|
tx_digest: x.transaction_hash,
|
|
454
|
+
dov_index: undefined,
|
|
443
455
|
};
|
|
444
456
|
// console.log(txHistory);
|
|
445
457
|
return txHistory;
|
|
@@ -451,6 +463,7 @@ function getRealizeOptionFromSentio(userAddress, startTimestamp, events) {
|
|
|
451
463
|
if (related) {
|
|
452
464
|
x.side = related.side;
|
|
453
465
|
x.size = related.size;
|
|
466
|
+
x.dov_index = related.dov_index;
|
|
454
467
|
}
|
|
455
468
|
return x;
|
|
456
469
|
});
|