@drift-labs/sdk 2.86.0-beta.32 → 2.86.0-beta.34

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.32
1
+ 2.86.0-beta.34
@@ -91,8 +91,8 @@ export declare class AdminClient extends DriftClient {
91
91
  getUpdateSpotMarketRevenueSettlePeriodIx(spotMarketIndex: number, revenueSettlePeriod: BN): Promise<TransactionInstruction>;
92
92
  updateSpotMarketMaxTokenDeposits(spotMarketIndex: number, maxTokenDeposits: BN): Promise<TransactionSignature>;
93
93
  getUpdateSpotMarketMaxTokenDepositsIx(spotMarketIndex: number, maxTokenDeposits: BN): Promise<TransactionInstruction>;
94
- updateSpotMarketMaxTokenBorrows(spotMarketIndex: number, maxTokenBorrows: BN): Promise<TransactionSignature>;
95
- getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex: number, maxTokenBorrows: BN): Promise<TransactionInstruction>;
94
+ updateSpotMarketMaxTokenBorrows(spotMarketIndex: number, maxTokenBorrowsFraction: number): Promise<TransactionSignature>;
95
+ getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex: number, maxTokenBorrowsFraction: number): Promise<TransactionInstruction>;
96
96
  updateSpotMarketScaleInitialAssetWeightStart(spotMarketIndex: number, scaleInitialAssetWeightStart: BN): Promise<TransactionSignature>;
97
97
  getUpdateSpotMarketScaleInitialAssetWeightStartIx(spotMarketIndex: number, scaleInitialAssetWeightStart: BN): Promise<TransactionInstruction>;
98
98
  updateInsuranceFundUnstakingPeriod(spotMarketIndex: number, insuranceWithdrawEscrowPeriod: BN): Promise<TransactionSignature>;
@@ -857,14 +857,14 @@ class AdminClient extends driftClient_1.DriftClient {
857
857
  },
858
858
  });
859
859
  }
860
- async updateSpotMarketMaxTokenBorrows(spotMarketIndex, maxTokenBorrows) {
861
- const updateSpotMarketMaxTokenBorrowsIx = await this.getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrows);
860
+ async updateSpotMarketMaxTokenBorrows(spotMarketIndex, maxTokenBorrowsFraction) {
861
+ const updateSpotMarketMaxTokenBorrowsIx = await this.getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrowsFraction);
862
862
  const tx = await this.buildTransaction(updateSpotMarketMaxTokenBorrowsIx);
863
863
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
864
864
  return txSig;
865
865
  }
866
- async getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrows) {
867
- return this.program.instruction.updateSpotMarketMaxTokenBorrows(maxTokenBorrows, {
866
+ async getUpdateSpotMarketMaxTokenBorrowsIx(spotMarketIndex, maxTokenBorrowsFraction) {
867
+ return this.program.instruction.updateSpotMarketMaxTokenBorrows(maxTokenBorrowsFraction, {
868
868
  accounts: {
869
869
  admin: this.isSubscribed
870
870
  ? this.getStateAccount().admin
@@ -3476,6 +3476,9 @@ class DriftClient {
3476
3476
  const isSolMarket = spotMarketAccount.mint.equals(spotMarkets_1.WRAPPED_SOL_MINT);
3477
3477
  const createWSOLTokenAccount = isSolMarket && collateralAccountPublicKey.equals(this.wallet.publicKey);
3478
3478
  let tokenAccount;
3479
+ if (!(await this.checkIfAccountExists(this.getUserStatsAccountPublicKey()))) {
3480
+ addIfStakeIxs.push(await this.getInitializeUserStatsIx());
3481
+ }
3479
3482
  if (createWSOLTokenAccount) {
3480
3483
  const { ixs, pubkey } = await this.getWrappedSolAccountCreationIxs(amount, true);
3481
3484
  tokenAccount = pubkey;
@@ -4200,6 +4200,32 @@
4200
4200
  }
4201
4201
  ]
4202
4202
  },
4203
+ {
4204
+ "name": "updateSpotMarketMaxTokenBorrows",
4205
+ "accounts": [
4206
+ {
4207
+ "name": "admin",
4208
+ "isMut": false,
4209
+ "isSigner": true
4210
+ },
4211
+ {
4212
+ "name": "state",
4213
+ "isMut": false,
4214
+ "isSigner": false
4215
+ },
4216
+ {
4217
+ "name": "spotMarket",
4218
+ "isMut": true,
4219
+ "isSigner": false
4220
+ }
4221
+ ],
4222
+ "args": [
4223
+ {
4224
+ "name": "maxTokenBorrowsFraction",
4225
+ "type": "u16"
4226
+ }
4227
+ ]
4228
+ },
4203
4229
  {
4204
4230
  "name": "updateSpotMarketScaleInitialAssetWeightStart",
4205
4231
  "accounts": [
@@ -9994,6 +10020,9 @@
9994
10020
  {
9995
10021
  "name": "Fill"
9996
10022
  },
10023
+ {
10024
+ "name": "Deposit"
10025
+ },
9997
10026
  {
9998
10027
  "name": "Withdraw"
9999
10028
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.86.0-beta.32",
3
+ "version": "2.86.0-beta.34",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1870,12 +1870,12 @@ export class AdminClient extends DriftClient {
1870
1870
 
1871
1871
  public async updateSpotMarketMaxTokenBorrows(
1872
1872
  spotMarketIndex: number,
1873
- maxTokenBorrows: BN
1873
+ maxTokenBorrowsFraction: number
1874
1874
  ): Promise<TransactionSignature> {
1875
1875
  const updateSpotMarketMaxTokenBorrowsIx =
1876
1876
  await this.getUpdateSpotMarketMaxTokenBorrowsIx(
1877
1877
  spotMarketIndex,
1878
- maxTokenBorrows
1878
+ maxTokenBorrowsFraction
1879
1879
  );
1880
1880
 
1881
1881
  const tx = await this.buildTransaction(updateSpotMarketMaxTokenBorrowsIx);
@@ -1887,10 +1887,10 @@ export class AdminClient extends DriftClient {
1887
1887
 
1888
1888
  public async getUpdateSpotMarketMaxTokenBorrowsIx(
1889
1889
  spotMarketIndex: number,
1890
- maxTokenBorrows: BN
1890
+ maxTokenBorrowsFraction: number
1891
1891
  ): Promise<TransactionInstruction> {
1892
1892
  return this.program.instruction.updateSpotMarketMaxTokenBorrows(
1893
- maxTokenBorrows,
1893
+ maxTokenBorrowsFraction,
1894
1894
  {
1895
1895
  accounts: {
1896
1896
  admin: this.isSubscribed
@@ -6587,6 +6587,12 @@ export class DriftClient {
6587
6587
 
6588
6588
  let tokenAccount;
6589
6589
 
6590
+ if (
6591
+ !(await this.checkIfAccountExists(this.getUserStatsAccountPublicKey()))
6592
+ ) {
6593
+ addIfStakeIxs.push(await this.getInitializeUserStatsIx());
6594
+ }
6595
+
6590
6596
  if (createWSOLTokenAccount) {
6591
6597
  const { ixs, pubkey } = await this.getWrappedSolAccountCreationIxs(
6592
6598
  amount,
@@ -4200,6 +4200,32 @@
4200
4200
  }
4201
4201
  ]
4202
4202
  },
4203
+ {
4204
+ "name": "updateSpotMarketMaxTokenBorrows",
4205
+ "accounts": [
4206
+ {
4207
+ "name": "admin",
4208
+ "isMut": false,
4209
+ "isSigner": true
4210
+ },
4211
+ {
4212
+ "name": "state",
4213
+ "isMut": false,
4214
+ "isSigner": false
4215
+ },
4216
+ {
4217
+ "name": "spotMarket",
4218
+ "isMut": true,
4219
+ "isSigner": false
4220
+ }
4221
+ ],
4222
+ "args": [
4223
+ {
4224
+ "name": "maxTokenBorrowsFraction",
4225
+ "type": "u16"
4226
+ }
4227
+ ]
4228
+ },
4203
4229
  {
4204
4230
  "name": "updateSpotMarketScaleInitialAssetWeightStart",
4205
4231
  "accounts": [
@@ -9994,6 +10020,9 @@
9994
10020
  {
9995
10021
  "name": "Fill"
9996
10022
  },
10023
+ {
10024
+ "name": "Deposit"
10025
+ },
9997
10026
  {
9998
10027
  "name": "Withdraw"
9999
10028
  },
@@ -17,19 +17,19 @@ dotenv.config();
17
17
  describe('Verify Constants', function () {
18
18
  this.timeout(100_000);
19
19
  const MAINNET_RPC_ENDPOINT = process.env.MAINNET_RPC_ENDPOINT;
20
- const DEVNET_RPC_ENDPOINT = process.env.DEVNET_RPC_ENDPOINT;
20
+ const DEVNET_RPC_ENDPOINT = process.env.DEVNET_RPC_ENDPOINT;
21
21
 
22
22
  if (MAINNET_RPC_ENDPOINT === undefined) {
23
- throw new Error("MAINNET_RPC_ENDPOINT not found in .env");
23
+ throw new Error('MAINNET_RPC_ENDPOINT not found in .env');
24
24
  }
25
25
 
26
- if (DEVNET_RPC_ENDPOINT === undefined) {
27
- throw new Error("DEVNET_RPC_ENDPOINT not found in .env");
26
+ if (DEVNET_RPC_ENDPOINT === undefined) {
27
+ throw new Error('DEVNET_RPC_ENDPOINT not found in .env');
28
28
  }
29
29
 
30
30
  const wallet = new Wallet(Keypair.generate());
31
31
 
32
- const devnetConnection = new Connection(DEVNET_RPC_ENDPOINT);
32
+ const devnetConnection = new Connection(DEVNET_RPC_ENDPOINT);
33
33
  const mainnetConnection = new Connection(MAINNET_RPC_ENDPOINT);
34
34
 
35
35
  const devnetBulkAccountLoader = new BulkAccountLoader(
@@ -76,7 +76,7 @@ describe('Verify Constants', function () {
76
76
 
77
77
  it('has all mainnet markets', async () => {
78
78
  const spotMarkets = mainnetDriftClient.getSpotMarketAccounts();
79
- spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
79
+ spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
80
80
 
81
81
  for (const market of spotMarkets) {
82
82
  const correspondingConfigMarket = MainnetSpotMarkets.find(
@@ -112,7 +112,7 @@ describe('Verify Constants', function () {
112
112
  }
113
113
 
114
114
  const perpMarkets = mainnetDriftClient.getPerpMarketAccounts();
115
- perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
115
+ perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
116
116
 
117
117
  for (const market of perpMarkets) {
118
118
  const correspondingConfigMarket = MainnetPerpMarkets.find(
@@ -145,7 +145,7 @@ describe('Verify Constants', function () {
145
145
 
146
146
  it('has all devnet markets', async () => {
147
147
  const spotMarkets = devnetDriftClient.getSpotMarketAccounts();
148
- spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
148
+ spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
149
149
 
150
150
  for (const market of spotMarkets) {
151
151
  const correspondingConfigMarket = DevnetSpotMarkets.find(
@@ -181,7 +181,7 @@ describe('Verify Constants', function () {
181
181
  }
182
182
 
183
183
  const perpMarkets = devnetDriftClient.getPerpMarketAccounts();
184
- perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
184
+ perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
185
185
 
186
186
  for (const market of perpMarkets) {
187
187
  const correspondingConfigMarket = DevnetPerpMarkets.find(