@drift-labs/sdk 2.114.0-beta.2 → 2.114.0-beta.4
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/browser/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
- package/lib/browser/user.d.ts +2 -2
- package/lib/browser/user.js +2 -2
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
- package/lib/node/user.d.ts +2 -2
- package/lib/node/user.js +2 -2
- package/package.json +1 -1
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +2 -2
- package/src/user.ts +4 -2
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.114.0-beta.
|
|
1
|
+
2.114.0-beta.4
|
|
@@ -18,7 +18,7 @@ class grpcSignedMsgUserOrdersAccountSubscriber extends signedMsgUserAccountSubsc
|
|
|
18
18
|
async subscribe() {
|
|
19
19
|
if (!this.subscriber) {
|
|
20
20
|
this.subscriber =
|
|
21
|
-
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, '
|
|
21
|
+
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'SignedMsgUserOrders', this.driftClient.program, this.decodeFn, {
|
|
22
22
|
filters: [(0, memcmp_1.getSignedMsgUserOrdersFilter)()],
|
|
23
23
|
}, this.resubOpts);
|
|
24
24
|
}
|
package/lib/browser/user.d.ts
CHANGED
|
@@ -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/browser/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));
|
|
@@ -18,7 +18,7 @@ class grpcSignedMsgUserOrdersAccountSubscriber extends signedMsgUserAccountSubsc
|
|
|
18
18
|
async subscribe() {
|
|
19
19
|
if (!this.subscriber) {
|
|
20
20
|
this.subscriber =
|
|
21
|
-
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, '
|
|
21
|
+
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'SignedMsgUserOrders', this.driftClient.program, this.decodeFn, {
|
|
22
22
|
filters: [(0, memcmp_1.getSignedMsgUserOrdersFilter)()],
|
|
23
23
|
}, this.resubOpts);
|
|
24
24
|
}
|
package/lib/node/user.d.ts
CHANGED
|
@@ -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
|
@@ -40,8 +40,8 @@ export class grpcSignedMsgUserOrdersAccountSubscriber extends SignedMsgUserOrder
|
|
|
40
40
|
this.subscriber =
|
|
41
41
|
await grpcProgramAccountSubscriber.create<SignedMsgUserOrdersAccount>(
|
|
42
42
|
this.grpcConfigs,
|
|
43
|
-
'
|
|
44
|
-
'
|
|
43
|
+
'SingedMsgUserOrdersAccountMap',
|
|
44
|
+
'SignedMsgUserOrders',
|
|
45
45
|
this.driftClient.program,
|
|
46
46
|
this.decodeFn,
|
|
47
47
|
{
|
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) {
|