@drift-labs/sdk 2.14.0 → 2.15.0-beta.0

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.14.0",
2
+ "version": "2.15.0-0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/lib/user.js CHANGED
@@ -777,7 +777,7 @@ class User {
777
777
  const maintenanceMarginRequirement = this.getMaintenanceMarginRequirement();
778
778
  const freeCollateral = _1.BN.max(numericConstants_1.ZERO, totalCollateral.sub(maintenanceMarginRequirement));
779
779
  const market = this.driftClient.getPerpMarketAccount(marketIndex);
780
- const currentPerpPosition = this.getPerpPosition(marketIndex);
780
+ const currentPerpPosition = this.getPerpPosition(marketIndex) || this.getEmptyPosition(marketIndex);
781
781
  let freeCollateralDelta = this.calculateFreeCollateralDeltaForPerp(market, currentPerpPosition, positionBaseSizeChange);
782
782
  if (!freeCollateralDelta) {
783
783
  return new _1.BN(-1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.14.0",
3
+ "version": "2.15.0-beta.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.14.0",
2
+ "version": "2.15.0-0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/src/user.ts CHANGED
@@ -1377,7 +1377,8 @@ export class User {
1377
1377
  );
1378
1378
 
1379
1379
  const market = this.driftClient.getPerpMarketAccount(marketIndex);
1380
- const currentPerpPosition = this.getPerpPosition(marketIndex);
1380
+ const currentPerpPosition =
1381
+ this.getPerpPosition(marketIndex) || this.getEmptyPosition(marketIndex);
1381
1382
 
1382
1383
  let freeCollateralDelta = this.calculateFreeCollateralDeltaForPerp(
1383
1384
  market,