@drift-labs/sdk 2.40.0-beta.6 → 2.40.0-beta.7
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.d.ts +2 -2
- package/lib/user.js +5 -5
- package/package.json +1 -1
- package/src/user.ts +7 -5
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.40.0-beta.
|
|
1
|
+
2.40.0-beta.7
|
package/lib/user.d.ts
CHANGED
|
@@ -180,14 +180,14 @@ export declare class User {
|
|
|
180
180
|
* calculates current user leverage which is (total liability size) / (net asset value)
|
|
181
181
|
* @returns : Precision TEN_THOUSAND
|
|
182
182
|
*/
|
|
183
|
-
getLeverage(): BN;
|
|
183
|
+
getLeverage(includeOpenOrders?: boolean): BN;
|
|
184
184
|
calculateLeverageFromComponents({ perpLiabilityValue, perpPnl, spotAssetValue, spotLiabilityValue, }: {
|
|
185
185
|
perpLiabilityValue: BN;
|
|
186
186
|
perpPnl: BN;
|
|
187
187
|
spotAssetValue: BN;
|
|
188
188
|
spotLiabilityValue: BN;
|
|
189
189
|
}): BN;
|
|
190
|
-
getLeverageComponents(): {
|
|
190
|
+
getLeverageComponents(includeOpenOrders?: boolean): {
|
|
191
191
|
perpLiabilityValue: BN;
|
|
192
192
|
perpPnl: BN;
|
|
193
193
|
spotAssetValue: BN;
|
package/lib/user.js
CHANGED
|
@@ -822,8 +822,8 @@ class User {
|
|
|
822
822
|
* calculates current user leverage which is (total liability size) / (net asset value)
|
|
823
823
|
* @returns : Precision TEN_THOUSAND
|
|
824
824
|
*/
|
|
825
|
-
getLeverage() {
|
|
826
|
-
return this.calculateLeverageFromComponents(this.getLeverageComponents());
|
|
825
|
+
getLeverage(includeOpenOrders = true) {
|
|
826
|
+
return this.calculateLeverageFromComponents(this.getLeverageComponents(includeOpenOrders));
|
|
827
827
|
}
|
|
828
828
|
calculateLeverageFromComponents({ perpLiabilityValue, perpPnl, spotAssetValue, spotLiabilityValue, }) {
|
|
829
829
|
const totalLiabilityValue = perpLiabilityValue.add(spotLiabilityValue);
|
|
@@ -834,10 +834,10 @@ class User {
|
|
|
834
834
|
}
|
|
835
835
|
return totalLiabilityValue.mul(numericConstants_1.TEN_THOUSAND).div(netAssetValue);
|
|
836
836
|
}
|
|
837
|
-
getLeverageComponents() {
|
|
838
|
-
const perpLiability = this.getTotalPerpPositionValue(undefined, undefined,
|
|
837
|
+
getLeverageComponents(includeOpenOrders = true) {
|
|
838
|
+
const perpLiability = this.getTotalPerpPositionValue(undefined, undefined, includeOpenOrders);
|
|
839
839
|
const perpPnl = this.getUnrealizedPNL(true);
|
|
840
|
-
const { totalAssetValue: spotAssetValue, totalLiabilityValue: spotLiabilityValue, } = this.getSpotMarketAssetAndLiabilityValue(undefined, undefined, undefined,
|
|
840
|
+
const { totalAssetValue: spotAssetValue, totalLiabilityValue: spotLiabilityValue, } = this.getSpotMarketAssetAndLiabilityValue(undefined, undefined, undefined, includeOpenOrders);
|
|
841
841
|
return {
|
|
842
842
|
perpLiabilityValue: perpLiability,
|
|
843
843
|
perpPnl,
|
package/package.json
CHANGED
package/src/user.ts
CHANGED
|
@@ -1465,8 +1465,10 @@ export class User {
|
|
|
1465
1465
|
* calculates current user leverage which is (total liability size) / (net asset value)
|
|
1466
1466
|
* @returns : Precision TEN_THOUSAND
|
|
1467
1467
|
*/
|
|
1468
|
-
public getLeverage(): BN {
|
|
1469
|
-
return this.calculateLeverageFromComponents(
|
|
1468
|
+
public getLeverage(includeOpenOrders = true): BN {
|
|
1469
|
+
return this.calculateLeverageFromComponents(
|
|
1470
|
+
this.getLeverageComponents(includeOpenOrders)
|
|
1471
|
+
);
|
|
1470
1472
|
}
|
|
1471
1473
|
|
|
1472
1474
|
calculateLeverageFromComponents({
|
|
@@ -1491,7 +1493,7 @@ export class User {
|
|
|
1491
1493
|
return totalLiabilityValue.mul(TEN_THOUSAND).div(netAssetValue);
|
|
1492
1494
|
}
|
|
1493
1495
|
|
|
1494
|
-
getLeverageComponents(): {
|
|
1496
|
+
getLeverageComponents(includeOpenOrders = true): {
|
|
1495
1497
|
perpLiabilityValue: BN;
|
|
1496
1498
|
perpPnl: BN;
|
|
1497
1499
|
spotAssetValue: BN;
|
|
@@ -1500,7 +1502,7 @@ export class User {
|
|
|
1500
1502
|
const perpLiability = this.getTotalPerpPositionValue(
|
|
1501
1503
|
undefined,
|
|
1502
1504
|
undefined,
|
|
1503
|
-
|
|
1505
|
+
includeOpenOrders
|
|
1504
1506
|
);
|
|
1505
1507
|
const perpPnl = this.getUnrealizedPNL(true);
|
|
1506
1508
|
|
|
@@ -1511,7 +1513,7 @@ export class User {
|
|
|
1511
1513
|
undefined,
|
|
1512
1514
|
undefined,
|
|
1513
1515
|
undefined,
|
|
1514
|
-
|
|
1516
|
+
includeOpenOrders
|
|
1515
1517
|
);
|
|
1516
1518
|
|
|
1517
1519
|
return {
|