@deriverse/kit 1.0.8 → 1.0.9

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/index.js CHANGED
@@ -181,7 +181,7 @@ function getMultipleSpotOrders(data, firstEntry, clientId) {
181
181
  while (entry != nullOrder) {
182
182
  const offset = entry * 64 + structure_models_1.SpotTradeAccountHeaderModel.LENGTH;
183
183
  const order = structure_models_1.OrderModel.fromBuffer(data, offset);
184
- if (order.clientId != clientId) {
184
+ if (order.origClientId != clientId) {
185
185
  break;
186
186
  }
187
187
  orders.push(order);
@@ -195,7 +195,7 @@ function getMultiplePerpOrders(data, firstEntry, clientId) {
195
195
  while (entry != nullOrder) {
196
196
  const offset = entry * 64 + structure_models_1.PerpTradeAccountHeaderModel.LENGTH;
197
197
  const order = structure_models_1.OrderModel.fromBuffer(data, offset);
198
- if (order.clientId != clientId) {
198
+ if (order.origClientId != clientId) {
199
199
  break;
200
200
  }
201
201
  orders.push(order);
@@ -1422,8 +1422,7 @@ class Engine {
1422
1422
  asks[i].sum /= crncyTokenDec;
1423
1423
  }
1424
1424
  return {
1425
- bidContextSlot: Number(infos.context.slot),
1426
- askContextSlot: Number(infos.context.slot),
1425
+ contextSlot: Number(infos.context.slot),
1427
1426
  bids: bids,
1428
1427
  asks: asks
1429
1428
  };
@@ -1450,7 +1449,7 @@ class Engine {
1450
1449
  }
1451
1450
  }).send();
1452
1451
  const order = structure_models_1.OrderModel.fromBuffer(info.value.data);
1453
- if (order.clientId == this.originalClientId) {
1452
+ if (order.origClientId == this.originalClientId) {
1454
1453
  bids = [order];
1455
1454
  }
1456
1455
  bidContextSlot = Number(info.context.slot);
@@ -1473,7 +1472,7 @@ class Engine {
1473
1472
  }
1474
1473
  }).send();
1475
1474
  const order = structure_models_1.OrderModel.fromBuffer(info.value.data);
1476
- if (order.clientId == this.originalClientId) {
1475
+ if (order.origClientId == this.originalClientId) {
1477
1476
  asks = [order];
1478
1477
  }
1479
1478
  askContextSlot = Number(info.context.slot);
@@ -1486,9 +1485,20 @@ class Engine {
1486
1485
  asks[i].qty /= assetTokenDec;
1487
1486
  asks[i].sum /= crncyTokenDec;
1488
1487
  }
1488
+ let contextSlot = 0;
1489
+ if (bidContextSlot > 0 || askContextSlot > 0) {
1490
+ if (bidContextSlot == 0) {
1491
+ contextSlot = askContextSlot;
1492
+ }
1493
+ else if (askContextSlot == 0) {
1494
+ contextSlot = bidContextSlot;
1495
+ }
1496
+ else {
1497
+ contextSlot = Math.min(bidContextSlot, askContextSlot);
1498
+ }
1499
+ }
1489
1500
  return {
1490
- bidContextSlot: bidContextSlot,
1491
- askContextSlot: askContextSlot,
1501
+ contextSlot: contextSlot,
1492
1502
  bids: bids,
1493
1503
  asks: asks
1494
1504
  };
@@ -1527,8 +1537,7 @@ class Engine {
1527
1537
  asks[i].sum /= crncyTokenDec;
1528
1538
  }
1529
1539
  return {
1530
- bidContextSlot: Number(infos.context.slot),
1531
- askContextSlot: Number(infos.context.slot),
1540
+ contextSlot: Number(infos.context.slot),
1532
1541
  bids: bids,
1533
1542
  asks: asks
1534
1543
  };
@@ -1552,7 +1561,7 @@ class Engine {
1552
1561
  }
1553
1562
  }).send();
1554
1563
  const order = structure_models_1.OrderModel.fromBuffer(info.value.data);
1555
- if (order.clientId == this.originalClientId) {
1564
+ if (order.origClientId == this.originalClientId) {
1556
1565
  bids = [order];
1557
1566
  }
1558
1567
  bidContextSlot = Number(info.context.slot);
@@ -1572,7 +1581,7 @@ class Engine {
1572
1581
  }
1573
1582
  }).send();
1574
1583
  const order = structure_models_1.OrderModel.fromBuffer(info.value.data);
1575
- if (order.clientId == this.originalClientId) {
1584
+ if (order.origClientId == this.originalClientId) {
1576
1585
  asks = [order];
1577
1586
  }
1578
1587
  askContextSlot = Number(info.context.slot);
@@ -1585,9 +1594,20 @@ class Engine {
1585
1594
  asks[i].qty /= assetTokenDec;
1586
1595
  asks[i].sum /= crncyTokenDec;
1587
1596
  }
1597
+ let contextSlot = 0;
1598
+ if (bidContextSlot > 0 || askContextSlot > 0) {
1599
+ if (bidContextSlot == 0) {
1600
+ contextSlot = askContextSlot;
1601
+ }
1602
+ else if (askContextSlot == 0) {
1603
+ contextSlot = bidContextSlot;
1604
+ }
1605
+ else {
1606
+ contextSlot = Math.min(bidContextSlot, askContextSlot);
1607
+ }
1608
+ }
1588
1609
  return {
1589
- bidContextSlot: bidContextSlot,
1590
- askContextSlot: askContextSlot,
1610
+ contextSlot: contextSlot,
1591
1611
  bids: bids,
1592
1612
  asks: asks
1593
1613
  };
package/dist/types.d.ts CHANGED
@@ -310,8 +310,7 @@ export interface GetClientPerpOrdersArgs {
310
310
  * @property {OrderModel[]} asks List of client ask spot orders
311
311
  */
312
312
  export interface GetClientSpotOrdersResponse {
313
- bidContextSlot: number;
314
- askContextSlot: number;
313
+ contextSlot: number;
315
314
  bids: OrderModel[];
316
315
  asks: OrderModel[];
317
316
  }
@@ -322,8 +321,7 @@ export interface GetClientSpotOrdersResponse {
322
321
  * @property {OrderModel[]} asks List of client ask perp orders
323
322
  */
324
323
  export interface GetClientPerpOrdersResponse {
325
- bidContextSlot: number;
326
- askContextSlot: number;
324
+ contextSlot: number;
327
325
  bids: Array<OrderModel>;
328
326
  asks: Array<OrderModel>;
329
327
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deriverse/kit",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",