@drift-labs/sdk 2.53.0-beta.2 → 2.53.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.53.0-beta.2
1
+ 2.53.0-beta.3
@@ -91,8 +91,8 @@ export declare class DLOB {
91
91
  takerNode: DLOBNode;
92
92
  makerNode: DLOBNode;
93
93
  } | undefined;
94
- getBestAsk(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): BN;
95
- getBestBid(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): BN;
94
+ getBestAsk(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): BN | undefined;
95
+ getBestBid(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): BN | undefined;
96
96
  getStopLosses(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
97
97
  getStopLossMarkets(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
98
98
  getStopLossLimits(marketIndex: number, marketType: MarketType, direction: PositionDirection): Generator<DLOBNode>;
package/lib/dlob/DLOB.js CHANGED
@@ -822,14 +822,18 @@ class DLOB {
822
822
  }
823
823
  }
824
824
  getBestAsk(marketIndex, slot, marketType, oraclePriceData) {
825
- return this.getRestingLimitAsks(marketIndex, slot, marketType, oraclePriceData)
826
- .next()
827
- .value.getPrice(oraclePriceData, slot);
825
+ const bestAsk = this.getRestingLimitAsks(marketIndex, slot, marketType, oraclePriceData).next().value;
826
+ if (bestAsk) {
827
+ return bestAsk.getPrice(oraclePriceData, slot);
828
+ }
829
+ return undefined;
828
830
  }
829
831
  getBestBid(marketIndex, slot, marketType, oraclePriceData) {
830
- return this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData)
831
- .next()
832
- .value.getPrice(oraclePriceData, slot);
832
+ const bestBid = this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData).next().value;
833
+ if (bestBid) {
834
+ return bestBid.getPrice(oraclePriceData, slot);
835
+ }
836
+ return undefined;
833
837
  }
834
838
  *getStopLosses(marketIndex, marketType, direction) {
835
839
  const marketTypeStr = (0, __1.getVariant)(marketType);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.53.0-beta.2",
3
+ "version": "2.53.0-beta.3",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
package/src/dlob/DLOB.ts CHANGED
@@ -1472,15 +1472,18 @@ export class DLOB {
1472
1472
  slot: number,
1473
1473
  marketType: MarketType,
1474
1474
  oraclePriceData: OraclePriceData
1475
- ): BN {
1476
- return this.getRestingLimitAsks(
1475
+ ): BN | undefined {
1476
+ const bestAsk = this.getRestingLimitAsks(
1477
1477
  marketIndex,
1478
1478
  slot,
1479
1479
  marketType,
1480
1480
  oraclePriceData
1481
- )
1482
- .next()
1483
- .value.getPrice(oraclePriceData, slot);
1481
+ ).next().value;
1482
+
1483
+ if (bestAsk) {
1484
+ return bestAsk.getPrice(oraclePriceData, slot);
1485
+ }
1486
+ return undefined;
1484
1487
  }
1485
1488
 
1486
1489
  public getBestBid(
@@ -1488,15 +1491,18 @@ export class DLOB {
1488
1491
  slot: number,
1489
1492
  marketType: MarketType,
1490
1493
  oraclePriceData: OraclePriceData
1491
- ): BN {
1492
- return this.getRestingLimitBids(
1494
+ ): BN | undefined {
1495
+ const bestBid = this.getRestingLimitBids(
1493
1496
  marketIndex,
1494
1497
  slot,
1495
1498
  marketType,
1496
1499
  oraclePriceData
1497
- )
1498
- .next()
1499
- .value.getPrice(oraclePriceData, slot);
1500
+ ).next().value;
1501
+
1502
+ if (bestBid) {
1503
+ return bestBid.getPrice(oraclePriceData, slot);
1504
+ }
1505
+ return undefined;
1500
1506
  }
1501
1507
 
1502
1508
  public *getStopLosses(