@drift-labs/sdk 2.43.0-beta.6 → 2.43.0-beta.8
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 +1 -1
- package/lib/dlob/DLOB.js +2 -0
- package/lib/dlob/orderBookLevels.d.ts +2 -0
- package/lib/user.js +4 -1
- package/package.json +1 -1
- package/src/dlob/DLOB.ts +2 -0
- package/src/dlob/orderBookLevels.ts +2 -0
- package/src/user.ts +5 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.43.0-beta.
|
|
1
|
+
2.43.0-beta.8
|
package/lib/dlob/DLOB.js
CHANGED
|
@@ -956,6 +956,7 @@ class DLOB {
|
|
|
956
956
|
return {
|
|
957
957
|
bids,
|
|
958
958
|
asks,
|
|
959
|
+
slot,
|
|
959
960
|
};
|
|
960
961
|
}
|
|
961
962
|
/**
|
|
@@ -990,6 +991,7 @@ class DLOB {
|
|
|
990
991
|
return {
|
|
991
992
|
bids,
|
|
992
993
|
asks,
|
|
994
|
+
slot,
|
|
993
995
|
};
|
|
994
996
|
}
|
|
995
997
|
estimateFillExactBaseAmountInForSide(baseAmountIn, oraclePriceData, slot, dlobSide) {
|
|
@@ -12,6 +12,7 @@ export type L2Level = {
|
|
|
12
12
|
export type L2OrderBook = {
|
|
13
13
|
asks: L2Level[];
|
|
14
14
|
bids: L2Level[];
|
|
15
|
+
slot?: number;
|
|
15
16
|
};
|
|
16
17
|
export interface L2OrderBookGenerator {
|
|
17
18
|
getL2Asks(): Generator<L2Level>;
|
|
@@ -26,6 +27,7 @@ export type L3Level = {
|
|
|
26
27
|
export type L3OrderBook = {
|
|
27
28
|
asks: L3Level[];
|
|
28
29
|
bids: L3Level[];
|
|
30
|
+
slot?: number;
|
|
29
31
|
};
|
|
30
32
|
export declare const DEFAULT_TOP_OF_BOOK_QUOTE_AMOUNTS: BN[];
|
|
31
33
|
/**
|
package/lib/user.js
CHANGED
|
@@ -1564,7 +1564,10 @@ class User {
|
|
|
1564
1564
|
this.getEmptyPosition(targetMarketIndex);
|
|
1565
1565
|
const oracleData = this.getOracleDataForPerpMarket(targetMarketIndex);
|
|
1566
1566
|
let currentPositionQuoteAmount = this.getPerpPositionValue(targetMarketIndex, oracleData, includeOpenOrders);
|
|
1567
|
-
const
|
|
1567
|
+
const worstCaseBase = (0, margin_1.calculateWorstCaseBaseAssetAmount)(currentPosition);
|
|
1568
|
+
// current side is short if position base asset amount is negative OR there is no position open but open orders are short
|
|
1569
|
+
const currentSide = currentPosition.baseAssetAmount.isNeg() ||
|
|
1570
|
+
(currentPosition.baseAssetAmount.eq(numericConstants_1.ZERO) && worstCaseBase.isNeg())
|
|
1568
1571
|
? _1.PositionDirection.SHORT
|
|
1569
1572
|
: _1.PositionDirection.LONG;
|
|
1570
1573
|
if (currentSide === _1.PositionDirection.SHORT)
|
package/package.json
CHANGED
package/src/dlob/DLOB.ts
CHANGED
|
@@ -29,6 +29,7 @@ export type L2Level = {
|
|
|
29
29
|
export type L2OrderBook = {
|
|
30
30
|
asks: L2Level[];
|
|
31
31
|
bids: L2Level[];
|
|
32
|
+
slot?: number;
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
export interface L2OrderBookGenerator {
|
|
@@ -46,6 +47,7 @@ export type L3Level = {
|
|
|
46
47
|
export type L3OrderBook = {
|
|
47
48
|
asks: L3Level[];
|
|
48
49
|
bids: L3Level[];
|
|
50
|
+
slot?: number;
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
export const DEFAULT_TOP_OF_BOOK_QUOTE_AMOUNTS = [
|
package/src/user.ts
CHANGED
|
@@ -2884,8 +2884,12 @@ export class User {
|
|
|
2884
2884
|
includeOpenOrders
|
|
2885
2885
|
);
|
|
2886
2886
|
|
|
2887
|
+
const worstCaseBase = calculateWorstCaseBaseAssetAmount(currentPosition);
|
|
2888
|
+
|
|
2889
|
+
// current side is short if position base asset amount is negative OR there is no position open but open orders are short
|
|
2887
2890
|
const currentSide =
|
|
2888
|
-
currentPosition
|
|
2891
|
+
currentPosition.baseAssetAmount.isNeg() ||
|
|
2892
|
+
(currentPosition.baseAssetAmount.eq(ZERO) && worstCaseBase.isNeg())
|
|
2889
2893
|
? PositionDirection.SHORT
|
|
2890
2894
|
: PositionDirection.LONG;
|
|
2891
2895
|
|