@drift-labs/sdk 2.82.0-beta.11 → 2.82.0-beta.13

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.82.0-beta.11
1
+ 2.82.0-beta.13
@@ -126,7 +126,7 @@ class WebSocketAccountSubscriber {
126
126
  }
127
127
  }
128
128
  unsubscribe(onResub = false) {
129
- if (!onResub) {
129
+ if (!onResub && this.resubOpts) {
130
130
  this.resubOpts.resubTimeoutMs = undefined;
131
131
  }
132
132
  this.isUnsubscribing = true;
package/lib/dlob/DLOB.js CHANGED
@@ -528,7 +528,7 @@ class DLOB {
528
528
  ];
529
529
  for (const bidGenerator of bidGenerators) {
530
530
  for (const bid of bidGenerator) {
531
- if ((0, __1.isOrderExpired)(bid.order, ts, true)) {
531
+ if ((0, __1.isOrderExpired)(bid.order, ts, true, 25)) {
532
532
  nodesToFill.push({
533
533
  node: bid,
534
534
  makerNodes: [],
@@ -538,7 +538,7 @@ class DLOB {
538
538
  }
539
539
  for (const askGenerator of askGenerators) {
540
540
  for (const ask of askGenerator) {
541
- if ((0, __1.isOrderExpired)(ask.order, ts, true)) {
541
+ if ((0, __1.isOrderExpired)(ask.order, ts, true, 25)) {
542
542
  nodesToFill.push({
543
543
  node: ask,
544
544
  makerNodes: [],
@@ -14,7 +14,7 @@ export declare function hasAuctionPrice(order: Order, slot: number): boolean;
14
14
  export declare function isFillableByVAMM(order: Order, market: PerpMarketAccount, oraclePriceData: OraclePriceData, slot: number, ts: number, minAuctionDuration: number): boolean;
15
15
  export declare function calculateBaseAssetAmountForAmmToFulfill(order: Order, market: PerpMarketAccount, oraclePriceData: OraclePriceData, slot: number): BN;
16
16
  export declare function calculateBaseAssetAmountToFillUpToLimitPrice(order: Order, amm: AMM, limitPrice: BN, oraclePriceData: OraclePriceData): BN;
17
- export declare function isOrderExpired(order: Order, ts: number, enforceBuffer?: boolean): boolean;
17
+ export declare function isOrderExpired(order: Order, ts: number, enforceBuffer?: boolean, bufferSeconds?: number): boolean;
18
18
  export declare function isMarketOrder(order: Order): boolean;
19
19
  export declare function isLimitOrder(order: Order): boolean;
20
20
  export declare function mustBeTriggered(order: Order): boolean;
@@ -168,7 +168,7 @@ function isSameDirection(firstDirection, secondDirection) {
168
168
  return (((0, types_1.isVariant)(firstDirection, 'long') && (0, types_1.isVariant)(secondDirection, 'long')) ||
169
169
  ((0, types_1.isVariant)(firstDirection, 'short') && (0, types_1.isVariant)(secondDirection, 'short')));
170
170
  }
171
- function isOrderExpired(order, ts, enforceBuffer = false) {
171
+ function isOrderExpired(order, ts, enforceBuffer = false, bufferSeconds = 15) {
172
172
  if (mustBeTriggered(order) ||
173
173
  !(0, types_1.isVariant)(order.status, 'open') ||
174
174
  order.maxTs.eq(numericConstants_1.ZERO)) {
@@ -176,7 +176,7 @@ function isOrderExpired(order, ts, enforceBuffer = false) {
176
176
  }
177
177
  let maxTs;
178
178
  if (enforceBuffer && isLimitOrder(order)) {
179
- maxTs = order.maxTs.addn(15);
179
+ maxTs = order.maxTs.addn(bufferSeconds);
180
180
  }
181
181
  else {
182
182
  maxTs = order.maxTs;
package/lib/types.d.ts CHANGED
@@ -46,7 +46,8 @@ export declare enum PerpOperation {
46
46
  AMM_FILL = 2,
47
47
  FILL = 4,
48
48
  SETTLE_PNL = 8,
49
- SETTLE_PNL_WITH_POSITION = 16
49
+ SETTLE_PNL_WITH_POSITION = 16,
50
+ LIQUIDATION = 32
50
51
  }
51
52
  export declare enum SpotOperation {
52
53
  UPDATE_CUMULATIVE_INTEREST = 1,
package/lib/types.js CHANGED
@@ -34,6 +34,7 @@ var PerpOperation;
34
34
  PerpOperation[PerpOperation["FILL"] = 4] = "FILL";
35
35
  PerpOperation[PerpOperation["SETTLE_PNL"] = 8] = "SETTLE_PNL";
36
36
  PerpOperation[PerpOperation["SETTLE_PNL_WITH_POSITION"] = 16] = "SETTLE_PNL_WITH_POSITION";
37
+ PerpOperation[PerpOperation["LIQUIDATION"] = 32] = "LIQUIDATION";
37
38
  })(PerpOperation = exports.PerpOperation || (exports.PerpOperation = {}));
38
39
  var SpotOperation;
39
40
  (function (SpotOperation) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.82.0-beta.11",
3
+ "version": "2.82.0-beta.13",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -183,7 +183,7 @@ export class WebSocketAccountSubscriber<T> implements AccountSubscriber<T> {
183
183
  }
184
184
 
185
185
  unsubscribe(onResub = false): Promise<void> {
186
- if (!onResub) {
186
+ if (!onResub && this.resubOpts) {
187
187
  this.resubOpts.resubTimeoutMs = undefined;
188
188
  }
189
189
  this.isUnsubscribing = true;
package/src/dlob/DLOB.ts CHANGED
@@ -985,7 +985,7 @@ export class DLOB {
985
985
 
986
986
  for (const bidGenerator of bidGenerators) {
987
987
  for (const bid of bidGenerator) {
988
- if (isOrderExpired(bid.order, ts, true)) {
988
+ if (isOrderExpired(bid.order, ts, true, 25)) {
989
989
  nodesToFill.push({
990
990
  node: bid,
991
991
  makerNodes: [],
@@ -996,7 +996,7 @@ export class DLOB {
996
996
 
997
997
  for (const askGenerator of askGenerators) {
998
998
  for (const ask of askGenerator) {
999
- if (isOrderExpired(ask.order, ts, true)) {
999
+ if (isOrderExpired(ask.order, ts, true, 25)) {
1000
1000
  nodesToFill.push({
1001
1001
  node: ask,
1002
1002
  makerNodes: [],
@@ -287,7 +287,8 @@ function isSameDirection(
287
287
  export function isOrderExpired(
288
288
  order: Order,
289
289
  ts: number,
290
- enforceBuffer = false
290
+ enforceBuffer = false,
291
+ bufferSeconds = 15
291
292
  ): boolean {
292
293
  if (
293
294
  mustBeTriggered(order) ||
@@ -299,7 +300,7 @@ export function isOrderExpired(
299
300
 
300
301
  let maxTs;
301
302
  if (enforceBuffer && isLimitOrder(order)) {
302
- maxTs = order.maxTs.addn(15);
303
+ maxTs = order.maxTs.addn(bufferSeconds);
303
304
  } else {
304
305
  maxTs = order.maxTs;
305
306
  }
package/src/types.ts CHANGED
@@ -33,6 +33,7 @@ export enum PerpOperation {
33
33
  FILL = 4,
34
34
  SETTLE_PNL = 8,
35
35
  SETTLE_PNL_WITH_POSITION = 16,
36
+ LIQUIDATION = 32,
36
37
  }
37
38
 
38
39
  export enum SpotOperation {