@drift-labs/sdk 2.41.0-beta.1 → 2.41.0-beta.2

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.2
@@ -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/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.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -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
  );