@drift-labs/sdk 2.93.0-beta.0 → 2.93.0-beta.10

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.93.0-beta.0
1
+ 2.93.0-beta.10
@@ -707,6 +707,36 @@ exports.MainnetPerpMarkets = [
707
707
  oracleSource: __1.OracleSource.PYTH_1K_PULL,
708
708
  pythFeedId: '0x5169491cd7e2a44c98353b779d5eb612e4ac32e073f5cc534303d86307c2f1bc',
709
709
  },
710
+ {
711
+ fullName: 'TRUMP-WIN-2024-BET',
712
+ category: ['Prediction', 'Election'],
713
+ symbol: 'TRUMP-WIN-2024-BET',
714
+ baseAssetSymbol: 'TRUMP-WIN-2024',
715
+ marketIndex: 36,
716
+ oracle: new web3_js_1.PublicKey('7YrQUxmxGdbk8pvns9KcL5ojbZSL2eHj62hxRqggtEUR'),
717
+ launchTs: 1723996800000,
718
+ oracleSource: __1.OracleSource.Prelaunch,
719
+ },
720
+ {
721
+ fullName: 'KAMALA-POPULAR-VOTE-2024-BET',
722
+ category: ['Prediction', 'Election'],
723
+ symbol: 'KAMALA-POPULAR-VOTE-2024-BET',
724
+ baseAssetSymbol: 'KAMALA-POPULAR-VOTE-2024',
725
+ marketIndex: 37,
726
+ oracle: new web3_js_1.PublicKey('AowFw1dCVjS8kngvTCoT3oshiUyL69k7P1uxqXwteWH4'),
727
+ launchTs: 1723996800000,
728
+ oracleSource: __1.OracleSource.Prelaunch,
729
+ },
730
+ {
731
+ fullName: 'FED-CUT-50-SEPT-2024-BET',
732
+ category: ['Prediction', 'Election'],
733
+ symbol: 'FED-CUT-50-SEPT-2024-BET',
734
+ baseAssetSymbol: 'FED-CUT-50-SEPT-2024',
735
+ marketIndex: 38,
736
+ oracle: new web3_js_1.PublicKey('5QzgqAbEhJ1cPnLX4tSZEXezmW7sz7PPVVg2VanGi8QQ'),
737
+ launchTs: 1724250126000,
738
+ oracleSource: __1.OracleSource.Prelaunch,
739
+ },
710
740
  ];
711
741
  exports.PerpMarkets = {
712
742
  devnet: exports.DevnetPerpMarkets,
@@ -87,7 +87,7 @@ exports.MainnetSpotMarkets = [
87
87
  {
88
88
  symbol: 'wBTC',
89
89
  marketIndex: 3,
90
- oracle: new web3_js_1.PublicKey('486kr3pmFPfTsS4aZgcsQ7kS4i9rjMsYYZup6HQNSTT4'),
90
+ oracle: new web3_js_1.PublicKey('9Tq8iN5WnMX2PcZGj4iSFEAgHCi8cM6x8LsDUbuzq8uw'),
91
91
  oracleSource: __1.OracleSource.PYTH_PULL,
92
92
  mint: new web3_js_1.PublicKey('3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh'),
93
93
  precision: new __1.BN(10).pow(numericConstants_1.EIGHT),
@@ -81,7 +81,7 @@ export declare class DLOB {
81
81
  findJitAuctionNodesToFill(marketIndex: number, slot: number, oraclePriceData: OraclePriceData, marketType: MarketType): NodeToFill[];
82
82
  getTakingBids(marketIndex: number, marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
83
83
  getTakingAsks(marketIndex: number, marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
84
- private getBestNode;
84
+ protected getBestNode(generatorList: Array<Generator<DLOBNode>>, oraclePriceData: OraclePriceData, slot: number, compareFcn: (bestDLOBNode: DLOBNode, currentDLOBNode: DLOBNode, slot: number, oraclePriceData: OraclePriceData) => boolean, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
85
85
  getRestingLimitAsks(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
86
86
  getRestingLimitBids(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
87
87
  getAsks(marketIndex: number, fallbackAsk: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, filterFcn?: DLOBFilterFcn): Generator<DLOBNode>;
@@ -640,6 +640,8 @@ export declare class DriftClient {
640
640
  settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
641
641
  settleMultiplePNLs(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode, txParams?: TxParams): Promise<TransactionSignature>;
642
642
  settleMultiplePNLsIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndexes: number[], mode: SettlePnlMode): Promise<TransactionInstruction>;
643
+ getSetUserStatusToBeingLiquidatedIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
644
+ setUserStatusToBeingLiquidated(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionSignature>;
643
645
  liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
644
646
  getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
645
647
  liquidatePerpWithFill(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, makerInfos: MakerInfo[], txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
@@ -3210,6 +3210,23 @@ class DriftClient {
3210
3210
  remainingAccounts: remainingAccounts,
3211
3211
  });
3212
3212
  }
3213
+ async getSetUserStatusToBeingLiquidatedIx(userAccountPublicKey, userAccount) {
3214
+ const remainingAccounts = this.getRemainingAccounts({
3215
+ userAccounts: [userAccount],
3216
+ });
3217
+ return await this.program.instruction.setUserStatusToBeingLiquidated({
3218
+ accounts: {
3219
+ state: await this.getStatePublicKey(),
3220
+ user: userAccountPublicKey,
3221
+ authority: this.wallet.publicKey,
3222
+ },
3223
+ remainingAccounts,
3224
+ });
3225
+ }
3226
+ async setUserStatusToBeingLiquidated(userAccountPublicKey, userAccount) {
3227
+ const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getSetUserStatusToBeingLiquidatedIx(userAccountPublicKey, userAccount)), [], this.opts);
3228
+ return txSig;
3229
+ }
3213
3230
  async liquidatePerp(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice, txParams, liquidatorSubAccountId) {
3214
3231
  const { txSig, slot } = await this.sendTransaction(await this.buildTransaction(await this.getLiquidatePerpIx(userAccountPublicKey, userAccount, marketIndex, maxBaseAssetAmount, limitPrice, liquidatorSubAccountId), txParams), [], this.opts);
3215
3232
  this.perpMarketLastSlotCache.set(marketIndex, slot);
@@ -1881,6 +1881,22 @@
1881
1881
  }
1882
1882
  ]
1883
1883
  },
1884
+ {
1885
+ "name": "setUserStatusToBeingLiquidated",
1886
+ "accounts": [
1887
+ {
1888
+ "name": "state",
1889
+ "isMut": false,
1890
+ "isSigner": false
1891
+ },
1892
+ {
1893
+ "name": "user",
1894
+ "isMut": true,
1895
+ "isSigner": false
1896
+ }
1897
+ ],
1898
+ "args": []
1899
+ },
1884
1900
  {
1885
1901
  "name": "resolvePerpPnlDeficit",
1886
1902
  "accounts": [
@@ -2259,7 +2275,7 @@
2259
2275
  },
2260
2276
  {
2261
2277
  "name": "spotMarket",
2262
- "isMut": false,
2278
+ "isMut": true,
2263
2279
  "isSigner": false
2264
2280
  },
2265
2281
  {
@@ -2295,7 +2311,7 @@
2295
2311
  },
2296
2312
  {
2297
2313
  "name": "spotMarket",
2298
- "isMut": false,
2314
+ "isMut": true,
2299
2315
  "isSigner": false
2300
2316
  },
2301
2317
  {
package/lib/math/amm.js CHANGED
@@ -449,7 +449,7 @@ function getQuoteAssetReservePredictionMarketBounds(amm, direction) {
449
449
  .mul(pegSqrt)
450
450
  .div(amm.pegMultiplier);
451
451
  if (direction === types_1.PositionDirection.LONG) {
452
- quoteAssetReserveLowerBound = this.amm.sqrtK
452
+ quoteAssetReserveLowerBound = amm.sqrtK
453
453
  .muln(22361)
454
454
  .mul(pegSqrt)
455
455
  .divn(100000)
@@ -28,6 +28,12 @@ export declare class OrderSubscriber {
28
28
  subscribe(): Promise<void>;
29
29
  fetch(): Promise<void>;
30
30
  tryUpdateUserAccount(key: string, dataType: 'raw' | 'decoded' | 'buffer', data: string[] | UserAccount | Buffer, slot: number): void;
31
+ /**
32
+ * Creates a new DLOB for the order subscriber to fill. This will allow a
33
+ * caller to extend the DLOB Subscriber with a custom DLOB type.
34
+ * @returns New, empty DLOB object.
35
+ */
36
+ protected createDLOB(): DLOB;
31
37
  getDLOB(slot: number): Promise<DLOB>;
32
38
  getSlot(): number;
33
39
  unsubscribe(): Promise<void>;
@@ -141,8 +141,16 @@ class OrderSubscriber {
141
141
  }
142
142
  }
143
143
  }
144
+ /**
145
+ * Creates a new DLOB for the order subscriber to fill. This will allow a
146
+ * caller to extend the DLOB Subscriber with a custom DLOB type.
147
+ * @returns New, empty DLOB object.
148
+ */
149
+ createDLOB() {
150
+ return new DLOB_1.DLOB();
151
+ }
144
152
  async getDLOB(slot) {
145
- const dlob = new DLOB_1.DLOB();
153
+ const dlob = this.createDLOB();
146
154
  for (const [key, { userAccount }] of this.usersAccounts.entries()) {
147
155
  for (const order of userAccount.orders) {
148
156
  dlob.insertOrder(order, key, slot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.93.0-beta.0",
3
+ "version": "2.93.0-beta.10",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -44,7 +44,7 @@
44
44
  "@pythnetwork/pyth-solana-receiver": "^0.7.0",
45
45
  "@solana/spl-token": "0.3.7",
46
46
  "@solana/web3.js": "1.92.3",
47
- "@switchboard-xyz/on-demand": "1.2.1",
47
+ "@switchboard-xyz/on-demand": "1.2.32",
48
48
  "anchor-bankrun": "^0.3.0",
49
49
  "node-cache": "^5.1.2",
50
50
  "rpc-websockets": "7.5.1",
@@ -780,6 +780,36 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
780
780
  pythFeedId:
781
781
  '0x5169491cd7e2a44c98353b779d5eb612e4ac32e073f5cc534303d86307c2f1bc',
782
782
  },
783
+ {
784
+ fullName: 'TRUMP-WIN-2024-BET',
785
+ category: ['Prediction', 'Election'],
786
+ symbol: 'TRUMP-WIN-2024-BET',
787
+ baseAssetSymbol: 'TRUMP-WIN-2024',
788
+ marketIndex: 36,
789
+ oracle: new PublicKey('7YrQUxmxGdbk8pvns9KcL5ojbZSL2eHj62hxRqggtEUR'),
790
+ launchTs: 1723996800000,
791
+ oracleSource: OracleSource.Prelaunch,
792
+ },
793
+ {
794
+ fullName: 'KAMALA-POPULAR-VOTE-2024-BET',
795
+ category: ['Prediction', 'Election'],
796
+ symbol: 'KAMALA-POPULAR-VOTE-2024-BET',
797
+ baseAssetSymbol: 'KAMALA-POPULAR-VOTE-2024',
798
+ marketIndex: 37,
799
+ oracle: new PublicKey('AowFw1dCVjS8kngvTCoT3oshiUyL69k7P1uxqXwteWH4'),
800
+ launchTs: 1723996800000,
801
+ oracleSource: OracleSource.Prelaunch,
802
+ },
803
+ {
804
+ fullName: 'FED-CUT-50-SEPT-2024-BET',
805
+ category: ['Prediction', 'Election'],
806
+ symbol: 'FED-CUT-50-SEPT-2024-BET',
807
+ baseAssetSymbol: 'FED-CUT-50-SEPT-2024',
808
+ marketIndex: 38,
809
+ oracle: new PublicKey('5QzgqAbEhJ1cPnLX4tSZEXezmW7sz7PPVVg2VanGi8QQ'),
810
+ launchTs: 1724250126000,
811
+ oracleSource: OracleSource.Prelaunch,
812
+ },
783
813
  ];
784
814
 
785
815
  export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {
@@ -123,7 +123,7 @@ export const MainnetSpotMarkets: SpotMarketConfig[] = [
123
123
  {
124
124
  symbol: 'wBTC',
125
125
  marketIndex: 3,
126
- oracle: new PublicKey('486kr3pmFPfTsS4aZgcsQ7kS4i9rjMsYYZup6HQNSTT4'),
126
+ oracle: new PublicKey('9Tq8iN5WnMX2PcZGj4iSFEAgHCi8cM6x8LsDUbuzq8uw'),
127
127
  oracleSource: OracleSource.PYTH_PULL,
128
128
  mint: new PublicKey('3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh'),
129
129
  precision: new BN(10).pow(EIGHT),
package/src/dlob/DLOB.ts CHANGED
@@ -1104,7 +1104,7 @@ export class DLOB {
1104
1104
  );
1105
1105
  }
1106
1106
 
1107
- private *getBestNode(
1107
+ protected *getBestNode(
1108
1108
  generatorList: Array<Generator<DLOBNode>>,
1109
1109
  oraclePriceData: OraclePriceData,
1110
1110
  slot: number,
@@ -5946,6 +5946,40 @@ export class DriftClient {
5946
5946
  );
5947
5947
  }
5948
5948
 
5949
+ public async getSetUserStatusToBeingLiquidatedIx(
5950
+ userAccountPublicKey: PublicKey,
5951
+ userAccount: UserAccount
5952
+ ): Promise<TransactionInstruction> {
5953
+ const remainingAccounts = this.getRemainingAccounts({
5954
+ userAccounts: [userAccount],
5955
+ });
5956
+ return await this.program.instruction.setUserStatusToBeingLiquidated({
5957
+ accounts: {
5958
+ state: await this.getStatePublicKey(),
5959
+ user: userAccountPublicKey,
5960
+ authority: this.wallet.publicKey,
5961
+ },
5962
+ remainingAccounts,
5963
+ });
5964
+ }
5965
+
5966
+ public async setUserStatusToBeingLiquidated(
5967
+ userAccountPublicKey: PublicKey,
5968
+ userAccount: UserAccount
5969
+ ): Promise<TransactionSignature> {
5970
+ const { txSig } = await this.sendTransaction(
5971
+ await this.buildTransaction(
5972
+ await this.getSetUserStatusToBeingLiquidatedIx(
5973
+ userAccountPublicKey,
5974
+ userAccount
5975
+ )
5976
+ ),
5977
+ [],
5978
+ this.opts
5979
+ );
5980
+ return txSig;
5981
+ }
5982
+
5949
5983
  public async liquidatePerp(
5950
5984
  userAccountPublicKey: PublicKey,
5951
5985
  userAccount: UserAccount,
@@ -1881,6 +1881,22 @@
1881
1881
  }
1882
1882
  ]
1883
1883
  },
1884
+ {
1885
+ "name": "setUserStatusToBeingLiquidated",
1886
+ "accounts": [
1887
+ {
1888
+ "name": "state",
1889
+ "isMut": false,
1890
+ "isSigner": false
1891
+ },
1892
+ {
1893
+ "name": "user",
1894
+ "isMut": true,
1895
+ "isSigner": false
1896
+ }
1897
+ ],
1898
+ "args": []
1899
+ },
1884
1900
  {
1885
1901
  "name": "resolvePerpPnlDeficit",
1886
1902
  "accounts": [
@@ -2259,7 +2275,7 @@
2259
2275
  },
2260
2276
  {
2261
2277
  "name": "spotMarket",
2262
- "isMut": false,
2278
+ "isMut": true,
2263
2279
  "isSigner": false
2264
2280
  },
2265
2281
  {
@@ -2295,7 +2311,7 @@
2295
2311
  },
2296
2312
  {
2297
2313
  "name": "spotMarket",
2298
- "isMut": false,
2314
+ "isMut": true,
2299
2315
  "isSigner": false
2300
2316
  },
2301
2317
  {
package/src/math/amm.ts CHANGED
@@ -866,7 +866,7 @@ export function getQuoteAssetReservePredictionMarketBounds(
866
866
  .div(amm.pegMultiplier);
867
867
 
868
868
  if (direction === PositionDirection.LONG) {
869
- quoteAssetReserveLowerBound = this.amm.sqrtK
869
+ quoteAssetReserveLowerBound = amm.sqrtK
870
870
  .muln(22361)
871
871
  .mul(pegSqrt)
872
872
  .divn(100000)
@@ -217,8 +217,17 @@ export class OrderSubscriber {
217
217
  }
218
218
  }
219
219
 
220
+ /**
221
+ * Creates a new DLOB for the order subscriber to fill. This will allow a
222
+ * caller to extend the DLOB Subscriber with a custom DLOB type.
223
+ * @returns New, empty DLOB object.
224
+ */
225
+ protected createDLOB(): DLOB {
226
+ return new DLOB();
227
+ }
228
+
220
229
  public async getDLOB(slot: number): Promise<DLOB> {
221
- const dlob = new DLOB();
230
+ const dlob = this.createDLOB();
222
231
  for (const [key, { userAccount }] of this.usersAccounts.entries()) {
223
232
  for (const order of userAccount.orders) {
224
233
  dlob.insertOrder(order, key, slot);
@@ -0,0 +1,53 @@
1
+ import {
2
+ DriftClient,
3
+ BulkAccountLoader,
4
+ } from '../../src';
5
+ import { Connection, Keypair } from '@solana/web3.js';
6
+ import { Wallet, Program } from '@coral-xyz/anchor';
7
+ import dotenv from 'dotenv';
8
+ import { assert } from 'chai';
9
+ import driftIDL from '../../src/idl/drift.json';
10
+
11
+ dotenv.config();
12
+
13
+ describe('Verify IDL', function () {
14
+ this.timeout(100_000);
15
+ const MAINNET_RPC_ENDPOINT = process.env.MAINNET_RPC_ENDPOINT;
16
+
17
+ // avoid breaking pre-commit
18
+ if (MAINNET_RPC_ENDPOINT === undefined) {
19
+ return;
20
+ }
21
+
22
+ const wallet = new Wallet(Keypair.generate());
23
+
24
+ const mainnetConnection = new Connection(MAINNET_RPC_ENDPOINT);
25
+
26
+ const mainnetBulkAccountLoader = new BulkAccountLoader(
27
+ mainnetConnection,
28
+ 'processed',
29
+ 1
30
+ );
31
+
32
+ const mainnetDriftClient = new DriftClient({
33
+ connection: mainnetConnection,
34
+ wallet,
35
+ env: 'mainnet-beta',
36
+ accountSubscription: {
37
+ type: 'polling',
38
+ accountLoader: mainnetBulkAccountLoader,
39
+ },
40
+ });
41
+
42
+ it('verify idl', async () => {
43
+ const idl = await Program.fetchIdl(mainnetDriftClient.program.programId, mainnetDriftClient.provider);
44
+
45
+ // anchor idl init seems to strip the metadata
46
+ idl["metadata"] = {"address":"dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"};
47
+ const encodedMainnetIdl = JSON.stringify(idl);
48
+
49
+ const encodedSdkIdl = JSON.stringify(driftIDL);
50
+
51
+ assert(encodedSdkIdl === encodedMainnetIdl);
52
+ });
53
+ });
@@ -20,7 +20,7 @@ describe('Verify Constants', function () {
20
20
  const DEVNET_RPC_ENDPOINT = process.env.DEVNET_RPC_ENDPOINT;
21
21
 
22
22
  // avoid breaking pre-commit
23
- if (MAINNET_RPC_ENDPOINT === undefined && DEVNET_RPC_ENDPOINT === undefined) {
23
+ if (MAINNET_RPC_ENDPOINT === undefined || DEVNET_RPC_ENDPOINT === undefined) {
24
24
  return;
25
25
  }
26
26
 
@@ -367,6 +367,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
367
367
  fuelBoostTaker: 0,
368
368
  fuelBoostMaker: 0,
369
369
  fuelBoostInsurance: 0,
370
+ tokenProgram: 0,
370
371
  },
371
372
  {
372
373
  status: MarketStatus.ACTIVE,
@@ -457,6 +458,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
457
458
  fuelBoostTaker: 0,
458
459
  fuelBoostMaker: 0,
459
460
  fuelBoostInsurance: 0,
461
+ tokenProgram: 0,
460
462
  },
461
463
  {
462
464
  status: MarketStatus.ACTIVE,
@@ -547,6 +549,7 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
547
549
  fuelBoostTaker: 0,
548
550
  fuelBoostMaker: 0,
549
551
  fuelBoostInsurance: 0,
552
+ tokenProgram: 0,
550
553
  },
551
554
  ];
552
555
 
@@ -4931,15 +4931,10 @@ describe('DLOB Spot Tests', () => {
4931
4931
  `cross found: taker orderId: ${n.node.order?.orderId.toString()}: BAA: ${n.node.order?.baseAssetAmountFilled.toString()}/${n.node.order?.baseAssetAmount.toString()}, maker orderId: ${n.makerNodes[0]?.order?.orderId.toString()}: BAA: ${n.makerNodes[0]?.order?.baseAssetAmountFilled.toString()}/${n.makerNodes[0]?.order?.baseAssetAmount.toString()}`
4932
4932
  );
4933
4933
  }
4934
- expect(nodesToFillAfter.length).to.equal(2);
4934
+ expect(nodesToFillAfter.length).to.equal(1);
4935
4935
 
4936
4936
  // taker should fill completely with best maker
4937
- expect(nodesToFillAfter[0].node.order?.orderId).to.equal(4);
4938
- expect(nodesToFillAfter[0].makerNodes[0]?.order?.orderId).to.equal(3);
4939
-
4940
- // taker should fill completely with second best maker
4941
- expect(nodesToFillAfter[1].node.order?.orderId).to.equal(4);
4942
- expect(nodesToFillAfter[1].makerNodes[0]?.order?.orderId).to.equal(2);
4937
+ expect(nodesToFillAfter[0].makerNodes.length).to.equal(2);
4943
4938
  });
4944
4939
 
4945
4940
  it('Test two market orders to fill one limit order', () => {
@@ -5,6 +5,10 @@ describe('openbook v2 subscriber', function () {
5
5
  this.timeout(100_000);
6
6
 
7
7
  it('works', async function () {
8
+ if (!process.env.MAINNET_RPC_ENDPOINT) {
9
+ return;
10
+ }
11
+
8
12
  const connection = new Connection(
9
13
  process.env.MAINNET_RPC_ENDPOINT as string
10
14
  );
@@ -82,10 +82,22 @@ async function makeMockUser(
82
82
  };
83
83
  }
84
84
 
85
+ function getOracleDataForPerpMarket(marketIndex) {
86
+ const oracle = getMockPerpMarket(marketIndex).amm.oracle;
87
+ return getMockOracle(oracle).data;
88
+ }
89
+
90
+ function getOracleDataForSpotMarket(marketIndex) {
91
+ const oracle = getMockSpotMarket(marketIndex).oracle;
92
+ return getMockOracle(oracle).data;
93
+ }
94
+
85
95
  mockUser.getUserAccount = getMockUserAccount;
86
96
  mockUser.driftClient.getPerpMarketAccount = getMockPerpMarket;
87
97
  mockUser.driftClient.getSpotMarketAccount = getMockSpotMarket;
88
98
  mockUser.driftClient.getOraclePriceDataAndSlot = getMockOracle;
99
+ mockUser.driftClient.getOracleDataForPerpMarket = getOracleDataForPerpMarket;
100
+ mockUser.driftClient.getOracleDataForSpotMarket = getOracleDataForSpotMarket;
89
101
  return mockUser;
90
102
  }
91
103