@drift-labs/sdk 2.49.0-beta.2 → 2.49.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.49.0-beta.2
1
+ 2.49.0-beta.3
@@ -23,7 +23,7 @@ class EventSubscriber {
23
23
  this.txEventCache = new txEventCache_1.TxEventCache(this.options.maxTx);
24
24
  this.eventListMap = new Map();
25
25
  for (const eventType of this.options.eventTypes) {
26
- this.eventListMap.set(eventType, new eventList_1.EventList(eventType, this.options.maxEventsPerType, (0, sort_1.getSortFn)(this.options.orderBy, this.options.orderDir, eventType), this.options.orderDir));
26
+ this.eventListMap.set(eventType, new eventList_1.EventList(eventType, this.options.maxEventsPerType, (0, sort_1.getSortFn)(this.options.orderBy, this.options.orderDir), this.options.orderDir));
27
27
  }
28
28
  this.eventEmitter = new events_1.EventEmitter();
29
29
  if (this.options.logProviderConfig.type === 'websocket') {
@@ -1,2 +1,2 @@
1
- import { EventSubscriptionOrderBy, EventSubscriptionOrderDirection, EventType, SortFn } from './types';
2
- export declare function getSortFn(orderBy: EventSubscriptionOrderBy, orderDir: EventSubscriptionOrderDirection, eventType: EventType): SortFn;
1
+ import { EventSubscriptionOrderBy, EventSubscriptionOrderDirection, SortFn } from './types';
2
+ export declare function getSortFn(orderBy: EventSubscriptionOrderBy, orderDir: EventSubscriptionOrderDirection): SortFn;
@@ -1,41 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSortFn = void 0;
4
- const index_1 = require("../index");
5
4
  function clientSortAscFn() {
6
5
  return 'less than';
7
6
  }
8
7
  function clientSortDescFn() {
9
8
  return 'greater than';
10
9
  }
11
- function defaultBlockchainSortFn(currentEvent, newEvent) {
12
- return currentEvent.slot <= newEvent.slot ? 'less than' : 'greater than';
13
- }
14
- function orderActionRecordSortFn(currentEvent, newEvent) {
15
- var _a, _b;
16
- const currentEventMarketIndex = currentEvent.marketIndex;
17
- const newEventMarketIndex = newEvent.marketIndex;
18
- if (currentEventMarketIndex !== newEventMarketIndex) {
19
- return currentEvent.ts.lte(newEvent.ts) ? 'less than' : 'greater than';
20
- }
21
- if (((_a = currentEvent.fillRecordId) === null || _a === void 0 ? void 0 : _a.gt(index_1.ZERO)) && ((_b = newEvent.fillRecordId) === null || _b === void 0 ? void 0 : _b.gt(index_1.ZERO))) {
22
- return currentEvent.fillRecordId.lte(newEvent.fillRecordId)
10
+ function blockchainSortFn(currentEvent, newEvent) {
11
+ if (currentEvent.slot == newEvent.slot) {
12
+ return currentEvent.txSigIndex < newEvent.txSigIndex
23
13
  ? 'less than'
24
14
  : 'greater than';
25
15
  }
26
- else {
27
- return currentEvent.ts.lte(newEvent.ts) ? 'less than' : 'greater than';
28
- }
16
+ return currentEvent.slot < newEvent.slot ? 'less than' : 'greater than';
29
17
  }
30
- function getSortFn(orderBy, orderDir, eventType) {
18
+ function getSortFn(orderBy, orderDir) {
31
19
  if (orderBy === 'client') {
32
20
  return orderDir === 'asc' ? clientSortAscFn : clientSortDescFn;
33
21
  }
34
- switch (eventType) {
35
- case 'OrderActionRecord':
36
- return orderActionRecordSortFn;
37
- default:
38
- return defaultBlockchainSortFn;
39
- }
22
+ return blockchainSortFn;
40
23
  }
41
24
  exports.getSortFn = getSortFn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.49.0-beta.2",
3
+ "version": "2.49.0-beta.3",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -47,7 +47,7 @@ export class EventSubscriber {
47
47
  new EventList(
48
48
  eventType,
49
49
  this.options.maxEventsPerType,
50
- getSortFn(this.options.orderBy, this.options.orderDir, eventType),
50
+ getSortFn(this.options.orderBy, this.options.orderDir),
51
51
  this.options.orderDir
52
52
  )
53
53
  );
@@ -4,10 +4,7 @@ import {
4
4
  EventSubscriptionOrderDirection,
5
5
  EventType,
6
6
  SortFn,
7
- Event,
8
7
  } from './types';
9
- import { OrderActionRecord } from '../types';
10
- import { ZERO } from '../index';
11
8
 
12
9
  function clientSortAscFn(): 'less than' {
13
10
  return 'less than';
@@ -17,45 +14,26 @@ function clientSortDescFn(): 'greater than' {
17
14
  return 'greater than';
18
15
  }
19
16
 
20
- function defaultBlockchainSortFn(
17
+ function blockchainSortFn(
21
18
  currentEvent: EventMap[EventType],
22
19
  newEvent: EventMap[EventType]
23
20
  ): 'less than' | 'greater than' {
24
- return currentEvent.slot <= newEvent.slot ? 'less than' : 'greater than';
25
- }
26
-
27
- function orderActionRecordSortFn(
28
- currentEvent: Event<OrderActionRecord>,
29
- newEvent: Event<OrderActionRecord>
30
- ): 'less than' | 'greater than' {
31
- const currentEventMarketIndex = currentEvent.marketIndex;
32
- const newEventMarketIndex = newEvent.marketIndex;
33
- if (currentEventMarketIndex !== newEventMarketIndex) {
34
- return currentEvent.ts.lte(newEvent.ts) ? 'less than' : 'greater than';
35
- }
36
-
37
- if (currentEvent.fillRecordId?.gt(ZERO) && newEvent.fillRecordId?.gt(ZERO)) {
38
- return currentEvent.fillRecordId.lte(newEvent.fillRecordId)
21
+ if (currentEvent.slot == newEvent.slot) {
22
+ return currentEvent.txSigIndex < newEvent.txSigIndex
39
23
  ? 'less than'
40
24
  : 'greater than';
41
- } else {
42
- return currentEvent.ts.lte(newEvent.ts) ? 'less than' : 'greater than';
43
25
  }
26
+
27
+ return currentEvent.slot < newEvent.slot ? 'less than' : 'greater than';
44
28
  }
45
29
 
46
30
  export function getSortFn(
47
31
  orderBy: EventSubscriptionOrderBy,
48
- orderDir: EventSubscriptionOrderDirection,
49
- eventType: EventType
32
+ orderDir: EventSubscriptionOrderDirection
50
33
  ): SortFn {
51
34
  if (orderBy === 'client') {
52
35
  return orderDir === 'asc' ? clientSortAscFn : clientSortDescFn;
53
36
  }
54
37
 
55
- switch (eventType) {
56
- case 'OrderActionRecord':
57
- return orderActionRecordSortFn;
58
- default:
59
- return defaultBlockchainSortFn;
60
- }
38
+ return blockchainSortFn;
61
39
  }