@drift-labs/sdk 2.43.0-beta.7 → 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/user.js +4 -1
- package/package.json +1 -1
- package/src/user.ts +5 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.43.0-beta.
|
|
1
|
+
2.43.0-beta.8
|
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/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
|
|