@drift-labs/sdk 2.101.0-beta.0 → 2.101.0-beta.1

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.101.0-beta.0
1
+ 2.101.0-beta.1
@@ -158,7 +158,7 @@ export declare class User {
158
158
  * calculates TotalCollateral: collateral + unrealized pnl
159
159
  * @returns : Precision QUOTE_PRECISION
160
160
  */
161
- getTotalCollateral(marginCategory?: MarginCategory, strict?: boolean): BN;
161
+ getTotalCollateral(marginCategory?: MarginCategory, strict?: boolean, includeOpenOrders?: boolean): BN;
162
162
  /**
163
163
  * calculates User Health by comparing total collateral and maint. margin requirement
164
164
  * @returns : number (value from [0, 100])
@@ -746,8 +746,8 @@ class User {
746
746
  * calculates TotalCollateral: collateral + unrealized pnl
747
747
  * @returns : Precision QUOTE_PRECISION
748
748
  */
749
- getTotalCollateral(marginCategory = 'Initial', strict = false) {
750
- return this.getSpotMarketAssetValue(undefined, marginCategory, true, strict).add(this.getUnrealizedPNL(true, undefined, marginCategory, strict));
749
+ getTotalCollateral(marginCategory = 'Initial', strict = false, includeOpenOrders = true) {
750
+ return this.getSpotMarketAssetValue(undefined, marginCategory, includeOpenOrders, strict).add(this.getUnrealizedPNL(true, undefined, marginCategory, strict));
751
751
  }
752
752
  /**
753
753
  * calculates User Health by comparing total collateral and maint. margin requirement
@@ -1216,7 +1216,7 @@ class User {
1216
1216
  * @returns Precision : PRICE_PRECISION
1217
1217
  */
1218
1218
  liquidationPrice(marketIndex, positionBaseSizeChange = numericConstants_1.ZERO, estimatedEntryPrice = numericConstants_1.ZERO, marginCategory = 'Maintenance', includeOpenOrders = false, offsetCollateral = numericConstants_1.ZERO) {
1219
- const totalCollateral = this.getTotalCollateral(marginCategory);
1219
+ const totalCollateral = this.getTotalCollateral(marginCategory, false, includeOpenOrders);
1220
1220
  const marginRequirement = this.getMarginRequirement(marginCategory, undefined, false, includeOpenOrders);
1221
1221
  let freeCollateral = _1.BN.max(numericConstants_1.ZERO, totalCollateral.sub(marginRequirement)).add(offsetCollateral);
1222
1222
  const oracle = this.driftClient.getPerpMarketAccount(marketIndex).amm.oracle;
@@ -158,7 +158,7 @@ export declare class User {
158
158
  * calculates TotalCollateral: collateral + unrealized pnl
159
159
  * @returns : Precision QUOTE_PRECISION
160
160
  */
161
- getTotalCollateral(marginCategory?: MarginCategory, strict?: boolean): BN;
161
+ getTotalCollateral(marginCategory?: MarginCategory, strict?: boolean, includeOpenOrders?: boolean): BN;
162
162
  /**
163
163
  * calculates User Health by comparing total collateral and maint. margin requirement
164
164
  * @returns : number (value from [0, 100])
package/lib/node/user.js CHANGED
@@ -746,8 +746,8 @@ class User {
746
746
  * calculates TotalCollateral: collateral + unrealized pnl
747
747
  * @returns : Precision QUOTE_PRECISION
748
748
  */
749
- getTotalCollateral(marginCategory = 'Initial', strict = false) {
750
- return this.getSpotMarketAssetValue(undefined, marginCategory, true, strict).add(this.getUnrealizedPNL(true, undefined, marginCategory, strict));
749
+ getTotalCollateral(marginCategory = 'Initial', strict = false, includeOpenOrders = true) {
750
+ return this.getSpotMarketAssetValue(undefined, marginCategory, includeOpenOrders, strict).add(this.getUnrealizedPNL(true, undefined, marginCategory, strict));
751
751
  }
752
752
  /**
753
753
  * calculates User Health by comparing total collateral and maint. margin requirement
@@ -1216,7 +1216,7 @@ class User {
1216
1216
  * @returns Precision : PRICE_PRECISION
1217
1217
  */
1218
1218
  liquidationPrice(marketIndex, positionBaseSizeChange = numericConstants_1.ZERO, estimatedEntryPrice = numericConstants_1.ZERO, marginCategory = 'Maintenance', includeOpenOrders = false, offsetCollateral = numericConstants_1.ZERO) {
1219
- const totalCollateral = this.getTotalCollateral(marginCategory);
1219
+ const totalCollateral = this.getTotalCollateral(marginCategory, false, includeOpenOrders);
1220
1220
  const marginRequirement = this.getMarginRequirement(marginCategory, undefined, false, includeOpenOrders);
1221
1221
  let freeCollateral = _1.BN.max(numericConstants_1.ZERO, totalCollateral.sub(marginRequirement)).add(offsetCollateral);
1222
1222
  const oracle = this.driftClient.getPerpMarketAccount(marketIndex).amm.oracle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.101.0-beta.0",
3
+ "version": "2.101.0-beta.1",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
package/src/user.ts CHANGED
@@ -1424,12 +1424,13 @@ export class User {
1424
1424
  */
1425
1425
  public getTotalCollateral(
1426
1426
  marginCategory: MarginCategory = 'Initial',
1427
- strict = false
1427
+ strict = false,
1428
+ includeOpenOrders = true
1428
1429
  ): BN {
1429
1430
  return this.getSpotMarketAssetValue(
1430
1431
  undefined,
1431
1432
  marginCategory,
1432
- true,
1433
+ includeOpenOrders,
1433
1434
  strict
1434
1435
  ).add(this.getUnrealizedPNL(true, undefined, marginCategory, strict));
1435
1436
  }
@@ -2309,7 +2310,11 @@ export class User {
2309
2310
  includeOpenOrders = false,
2310
2311
  offsetCollateral = ZERO
2311
2312
  ): BN {
2312
- const totalCollateral = this.getTotalCollateral(marginCategory);
2313
+ const totalCollateral = this.getTotalCollateral(
2314
+ marginCategory,
2315
+ false,
2316
+ includeOpenOrders
2317
+ );
2313
2318
  const marginRequirement = this.getMarginRequirement(
2314
2319
  marginCategory,
2315
2320
  undefined,