@drift-labs/sdk 2.142.0-beta.2 → 2.142.0-beta.21

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 (41) hide show
  1. package/VERSION +1 -1
  2. package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.d.ts +52 -4
  3. package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.js +315 -38
  4. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +11 -4
  5. package/lib/browser/accounts/grpcMultiAccountSubscriber.js +124 -18
  6. package/lib/browser/adminClient.d.ts +2 -0
  7. package/lib/browser/adminClient.js +17 -0
  8. package/lib/browser/constants/spotMarkets.js +4 -4
  9. package/lib/browser/driftClient.d.ts +25 -2
  10. package/lib/browser/driftClient.js +27 -4
  11. package/lib/browser/events/types.d.ts +3 -3
  12. package/lib/browser/idl/drift.json +72 -0
  13. package/lib/browser/types.d.ts +22 -1
  14. package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts +52 -4
  15. package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts.map +1 -1
  16. package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.js +315 -38
  17. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +11 -4
  18. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  19. package/lib/node/accounts/grpcMultiAccountSubscriber.js +124 -18
  20. package/lib/node/adminClient.d.ts +2 -0
  21. package/lib/node/adminClient.d.ts.map +1 -1
  22. package/lib/node/adminClient.js +17 -0
  23. package/lib/node/constants/spotMarkets.js +4 -4
  24. package/lib/node/driftClient.d.ts +25 -2
  25. package/lib/node/driftClient.d.ts.map +1 -1
  26. package/lib/node/driftClient.js +27 -4
  27. package/lib/node/events/types.d.ts +3 -3
  28. package/lib/node/events/types.d.ts.map +1 -1
  29. package/lib/node/idl/drift.json +72 -0
  30. package/lib/node/types.d.ts +22 -1
  31. package/lib/node/types.d.ts.map +1 -1
  32. package/package.json +8 -2
  33. package/scripts/client-test.ts +361 -75
  34. package/src/accounts/grpcDriftClientAccountSubscriberV2.ts +517 -77
  35. package/src/accounts/grpcMultiAccountSubscriber.ts +179 -32
  36. package/src/adminClient.ts +34 -0
  37. package/src/constants/spotMarkets.ts +4 -4
  38. package/src/driftClient.ts +32 -4
  39. package/src/events/types.ts +4 -2
  40. package/src/idl/drift.json +72 -0
  41. package/src/types.ts +25 -2
@@ -1,5 +1,5 @@
1
1
  import { Program } from '@coral-xyz/anchor';
2
- import { Context, PublicKey } from '@solana/web3.js';
2
+ import { Commitment, Context, PublicKey } from '@solana/web3.js';
3
3
  import * as Buffer from 'buffer';
4
4
  import bs58 from 'bs58';
5
5
 
@@ -11,7 +11,7 @@ import {
11
11
  SubscribeUpdate,
12
12
  createClient,
13
13
  } from '../isomorphic/grpc';
14
- import { GrpcConfigs, ResubOpts } from './types';
14
+ import { BufferAndSlot, DataAndSlot, GrpcConfigs, ResubOpts } from './types';
15
15
 
16
16
  interface AccountInfoLike {
17
17
  owner: PublicKey;
@@ -21,13 +21,32 @@ interface AccountInfoLike {
21
21
  rentEpoch: number;
22
22
  }
23
23
 
24
- export class grpcMultiAccountSubscriber<T> {
24
+ function commitmentLevelToCommitment(
25
+ commitmentLevel: CommitmentLevel
26
+ ): Commitment {
27
+ switch (commitmentLevel) {
28
+ case CommitmentLevel.PROCESSED:
29
+ return 'processed';
30
+ case CommitmentLevel.CONFIRMED:
31
+ return 'confirmed';
32
+ case CommitmentLevel.FINALIZED:
33
+ return 'finalized';
34
+ default:
35
+ return 'confirmed';
36
+ }
37
+ }
38
+
39
+ export class grpcMultiAccountSubscriber<T, U = undefined> {
25
40
  private client: Client;
26
41
  private stream: ClientDuplexStream<SubscribeRequest, SubscribeUpdate>;
27
42
  private commitmentLevel: CommitmentLevel;
28
43
  private program: Program;
29
44
  private accountName: string;
30
- private decodeBufferFn?: (buffer: Buffer, pubkey?: string) => T;
45
+ private decodeBufferFn?: (
46
+ buffer: Buffer,
47
+ pubkey?: string,
48
+ accountProps?: U
49
+ ) => T;
31
50
  private resubOpts?: ResubOpts;
32
51
  private onUnsubscribe?: () => Promise<void>;
33
52
 
@@ -39,9 +58,13 @@ export class grpcMultiAccountSubscriber<T> {
39
58
  private subscribedAccounts = new Set<string>();
40
59
  private onChangeMap = new Map<
41
60
  string,
42
- (data: T, context: Context, buffer: Buffer) => void
61
+ (data: T, context: Context, buffer: Buffer, accountProps: U) => void
43
62
  >();
44
63
 
64
+ private dataMap = new Map<string, DataAndSlot<T>>();
65
+ private accountPropsMap = new Map<string, U | Array<U>>();
66
+ private bufferMap = new Map<string, BufferAndSlot>();
67
+
45
68
  private constructor(
46
69
  client: Client,
47
70
  commitmentLevel: CommitmentLevel,
@@ -49,7 +72,8 @@ export class grpcMultiAccountSubscriber<T> {
49
72
  program: Program,
50
73
  decodeBuffer?: (buffer: Buffer, pubkey?: string) => T,
51
74
  resubOpts?: ResubOpts,
52
- onUnsubscribe?: () => Promise<void>
75
+ onUnsubscribe?: () => Promise<void>,
76
+ accountPropsMap?: Map<string, U | Array<U>>
53
77
  ) {
54
78
  this.client = client;
55
79
  this.commitmentLevel = commitmentLevel;
@@ -58,17 +82,19 @@ export class grpcMultiAccountSubscriber<T> {
58
82
  this.decodeBufferFn = decodeBuffer;
59
83
  this.resubOpts = resubOpts;
60
84
  this.onUnsubscribe = onUnsubscribe;
85
+ this.accountPropsMap = accountPropsMap;
61
86
  }
62
87
 
63
- public static async create<U>(
88
+ public static async create<T, U = undefined>(
64
89
  grpcConfigs: GrpcConfigs,
65
90
  accountName: string,
66
91
  program: Program,
67
- decodeBuffer?: (buffer: Buffer, pubkey?: string) => U,
92
+ decodeBuffer?: (buffer: Buffer, pubkey?: string, accountProps?: U) => T,
68
93
  resubOpts?: ResubOpts,
69
94
  clientProp?: Client,
70
- onUnsubscribe?: () => Promise<void>
71
- ): Promise<grpcMultiAccountSubscriber<U>> {
95
+ onUnsubscribe?: () => Promise<void>,
96
+ accountPropsMap?: Map<string, U | Array<U>>
97
+ ): Promise<grpcMultiAccountSubscriber<T, U>> {
72
98
  const client = clientProp
73
99
  ? clientProp
74
100
  : await createClient(
@@ -87,19 +113,104 @@ export class grpcMultiAccountSubscriber<T> {
87
113
  program,
88
114
  decodeBuffer,
89
115
  resubOpts,
90
- onUnsubscribe
116
+ onUnsubscribe,
117
+ accountPropsMap
91
118
  );
92
119
  }
93
120
 
121
+ setAccountData(accountPubkey: string, data: T, slot?: number): void {
122
+ this.dataMap.set(accountPubkey, { data, slot });
123
+ }
124
+
125
+ getAccountData(accountPubkey: string): DataAndSlot<T> | undefined {
126
+ return this.dataMap.get(accountPubkey);
127
+ }
128
+
129
+ getAccountDataMap(): Map<string, DataAndSlot<T>> {
130
+ return this.dataMap;
131
+ }
132
+
133
+ async fetch(): Promise<void> {
134
+ try {
135
+ // Chunk account IDs into groups of 100 (getMultipleAccounts limit)
136
+ const chunkSize = 100;
137
+ const chunks: string[][] = [];
138
+ const accountIds = Array.from(this.subscribedAccounts.values());
139
+ for (let i = 0; i < accountIds.length; i += chunkSize) {
140
+ chunks.push(accountIds.slice(i, i + chunkSize));
141
+ }
142
+
143
+ // Process all chunks concurrently
144
+ await Promise.all(
145
+ chunks.map(async (chunk) => {
146
+ const accountAddresses = chunk.map(
147
+ (accountId) => new PublicKey(accountId)
148
+ );
149
+ const rpcResponseAndContext =
150
+ await this.program.provider.connection.getMultipleAccountsInfoAndContext(
151
+ accountAddresses,
152
+ {
153
+ commitment: commitmentLevelToCommitment(this.commitmentLevel),
154
+ }
155
+ );
156
+
157
+ const rpcResponse = rpcResponseAndContext.value;
158
+ const currentSlot = rpcResponseAndContext.context.slot;
159
+
160
+ for (let i = 0; i < chunk.length; i++) {
161
+ const accountId = chunk[i];
162
+ const accountInfo = rpcResponse[i];
163
+ if (accountInfo) {
164
+ const prev = this.bufferMap.get(accountId);
165
+ const newBuffer = accountInfo.data as Buffer;
166
+ if (prev && currentSlot < prev.slot) {
167
+ continue;
168
+ }
169
+ if (
170
+ prev &&
171
+ prev.buffer &&
172
+ newBuffer &&
173
+ newBuffer.equals(prev.buffer)
174
+ ) {
175
+ continue;
176
+ }
177
+ this.bufferMap.set(accountId, {
178
+ buffer: newBuffer,
179
+ slot: currentSlot,
180
+ });
181
+
182
+ const accountDecoded = this.program.coder.accounts.decode(
183
+ this.capitalize(this.accountName),
184
+ newBuffer
185
+ );
186
+ this.setAccountData(accountId, accountDecoded, currentSlot);
187
+ }
188
+ }
189
+ })
190
+ );
191
+ } catch (error) {
192
+ if (this.resubOpts?.logResubMessages) {
193
+ console.log(
194
+ `[${this.accountName}] grpcMultiAccountSubscriber error fetching accounts:`,
195
+ error
196
+ );
197
+ }
198
+ }
199
+ }
200
+
94
201
  async subscribe(
95
202
  accounts: PublicKey[],
96
203
  onChange: (
97
204
  accountId: PublicKey,
98
205
  data: T,
99
206
  context: Context,
100
- buffer: Buffer
207
+ buffer: Buffer,
208
+ accountProps: U
101
209
  ) => void
102
210
  ): Promise<void> {
211
+ if (this.resubOpts?.logResubMessages) {
212
+ console.log(`[${this.accountName}] grpcMultiAccountSubscriber subscribe`);
213
+ }
103
214
  if (this.listenerId != null || this.isUnsubscribing) {
104
215
  return;
105
216
  }
@@ -108,9 +219,10 @@ export class grpcMultiAccountSubscriber<T> {
108
219
  for (const pk of accounts) {
109
220
  const key = pk.toBase58();
110
221
  this.subscribedAccounts.add(key);
111
- this.onChangeMap.set(key, (data, ctx, buffer) =>
112
- onChange(new PublicKey(key), data, ctx, buffer)
113
- );
222
+ this.onChangeMap.set(key, (data, ctx, buffer, accountProps) => {
223
+ this.setAccountData(key, data, ctx.slot);
224
+ onChange(new PublicKey(key), data, ctx, buffer, accountProps);
225
+ });
114
226
  }
115
227
 
116
228
  this.stream =
@@ -145,6 +257,19 @@ export class grpcMultiAccountSubscriber<T> {
145
257
  if (!accountPubkey || !this.subscribedAccounts.has(accountPubkey)) {
146
258
  return;
147
259
  }
260
+
261
+ // Touch resub timer on any incoming account update for subscribed keys
262
+ if (this.resubOpts?.resubTimeoutMs) {
263
+ this.receivingData = true;
264
+ clearTimeout(this.timeoutId);
265
+ this.setTimeout();
266
+ }
267
+
268
+ // Skip processing if we already have data for this account at a newer slot
269
+ const existing = this.dataMap.get(accountPubkey);
270
+ if (existing?.slot !== undefined && existing.slot > slot) {
271
+ return;
272
+ }
148
273
  const accountInfo: AccountInfoLike = {
149
274
  owner: new PublicKey(chunk.account.account.owner),
150
275
  lamports: Number(chunk.account.account.lamports),
@@ -155,23 +280,46 @@ export class grpcMultiAccountSubscriber<T> {
155
280
 
156
281
  const context = { slot } as Context;
157
282
  const buffer = accountInfo.data;
158
- const data = this.decodeBufferFn
159
- ? this.decodeBufferFn(buffer, accountPubkey)
160
- : this.program.account[this.accountName].coder.accounts.decode(
161
- this.capitalize(this.accountName),
162
- buffer
163
- );
164
-
165
- const handler = this.onChangeMap.get(accountPubkey);
166
- if (handler) {
167
- if (this.resubOpts?.resubTimeoutMs) {
168
- this.receivingData = true;
169
- clearTimeout(this.timeoutId);
170
- handler(data, context, buffer);
171
- this.setTimeout();
172
- } else {
173
- handler(data, context, buffer);
283
+
284
+ // Check existing buffer for this account and skip if unchanged or slot regressed
285
+ const prevBuffer = this.bufferMap.get(accountPubkey);
286
+ if (prevBuffer && slot < prevBuffer.slot) {
287
+ return;
288
+ }
289
+ if (
290
+ prevBuffer &&
291
+ prevBuffer.buffer &&
292
+ buffer &&
293
+ buffer.equals(prevBuffer.buffer)
294
+ ) {
295
+ return;
296
+ }
297
+ this.bufferMap.set(accountPubkey, { buffer, slot });
298
+ const accountProps = this.accountPropsMap?.get(accountPubkey);
299
+
300
+ const handleDataBuffer = (
301
+ context: Context,
302
+ buffer: Buffer,
303
+ accountProps: U
304
+ ) => {
305
+ const data = this.decodeBufferFn
306
+ ? this.decodeBufferFn(buffer, accountPubkey, accountProps)
307
+ : this.program.account[this.accountName].coder.accounts.decode(
308
+ this.capitalize(this.accountName),
309
+ buffer
310
+ );
311
+ const handler = this.onChangeMap.get(accountPubkey);
312
+ if (handler) {
313
+ handler(data, context, buffer, accountProps);
314
+ }
315
+ };
316
+
317
+ if (Array.isArray(accountProps)) {
318
+ for (const props of accountProps) {
319
+ handleDataBuffer(context, buffer, props);
174
320
  }
321
+ } else {
322
+ handleDataBuffer(context, buffer, accountProps);
175
323
  }
176
324
  });
177
325
 
@@ -181,7 +329,6 @@ export class grpcMultiAccountSubscriber<T> {
181
329
  this.listenerId = 1;
182
330
  if (this.resubOpts?.resubTimeoutMs) {
183
331
  this.receivingData = true;
184
- this.setTimeout();
185
332
  }
186
333
  resolve();
187
334
  } else {
@@ -4835,4 +4835,38 @@ export class AdminClient extends DriftClient {
4835
4835
  }
4836
4836
  );
4837
4837
  }
4838
+
4839
+ public async adminDisableUpdatePerpBidAskTwap(
4840
+ authority: PublicKey,
4841
+ disable: boolean
4842
+ ): Promise<TransactionSignature> {
4843
+ const disableBidAskTwapUpdateIx =
4844
+ await this.getAdminDisableUpdatePerpBidAskTwapIx(authority, disable);
4845
+
4846
+ const tx = await this.buildTransaction(disableBidAskTwapUpdateIx);
4847
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
4848
+
4849
+ return txSig;
4850
+ }
4851
+
4852
+ public async getAdminDisableUpdatePerpBidAskTwapIx(
4853
+ authority: PublicKey,
4854
+ disable: boolean
4855
+ ): Promise<TransactionInstruction> {
4856
+ return await this.program.instruction.adminDisableUpdatePerpBidAskTwap(
4857
+ disable,
4858
+ {
4859
+ accounts: {
4860
+ admin: this.useHotWalletAdmin
4861
+ ? this.wallet.publicKey
4862
+ : this.getStateAccount().admin,
4863
+ state: await this.getStatePublicKey(),
4864
+ userStats: getUserStatsAccountPublicKey(
4865
+ this.program.programId,
4866
+ authority
4867
+ ),
4868
+ },
4869
+ }
4870
+ );
4871
+ }
4838
4872
  }
@@ -39,8 +39,8 @@ export const DevnetSpotMarkets: SpotMarketConfig[] = [
39
39
  symbol: 'USDC',
40
40
  marketIndex: 0,
41
41
  poolId: 0,
42
- oracle: new PublicKey('En8hkHLkRe9d9DraYmBTrus518BvmVH448YcvmrFM6Ce'),
43
- oracleSource: OracleSource.PYTH_STABLE_COIN_PULL,
42
+ oracle: new PublicKey('9VCioxmni2gDLv11qufWzT3RDERhQE4iY5Gf7NTfYyAV'),
43
+ oracleSource: OracleSource.PYTH_LAZER_STABLE_COIN,
44
44
  mint: new PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
45
45
  precision: new BN(10).pow(SIX),
46
46
  precisionExp: SIX,
@@ -52,8 +52,8 @@ export const DevnetSpotMarkets: SpotMarketConfig[] = [
52
52
  symbol: 'SOL',
53
53
  marketIndex: 1,
54
54
  poolId: 0,
55
- oracle: new PublicKey('BAtFj4kQttZRVep3UZS2aZRDixkGYgWsbqTBVDbnSsPF'),
56
- oracleSource: OracleSource.PYTH_PULL,
55
+ oracle: new PublicKey('3m6i4RFWEDw2Ft4tFHPJtYgmpPe21k56M3FHeWYrgGBz'),
56
+ oracleSource: OracleSource.PYTH_LAZER,
57
57
  mint: new PublicKey(WRAPPED_SOL_MINT),
58
58
  precision: LAMPORTS_PRECISION,
59
59
  precisionExp: LAMPORTS_EXP,
@@ -1373,6 +1373,16 @@ export class DriftClient {
1373
1373
  });
1374
1374
  }
1375
1375
 
1376
+ /**
1377
+ * Creates the transaction to add or update an approved builder.
1378
+ * This allows the builder to receive revenue share from referrals.
1379
+ *
1380
+ * @param builder - The public key of the builder to add or update.
1381
+ * @param maxFeeTenthBps - The maximum fee tenth bps to set for the builder.
1382
+ * @param add - Whether to add or update the builder. If the builder already exists, `add = true` will update the `maxFeeTenthBps`, otherwise it will add the builder. If `add = false`, the builder's `maxFeeTenthBps` will be set to 0.
1383
+ * @param txParams - The transaction parameters to use for the transaction.
1384
+ * @returns The transaction to add or update an approved builder.
1385
+ */
1376
1386
  public async changeApprovedBuilder(
1377
1387
  builder: PublicKey,
1378
1388
  maxFeeTenthBps: number,
@@ -1389,6 +1399,15 @@ export class DriftClient {
1389
1399
  return txSig;
1390
1400
  }
1391
1401
 
1402
+ /**
1403
+ * Creates the transaction instruction to add or update an approved builder.
1404
+ * This allows the builder to receive revenue share from referrals.
1405
+ *
1406
+ * @param builder - The public key of the builder to add or update.
1407
+ * @param maxFeeTenthBps - The maximum fee tenth bps to set for the builder.
1408
+ * @param add - Whether to add or update the builder. If the builder already exists, `add = true` will update the `maxFeeTenthBps`, otherwise it will add the builder. If `add = false`, the builder's `maxFeeTenthBps` will be set to 0.
1409
+ * @returns The transaction instruction to add or update an approved builder.
1410
+ */
1392
1411
  public async getChangeApprovedBuilderIx(
1393
1412
  builder: PublicKey,
1394
1413
  maxFeeTenthBps: number,
@@ -4924,7 +4943,10 @@ export class DriftClient {
4924
4943
 
4925
4944
  public async getPlaceOrdersIx(
4926
4945
  params: OptionalOrderParams[],
4927
- subAccountId?: number
4946
+ subAccountId?: number,
4947
+ overrides?: {
4948
+ authority?: PublicKey;
4949
+ }
4928
4950
  ): Promise<TransactionInstruction> {
4929
4951
  const user = await this.getUserAccountPublicKey(subAccountId);
4930
4952
 
@@ -4959,13 +4981,14 @@ export class DriftClient {
4959
4981
  }
4960
4982
 
4961
4983
  const formattedParams = params.map((item) => getOrderParams(item));
4984
+ const authority = overrides?.authority ?? this.wallet.publicKey;
4962
4985
 
4963
4986
  return await this.program.instruction.placeOrders(formattedParams, {
4964
4987
  accounts: {
4965
4988
  state: await this.getStatePublicKey(),
4966
4989
  user,
4967
4990
  userStats: this.getUserStatsAccountPublicKey(),
4968
- authority: this.wallet.publicKey,
4991
+ authority,
4969
4992
  },
4970
4993
  remainingAccounts,
4971
4994
  });
@@ -6669,7 +6692,10 @@ export class DriftClient {
6669
6692
  referrerInfo?: ReferrerInfo,
6670
6693
  successCondition?: PlaceAndTakeOrderSuccessCondition,
6671
6694
  auctionDurationPercentage?: number,
6672
- subAccountId?: number
6695
+ subAccountId?: number,
6696
+ overrides?: {
6697
+ authority?: PublicKey;
6698
+ }
6673
6699
  ): Promise<TransactionInstruction> {
6674
6700
  orderParams = getOrderParams(orderParams, { marketType: MarketType.PERP });
6675
6701
  const userStatsPublicKey = await this.getUserStatsAccountPublicKey();
@@ -6737,6 +6763,8 @@ export class DriftClient {
6737
6763
  ((auctionDurationPercentage ?? 100) << 8) | (successCondition ?? 0);
6738
6764
  }
6739
6765
 
6766
+ const authority = overrides?.authority ?? this.wallet.publicKey;
6767
+
6740
6768
  return await this.program.instruction.placeAndTakePerpOrder(
6741
6769
  orderParams,
6742
6770
  optionalParams,
@@ -6745,7 +6773,7 @@ export class DriftClient {
6745
6773
  state: await this.getStatePublicKey(),
6746
6774
  user,
6747
6775
  userStats: userStatsPublicKey,
6748
- authority: this.wallet.publicKey,
6776
+ authority,
6749
6777
  },
6750
6778
  remainingAccounts,
6751
6779
  }
@@ -24,6 +24,7 @@ import {
24
24
  LPMintRedeemRecord,
25
25
  LPSettleRecord,
26
26
  LPSwapRecord,
27
+ LPBorrowLendDepositRecord,
27
28
  } from '../types';
28
29
  import { EventEmitter } from 'events';
29
30
 
@@ -116,8 +117,8 @@ export type EventMap = {
116
117
  FuelSeasonRecord: Event<FuelSeasonRecord>;
117
118
  InsuranceFundSwapRecord: Event<InsuranceFundSwapRecord>;
118
119
  TransferProtocolIfSharesToRevenuePoolRecord: Event<TransferProtocolIfSharesToRevenuePoolRecord>;
119
- LPMintRedeemRecord: Event<LPMintRedeemRecord>;
120
120
  LPSettleRecord: Event<LPSettleRecord>;
121
+ LPMintRedeemRecord: Event<LPMintRedeemRecord>;
121
122
  LPSwapRecord: Event<LPSwapRecord>;
122
123
  };
123
124
 
@@ -146,8 +147,9 @@ export type DriftEvent =
146
147
  | Event<InsuranceFundSwapRecord>
147
148
  | Event<TransferProtocolIfSharesToRevenuePoolRecord>
148
149
  | Event<LPSettleRecord>
150
+ | Event<LPMintRedeemRecord>
149
151
  | Event<LPSwapRecord>
150
- | Event<LPMintRedeemRecord>;
152
+ | Event<LPBorrowLendDepositRecord>;
151
153
 
152
154
  export interface EventSubscriberEvents {
153
155
  newEvent: (event: WrappedEvent<EventType>) => void;
@@ -14875,6 +14875,11 @@
14875
14875
  "name": "lpPrice",
14876
14876
  "type": "u128",
14877
14877
  "index": false
14878
+ },
14879
+ {
14880
+ "name": "lpPool",
14881
+ "type": "publicKey",
14882
+ "index": false
14878
14883
  }
14879
14884
  ]
14880
14885
  },
@@ -14985,6 +14990,11 @@
14985
14990
  "name": "outSwapId",
14986
14991
  "type": "u64",
14987
14992
  "index": false
14993
+ },
14994
+ {
14995
+ "name": "lpPool",
14996
+ "type": "publicKey",
14997
+ "index": false
14988
14998
  }
14989
14999
  ]
14990
15000
  },
@@ -15080,6 +15090,68 @@
15080
15090
  "name": "inMarketTargetWeight",
15081
15091
  "type": "i64",
15082
15092
  "index": false
15093
+ },
15094
+ {
15095
+ "name": "lpPool",
15096
+ "type": "publicKey",
15097
+ "index": false
15098
+ }
15099
+ ]
15100
+ },
15101
+ {
15102
+ "name": "LPBorrowLendDepositRecord",
15103
+ "fields": [
15104
+ {
15105
+ "name": "ts",
15106
+ "type": "i64",
15107
+ "index": false
15108
+ },
15109
+ {
15110
+ "name": "slot",
15111
+ "type": "u64",
15112
+ "index": false
15113
+ },
15114
+ {
15115
+ "name": "spotMarketIndex",
15116
+ "type": "u16",
15117
+ "index": false
15118
+ },
15119
+ {
15120
+ "name": "constituentIndex",
15121
+ "type": "u16",
15122
+ "index": false
15123
+ },
15124
+ {
15125
+ "name": "direction",
15126
+ "type": {
15127
+ "defined": "DepositDirection"
15128
+ },
15129
+ "index": false
15130
+ },
15131
+ {
15132
+ "name": "tokenBalance",
15133
+ "type": "i64",
15134
+ "index": false
15135
+ },
15136
+ {
15137
+ "name": "lastTokenBalance",
15138
+ "type": "i64",
15139
+ "index": false
15140
+ },
15141
+ {
15142
+ "name": "interestAccruedTokenAmount",
15143
+ "type": "i64",
15144
+ "index": false
15145
+ },
15146
+ {
15147
+ "name": "amountDepositWithdraw",
15148
+ "type": "u64",
15149
+ "index": false
15150
+ },
15151
+ {
15152
+ "name": "lpPool",
15153
+ "type": "publicKey",
15154
+ "index": false
15083
15155
  }
15084
15156
  ]
15085
15157
  }
package/src/types.ts CHANGED
@@ -767,6 +767,7 @@ export type LPSwapRecord = {
767
767
  outMarketTargetWeight: BN;
768
768
  inSwapId: BN;
769
769
  outSwapId: BN;
770
+ lpPool: PublicKey;
770
771
  };
771
772
 
772
773
  export type LPMintRedeemRecord = {
@@ -789,6 +790,7 @@ export type LPMintRedeemRecord = {
789
790
  lastAumSlot: BN;
790
791
  inMarketCurrentWeight: BN;
791
792
  inMarketTargetWeight: BN;
793
+ lpPool: PublicKey;
792
794
  };
793
795
 
794
796
  export type LPSettleRecord = {
@@ -803,6 +805,20 @@ export type LPSettleRecord = {
803
805
  perpAmmExFeeDelta: BN;
804
806
  lpAum: BN;
805
807
  lpPrice: BN;
808
+ lpPool: PublicKey;
809
+ };
810
+
811
+ export type LPBorrowLendDepositRecord = {
812
+ ts: BN;
813
+ slot: BN;
814
+ spotMarketIndex: number;
815
+ constituentIndex: number;
816
+ direction: DepositDirection;
817
+ tokenBalance: BN;
818
+ lastTokenBalance: BN;
819
+ interestAccruedTokenAmount: BN;
820
+ amountDepositWithdraw: BN;
821
+ lpPool: PublicKey;
806
822
  };
807
823
 
808
824
  export type StateAccount = {
@@ -878,6 +894,11 @@ export type PerpMarketAccount = {
878
894
  protectedMakerLimitPriceDivisor: number;
879
895
  protectedMakerDynamicDivisor: number;
880
896
  lastFillPrice: BN;
897
+
898
+ lpFeeTransferScalar: number;
899
+ lpExchangeFeeExcluscionScalar: number;
900
+ lpStatus: number;
901
+ lpPausedOperations: number;
881
902
  };
882
903
 
883
904
  export type HistoricalOracleData = {
@@ -1669,13 +1690,15 @@ export type RevenueShareEscrowAccount = {
1669
1690
  };
1670
1691
 
1671
1692
  export type RevenueShareOrder = {
1672
- builderIdx: number;
1673
1693
  feesAccrued: BN;
1674
1694
  orderId: number;
1675
1695
  feeTenthBps: number;
1676
1696
  marketIndex: number;
1697
+ subAccountId: number;
1698
+ builderIdx: number;
1677
1699
  bitFlags: number;
1678
- marketType: MarketType; // 0: spot, 1: perp
1700
+ userOrderIndex: number;
1701
+ marketType: MarketType;
1679
1702
  padding: number[];
1680
1703
  };
1681
1704