@drift-labs/sdk-browser 2.155.0-beta.1 → 2.155.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.
Files changed (71) hide show
  1. package/VERSION +1 -1
  2. package/lib/browser/accounts/grpcAccountSubscriber.d.ts +0 -1
  3. package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +0 -1
  4. package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +0 -1
  5. package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +2 -3
  6. package/lib/browser/accounts/laserProgramAccountSubscriber.js +6 -8
  7. package/lib/browser/accounts/types.d.ts +4 -12
  8. package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +0 -1
  9. package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +0 -1
  10. package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +0 -1
  11. package/lib/browser/driftClient.d.ts +1 -2
  12. package/lib/browser/driftClient.js +5 -6
  13. package/lib/browser/oracles/pythPullClient.d.ts +2 -2
  14. package/lib/browser/oracles/pythPullClient.js +5 -2
  15. package/lib/browser/pyth/constants.d.ts +3 -0
  16. package/lib/browser/pyth/constants.js +6 -0
  17. package/lib/browser/pyth/index.d.ts +3 -0
  18. package/lib/browser/pyth/index.js +10 -0
  19. package/lib/browser/pyth/types.d.ts +2226 -0
  20. package/lib/browser/pyth/types.js +2224 -0
  21. package/lib/browser/pyth/utils.d.ts +2 -0
  22. package/lib/browser/pyth/utils.js +10 -0
  23. package/lib/node/accounts/grpcAccountSubscriber.d.ts +0 -1
  24. package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
  25. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +0 -1
  26. package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
  27. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +0 -1
  28. package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
  29. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +2 -3
  30. package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
  31. package/lib/node/accounts/laserProgramAccountSubscriber.js +6 -8
  32. package/lib/node/accounts/types.d.ts +4 -12
  33. package/lib/node/accounts/types.d.ts.map +1 -1
  34. package/lib/node/accounts/webSocketAccountSubscriber.d.ts +0 -1
  35. package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  36. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +0 -1
  37. package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts.map +1 -1
  38. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +0 -1
  39. package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
  40. package/lib/node/driftClient.d.ts +1 -2
  41. package/lib/node/driftClient.d.ts.map +1 -1
  42. package/lib/node/driftClient.js +5 -6
  43. package/lib/node/oracles/pythPullClient.d.ts +2 -2
  44. package/lib/node/oracles/pythPullClient.d.ts.map +1 -1
  45. package/lib/node/oracles/pythPullClient.js +5 -2
  46. package/lib/node/pyth/constants.d.ts +4 -0
  47. package/lib/node/pyth/constants.d.ts.map +1 -0
  48. package/lib/node/pyth/constants.js +6 -0
  49. package/lib/node/pyth/index.d.ts +4 -0
  50. package/lib/node/pyth/index.d.ts.map +1 -0
  51. package/lib/node/pyth/index.js +10 -0
  52. package/lib/node/pyth/types.d.ts +2227 -0
  53. package/lib/node/pyth/types.d.ts.map +1 -0
  54. package/lib/node/pyth/types.js +2224 -0
  55. package/lib/node/pyth/utils.d.ts +3 -0
  56. package/lib/node/pyth/utils.d.ts.map +1 -0
  57. package/lib/node/pyth/utils.js +10 -0
  58. package/package.json +4 -5
  59. package/scripts/grpc-client-test-comparison.ts +3 -2
  60. package/scripts/grpc-multiuser-client-test-comparison.ts +138 -140
  61. package/scripts/single-grpc-client-test.ts +21 -39
  62. package/src/accounts/laserProgramAccountSubscriber.ts +6 -9
  63. package/src/accounts/types.ts +4 -14
  64. package/src/driftClient.ts +9 -11
  65. package/src/oracles/pythPullClient.ts +4 -5
  66. package/src/pyth/constants.ts +9 -0
  67. package/src/pyth/index.ts +11 -0
  68. package/src/pyth/types.ts +4453 -0
  69. package/src/pyth/utils.ts +13 -0
  70. package/tests/decode/test.ts +2 -1
  71. package/tests/dlob/helpers.ts +0 -1
@@ -0,0 +1,3 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ export declare const getGuardianSetPda: (guardianSetIndex: number, wormholeProgramId: PublicKey) => PublicKey;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/pyth/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,iBAAiB,qBACX,MAAM,qBACL,SAAS,cAQ5B,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGuardianSetPda = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const getGuardianSetPda = (guardianSetIndex, wormholeProgramId) => {
6
+ const guardianSetIndexBuf = Buffer.alloc(4);
7
+ guardianSetIndexBuf.writeUInt32BE(guardianSetIndex, 0);
8
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('GuardianSet'), guardianSetIndexBuf], wormholeProgramId)[0];
9
+ };
10
+ exports.getGuardianSetPda = getGuardianSetPda;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk-browser",
3
- "version": "2.155.0-beta.1",
3
+ "version": "2.155.0-beta.3",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "module": "./lib/browser/index.js",
@@ -51,12 +51,11 @@
51
51
  "@project-serum/serum": "0.13.65",
52
52
  "@pythnetwork/client": "2.5.3",
53
53
  "@pythnetwork/price-service-sdk": "1.7.1",
54
- "@pythnetwork/pyth-solana-receiver": "0.7.0",
55
54
  "@solana/spl-token": "0.4.13",
56
55
  "@solana/web3.js": "1.98.0",
57
56
  "@switchboard-xyz/common": "3.0.14",
58
57
  "@switchboard-xyz/on-demand": "2.4.1",
59
- "@triton-one/yellowstone-grpc": "5.0.1",
58
+ "@triton-one/yellowstone-grpc": "1.4.1",
60
59
  "anchor-bankrun": "0.3.0",
61
60
  "gill": "^0.10.2",
62
61
  "helius-laserstream": "0.1.8",
@@ -150,9 +149,9 @@
150
149
  "has-ansi": "<6.0.1"
151
150
  },
152
151
  "browser": {
153
- "helius-laserstream": false,
154
- "@triton-one/yellowstone-grpc": false,
155
152
  "@grpc/grpc-js": false,
153
+ "@triton-one/yellowstone-grpc": false,
154
+ "helius-laserstream": false,
156
155
  "zstddec": false
157
156
  }
158
157
  }
@@ -96,8 +96,9 @@ async function initializeGrpcDriftClientV2VersusV1() {
96
96
  token: TOKEN,
97
97
  commitmentLevel: CommitmentLevel.PROCESSED,
98
98
  channelOptions: {
99
- grpcKeepAliveTimeout: 1_000,
100
- grpcTcpKeepalive: 10_000,
99
+ 'grpc.keepalive_time_ms': 10_000,
100
+ 'grpc.keepalive_timeout_ms': 1_000,
101
+ 'grpc.keepalive_permit_without_calls': 1,
101
102
  },
102
103
  },
103
104
  };
@@ -13,146 +13,144 @@ const TOKEN = process.env.TOKEN;
13
13
  const RPC_ENDPOINT = process.env.RPC_ENDPOINT;
14
14
 
15
15
  const USER_ACCOUNT_PUBKEYS = [
16
- // Add user account public keys here, e.g.:
17
- // new PublicKey('...')
16
+ // Add user account public keys here, e.g.:
17
+ // new PublicKey('...')
18
18
  ];
19
19
 
20
20
  async function testGrpcUserAccountSubscriberV1VsV2() {
21
- console.log('🚀 Initializing User Account Subscriber V1 vs V2 Test...');
22
-
23
- if (USER_ACCOUNT_PUBKEYS.length === 0) {
24
- console.error(
25
- '❌ No user account public keys provided. Please add some to USER_ACCOUNT_PUBKEYS array.'
26
- );
27
- process.exit(1);
28
- }
29
-
30
- const connection = new Connection(RPC_ENDPOINT);
31
- const wallet = new Wallet(new Keypair());
32
-
33
- const programId = new PublicKey(DRIFT_PROGRAM_ID);
34
- const provider = new AnchorProvider(
35
- connection,
36
- // @ts-ignore
37
- wallet,
38
- {
39
- commitment: 'processed',
40
- }
41
- );
42
-
43
- const program = new Program(driftIDL as Idl, programId, provider);
44
-
45
- const grpcConfigs = {
46
- endpoint: GRPC_ENDPOINT,
47
- token: TOKEN,
48
- commitmentLevel: CommitmentLevel.PROCESSED,
49
- channelOptions: {
50
- grpcKeepAliveTimeout: 1_000,
51
- grpcTcpKeepalive: 10_000,
52
- },
53
- };
54
-
55
- console.log(`📊 Testing ${USER_ACCOUNT_PUBKEYS.length} user accounts...`);
56
-
57
- // V1: Create individual subscribers for each user account
58
- const v1Subscribers = USER_ACCOUNT_PUBKEYS.map(
59
- (pubkey) =>
60
- new grpcUserAccountSubscriber(grpcConfigs, program, pubkey, {
61
- logResubMessages: true,
62
- })
63
- );
64
-
65
- // V2: Create a single multi-subscriber and get per-user interfaces
66
- const v2MultiSubscriber = new grpcMultiUserAccountSubscriber(
67
- program,
68
- grpcConfigs,
69
- { logResubMessages: true }
70
- );
71
- const v2Subscribers = USER_ACCOUNT_PUBKEYS.map((pubkey) =>
72
- v2MultiSubscriber.forUser(pubkey)
73
- );
74
-
75
- // Subscribe all V1 subscribers
76
- console.log('🔗 Subscribing V1 subscribers...');
77
- await Promise.all(v1Subscribers.map((sub) => sub.subscribe()));
78
- console.log(' V1 subscribers ready');
79
-
80
- // Subscribe all V2 subscribers
81
- console.log('🔗 Subscribing V2 subscribers...');
82
- await v2MultiSubscriber.subscribe();
83
- console.log(' V2 subscribers ready');
84
-
85
- const compare = () => {
86
- try {
87
- let passedTests = 0;
88
- let totalTests = 0;
89
-
90
- // Test each user account
91
- for (let i = 0; i < USER_ACCOUNT_PUBKEYS.length; i++) {
92
- const pubkey = USER_ACCOUNT_PUBKEYS[i];
93
- const v1Sub = v1Subscribers[i];
94
- const v2Sub = v2Subscribers[i];
95
-
96
- totalTests++;
97
-
98
- // 1. Test isSubscribed
99
- assert.strictEqual(
100
- v1Sub.isSubscribed,
101
- v2Sub.isSubscribed,
102
- `User ${pubkey.toBase58()}: isSubscribed should match`
103
- );
104
-
105
- // 2. Test getUserAccountAndSlot
106
- const v1Data = v1Sub.getUserAccountAndSlot();
107
- const v2Data = v2Sub.getUserAccountAndSlot();
108
-
109
- // Compare the user account data
110
- assert.deepStrictEqual(
111
- v1Data.data,
112
- v2Data.data,
113
- `User ${pubkey.toBase58()}: account data should match`
114
- );
115
-
116
- // Slots might differ slightly due to timing, but let's check if they're close
117
- const slotDiff = Math.abs(v1Data.slot - v2Data.slot);
118
- if (slotDiff > 10) {
119
- console.warn(
120
- `⚠️ User ${pubkey.toBase58()}: slot difference is ${slotDiff} (v1: ${
121
- v1Data.slot
122
- }, v2: ${v2Data.slot})`
123
- );
124
- }
125
-
126
- passedTests++;
127
- }
128
-
129
- console.log(
130
- `✅ All comparisons passed (${passedTests}/${totalTests} user accounts)`
131
- );
132
- } catch (error) {
133
- console.error('❌ Comparison failed:', error);
134
- }
135
- };
136
-
137
- // Run initial comparison
138
- compare();
139
-
140
- // Run comparison every second to verify live updates
141
- const interval = setInterval(compare, 1000);
142
-
143
- const cleanup = async () => {
144
- clearInterval(interval);
145
- console.log('🧹 Cleaning up...');
146
- await Promise.all([
147
- ...v1Subscribers.map((sub) => sub.unsubscribe()),
148
- ...v2Subscribers.map((sub) => sub.unsubscribe()),
149
- ]);
150
- console.log('✅ Cleanup complete');
151
- process.exit(0);
152
- };
153
-
154
- process.on('SIGINT', cleanup);
155
- process.on('SIGTERM', cleanup);
156
- }
157
-
158
- testGrpcUserAccountSubscriberV1VsV2().catch(console.error);
21
+ console.log('🚀 Initializing User Account Subscriber V1 vs V2 Test...');
22
+
23
+ if (USER_ACCOUNT_PUBKEYS.length === 0) {
24
+ console.error('❌ No user account public keys provided. Please add some to USER_ACCOUNT_PUBKEYS array.');
25
+ process.exit(1);
26
+ }
27
+
28
+ const connection = new Connection(RPC_ENDPOINT);
29
+ const wallet = new Wallet(new Keypair());
30
+
31
+ const programId = new PublicKey(DRIFT_PROGRAM_ID);
32
+ const provider = new AnchorProvider(
33
+ connection,
34
+ // @ts-ignore
35
+ wallet,
36
+ {
37
+ commitment: 'processed',
38
+ }
39
+ );
40
+
41
+ const program = new Program(driftIDL as Idl, programId, provider);
42
+
43
+ const grpcConfigs = {
44
+ endpoint: GRPC_ENDPOINT,
45
+ token: TOKEN,
46
+ commitmentLevel: CommitmentLevel.PROCESSED,
47
+ channelOptions: {
48
+ 'grpc.keepalive_time_ms': 10_000,
49
+ 'grpc.keepalive_timeout_ms': 1_000,
50
+ 'grpc.keepalive_permit_without_calls': 1,
51
+ },
52
+ };
53
+
54
+ console.log(`📊 Testing ${USER_ACCOUNT_PUBKEYS.length} user accounts...`);
55
+
56
+ // V1: Create individual subscribers for each user account
57
+ const v1Subscribers = USER_ACCOUNT_PUBKEYS.map(
58
+ (pubkey) =>
59
+ new grpcUserAccountSubscriber(
60
+ grpcConfigs,
61
+ program,
62
+ pubkey,
63
+ { logResubMessages: true }
64
+ )
65
+ );
66
+
67
+ // V2: Create a single multi-subscriber and get per-user interfaces
68
+ const v2MultiSubscriber = new grpcMultiUserAccountSubscriber(
69
+ program,
70
+ grpcConfigs,
71
+ { logResubMessages: true }
72
+ );
73
+ const v2Subscribers = USER_ACCOUNT_PUBKEYS.map((pubkey) =>
74
+ v2MultiSubscriber.forUser(pubkey)
75
+ );
76
+
77
+ // Subscribe all V1 subscribers
78
+ console.log('🔗 Subscribing V1 subscribers...');
79
+ await Promise.all(v1Subscribers.map((sub) => sub.subscribe()));
80
+ console.log('✅ V1 subscribers ready');
81
+
82
+ // Subscribe all V2 subscribers
83
+ console.log('🔗 Subscribing V2 subscribers...');
84
+ await v2MultiSubscriber.subscribe();
85
+ console.log('✅ V2 subscribers ready');
86
+
87
+ const compare = () => {
88
+ try {
89
+ let passedTests = 0;
90
+ let totalTests = 0;
91
+
92
+ // Test each user account
93
+ for (let i = 0; i < USER_ACCOUNT_PUBKEYS.length; i++) {
94
+ const pubkey = USER_ACCOUNT_PUBKEYS[i];
95
+ const v1Sub = v1Subscribers[i];
96
+ const v2Sub = v2Subscribers[i];
97
+
98
+ totalTests++;
99
+
100
+ // 1. Test isSubscribed
101
+ assert.strictEqual(
102
+ v1Sub.isSubscribed,
103
+ v2Sub.isSubscribed,
104
+ `User ${pubkey.toBase58()}: isSubscribed should match`
105
+ );
106
+
107
+ // 2. Test getUserAccountAndSlot
108
+ const v1Data = v1Sub.getUserAccountAndSlot();
109
+ const v2Data = v2Sub.getUserAccountAndSlot();
110
+
111
+ // Compare the user account data
112
+ assert.deepStrictEqual(
113
+ v1Data.data,
114
+ v2Data.data,
115
+ `User ${pubkey.toBase58()}: account data should match`
116
+ );
117
+
118
+ // Slots might differ slightly due to timing, but let's check if they're close
119
+ const slotDiff = Math.abs(v1Data.slot - v2Data.slot);
120
+ if (slotDiff > 10) {
121
+ console.warn(
122
+ `⚠️ User ${pubkey.toBase58()}: slot difference is ${slotDiff} (v1: ${v1Data.slot}, v2: ${v2Data.slot})`
123
+ );
124
+ }
125
+
126
+ passedTests++;
127
+ }
128
+
129
+ console.log(`✅ All comparisons passed (${passedTests}/${totalTests} user accounts)`);
130
+ } catch (error) {
131
+ console.error('❌ Comparison failed:', error);
132
+ }
133
+ };
134
+
135
+ // Run initial comparison
136
+ compare();
137
+
138
+ // Run comparison every second to verify live updates
139
+ const interval = setInterval(compare, 1000);
140
+
141
+ const cleanup = async () => {
142
+ clearInterval(interval);
143
+ console.log('🧹 Cleaning up...');
144
+ await Promise.all([
145
+ ...v1Subscribers.map((sub) => sub.unsubscribe()),
146
+ ...v2Subscribers.map((sub) => sub.unsubscribe()),
147
+ ]);
148
+ console.log('✅ Cleanup complete');
149
+ process.exit(0);
150
+ };
151
+
152
+ process.on('SIGINT', cleanup);
153
+ process.on('SIGTERM', cleanup);
154
+ }
155
+
156
+ testGrpcUserAccountSubscriberV1VsV2().catch(console.error);
@@ -94,18 +94,18 @@ async function initializeSingleGrpcClient() {
94
94
  }
95
95
  }
96
96
 
97
- console.log(
98
- `📊 Markets: ${perpMarketIndexes.length} perp, ${spotMarketIndexes.length} spot`
99
- );
97
+ console.log(`📊 Markets: ${perpMarketIndexes.length} perp, ${spotMarketIndexes.length} spot`);
100
98
  console.log(`🔮 Oracles: ${oracleInfos.length}`);
101
99
 
100
+
102
101
  const grpcConfigs = {
103
102
  endpoint: GRPC_ENDPOINT,
104
103
  token: TOKEN,
105
104
  commitmentLevel: CommitmentLevel.PROCESSED,
106
105
  channelOptions: {
107
- grpcKeepAliveTimeout: 1_000,
108
- grpcTcpKeepalive: 10_000,
106
+ 'grpc.keepalive_time_ms': 10_000,
107
+ 'grpc.keepalive_timeout_ms': 1_000,
108
+ 'grpc.keepalive_permit_without_calls': 1,
109
109
  },
110
110
  };
111
111
 
@@ -171,9 +171,7 @@ async function initializeSingleGrpcClient() {
171
171
  await client.subscribe();
172
172
 
173
173
  console.log('✅ Client subscribed successfully!');
174
- console.log(
175
- '🚀 Starting high-load testing (50 reads/sec per perp market)...'
176
- );
174
+ console.log('🚀 Starting high-load testing (50 reads/sec per perp market)...');
177
175
 
178
176
  // High-frequency load testing - 50 reads per second per perp market
179
177
  const loadTestInterval = setInterval(async () => {
@@ -181,35 +179,25 @@ async function initializeSingleGrpcClient() {
181
179
  // Test getPerpMarketAccount for each perp market (50 times per second per market)
182
180
  for (const marketIndex of perpMarketIndexes) {
183
181
  const perpMarketAccount = client.getPerpMarketAccount(marketIndex);
184
- console.log(
185
- 'perpMarketAccount name: ',
186
- decodeName(perpMarketAccount.name)
187
- );
188
- console.log(
189
- 'perpMarketAccount data: ',
190
- JSON.stringify({
191
- marketIndex: perpMarketAccount.marketIndex,
192
- name: decodeName(perpMarketAccount.name),
193
- baseAssetReserve: perpMarketAccount.amm.baseAssetReserve.toString(),
194
- quoteAssetReserve:
195
- perpMarketAccount.amm.quoteAssetReserve.toString(),
196
- })
197
- );
182
+ console.log("perpMarketAccount name: ", decodeName(perpMarketAccount.name));
183
+ console.log("perpMarketAccount data: ", JSON.stringify({
184
+ marketIndex: perpMarketAccount.marketIndex,
185
+ name: decodeName(perpMarketAccount.name),
186
+ baseAssetReserve: perpMarketAccount.amm.baseAssetReserve.toString(),
187
+ quoteAssetReserve: perpMarketAccount.amm.quoteAssetReserve.toString()
188
+ }));
198
189
  }
199
190
 
200
191
  // Test getMMOracleDataForPerpMarket for each perp market (50 times per second per market)
201
192
  for (const marketIndex of perpMarketIndexes) {
202
193
  try {
203
194
  const oracleData = client.getMMOracleDataForPerpMarket(marketIndex);
204
- console.log('oracleData price: ', oracleData.price.toString());
205
- console.log(
206
- 'oracleData: ',
207
- JSON.stringify({
208
- price: oracleData.price.toString(),
209
- confidence: oracleData.confidence?.toString(),
210
- slot: oracleData.slot?.toString(),
211
- })
212
- );
195
+ console.log("oracleData price: ", oracleData.price.toString());
196
+ console.log("oracleData: ", JSON.stringify({
197
+ price: oracleData.price.toString(),
198
+ confidence: oracleData.confidence?.toString(),
199
+ slot: oracleData.slot?.toString()
200
+ }));
213
201
  } catch (error) {
214
202
  // Ignore errors for load testing
215
203
  }
@@ -223,14 +211,8 @@ async function initializeSingleGrpcClient() {
223
211
  const statsInterval = setInterval(() => {
224
212
  console.log('\n📈 Event Counts:', eventCounts);
225
213
  console.log(`⏱️ Client subscribed: ${client.isSubscribed}`);
226
- console.log(
227
- `🔗 Account subscriber subscribed: ${client.accountSubscriber.isSubscribed}`
228
- );
229
- console.log(
230
- `🔥 Load: ${perpMarketIndexes.length * 50 * 2} reads/sec (${
231
- perpMarketIndexes.length
232
- } markets × 50 getPerpMarketAccount + 50 getMMOracleDataForPerpMarket)`
233
- );
214
+ console.log(`🔗 Account subscriber subscribed: ${client.accountSubscriber.isSubscribed}`);
215
+ console.log(`🔥 Load: ${perpMarketIndexes.length * 50 * 2} reads/sec (${perpMarketIndexes.length} markets × 50 getPerpMarketAccount + 50 getMMOracleDataForPerpMarket)`);
234
216
  }, 5000);
235
217
 
236
218
  // Handle shutdown signals - just exit without cleanup since they never unsubscribe
@@ -1,4 +1,4 @@
1
- import { LaserGrpcConfigs, ResubOpts } from './types';
1
+ import { GrpcConfigs, ResubOpts } from './types';
2
2
  import { Program } from '@coral-xyz/anchor';
3
3
  import { Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
4
4
  import * as Buffer from 'buffer';
@@ -56,7 +56,7 @@ export class LaserstreamProgramAccountSubscriber<
56
56
  }
57
57
 
58
58
  public static async create<U>(
59
- grpcConfigs: LaserGrpcConfigs,
59
+ grpcConfigs: GrpcConfigs,
60
60
  subscriptionName: string,
61
61
  accountDiscriminator: string,
62
62
  program: Program,
@@ -66,17 +66,14 @@ export class LaserstreamProgramAccountSubscriber<
66
66
  },
67
67
  resubOpts?: ResubOpts
68
68
  ): Promise<LaserstreamProgramAccountSubscriber<U>> {
69
- const channelOptions = {
70
- 'grpc.default_compression_algorithm': CompressionAlgorithms.zstd,
71
- 'grpc.max_receive_message_length': 1_000_000_000,
72
- ...(grpcConfigs.channelOptions ?? {}),
73
- };
74
-
75
69
  const laserConfig: LaserstreamConfig = {
76
70
  apiKey: grpcConfigs.token,
77
71
  endpoint: grpcConfigs.endpoint,
78
72
  maxReconnectAttempts: grpcConfigs.enableReconnect ? 10 : 0,
79
- channelOptions,
73
+ channelOptions: {
74
+ 'grpc.default_compression_algorithm': CompressionAlgorithms.zstd,
75
+ 'grpc.max_receive_message_length': 1_000_000_000,
76
+ },
80
77
  };
81
78
 
82
79
  const commitmentLevel =
@@ -15,7 +15,7 @@ import { Context, PublicKey } from '@solana/web3.js';
15
15
  import { Account } from '@solana/spl-token';
16
16
  import { OracleInfo, OraclePriceData } from '../oracles/types';
17
17
  import { User } from '../user';
18
- import { Client, CommitmentLevel, LaserstreamConfig } from '../isomorphic/grpc';
18
+ import { ChannelOptions, CommitmentLevel } from '../isomorphic/grpc';
19
19
 
20
20
  export interface AccountSubscriber<T> {
21
21
  dataAndSlot?: DataAndSlot<T>;
@@ -225,29 +225,19 @@ export interface UserStatsAccountSubscriber {
225
225
  getUserStatsAccountAndSlot(): DataAndSlot<UserStatsAccount>;
226
226
  }
227
227
 
228
- type BaseGrpcConfigs = {
228
+ export type GrpcConfigs = {
229
229
  endpoint: string;
230
230
  token: string;
231
231
  commitmentLevel?: CommitmentLevel;
232
+ channelOptions?: ChannelOptions;
232
233
  /**
233
234
  * Whether to enable automatic reconnection on connection loss .
234
235
  * Defaults to false, will throw on connection loss.
235
236
  */
236
237
  enableReconnect?: boolean;
238
+ client?: 'yellowstone' | 'laser';
237
239
  };
238
240
 
239
- export type YellowstoneGrpcConfigs = BaseGrpcConfigs & {
240
- client?: 'yellowstone';
241
- channelOptions?: ConstructorParameters<typeof Client>[2];
242
- };
243
-
244
- export type LaserGrpcConfigs = BaseGrpcConfigs & {
245
- client: 'laser';
246
- channelOptions?: LaserstreamConfig['channelOptions'];
247
- };
248
-
249
- export type GrpcConfigs = YellowstoneGrpcConfigs | LaserGrpcConfigs;
250
-
251
241
  export interface HighLeverageModeConfigAccountSubscriber {
252
242
  eventEmitter: StrictEventEmitter<
253
243
  EventEmitter,
@@ -185,17 +185,7 @@ import {
185
185
  trimVaaSignatures,
186
186
  } from './math/oracles';
187
187
  import { TxHandler } from './tx/txHandler';
188
- import {
189
- DEFAULT_RECEIVER_PROGRAM_ID,
190
- wormholeCoreBridgeIdl,
191
- } from '@pythnetwork/pyth-solana-receiver';
192
188
  import { parseAccumulatorUpdateData } from '@pythnetwork/price-service-sdk';
193
- import {
194
- DEFAULT_WORMHOLE_PROGRAM_ID,
195
- getGuardianSetPda,
196
- } from '@pythnetwork/pyth-solana-receiver/lib/address';
197
- import { WormholeCoreBridgeSolana } from '@pythnetwork/pyth-solana-receiver/lib/idl/wormhole_core_bridge_solana';
198
- import { PythSolanaReceiver } from '@pythnetwork/pyth-solana-receiver/lib/idl/pyth_solana_receiver';
199
189
  import { getFeedIdUint8Array, trimFeedId } from './util/pythOracleUtils';
200
190
  import { createMinimalEd25519VerifyIx } from './util/ed25519Utils';
201
191
  import {
@@ -221,6 +211,14 @@ import {
221
211
  } from './math/builder';
222
212
  import { TitanClient, SwapMode as TitanSwapMode } from './titan/titanClient';
223
213
  import { UnifiedSwapClient } from './swap/UnifiedSwapClient';
214
+ import {
215
+ DEFAULT_RECEIVER_PROGRAM_ID,
216
+ WORMHOLE_CORE_BRIDGE_SOLANA_IDL,
217
+ DEFAULT_WORMHOLE_PROGRAM_ID,
218
+ getGuardianSetPda,
219
+ WormholeCoreBridgeSolana,
220
+ PythSolanaReceiver,
221
+ } from './pyth';
224
222
 
225
223
  /**
226
224
  * Union type for swap clients (Titan and Jupiter) - Legacy type
@@ -11208,7 +11206,7 @@ export class DriftClient {
11208
11206
 
11209
11207
  if (this.wormholeProgram === undefined) {
11210
11208
  this.wormholeProgram = new Program(
11211
- wormholeCoreBridgeIdl,
11209
+ WORMHOLE_CORE_BRIDGE_SOLANA_IDL,
11212
11210
  DEFAULT_WORMHOLE_PROGRAM_ID,
11213
11211
  this.provider
11214
11212
  );
@@ -7,13 +7,12 @@ import {
7
7
  QUOTE_PRECISION,
8
8
  TEN,
9
9
  } from '../constants/numericConstants';
10
- import {
11
- PythSolanaReceiverProgram,
12
- pythSolanaReceiverIdl,
13
- } from '@pythnetwork/pyth-solana-receiver';
14
- import { PriceUpdateAccount } from '@pythnetwork/pyth-solana-receiver/lib/PythSolanaReceiver';
10
+
11
+ import pythSolanaReceiverIdl from '../idl/pyth_solana_receiver.json';
12
+ import { PythSolanaReceiver as PythSolanaReceiverProgram } from '../pyth';
15
13
  import { DRIFT_ORACLE_RECEIVER_ID } from '../config';
16
14
  import { Wallet } from '../wallet';
15
+ import { PriceUpdateAccount } from '../pyth';
17
16
 
18
17
  export class PythPullClient implements OracleClient {
19
18
  private connection: Connection;
@@ -0,0 +1,9 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+
3
+ export const DEFAULT_WORMHOLE_PROGRAM_ID = new PublicKey(
4
+ 'HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ'
5
+ );
6
+
7
+ export const DEFAULT_RECEIVER_PROGRAM_ID = new PublicKey(
8
+ 'rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ'
9
+ );
@@ -0,0 +1,11 @@
1
+ export {
2
+ WormholeCoreBridgeSolana,
3
+ WORMHOLE_CORE_BRIDGE_SOLANA_IDL,
4
+ PythSolanaReceiver,
5
+ PriceUpdateAccount,
6
+ } from './types';
7
+ export {
8
+ DEFAULT_WORMHOLE_PROGRAM_ID,
9
+ DEFAULT_RECEIVER_PROGRAM_ID,
10
+ } from './constants';
11
+ export { getGuardianSetPda } from './utils';