@drift-labs/sdk 2.41.0-beta.1 → 2.41.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.
package/VERSION CHANGED
@@ -1 +1 @@
1
- 2.41.0-beta.1
1
+ 2.41.0-beta.3
@@ -67,6 +67,7 @@ export declare class AdminClient extends DriftClient {
67
67
  updatePerpMarketUnrealizedAssetWeight(perpMarketIndex: number, unrealizedInitialAssetWeight: number, unrealizedMaintenanceAssetWeight: number): Promise<TransactionSignature>;
68
68
  updatePerpMarketMaxImbalances(perpMarketIndex: number, unrealizedMaxImbalance: BN, maxRevenueWithdrawPerPeriod: BN, quoteMaxInsurance: BN): Promise<TransactionSignature>;
69
69
  updatePerpMarketMaxOpenInterest(perpMarketIndex: number, maxOpenInterest: BN): Promise<TransactionSignature>;
70
+ updatePerpMarketFeeAdjustment(perpMarketIndex: number, feeAdjustment: number): Promise<TransactionSignature>;
70
71
  updateSerumVault(srmVault: PublicKey): Promise<TransactionSignature>;
71
72
  updatePerpMarketLiquidationFee(perpMarketIndex: number, liquidatorFee: number, ifLiquidationFee: number): Promise<TransactionSignature>;
72
73
  updateSpotMarketLiquidationFee(spotMarketIndex: number, liquidatorFee: number, ifLiquidationFee: number): Promise<TransactionSignature>;
@@ -764,6 +764,15 @@ class AdminClient extends driftClient_1.DriftClient {
764
764
  },
765
765
  });
766
766
  }
767
+ async updatePerpMarketFeeAdjustment(perpMarketIndex, feeAdjustment) {
768
+ return await this.program.rpc.updatePerpMarketFeeAdjustment(feeAdjustment, {
769
+ accounts: {
770
+ admin: this.wallet.publicKey,
771
+ state: await this.getStatePublicKey(),
772
+ perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
773
+ },
774
+ });
775
+ }
767
776
  async updateSerumVault(srmVault) {
768
777
  return await this.program.rpc.updateSerumVault({
769
778
  accounts: {
@@ -925,29 +925,27 @@ class DriftClient {
925
925
  * @param reduceOnly
926
926
  */
927
927
  async deposit(amount, marketIndex, associatedTokenAccount, subAccountId, reduceOnly = false) {
928
- const tx = new web3_js_1.Transaction();
929
- tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
930
- units: 600000,
931
- }));
928
+ const ixs = [];
932
929
  const additionalSigners = [];
933
930
  const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
934
931
  const isSolMarket = spotMarketAccount.mint.equals(spotMarkets_1.WRAPPED_SOL_MINT);
935
932
  const signerAuthority = this.wallet.publicKey;
936
933
  const createWSOLTokenAccount = isSolMarket && associatedTokenAccount.equals(signerAuthority);
937
934
  if (createWSOLTokenAccount) {
938
- const { ixs, pubkey } = await this.getWrappedSolAccountCreationIxs(amount, true);
935
+ const { ixs: wrappedSolIxs, pubkey } = await this.getWrappedSolAccountCreationIxs(amount, true);
939
936
  associatedTokenAccount = pubkey;
940
- ixs.forEach((ix) => {
941
- tx.add(ix);
937
+ wrappedSolIxs.forEach((ix) => {
938
+ ixs.push(ix);
942
939
  });
943
940
  }
944
941
  const depositCollateralIx = await this.getDepositInstruction(amount, marketIndex, associatedTokenAccount, subAccountId, reduceOnly, true);
945
- tx.add(depositCollateralIx);
942
+ ixs.push(depositCollateralIx);
946
943
  // Close the wrapped sol account at the end of the transaction
947
944
  if (createWSOLTokenAccount) {
948
- tx.add((0, spl_token_1.createCloseAccountInstruction)(associatedTokenAccount, signerAuthority, signerAuthority, []));
945
+ ixs.push((0, spl_token_1.createCloseAccountInstruction)(associatedTokenAccount, signerAuthority, signerAuthority, []));
949
946
  }
950
- const { txSig, slot } = await this.sendTransaction(tx, additionalSigners, this.opts);
947
+ console.log(ixs);
948
+ const { txSig, slot } = await this.sendTransaction(await this.buildTransaction(ixs, { computeUnits: 600000 }, 0), additionalSigners, this.opts);
951
949
  this.spotMarketLastSlotCache.set(marketIndex, slot);
952
950
  return txSig;
953
951
  }
package/lib/types.d.ts CHANGED
@@ -664,6 +664,7 @@ export type PerpMarketAccount = {
664
664
  quoteMaxInsurance: BN;
665
665
  };
666
666
  quoteSpotMarketIndex: number;
667
+ feeAdjustment: number;
667
668
  };
668
669
  export type HistoricalOracleData = {
669
670
  lastOraclePrice: BN;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.41.0-beta.1",
3
+ "version": "2.41.0-beta.3",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1464,6 +1464,22 @@ export class AdminClient extends DriftClient {
1464
1464
  );
1465
1465
  }
1466
1466
 
1467
+ public async updatePerpMarketFeeAdjustment(
1468
+ perpMarketIndex: number,
1469
+ feeAdjustment: number
1470
+ ): Promise<TransactionSignature> {
1471
+ return await this.program.rpc.updatePerpMarketFeeAdjustment(feeAdjustment, {
1472
+ accounts: {
1473
+ admin: this.wallet.publicKey,
1474
+ state: await this.getStatePublicKey(),
1475
+ perpMarket: await getPerpMarketPublicKey(
1476
+ this.program.programId,
1477
+ perpMarketIndex
1478
+ ),
1479
+ },
1480
+ });
1481
+ }
1482
+
1467
1483
  public async updateSerumVault(
1468
1484
  srmVault: PublicKey
1469
1485
  ): Promise<TransactionSignature> {
@@ -1557,12 +1557,7 @@ export class DriftClient {
1557
1557
  subAccountId?: number,
1558
1558
  reduceOnly = false
1559
1559
  ): Promise<TransactionSignature> {
1560
- const tx = new Transaction();
1561
- tx.add(
1562
- ComputeBudgetProgram.setComputeUnitLimit({
1563
- units: 600_000,
1564
- })
1565
- );
1560
+ const ixs: Array<TransactionInstruction> = [];
1566
1561
 
1567
1562
  const additionalSigners: Array<Signer> = [];
1568
1563
 
@@ -1576,15 +1571,13 @@ export class DriftClient {
1576
1571
  isSolMarket && associatedTokenAccount.equals(signerAuthority);
1577
1572
 
1578
1573
  if (createWSOLTokenAccount) {
1579
- const { ixs, pubkey } = await this.getWrappedSolAccountCreationIxs(
1580
- amount,
1581
- true
1582
- );
1574
+ const { ixs: wrappedSolIxs, pubkey } =
1575
+ await this.getWrappedSolAccountCreationIxs(amount, true);
1583
1576
 
1584
1577
  associatedTokenAccount = pubkey;
1585
1578
 
1586
- ixs.forEach((ix) => {
1587
- tx.add(ix);
1579
+ wrappedSolIxs.forEach((ix) => {
1580
+ ixs.push(ix);
1588
1581
  });
1589
1582
  }
1590
1583
 
@@ -1597,11 +1590,11 @@ export class DriftClient {
1597
1590
  true
1598
1591
  );
1599
1592
 
1600
- tx.add(depositCollateralIx);
1593
+ ixs.push(depositCollateralIx);
1601
1594
 
1602
1595
  // Close the wrapped sol account at the end of the transaction
1603
1596
  if (createWSOLTokenAccount) {
1604
- tx.add(
1597
+ ixs.push(
1605
1598
  createCloseAccountInstruction(
1606
1599
  associatedTokenAccount,
1607
1600
  signerAuthority,
@@ -1611,8 +1604,9 @@ export class DriftClient {
1611
1604
  );
1612
1605
  }
1613
1606
 
1607
+ console.log(ixs);
1614
1608
  const { txSig, slot } = await this.sendTransaction(
1615
- tx,
1609
+ await this.buildTransaction(ixs, { computeUnits: 600_000 }, 0),
1616
1610
  additionalSigners,
1617
1611
  this.opts
1618
1612
  );
package/src/types.ts CHANGED
@@ -585,6 +585,7 @@ export type PerpMarketAccount = {
585
585
  quoteMaxInsurance: BN;
586
586
  };
587
587
  quoteSpotMarketIndex: number;
588
+ feeAdjustment: number;
588
589
  };
589
590
 
590
591
  export type HistoricalOracleData = {
@@ -178,6 +178,7 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
178
178
  quoteMaxInsurance: new BN(0),
179
179
  },
180
180
  quoteSpotMarketIndex: 0,
181
+ feeAdjustment: 0,
181
182
  },
182
183
  {
183
184
  status: MarketStatus.INITIALIZED,
@@ -215,6 +216,7 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
215
216
  quoteMaxInsurance: new BN(0),
216
217
  },
217
218
  quoteSpotMarketIndex: 0,
219
+ feeAdjustment: 0,
218
220
  },
219
221
  {
220
222
  status: MarketStatus.INITIALIZED,
@@ -252,6 +254,7 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
252
254
  quoteMaxInsurance: new BN(0),
253
255
  },
254
256
  quoteSpotMarketIndex: 0,
257
+ feeAdjustment: 0,
255
258
  },
256
259
  ];
257
260