@drift-labs/sdk 2.43.0-beta.7 → 2.43.0-beta.9

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.43.0-beta.7
1
+ 2.43.0-beta.9
@@ -174,6 +174,16 @@ exports.DevnetPerpMarkets = [
174
174
  launchTs: 1698074659000,
175
175
  oracleSource: __1.OracleSource.PYTH,
176
176
  },
177
+ {
178
+ fullName: 'Rollbit',
179
+ category: ['Exchange'],
180
+ symbol: 'RLB-PERP',
181
+ baseAssetSymbol: 'RLB',
182
+ marketIndex: 17,
183
+ oracle: new web3_js_1.PublicKey('6BmJozusMugAySsfNfMFsU1YRWcGwyP3oycNX9Pv9oCz'),
184
+ launchTs: 11699265968000,
185
+ oracleSource: __1.OracleSource.PYTH,
186
+ },
177
187
  ];
178
188
  exports.MainnetPerpMarkets = [
179
189
  {
@@ -346,6 +356,16 @@ exports.MainnetPerpMarkets = [
346
356
  launchTs: 1698074659000,
347
357
  oracleSource: __1.OracleSource.PYTH,
348
358
  },
359
+ {
360
+ fullName: 'Rollbit',
361
+ category: ['Exchange'],
362
+ symbol: 'RLB-PERP',
363
+ baseAssetSymbol: 'RLB',
364
+ marketIndex: 17,
365
+ oracle: new web3_js_1.PublicKey('4BA3RcS4zE32WWgp49vvvre2t6nXY1W1kMyKZxeeuUey'),
366
+ launchTs: 11699265968000,
367
+ oracleSource: __1.OracleSource.PYTH,
368
+ },
349
369
  ];
350
370
  exports.PerpMarkets = {
351
371
  devnet: exports.DevnetPerpMarkets,
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 currentSide = currentPosition && currentPosition.baseAssetAmount.isNeg()
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.43.0-beta.7",
3
+ "version": "2.43.0-beta.9",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -184,6 +184,16 @@ export const DevnetPerpMarkets: PerpMarketConfig[] = [
184
184
  launchTs: 1698074659000,
185
185
  oracleSource: OracleSource.PYTH,
186
186
  },
187
+ {
188
+ fullName: 'Rollbit',
189
+ category: ['Exchange'],
190
+ symbol: 'RLB-PERP',
191
+ baseAssetSymbol: 'RLB',
192
+ marketIndex: 17,
193
+ oracle: new PublicKey('6BmJozusMugAySsfNfMFsU1YRWcGwyP3oycNX9Pv9oCz'),
194
+ launchTs: 11699265968000,
195
+ oracleSource: OracleSource.PYTH,
196
+ },
187
197
  ];
188
198
 
189
199
  export const MainnetPerpMarkets: PerpMarketConfig[] = [
@@ -357,6 +367,16 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
357
367
  launchTs: 1698074659000,
358
368
  oracleSource: OracleSource.PYTH,
359
369
  },
370
+ {
371
+ fullName: 'Rollbit',
372
+ category: ['Exchange'],
373
+ symbol: 'RLB-PERP',
374
+ baseAssetSymbol: 'RLB',
375
+ marketIndex: 17,
376
+ oracle: new PublicKey('4BA3RcS4zE32WWgp49vvvre2t6nXY1W1kMyKZxeeuUey'),
377
+ launchTs: 11699265968000,
378
+ oracleSource: OracleSource.PYTH,
379
+ },
360
380
  ];
361
381
 
362
382
  export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {
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 && currentPosition.baseAssetAmount.isNeg()
2891
+ currentPosition.baseAssetAmount.isNeg() ||
2892
+ (currentPosition.baseAssetAmount.eq(ZERO) && worstCaseBase.isNeg())
2889
2893
  ? PositionDirection.SHORT
2890
2894
  : PositionDirection.LONG;
2891
2895