@drift-labs/sdk 2.93.0-beta.8 → 2.94.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.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.93.0-beta.8
1
+ 2.94.0-beta.0
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.92.0",
2
+ "version": "2.93.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.93.0-beta.8",
3
+ "version": "2.94.0-beta.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.92.0",
2
+ "version": "2.93.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -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