@drift-labs/sdk 2.86.0-beta.15 → 2.86.0-beta.16

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.86.0-beta.15
1
+ 2.86.0-beta.16
@@ -101,7 +101,7 @@ exports.MainnetSpotMarkets = [
101
101
  symbol: 'USDT',
102
102
  marketIndex: 5,
103
103
  oracle: new web3_js_1.PublicKey('3vxLXJqLqF3JG5TCbYycbKWRBbCJQLxQmBGCkyqEEefL'),
104
- oracleSource: __1.OracleSource.PYTH_STABLE_COIN,
104
+ oracleSource: __1.OracleSource.PYTH,
105
105
  mint: new web3_js_1.PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'),
106
106
  precision: numericConstants_1.QUOTE_PRECISION,
107
107
  precisionExp: numericConstants_1.QUOTE_PRECISION_EXP,
@@ -146,8 +146,8 @@ exports.MainnetSpotMarkets = [
146
146
  {
147
147
  symbol: 'JTO',
148
148
  marketIndex: 9,
149
- oracle: new web3_js_1.PublicKey('Ffq6ACJ17NAgaxC6ocfMzVXL3K61qxB2xHg6WUawWPfP'),
150
- oracleSource: __1.OracleSource.PYTH_PULL,
149
+ oracle: new web3_js_1.PublicKey('D8UUgr8a3aR3yUeHLu7v8FWK7E8Y5sSU7qrYBXUJXBQ5'),
150
+ oracleSource: __1.OracleSource.PYTH,
151
151
  mint: new web3_js_1.PublicKey('jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL'),
152
152
  precision: new __1.BN(10).pow(numericConstants_1.NINE),
153
153
  precisionExp: numericConstants_1.NINE,
@@ -194,8 +194,8 @@ exports.MainnetSpotMarkets = [
194
194
  {
195
195
  symbol: 'W',
196
196
  marketIndex: 13,
197
- oracle: new web3_js_1.PublicKey('4HbitGsdcFbtFotmYscikQFAAKJ3nYx4t7sV7fTvsk8U'),
198
- oracleSource: __1.OracleSource.PYTH_PULL,
197
+ oracle: new web3_js_1.PublicKey('H9j8CT1bFiWHaZUPMooEaxMRHdWdJ5T9CzFn41z96JHW'),
198
+ oracleSource: __1.OracleSource.PYTH,
199
199
  mint: new web3_js_1.PublicKey('85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ'),
200
200
  precision: new __1.BN(10).pow(numericConstants_1.SIX),
201
201
  precisionExp: numericConstants_1.SIX,
@@ -206,8 +206,8 @@ exports.MainnetSpotMarkets = [
206
206
  {
207
207
  symbol: 'TNSR',
208
208
  marketIndex: 14,
209
- oracle: new web3_js_1.PublicKey('13jpjpVyU5hGpjsZ4HzCcmBo85wze4N8Au7U6cC3GMip'),
210
- oracleSource: __1.OracleSource.PYTH_PULL,
209
+ oracle: new web3_js_1.PublicKey('7Cfyymx49ipGsgEsCA2XygAB2DUsan4C6Cyb5c8oR5st'),
210
+ oracleSource: __1.OracleSource.SWITCHBOARD,
211
211
  mint: new web3_js_1.PublicKey('TNSRxcUxoT9xBG3de7PiJyTDYu7kskLqcpddxnEJAS6'),
212
212
  precision: new __1.BN(10).pow(numericConstants_1.NINE),
213
213
  precisionExp: numericConstants_1.NINE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.86.0-beta.15",
3
+ "version": "2.86.0-beta.16",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -139,7 +139,7 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
139
139
  symbol: 'USDT',
140
140
  marketIndex: 5,
141
141
  oracle: new PublicKey('3vxLXJqLqF3JG5TCbYycbKWRBbCJQLxQmBGCkyqEEefL'),
142
- oracleSource: OracleSource.PYTH_STABLE_COIN,
142
+ oracleSource: OracleSource.PYTH,
143
143
  mint: new PublicKey('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'),
144
144
  precision: QUOTE_PRECISION,
145
145
  precisionExp: QUOTE_PRECISION_EXP,
@@ -192,8 +192,8 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
192
192
  {
193
193
  symbol: 'JTO',
194
194
  marketIndex: 9,
195
- oracle: new PublicKey('Ffq6ACJ17NAgaxC6ocfMzVXL3K61qxB2xHg6WUawWPfP'),
196
- oracleSource: OracleSource.PYTH_PULL,
195
+ oracle: new PublicKey('D8UUgr8a3aR3yUeHLu7v8FWK7E8Y5sSU7qrYBXUJXBQ5'),
196
+ oracleSource: OracleSource.PYTH,
197
197
  mint: new PublicKey('jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL'),
198
198
  precision: new BN(10).pow(NINE),
199
199
  precisionExp: NINE,
@@ -250,8 +250,8 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
250
250
  {
251
251
  symbol: 'W',
252
252
  marketIndex: 13,
253
- oracle: new PublicKey('4HbitGsdcFbtFotmYscikQFAAKJ3nYx4t7sV7fTvsk8U'),
254
- oracleSource: OracleSource.PYTH_PULL,
253
+ oracle: new PublicKey('H9j8CT1bFiWHaZUPMooEaxMRHdWdJ5T9CzFn41z96JHW'),
254
+ oracleSource: OracleSource.PYTH,
255
255
  mint: new PublicKey('85VBFQZC9TZkfaptBWjvUw7YbZjy52A6mjtPGjstQAmQ'),
256
256
  precision: new BN(10).pow(SIX),
257
257
  precisionExp: SIX,
@@ -265,8 +265,8 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
265
265
  {
266
266
  symbol: 'TNSR',
267
267
  marketIndex: 14,
268
- oracle: new PublicKey('13jpjpVyU5hGpjsZ4HzCcmBo85wze4N8Au7U6cC3GMip'),
269
- oracleSource: OracleSource.PYTH_PULL,
268
+ oracle: new PublicKey('7Cfyymx49ipGsgEsCA2XygAB2DUsan4C6Cyb5c8oR5st'),
269
+ oracleSource: OracleSource.SWITCHBOARD,
270
270
  mint: new PublicKey('TNSRxcUxoT9xBG3de7PiJyTDYu7kskLqcpddxnEJAS6'),
271
271
  precision: new BN(10).pow(NINE),
272
272
  precisionExp: NINE,
@@ -0,0 +1,214 @@
1
+ import {
2
+ DriftClient,
3
+ DevnetSpotMarkets,
4
+ MainnetSpotMarkets,
5
+ DevnetPerpMarkets,
6
+ MainnetPerpMarkets,
7
+ BulkAccountLoader,
8
+ getVariant,
9
+ } from '../../src';
10
+ import { Connection, Keypair } from '@solana/web3.js';
11
+ import { Wallet } from '@coral-xyz/anchor';
12
+ import dotenv from 'dotenv';
13
+ import { assert } from 'chai';
14
+
15
+ dotenv.config();
16
+
17
+ describe('Verify Constants', function () {
18
+ this.timeout(100_000);
19
+ const MAINNET_RPC_ENDPOINT = process.env.MAINNET_RPC_ENDPOINT;
20
+ const DEVNET_RPC_ENDPOINT = process.env.DEVNET_RPC_ENDPOINT;
21
+
22
+ if (MAINNET_RPC_ENDPOINT === undefined) {
23
+ throw new Error("MAINNET_RPC_ENDPOINT not found in .env");
24
+ }
25
+
26
+ if (DEVNET_RPC_ENDPOINT === undefined) {
27
+ throw new Error("DEVNET_RPC_ENDPOINT not found in .env");
28
+ }
29
+
30
+ const wallet = new Wallet(Keypair.generate());
31
+
32
+ const devnetConnection = new Connection(DEVNET_RPC_ENDPOINT);
33
+ const mainnetConnection = new Connection(MAINNET_RPC_ENDPOINT);
34
+
35
+ const devnetBulkAccountLoader = new BulkAccountLoader(
36
+ devnetConnection,
37
+ 'processed',
38
+ 1
39
+ );
40
+
41
+ const mainnetBulkAccountLoader = new BulkAccountLoader(
42
+ mainnetConnection,
43
+ 'processed',
44
+ 1
45
+ );
46
+
47
+ const devnetDriftClient = new DriftClient({
48
+ connection: devnetConnection,
49
+ wallet,
50
+ env: 'devnet',
51
+ accountSubscription: {
52
+ type: 'polling',
53
+ accountLoader: devnetBulkAccountLoader,
54
+ },
55
+ });
56
+
57
+ const mainnetDriftClient = new DriftClient({
58
+ connection: mainnetConnection,
59
+ wallet,
60
+ env: 'mainnet-beta',
61
+ accountSubscription: {
62
+ type: 'polling',
63
+ accountLoader: mainnetBulkAccountLoader,
64
+ },
65
+ });
66
+
67
+ before(async () => {
68
+ await devnetDriftClient.subscribe();
69
+ await mainnetDriftClient.subscribe();
70
+ });
71
+
72
+ after(async () => {
73
+ await devnetDriftClient.unsubscribe();
74
+ await mainnetDriftClient.unsubscribe();
75
+ });
76
+
77
+ it('has all mainnet markets', async () => {
78
+ const spotMarkets = mainnetDriftClient.getSpotMarketAccounts();
79
+ spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
80
+
81
+ for (const market of spotMarkets) {
82
+ const correspondingConfigMarket = MainnetSpotMarkets.find(
83
+ (configMarket) => configMarket.marketIndex === market.marketIndex
84
+ );
85
+ assert(
86
+ correspondingConfigMarket !== undefined,
87
+ `Market ${
88
+ market.marketIndex
89
+ } not found in MainnetSpotMarkets. market: ${market.pubkey.toBase58()}`
90
+ );
91
+ assert(
92
+ correspondingConfigMarket.oracle.toBase58() == market.oracle.toBase58(),
93
+ `Oracle mismatch for mainnet spot market ${
94
+ market.marketIndex
95
+ }, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.oracle.toBase58()}, chain: ${market.oracle.toBase58()}`
96
+ );
97
+ assert(
98
+ getVariant(correspondingConfigMarket.oracleSource) ===
99
+ getVariant(market.oracleSource),
100
+ `Oracle source mismatch for mainnet spot market ${
101
+ market.marketIndex
102
+ }, market: ${market.pubkey.toBase58()}, constants: ${getVariant(
103
+ correspondingConfigMarket.oracleSource
104
+ )}, chain: ${getVariant(market.oracleSource)}`
105
+ );
106
+ assert(
107
+ correspondingConfigMarket.mint.toBase58() === market.mint.toBase58(),
108
+ `Mint mismatch for mainnet spot market ${
109
+ market.marketIndex
110
+ }, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.mint.toBase58()}, chain: ${market.mint.toBase58()}`
111
+ );
112
+ }
113
+
114
+ const perpMarkets = mainnetDriftClient.getPerpMarketAccounts();
115
+ perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
116
+
117
+ for (const market of perpMarkets) {
118
+ const correspondingConfigMarket = MainnetPerpMarkets.find(
119
+ (configMarket) => configMarket.marketIndex === market.marketIndex
120
+ );
121
+ assert(
122
+ correspondingConfigMarket !== undefined,
123
+ `Market ${
124
+ market.marketIndex
125
+ } not found in MainnetPerpMarkets, market: ${market.pubkey.toBase58()}`
126
+ );
127
+ assert(
128
+ correspondingConfigMarket.oracle.toBase58() ==
129
+ market.amm.oracle.toBase58(),
130
+ `Oracle mismatch for mainnet perp market ${
131
+ market.marketIndex
132
+ }, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.oracle.toBase58()}, chain: ${market.amm.oracle.toBase58()}`
133
+ );
134
+ assert(
135
+ getVariant(correspondingConfigMarket.oracleSource) ===
136
+ getVariant(market.amm.oracleSource),
137
+ `Oracle source mismatch for mainnet perp market ${
138
+ market.marketIndex
139
+ }, market: ${market.pubkey.toBase58()}, constants: ${getVariant(
140
+ correspondingConfigMarket.oracleSource
141
+ )}, chain: ${getVariant(market.amm.oracleSource)}`
142
+ );
143
+ }
144
+ });
145
+
146
+ it('has all devnet markets', async () => {
147
+ const spotMarkets = devnetDriftClient.getSpotMarketAccounts();
148
+ spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
149
+
150
+ for (const market of spotMarkets) {
151
+ const correspondingConfigMarket = DevnetSpotMarkets.find(
152
+ (configMarket) => configMarket.marketIndex === market.marketIndex
153
+ );
154
+ assert(
155
+ correspondingConfigMarket !== undefined,
156
+ `Market ${
157
+ market.marketIndex
158
+ } not found in DevnetSpotMarkets, market: ${market.pubkey.toBase58()}`
159
+ );
160
+ assert(
161
+ correspondingConfigMarket.oracle.toBase58() == market.oracle.toBase58(),
162
+ `Oracle mismatch for devnet spot market ${
163
+ market.marketIndex
164
+ }, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.oracle.toBase58()}, chain: ${market.oracle.toBase58()}`
165
+ );
166
+ assert(
167
+ getVariant(correspondingConfigMarket.oracleSource) ===
168
+ getVariant(market.oracleSource),
169
+ `Oracle source mismatch for devnet spot market ${
170
+ market.marketIndex
171
+ }, market: ${market.pubkey.toBase58()}, constants: ${getVariant(
172
+ correspondingConfigMarket.oracleSource
173
+ )}, chain: ${getVariant(market.oracleSource)}`
174
+ );
175
+ assert(
176
+ correspondingConfigMarket.mint.toBase58() === market.mint.toBase58(),
177
+ `Mint mismatch for devnet spot market ${
178
+ market.marketIndex
179
+ }, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.mint.toBase58()}, chain: ${market.mint.toBase58()}`
180
+ );
181
+ }
182
+
183
+ const perpMarkets = devnetDriftClient.getPerpMarketAccounts();
184
+ perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
185
+
186
+ for (const market of perpMarkets) {
187
+ const correspondingConfigMarket = DevnetPerpMarkets.find(
188
+ (configMarket) => configMarket.marketIndex === market.marketIndex
189
+ );
190
+ assert(
191
+ correspondingConfigMarket !== undefined,
192
+ `Market ${
193
+ market.marketIndex
194
+ } not found in DevnetPerpMarkets, market: ${market.pubkey.toBase58()}`
195
+ );
196
+ assert(
197
+ correspondingConfigMarket.oracle.toBase58() ==
198
+ market.amm.oracle.toBase58(),
199
+ `Oracle mismatch for devnet perp market ${
200
+ market.marketIndex
201
+ }, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.oracle.toBase58()}, chain: ${market.amm.oracle.toBase58()}`
202
+ );
203
+ assert(
204
+ getVariant(correspondingConfigMarket.oracleSource) ===
205
+ getVariant(market.amm.oracleSource),
206
+ `Oracle source mismatch for devnet perp market ${
207
+ market.marketIndex
208
+ }, market: ${market.pubkey.toBase58()}, constants: ${getVariant(
209
+ correspondingConfigMarket.oracleSource
210
+ )}, chain: ${getVariant(market.amm.oracleSource)}`
211
+ );
212
+ }
213
+ });
214
+ });