@drift-labs/sdk 2.53.0-beta.6 → 2.53.0-beta.8
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.53.0-beta.
|
|
1
|
+
2.53.0-beta.8
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -213,7 +213,7 @@ export declare class DriftClient {
|
|
|
213
213
|
* @param subAccountId subaccountId to deposit
|
|
214
214
|
* @param reduceOnly if true, deposit must not increase account risk
|
|
215
215
|
*/
|
|
216
|
-
deposit(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
216
|
+
deposit(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, txParams?: TxParams): Promise<TransactionSignature>;
|
|
217
217
|
getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
|
|
218
218
|
private checkIfAccountExists;
|
|
219
219
|
getWrappedSolAccountCreationIxs(amount: BN, includeRent?: boolean): Promise<{
|
package/lib/driftClient.js
CHANGED
|
@@ -979,7 +979,7 @@ class DriftClient {
|
|
|
979
979
|
* @param subAccountId subaccountId to deposit
|
|
980
980
|
* @param reduceOnly if true, deposit must not increase account risk
|
|
981
981
|
*/
|
|
982
|
-
async deposit(amount, marketIndex, associatedTokenAccount, subAccountId, reduceOnly = false) {
|
|
982
|
+
async deposit(amount, marketIndex, associatedTokenAccount, subAccountId, reduceOnly = false, txParams) {
|
|
983
983
|
const additionalSigners = [];
|
|
984
984
|
const spotMarketAccount = this.getSpotMarketAccount(marketIndex);
|
|
985
985
|
const isSolMarket = spotMarketAccount.mint.equals(spotMarkets_1.WRAPPED_SOL_MINT);
|
|
@@ -997,7 +997,7 @@ class DriftClient {
|
|
|
997
997
|
if (createWSOLTokenAccount) {
|
|
998
998
|
instructions.push((0, spl_token_1.createCloseAccountInstruction)(associatedTokenAccount, signerAuthority, signerAuthority, []));
|
|
999
999
|
}
|
|
1000
|
-
|
|
1000
|
+
txParams = { ...(txParams !== null && txParams !== void 0 ? txParams : this.txParams), computeUnits: 600000 };
|
|
1001
1001
|
const tx = await this.buildTransaction(instructions, txParams);
|
|
1002
1002
|
const { txSig, slot } = await this.sendTransaction(tx, additionalSigners, this.opts);
|
|
1003
1003
|
this.spotMarketLastSlotCache.set(marketIndex, slot);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { TxSigAndSlot } from './types';
|
|
3
|
-
import { ConfirmOptions, Signer, Transaction, Connection, VersionedTransaction, TransactionInstruction, AddressLookupTableAccount } from '@solana/web3.js';
|
|
3
|
+
import { ConfirmOptions, Signer, Transaction, Connection, VersionedTransaction, TransactionInstruction, AddressLookupTableAccount, Commitment } from '@solana/web3.js';
|
|
4
4
|
import { IWallet } from '../types';
|
|
5
5
|
import { BaseTxSender } from './baseTxSender';
|
|
6
6
|
export declare class FastSingleTxSender extends BaseTxSender {
|
|
@@ -13,7 +13,8 @@ export declare class FastSingleTxSender extends BaseTxSender {
|
|
|
13
13
|
timoutCount: number;
|
|
14
14
|
recentBlockhash: string;
|
|
15
15
|
skipConfirmation: boolean;
|
|
16
|
-
|
|
16
|
+
blockhashCommitment: Commitment;
|
|
17
|
+
constructor({ connection, wallet, opts, timeout, blockhashRefreshInterval, additionalConnections, skipConfirmation, blockhashCommitment, }: {
|
|
17
18
|
connection: Connection;
|
|
18
19
|
wallet: IWallet;
|
|
19
20
|
opts?: ConfirmOptions;
|
|
@@ -21,9 +22,10 @@ export declare class FastSingleTxSender extends BaseTxSender {
|
|
|
21
22
|
blockhashRefreshInterval?: number;
|
|
22
23
|
additionalConnections?: any;
|
|
23
24
|
skipConfirmation?: boolean;
|
|
25
|
+
blockhashCommitment?: Commitment;
|
|
24
26
|
});
|
|
25
27
|
startBlockhashRefreshLoop(): void;
|
|
26
|
-
prepareTx(tx: Transaction, additionalSigners: Array<Signer>,
|
|
28
|
+
prepareTx(tx: Transaction, additionalSigners: Array<Signer>, _opts: ConfirmOptions): Promise<Transaction>;
|
|
27
29
|
getVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<VersionedTransaction>;
|
|
28
30
|
sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
|
|
29
31
|
}
|
|
@@ -7,7 +7,7 @@ const baseTxSender_1 = require("./baseTxSender");
|
|
|
7
7
|
const DEFAULT_TIMEOUT = 35000;
|
|
8
8
|
const DEFAULT_BLOCKHASH_REFRESH = 10000;
|
|
9
9
|
class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
|
|
10
|
-
constructor({ connection, wallet, opts = anchor_1.AnchorProvider.defaultOptions(), timeout = DEFAULT_TIMEOUT, blockhashRefreshInterval = DEFAULT_BLOCKHASH_REFRESH, additionalConnections = new Array(), skipConfirmation = false, }) {
|
|
10
|
+
constructor({ connection, wallet, opts = anchor_1.AnchorProvider.defaultOptions(), timeout = DEFAULT_TIMEOUT, blockhashRefreshInterval = DEFAULT_BLOCKHASH_REFRESH, additionalConnections = new Array(), skipConfirmation = false, blockhashCommitment = 'finalized', }) {
|
|
11
11
|
super({ connection, wallet, opts, timeout, additionalConnections });
|
|
12
12
|
this.timoutCount = 0;
|
|
13
13
|
this.connection = connection;
|
|
@@ -17,23 +17,24 @@ class FastSingleTxSender extends baseTxSender_1.BaseTxSender {
|
|
|
17
17
|
this.blockhashRefreshInterval = blockhashRefreshInterval;
|
|
18
18
|
this.additionalConnections = additionalConnections;
|
|
19
19
|
this.skipConfirmation = skipConfirmation;
|
|
20
|
+
this.blockhashCommitment = blockhashCommitment;
|
|
20
21
|
this.startBlockhashRefreshLoop();
|
|
21
22
|
}
|
|
22
23
|
startBlockhashRefreshLoop() {
|
|
23
24
|
setInterval(async () => {
|
|
24
25
|
try {
|
|
25
|
-
this.recentBlockhash = (await this.connection.getLatestBlockhash(this.
|
|
26
|
+
this.recentBlockhash = (await this.connection.getLatestBlockhash(this.blockhashCommitment)).blockhash;
|
|
26
27
|
}
|
|
27
28
|
catch (e) {
|
|
28
29
|
console.error('Error in startBlockhashRefreshLoop: ', e);
|
|
29
30
|
}
|
|
30
31
|
}, this.blockhashRefreshInterval);
|
|
31
32
|
}
|
|
32
|
-
async prepareTx(tx, additionalSigners,
|
|
33
|
+
async prepareTx(tx, additionalSigners, _opts) {
|
|
33
34
|
var _a;
|
|
34
35
|
tx.feePayer = this.wallet.publicKey;
|
|
35
36
|
tx.recentBlockhash =
|
|
36
|
-
(_a = this.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.connection.getLatestBlockhash(
|
|
37
|
+
(_a = this.recentBlockhash) !== null && _a !== void 0 ? _a : (await this.connection.getLatestBlockhash(this.blockhashCommitment))
|
|
37
38
|
.blockhash;
|
|
38
39
|
additionalSigners
|
|
39
40
|
.filter((s) => s !== undefined)
|
package/package.json
CHANGED
package/src/driftClient.ts
CHANGED
|
@@ -1652,7 +1652,8 @@ export class DriftClient {
|
|
|
1652
1652
|
marketIndex: number,
|
|
1653
1653
|
associatedTokenAccount: PublicKey,
|
|
1654
1654
|
subAccountId?: number,
|
|
1655
|
-
reduceOnly = false
|
|
1655
|
+
reduceOnly = false,
|
|
1656
|
+
txParams?: TxParams
|
|
1656
1657
|
): Promise<TransactionSignature> {
|
|
1657
1658
|
const additionalSigners: Array<Signer> = [];
|
|
1658
1659
|
|
|
@@ -1701,7 +1702,7 @@ export class DriftClient {
|
|
|
1701
1702
|
);
|
|
1702
1703
|
}
|
|
1703
1704
|
|
|
1704
|
-
|
|
1705
|
+
txParams = { ...(txParams ?? this.txParams), computeUnits: 600_000 };
|
|
1705
1706
|
|
|
1706
1707
|
const tx = await this.buildTransaction(instructions, txParams);
|
|
1707
1708
|
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
TransactionMessage,
|
|
10
10
|
TransactionInstruction,
|
|
11
11
|
AddressLookupTableAccount,
|
|
12
|
+
Commitment,
|
|
12
13
|
} from '@solana/web3.js';
|
|
13
14
|
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
14
15
|
import { IWallet } from '../types';
|
|
@@ -27,6 +28,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
27
28
|
timoutCount = 0;
|
|
28
29
|
recentBlockhash: string;
|
|
29
30
|
skipConfirmation: boolean;
|
|
31
|
+
blockhashCommitment: Commitment;
|
|
30
32
|
|
|
31
33
|
public constructor({
|
|
32
34
|
connection,
|
|
@@ -36,6 +38,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
36
38
|
blockhashRefreshInterval = DEFAULT_BLOCKHASH_REFRESH,
|
|
37
39
|
additionalConnections = new Array<Connection>(),
|
|
38
40
|
skipConfirmation = false,
|
|
41
|
+
blockhashCommitment = 'finalized',
|
|
39
42
|
}: {
|
|
40
43
|
connection: Connection;
|
|
41
44
|
wallet: IWallet;
|
|
@@ -44,6 +47,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
44
47
|
blockhashRefreshInterval?: number;
|
|
45
48
|
additionalConnections?;
|
|
46
49
|
skipConfirmation?: boolean;
|
|
50
|
+
blockhashCommitment?: Commitment;
|
|
47
51
|
}) {
|
|
48
52
|
super({ connection, wallet, opts, timeout, additionalConnections });
|
|
49
53
|
this.connection = connection;
|
|
@@ -53,6 +57,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
53
57
|
this.blockhashRefreshInterval = blockhashRefreshInterval;
|
|
54
58
|
this.additionalConnections = additionalConnections;
|
|
55
59
|
this.skipConfirmation = skipConfirmation;
|
|
60
|
+
this.blockhashCommitment = blockhashCommitment;
|
|
56
61
|
this.startBlockhashRefreshLoop();
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -60,7 +65,7 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
60
65
|
setInterval(async () => {
|
|
61
66
|
try {
|
|
62
67
|
this.recentBlockhash = (
|
|
63
|
-
await this.connection.getLatestBlockhash(this.
|
|
68
|
+
await this.connection.getLatestBlockhash(this.blockhashCommitment)
|
|
64
69
|
).blockhash;
|
|
65
70
|
} catch (e) {
|
|
66
71
|
console.error('Error in startBlockhashRefreshLoop: ', e);
|
|
@@ -71,13 +76,13 @@ export class FastSingleTxSender extends BaseTxSender {
|
|
|
71
76
|
async prepareTx(
|
|
72
77
|
tx: Transaction,
|
|
73
78
|
additionalSigners: Array<Signer>,
|
|
74
|
-
|
|
79
|
+
_opts: ConfirmOptions
|
|
75
80
|
): Promise<Transaction> {
|
|
76
81
|
tx.feePayer = this.wallet.publicKey;
|
|
77
82
|
|
|
78
83
|
tx.recentBlockhash =
|
|
79
84
|
this.recentBlockhash ??
|
|
80
|
-
(await this.connection.getLatestBlockhash(
|
|
85
|
+
(await this.connection.getLatestBlockhash(this.blockhashCommitment))
|
|
81
86
|
.blockhash;
|
|
82
87
|
|
|
83
88
|
additionalSigners
|