@drift-labs/sdk 2.109.0-beta.8 → 2.110.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.
Files changed (78) hide show
  1. package/VERSION +1 -1
  2. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +5 -5
  3. package/lib/browser/accounts/grpcAccountSubscriber.js +11 -6
  4. package/lib/browser/accounts/grpcDriftClientAccountSubscriber.js +5 -4
  5. package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.js +4 -3
  6. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +6 -6
  7. package/lib/browser/accounts/grpcProgramAccountSubscriber.js +13 -6
  8. package/lib/browser/accounts/grpcUserAccountSubscriber.js +1 -1
  9. package/lib/browser/accounts/grpcUserStatsAccountSubscriber.js +1 -1
  10. package/lib/browser/addresses/pda.d.ts +1 -0
  11. package/lib/browser/addresses/pda.js +8 -1
  12. package/lib/browser/adminClient.d.ts +7 -0
  13. package/lib/browser/adminClient.js +34 -0
  14. package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
  15. package/lib/browser/constants/perpMarkets.js +11 -0
  16. package/lib/browser/constants/txConstants.d.ts +2 -0
  17. package/lib/browser/constants/txConstants.js +3 -1
  18. package/lib/browser/decode/user.js +1 -0
  19. package/lib/browser/driftClient.d.ts +4 -0
  20. package/lib/browser/driftClient.js +34 -0
  21. package/lib/browser/factory/oracleClient.js +3 -0
  22. package/lib/browser/idl/drift.json +297 -2
  23. package/lib/browser/oracles/oracleId.js +2 -0
  24. package/lib/browser/orderSubscriber/grpcSubscription.js +1 -1
  25. package/lib/browser/types.d.ts +22 -2
  26. package/lib/browser/types.js +9 -3
  27. package/lib/browser/userMap/grpcSubscription.js +1 -1
  28. package/lib/node/accounts/grpcAccountSubscriber.d.ts +5 -5
  29. package/lib/node/accounts/grpcAccountSubscriber.js +11 -6
  30. package/lib/node/accounts/grpcDriftClientAccountSubscriber.js +5 -4
  31. package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.js +4 -3
  32. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +6 -6
  33. package/lib/node/accounts/grpcProgramAccountSubscriber.js +13 -6
  34. package/lib/node/accounts/grpcUserAccountSubscriber.js +1 -1
  35. package/lib/node/accounts/grpcUserStatsAccountSubscriber.js +1 -1
  36. package/lib/node/addresses/pda.d.ts +1 -0
  37. package/lib/node/addresses/pda.js +8 -1
  38. package/lib/node/adminClient.d.ts +7 -0
  39. package/lib/node/adminClient.js +34 -0
  40. package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
  41. package/lib/node/constants/perpMarkets.js +11 -0
  42. package/lib/node/constants/txConstants.d.ts +2 -0
  43. package/lib/node/constants/txConstants.js +3 -1
  44. package/lib/node/decode/user.js +1 -0
  45. package/lib/node/driftClient.d.ts +4 -0
  46. package/lib/node/driftClient.js +34 -0
  47. package/lib/node/factory/oracleClient.js +3 -0
  48. package/lib/node/idl/drift.json +297 -2
  49. package/lib/node/isomorphic/grpc.d.ts +3 -3
  50. package/lib/node/isomorphic/grpc.js +26 -11
  51. package/lib/node/isomorphic/grpc.node.d.ts +3 -3
  52. package/lib/node/isomorphic/grpc.node.js +26 -11
  53. package/lib/node/oracles/oracleId.js +2 -0
  54. package/lib/node/orderSubscriber/grpcSubscription.js +1 -1
  55. package/lib/node/types.d.ts +22 -2
  56. package/lib/node/types.js +9 -3
  57. package/lib/node/userMap/grpcSubscription.js +1 -1
  58. package/package.json +1 -1
  59. package/src/accounts/grpcAccountSubscriber.ts +31 -8
  60. package/src/accounts/grpcDriftClientAccountSubscriber.ts +38 -34
  61. package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +11 -10
  62. package/src/accounts/grpcProgramAccountSubscriber.ts +35 -8
  63. package/src/accounts/grpcUserAccountSubscriber.ts +1 -1
  64. package/src/accounts/grpcUserStatsAccountSubscriber.ts +1 -1
  65. package/src/addresses/pda.ts +13 -0
  66. package/src/adminClient.ts +52 -0
  67. package/src/auctionSubscriber/auctionSubscriberGrpc.ts +1 -1
  68. package/src/constants/perpMarkets.ts +12 -0
  69. package/src/constants/txConstants.ts +5 -0
  70. package/src/decode/user.ts +1 -0
  71. package/src/driftClient.ts +57 -0
  72. package/src/factory/oracleClient.ts +4 -0
  73. package/src/idl/drift.json +297 -2
  74. package/src/isomorphic/grpc.node.ts +6 -5
  75. package/src/oracles/oracleId.ts +2 -0
  76. package/src/orderSubscriber/grpcSubscription.ts +1 -1
  77. package/src/types.ts +22 -3
  78. package/src/userMap/grpcSubscription.ts +1 -1
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.109.0-beta.8
1
+ 2.110.0-beta.0
@@ -4,13 +4,13 @@ import { ResubOpts, GrpcConfigs } from './types';
4
4
  import { Program } from '@coral-xyz/anchor';
5
5
  import { PublicKey } from '@solana/web3.js';
6
6
  import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber';
7
- import { Client, ClientDuplexStream, CommitmentLevel, SubscribeRequest, SubscribeUpdate } from '../isomorphic/grpc';
8
7
  export declare class grpcAccountSubscriber<T> extends WebSocketAccountSubscriber<T> {
9
- client: Client;
10
- stream: ClientDuplexStream<SubscribeRequest, SubscribeUpdate>;
11
- commitmentLevel: CommitmentLevel;
8
+ private client;
9
+ private stream;
10
+ private commitmentLevel;
12
11
  listenerId?: number;
13
- constructor(grpcConfigs: GrpcConfigs, accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => T, resubOpts?: ResubOpts);
12
+ private constructor();
13
+ static create<U>(grpcConfigs: GrpcConfigs, accountName: string, program: Program, accountPublicKey: PublicKey, decodeBuffer?: (buffer: Buffer) => U, resubOpts?: ResubOpts): Promise<grpcAccountSubscriber<U>>;
14
14
  subscribe(onChange: (data: T) => void): Promise<void>;
15
15
  unsubscribe(onResub?: boolean): Promise<void>;
16
16
  }
@@ -29,13 +29,18 @@ const Buffer = __importStar(require("buffer"));
29
29
  const webSocketAccountSubscriber_1 = require("./webSocketAccountSubscriber");
30
30
  const grpc_1 = require("../isomorphic/grpc");
31
31
  class grpcAccountSubscriber extends webSocketAccountSubscriber_1.WebSocketAccountSubscriber {
32
- constructor(grpcConfigs, accountName, program, accountPublicKey, decodeBuffer, resubOpts) {
33
- var _a, _b;
32
+ constructor(client, commitmentLevel, accountName, program, accountPublicKey, decodeBuffer, resubOpts) {
34
33
  super(accountName, program, accountPublicKey, decodeBuffer, resubOpts);
35
- this.client = (0, grpc_1.createClient)(grpcConfigs.endpoint, grpcConfigs.token, (_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {});
36
- this.commitmentLevel =
37
- // @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
38
- (_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : grpc_1.CommitmentLevel.CONFIRMED;
34
+ this.client = client;
35
+ this.commitmentLevel = commitmentLevel;
36
+ }
37
+ static async create(grpcConfigs, accountName, program, accountPublicKey, decodeBuffer, resubOpts) {
38
+ var _a, _b;
39
+ const client = await (0, grpc_1.createClient)(grpcConfigs.endpoint, grpcConfigs.token, (_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {});
40
+ const commitmentLevel =
41
+ // @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
42
+ (_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : CommitmentLevel.CONFIRMED;
43
+ return new grpcAccountSubscriber(client, commitmentLevel, accountName, program, accountPublicKey, decodeBuffer, resubOpts);
39
44
  }
40
45
  async subscribe(onChange) {
41
46
  if (this.listenerId != null || this.isUnsubscribing) {
@@ -33,7 +33,8 @@ class gprcDriftClientAccountSubscriber extends webSocketDriftClientAccountSubscr
33
33
  }
34
34
  const statePublicKey = await (0, pda_1.getDriftStateAccountPublicKey)(this.program.programId);
35
35
  // create and activate main state account subscription
36
- this.stateAccountSubscriber = new grpcAccountSubscriber_1.grpcAccountSubscriber(this.grpcConfigs, 'state', this.program, statePublicKey, undefined, undefined);
36
+ this.stateAccountSubscriber =
37
+ await grpcAccountSubscriber_1.grpcAccountSubscriber.create(this.grpcConfigs, 'state', this.program, statePublicKey, undefined, undefined);
37
38
  await this.stateAccountSubscriber.subscribe((data) => {
38
39
  this.eventEmitter.emit('stateAccountUpdate', data);
39
40
  this.eventEmitter.emit('update');
@@ -60,7 +61,7 @@ class gprcDriftClientAccountSubscriber extends webSocketDriftClientAccountSubscr
60
61
  }
61
62
  async subscribeToSpotMarketAccount(marketIndex) {
62
63
  const marketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
63
- const accountSubscriber = new grpcAccountSubscriber_1.grpcAccountSubscriber(this.grpcConfigs, 'spotMarket', this.program, marketPublicKey, undefined, this.resubOpts);
64
+ const accountSubscriber = await grpcAccountSubscriber_1.grpcAccountSubscriber.create(this.grpcConfigs, 'spotMarket', this.program, marketPublicKey, undefined, this.resubOpts);
64
65
  accountSubscriber.setData(this.initialSpotMarketAccountData.get(marketIndex));
65
66
  await accountSubscriber.subscribe((data) => {
66
67
  this.eventEmitter.emit('spotMarketAccountUpdate', data);
@@ -71,7 +72,7 @@ class gprcDriftClientAccountSubscriber extends webSocketDriftClientAccountSubscr
71
72
  }
72
73
  async subscribeToPerpMarketAccount(marketIndex) {
73
74
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
74
- const accountSubscriber = new grpcAccountSubscriber_1.grpcAccountSubscriber(this.grpcConfigs, 'perpMarket', this.program, perpMarketPublicKey, undefined, this.resubOpts);
75
+ const accountSubscriber = await grpcAccountSubscriber_1.grpcAccountSubscriber.create(this.grpcConfigs, 'perpMarket', this.program, perpMarketPublicKey, undefined, this.resubOpts);
75
76
  accountSubscriber.setData(this.initialPerpMarketAccountData.get(marketIndex));
76
77
  await accountSubscriber.subscribe((data) => {
77
78
  this.eventEmitter.emit('perpMarketAccountUpdate', data);
@@ -83,7 +84,7 @@ class gprcDriftClientAccountSubscriber extends webSocketDriftClientAccountSubscr
83
84
  async subscribeToOracle(oracleInfo) {
84
85
  const oracleId = (0, oracleId_1.getOracleId)(oracleInfo.publicKey, oracleInfo.source);
85
86
  const client = this.oracleClientCache.get(oracleInfo.source, this.program.provider.connection, this.program);
86
- const accountSubscriber = new grpcAccountSubscriber_1.grpcAccountSubscriber(this.grpcConfigs, 'oracle', this.program, oracleInfo.publicKey, (buffer) => {
87
+ const accountSubscriber = await grpcAccountSubscriber_1.grpcAccountSubscriber.create(this.grpcConfigs, 'oracle', this.program, oracleInfo.publicKey, (buffer) => {
87
88
  return client.getOraclePriceDataFromBuffer(buffer);
88
89
  }, this.resubOpts);
89
90
  accountSubscriber.setData(this.initialOraclePriceData.get(oracleId));
@@ -12,9 +12,10 @@ class grpcInsuranceFundStakeAccountSubscriber extends webSocketInsuranceFundStak
12
12
  if (this.isSubscribed) {
13
13
  return true;
14
14
  }
15
- this.insuranceFundStakeDataAccountSubscriber = new grpcAccountSubscriber_1.grpcAccountSubscriber(this.grpcConfigs, 'insuranceFundStake', this.program, this.insuranceFundStakeAccountPublicKey, undefined, {
16
- resubTimeoutMs: this.resubTimeoutMs,
17
- });
15
+ this.insuranceFundStakeDataAccountSubscriber =
16
+ await grpcAccountSubscriber_1.grpcAccountSubscriber.create(this.grpcConfigs, 'insuranceFundStake', this.program, this.insuranceFundStakeAccountPublicKey, undefined, {
17
+ resubTimeoutMs: this.resubTimeoutMs,
18
+ });
18
19
  if (insuranceFundStakeAccount) {
19
20
  this.insuranceFundStakeDataAccountSubscriber.setData(insuranceFundStakeAccount);
20
21
  }
@@ -4,15 +4,15 @@ import { ResubOpts, GrpcConfigs } from './types';
4
4
  import { Program } from '@coral-xyz/anchor';
5
5
  import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
6
6
  import { WebSocketProgramAccountSubscriber } from './webSocketProgramAccountSubscriber';
7
- import { Client, ClientDuplexStream, CommitmentLevel, SubscribeRequest, SubscribeUpdate } from '../isomorphic/grpc';
8
7
  export declare class grpcProgramAccountSubscriber<T> extends WebSocketProgramAccountSubscriber<T> {
9
- client: Client;
10
- stream: ClientDuplexStream<SubscribeRequest, SubscribeUpdate>;
11
- commitmentLevel: CommitmentLevel;
8
+ private client;
9
+ private stream;
10
+ private commitmentLevel;
12
11
  listenerId?: number;
13
- constructor(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => T, options?: {
12
+ private constructor();
13
+ static create<U>(grpcConfigs: GrpcConfigs, subscriptionName: string, accountDiscriminator: string, program: Program, decodeBufferFn: (accountName: string, ix: Buffer) => U, options?: {
14
14
  filters: MemcmpFilter[];
15
- }, resubOpts?: ResubOpts);
15
+ }, resubOpts?: ResubOpts): Promise<grpcProgramAccountSubscriber<U>>;
16
16
  subscribe(onChange: (accountId: PublicKey, data: T, context: Context, buffer: Buffer) => void): Promise<void>;
17
17
  unsubscribe(onResub?: boolean): Promise<void>;
18
18
  }
@@ -33,15 +33,22 @@ const Buffer = __importStar(require("buffer"));
33
33
  const webSocketProgramAccountSubscriber_1 = require("./webSocketProgramAccountSubscriber");
34
34
  const grpc_1 = require("../isomorphic/grpc");
35
35
  class grpcProgramAccountSubscriber extends webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber {
36
- constructor(grpcConfigs, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
36
+ constructor(client, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
37
37
  filters: [],
38
38
  }, resubOpts) {
39
- var _a, _b;
40
39
  super(subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
41
- this.client = (0, grpc_1.createClient)(grpcConfigs.endpoint, grpcConfigs.token, (_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {});
42
- this.commitmentLevel =
43
- // @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
44
- (_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : grpc_1.CommitmentLevel.CONFIRMED;
40
+ this.client = client;
41
+ this.commitmentLevel = commitmentLevel;
42
+ }
43
+ static async create(grpcConfigs, subscriptionName, accountDiscriminator, program, decodeBufferFn, options = {
44
+ filters: [],
45
+ }, resubOpts) {
46
+ var _a, _b;
47
+ const client = await (0, grpc_1.createClient)(grpcConfigs.endpoint, grpcConfigs.token, (_a = grpcConfigs.channelOptions) !== null && _a !== void 0 ? _a : {});
48
+ const commitmentLevel =
49
+ // @ts-ignore :: isomorphic exported enum fails typescript but will work at runtime
50
+ (_b = grpcConfigs.commitmentLevel) !== null && _b !== void 0 ? _b : CommitmentLevel.CONFIRMED;
51
+ return new grpcProgramAccountSubscriber(client, commitmentLevel, subscriptionName, accountDiscriminator, program, decodeBufferFn, options, resubOpts);
45
52
  }
46
53
  async subscribe(onChange) {
47
54
  if (this.listenerId != null || this.isUnsubscribing) {
@@ -12,7 +12,7 @@ class grpcUserAccountSubscriber extends webSocketUserAccountSubscriber_1.WebSock
12
12
  if (this.isSubscribed) {
13
13
  return true;
14
14
  }
15
- this.userDataAccountSubscriber = new grpcAccountSubscriber_1.grpcAccountSubscriber(this.grpcConfigs, 'user', this.program, this.userAccountPublicKey, undefined, this.resubOpts);
15
+ this.userDataAccountSubscriber = await grpcAccountSubscriber_1.grpcAccountSubscriber.create(this.grpcConfigs, 'user', this.program, this.userAccountPublicKey, undefined, this.resubOpts);
16
16
  if (userAccount) {
17
17
  this.userDataAccountSubscriber.setData(userAccount);
18
18
  }
@@ -12,7 +12,7 @@ class grpcUserStatsAccountSubscriber extends webSocketUserStatsAccountSubsriber_
12
12
  if (this.isSubscribed) {
13
13
  return true;
14
14
  }
15
- this.userStatsAccountSubscriber = new grpcAccountSubscriber_1.grpcAccountSubscriber(this.grpcConfigs, 'userStats', this.program, this.userStatsAccountPublicKey, undefined, this.resubOpts);
15
+ this.userStatsAccountSubscriber = await grpcAccountSubscriber_1.grpcAccountSubscriber.create(this.grpcConfigs, 'userStats', this.program, this.userStatsAccountPublicKey, undefined, this.resubOpts);
16
16
  if (userStatsAccount) {
17
17
  this.userStatsAccountSubscriber.setData(userStatsAccount);
18
18
  }
@@ -8,6 +8,7 @@ export declare function getUserAccountPublicKeyAndNonce(programId: PublicKey, au
8
8
  export declare function getUserAccountPublicKey(programId: PublicKey, authority: PublicKey, subAccountId?: number): Promise<PublicKey>;
9
9
  export declare function getUserAccountPublicKeySync(programId: PublicKey, authority: PublicKey, subAccountId?: number): PublicKey;
10
10
  export declare function getUserStatsAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
11
+ export declare function getFuelOverflowAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
11
12
  export declare function getRFQUserAccountPublicKey(programId: PublicKey, userAccountPublicKey: PublicKey): PublicKey;
12
13
  export declare function getSwiftUserAccountPublicKey(programId: PublicKey, authority: PublicKey): PublicKey;
13
14
  export declare function getPerpMarketPublicKey(programId: PublicKey, marketIndex: number): Promise<PublicKey>;
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getProtectedMakerModeConfigPublicKey = exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSwiftUserAccountPublicKey = exports.getRFQUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
26
+ exports.getProtectedMakerModeConfigPublicKey = exports.getHighLeverageModeConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPythPullOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getOpenbookV2FulfillmentConfigPublicKey = exports.getPhoenixFulfillmentConfigPublicKey = exports.getSerumFulfillmentConfigPublicKey = exports.getSerumSignerPublicKey = exports.getSerumOpenOrdersPublicKey = exports.getDriftSignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSwiftUserAccountPublicKey = exports.getRFQUserAccountPublicKey = exports.getFuelOverflowAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getDriftStateAccountPublicKey = exports.getDriftStateAccountPublicKeyAndNonce = void 0;
27
27
  const web3_js_1 = require("@solana/web3.js");
28
28
  const anchor = __importStar(require("@coral-xyz/anchor"));
29
29
  const spl_token_1 = require("@solana/spl-token");
@@ -62,6 +62,13 @@ function getUserStatsAccountPublicKey(programId, authority) {
62
62
  ], programId)[0];
63
63
  }
64
64
  exports.getUserStatsAccountPublicKey = getUserStatsAccountPublicKey;
65
+ function getFuelOverflowAccountPublicKey(programId, authority) {
66
+ return web3_js_1.PublicKey.findProgramAddressSync([
67
+ Buffer.from(anchor.utils.bytes.utf8.encode('fuel_overflow')),
68
+ authority.toBuffer(),
69
+ ], programId)[0];
70
+ }
71
+ exports.getFuelOverflowAccountPublicKey = getFuelOverflowAccountPublicKey;
65
72
  function getRFQUserAccountPublicKey(programId, userAccountPublicKey) {
66
73
  return web3_js_1.PublicKey.findProgramAddressSync([
67
74
  Buffer.from(anchor.utils.bytes.utf8.encode('RFQ')),
@@ -195,6 +195,13 @@ export declare class AdminClient extends DriftClient {
195
195
  getUpdatePerpMarketFuelIx(perpMarketIndex: number, fuelBoostTaker?: number, fuelBoostMaker?: number, fuelBoostPosition?: number): Promise<TransactionInstruction>;
196
196
  initUserFuel(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionSignature>;
197
197
  getInitUserFuelIx(user: PublicKey, authority: PublicKey, fuelBonusDeposits?: number, fuelBonusBorrows?: number, fuelBonusTaker?: number, fuelBonusMaker?: number, fuelBonusInsurance?: number): Promise<TransactionInstruction>;
198
+ /**
199
+ * @param fuelSweepExists - whether the fuel sweep account exists, must provide this if the user has a FuelSweep account in order to properly reset the fuel season
200
+ * @param authority - the authority to reset fuel for
201
+ * @returns the transaction signature
202
+ */
203
+ resetFuelSeason(fuelSweepExists: boolean, authority?: PublicKey): Promise<TransactionSignature>;
204
+ getResetFuelSeasonIx(fuelSweepExists: boolean, authority?: PublicKey): Promise<TransactionInstruction>;
198
205
  initializePythPullOracle(feedId: string): Promise<TransactionSignature>;
199
206
  getInitializePythPullOracleIx(feedId: string): Promise<TransactionInstruction>;
200
207
  initializePythLazerOracle(feedId: number): Promise<TransactionSignature>;
@@ -39,6 +39,7 @@ const amm_1 = require("./math/amm");
39
39
  const phoenix_sdk_1 = require("@ellipsis-labs/phoenix-sdk");
40
40
  const config_1 = require("./config");
41
41
  const pythOracleUtils_1 = require("./util/pythOracleUtils");
42
+ const txConstants_1 = require("./constants/txConstants");
42
43
  const OPENBOOK_PROGRAM_ID = new web3_js_1.PublicKey('opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb');
43
44
  class AdminClient extends driftClient_1.DriftClient {
44
45
  async initialize(usdcMint, _adminControlsPrices) {
@@ -1789,6 +1790,39 @@ class AdminClient extends driftClient_1.DriftClient {
1789
1790
  },
1790
1791
  });
1791
1792
  }
1793
+ /**
1794
+ * @param fuelSweepExists - whether the fuel sweep account exists, must provide this if the user has a FuelSweep account in order to properly reset the fuel season
1795
+ * @param authority - the authority to reset fuel for
1796
+ * @returns the transaction signature
1797
+ */
1798
+ async resetFuelSeason(fuelSweepExists, authority) {
1799
+ const resetFuelSeasonIx = await this.getResetFuelSeasonIx(fuelSweepExists, authority);
1800
+ const tx = await this.buildTransaction([resetFuelSeasonIx], this.txParams);
1801
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
1802
+ return txSig;
1803
+ }
1804
+ async getResetFuelSeasonIx(fuelSweepExists, authority) {
1805
+ const remainingAccounts = [];
1806
+ if (fuelSweepExists) {
1807
+ remainingAccounts.push({
1808
+ pubkey: (0, pda_1.getFuelOverflowAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
1809
+ isSigner: false,
1810
+ isWritable: true,
1811
+ });
1812
+ }
1813
+ return this.program.instruction.resetFuelSeason({
1814
+ accounts: {
1815
+ userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
1816
+ authority: authority !== null && authority !== void 0 ? authority : this.wallet.publicKey,
1817
+ state: await this.getStatePublicKey(),
1818
+ admin: this.useHotWalletAdmin
1819
+ ? this.wallet.publicKey
1820
+ : this.getStateAccount().admin,
1821
+ logAccount: txConstants_1.FUEL_RESET_LOG_ACCOUNT,
1822
+ },
1823
+ remainingAccounts,
1824
+ });
1825
+ }
1792
1826
  async initializePythPullOracle(feedId) {
1793
1827
  const initializePythPullOracleIx = await this.getInitializePythPullOracleIx(feedId);
1794
1828
  const tx = await this.buildTransaction(initializePythPullOracleIx);
@@ -14,7 +14,7 @@ class AuctionSubscriberGrpc {
14
14
  }
15
15
  async subscribe() {
16
16
  if (!this.subscriber) {
17
- this.subscriber = new grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber(this.grpcConfigs, 'AuctionSubscriber', 'User', this.driftClient.program, this.driftClient.program.account.user.coder.accounts.decode.bind(this.driftClient.program.account.user.coder.accounts), {
17
+ this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'AuctionSubscriber', 'User', this.driftClient.program, this.driftClient.program.account.user.coder.accounts.decode.bind(this.driftClient.program.account.user.coder.accounts), {
18
18
  filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getUserWithAuctionFilter)()],
19
19
  }, this.resubOpts);
20
20
  }
@@ -1089,6 +1089,17 @@ exports.MainnetPerpMarkets = [
1089
1089
  oracleSource: __1.OracleSource.PYTH_PULL,
1090
1090
  pythFeedId: '0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
1091
1091
  },
1092
+ {
1093
+ fullName: 'BERA',
1094
+ category: ['L1', 'EVM'],
1095
+ symbol: 'BERA-PERP',
1096
+ baseAssetSymbol: 'BERA',
1097
+ marketIndex: 66,
1098
+ oracle: new web3_js_1.PublicKey('53Ae7ArP9yCnjqL2CqxJ1zdv3ba64NoVTqRcwjrCg181'),
1099
+ launchTs: 1738850177000,
1100
+ oracleSource: __1.OracleSource.PYTH_PULL,
1101
+ pythFeedId: '0x962088abcfdbdb6e30db2e340c8cf887d9efb311b1f2f17b155a63dbb6d40265',
1102
+ },
1092
1103
  ];
1093
1104
  exports.PerpMarkets = {
1094
1105
  devnet: exports.DevnetPerpMarkets,
@@ -1 +1,3 @@
1
+ import { PublicKey } from '@solana/web3.js';
1
2
  export declare const NOT_CONFIRMED_ERROR_CODE = -1001;
3
+ export declare const FUEL_RESET_LOG_ACCOUNT: PublicKey;
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NOT_CONFIRMED_ERROR_CODE = void 0;
3
+ exports.FUEL_RESET_LOG_ACCOUNT = exports.NOT_CONFIRMED_ERROR_CODE = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
4
5
  exports.NOT_CONFIRMED_ERROR_CODE = -1001;
6
+ exports.FUEL_RESET_LOG_ACCOUNT = new web3_js_1.PublicKey('FuE1gqp2fzw2sDNLrbZqKsqpphJcoSW6HPaSJjGd4RZ4');
@@ -229,6 +229,7 @@ function decodeUser(buffer) {
229
229
  const auctionDuration = buffer.readUInt8(offset);
230
230
  offset += 1;
231
231
  const postedSlotTail = buffer.readUint8(offset);
232
+ offset += 1;
232
233
  offset += 2; // padding
233
234
  orders.push({
234
235
  slot,
@@ -148,6 +148,10 @@ export declare class DriftClient {
148
148
  getInitializeSwiftUserOrdersAccountIx(authority: PublicKey, numOrders: number): Promise<[PublicKey, TransactionInstruction]>;
149
149
  resizeSwiftUserOrders(authority: PublicKey, numOrders: number, txParams?: TxParams): Promise<TransactionSignature>;
150
150
  getResizeSwiftUserOrdersInstruction(authority: PublicKey, numOrders: number): Promise<TransactionInstruction>;
151
+ initializeFuelOverflow(authority?: PublicKey): Promise<TransactionSignature>;
152
+ getInitializeFuelOverflowIx(authority?: PublicKey): Promise<TransactionInstruction>;
153
+ sweepFuel(authority?: PublicKey): Promise<TransactionSignature>;
154
+ getSweepFuelIx(authority?: PublicKey): Promise<TransactionInstruction>;
151
155
  getInitializeUserInstructions(subAccountId?: number, name?: string, referrerInfo?: ReferrerInfo): Promise<[PublicKey, TransactionInstruction]>;
152
156
  getNextSubAccountId(): Promise<number>;
153
157
  initializeReferrerName(name: string): Promise<TransactionSignature>;
@@ -646,6 +646,40 @@ class DriftClient {
646
646
  });
647
647
  return resizeUserAccountIx;
648
648
  }
649
+ async initializeFuelOverflow(authority) {
650
+ const ix = await this.getInitializeFuelOverflowIx(authority);
651
+ const tx = await this.buildTransaction([ix], this.txParams);
652
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
653
+ return txSig;
654
+ }
655
+ async getInitializeFuelOverflowIx(authority) {
656
+ return await this.program.instruction.initializeFuelOverflow({
657
+ accounts: {
658
+ fuelOverflow: (0, pda_1.getFuelOverflowAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
659
+ userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
660
+ authority: authority !== null && authority !== void 0 ? authority : this.wallet.publicKey,
661
+ payer: this.wallet.publicKey,
662
+ rent: anchor.web3.SYSVAR_RENT_PUBKEY,
663
+ systemProgram: anchor.web3.SystemProgram.programId,
664
+ },
665
+ });
666
+ }
667
+ async sweepFuel(authority) {
668
+ const ix = await this.getSweepFuelIx(authority);
669
+ const tx = await this.buildTransaction([ix], this.txParams);
670
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
671
+ return txSig;
672
+ }
673
+ async getSweepFuelIx(authority) {
674
+ return await this.program.instruction.sweepFuel({
675
+ accounts: {
676
+ fuelOverflow: (0, pda_1.getFuelOverflowAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
677
+ userStats: (0, pda_1.getUserStatsAccountPublicKey)(this.program.programId, authority !== null && authority !== void 0 ? authority : this.wallet.publicKey),
678
+ authority: authority !== null && authority !== void 0 ? authority : this.wallet.publicKey,
679
+ signer: this.wallet.publicKey,
680
+ },
681
+ });
682
+ }
649
683
  async getInitializeUserInstructions(subAccountId = 0, name, referrerInfo) {
650
684
  const userAccountPublicKey = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, subAccountId);
651
685
  const remainingAccounts = new Array();
@@ -57,6 +57,9 @@ function getOracleClient(oracleSource, connection, program) {
57
57
  if ((0, types_1.isVariant)(oracleSource, 'pythLazer1M')) {
58
58
  return new pythLazerClient_1.PythLazerClient(connection, new anchor_1.BN(1000000));
59
59
  }
60
+ if ((0, types_1.isVariant)(oracleSource, 'pythLazerStableCoin')) {
61
+ return new pythLazerClient_1.PythLazerClient(connection, undefined, true);
62
+ }
60
63
  throw new Error(`Unknown oracle source ${oracleSource}`);
61
64
  }
62
65
  exports.getOracleClient = getOracleClient;