@drift-labs/sdk 2.114.0-beta.2 → 2.114.0-beta.3

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.114.0-beta.2
1
+ 2.114.0-beta.3
@@ -6,7 +6,7 @@ import StrictEventEmitter from 'strict-event-emitter-types';
6
6
  import { DriftClient } from './driftClient';
7
7
  import { HealthComponent, HealthComponents, MarginCategory, Order, PerpMarketAccount, PerpPosition, SpotPosition, UserAccount, UserStatus } from './types';
8
8
  import { DataAndSlot, UserAccountEvents, UserAccountSubscriber } from './accounts/types';
9
- import { BN, MarketType, PositionDirection, SpotMarketAccount } from '.';
9
+ import { BN, MarketType, PositionDirection, SpotMarketAccount, UserStats } from '.';
10
10
  import { OraclePriceData } from './oracles/types';
11
11
  import { UserConfig } from './userConfig';
12
12
  import { StrictOraclePrice } from './oracles/strictOraclePrice';
@@ -136,7 +136,7 @@ export declare class User {
136
136
  * @returns : Precision QUOTE_PRECISION
137
137
  */
138
138
  getUnrealizedFundingPNL(marketIndex?: number): BN;
139
- getFuelBonus(now: BN, includeSettled?: boolean, includeUnsettled?: boolean): {
139
+ getFuelBonus(now: BN, includeSettled?: boolean, includeUnsettled?: boolean, givenUserStats?: UserStats): {
140
140
  depositFuel: BN;
141
141
  borrowFuel: BN;
142
142
  positionFuel: BN;
@@ -547,7 +547,7 @@ class User {
547
547
  return pnl.add((0, position_1.calculateUnsettledFundingPnl)(market, perpPosition));
548
548
  }, numericConstants_1.ZERO);
549
549
  }
550
- getFuelBonus(now, includeSettled = true, includeUnsettled = true) {
550
+ getFuelBonus(now, includeSettled = true, includeUnsettled = true, givenUserStats) {
551
551
  const userAccount = this.getUserAccount();
552
552
  const result = {
553
553
  insuranceFuel: numericConstants_1.ZERO,
@@ -557,7 +557,7 @@ class User {
557
557
  borrowFuel: numericConstants_1.ZERO,
558
558
  positionFuel: numericConstants_1.ZERO,
559
559
  };
560
- const userStats = this.driftClient.getUserStats();
560
+ const userStats = givenUserStats !== null && givenUserStats !== void 0 ? givenUserStats : this.driftClient.getUserStats();
561
561
  const userStatsAccount = userStats.getAccount();
562
562
  if (includeSettled) {
563
563
  result.takerFuel = result.takerFuel.add(new _1.BN(userStatsAccount.fuelTaker));
@@ -6,7 +6,7 @@ import StrictEventEmitter from 'strict-event-emitter-types';
6
6
  import { DriftClient } from './driftClient';
7
7
  import { HealthComponent, HealthComponents, MarginCategory, Order, PerpMarketAccount, PerpPosition, SpotPosition, UserAccount, UserStatus } from './types';
8
8
  import { DataAndSlot, UserAccountEvents, UserAccountSubscriber } from './accounts/types';
9
- import { BN, MarketType, PositionDirection, SpotMarketAccount } from '.';
9
+ import { BN, MarketType, PositionDirection, SpotMarketAccount, UserStats } from '.';
10
10
  import { OraclePriceData } from './oracles/types';
11
11
  import { UserConfig } from './userConfig';
12
12
  import { StrictOraclePrice } from './oracles/strictOraclePrice';
@@ -136,7 +136,7 @@ export declare class User {
136
136
  * @returns : Precision QUOTE_PRECISION
137
137
  */
138
138
  getUnrealizedFundingPNL(marketIndex?: number): BN;
139
- getFuelBonus(now: BN, includeSettled?: boolean, includeUnsettled?: boolean): {
139
+ getFuelBonus(now: BN, includeSettled?: boolean, includeUnsettled?: boolean, givenUserStats?: UserStats): {
140
140
  depositFuel: BN;
141
141
  borrowFuel: BN;
142
142
  positionFuel: BN;
package/lib/node/user.js CHANGED
@@ -547,7 +547,7 @@ class User {
547
547
  return pnl.add((0, position_1.calculateUnsettledFundingPnl)(market, perpPosition));
548
548
  }, numericConstants_1.ZERO);
549
549
  }
550
- getFuelBonus(now, includeSettled = true, includeUnsettled = true) {
550
+ getFuelBonus(now, includeSettled = true, includeUnsettled = true, givenUserStats) {
551
551
  const userAccount = this.getUserAccount();
552
552
  const result = {
553
553
  insuranceFuel: numericConstants_1.ZERO,
@@ -557,7 +557,7 @@ class User {
557
557
  borrowFuel: numericConstants_1.ZERO,
558
558
  positionFuel: numericConstants_1.ZERO,
559
559
  };
560
- const userStats = this.driftClient.getUserStats();
560
+ const userStats = givenUserStats !== null && givenUserStats !== void 0 ? givenUserStats : this.driftClient.getUserStats();
561
561
  const userStatsAccount = userStats.getAccount();
562
562
  if (includeSettled) {
563
563
  result.takerFuel = result.takerFuel.add(new _1.BN(userStatsAccount.fuelTaker));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.114.0-beta.2",
3
+ "version": "2.114.0-beta.3",
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
@@ -69,6 +69,7 @@ import {
69
69
  SpotBalanceType,
70
70
  SpotMarketAccount,
71
71
  standardizeBaseAssetAmount,
72
+ UserStats,
72
73
  } from '.';
73
74
  import {
74
75
  calculateAssetWeight,
@@ -907,7 +908,8 @@ export class User {
907
908
  public getFuelBonus(
908
909
  now: BN,
909
910
  includeSettled = true,
910
- includeUnsettled = true
911
+ includeUnsettled = true,
912
+ givenUserStats?: UserStats
911
913
  ): {
912
914
  depositFuel: BN;
913
915
  borrowFuel: BN;
@@ -927,7 +929,7 @@ export class User {
927
929
  positionFuel: ZERO,
928
930
  };
929
931
 
930
- const userStats = this.driftClient.getUserStats();
932
+ const userStats = givenUserStats ?? this.driftClient.getUserStats();
931
933
  const userStatsAccount: UserStatsAccount = userStats.getAccount();
932
934
 
933
935
  if (includeSettled) {