@drift-labs/sdk 2.31.0-beta.6 → 2.31.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/lib/constants/perpMarkets.js +20 -0
- package/lib/driftClient.js +4 -5
- package/lib/idl/drift.json +1 -1
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +6 -3
- package/lib/tx/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/constants/perpMarkets.ts +20 -0
- package/src/driftClient.ts +11 -15
- package/src/idl/drift.json +1 -1
- package/src/tx/retryTxSender.ts +6 -3
- package/src/tx/types.ts +2 -1
|
@@ -114,6 +114,16 @@ exports.DevnetPerpMarkets = [
|
|
|
114
114
|
launchTs: 1683125906000,
|
|
115
115
|
oracleSource: __1.OracleSource.PYTH_1M,
|
|
116
116
|
},
|
|
117
|
+
{
|
|
118
|
+
fullName: 'OP',
|
|
119
|
+
category: ['L2', 'Infra'],
|
|
120
|
+
symbol: 'OP-PERP',
|
|
121
|
+
baseAssetSymbol: 'OP',
|
|
122
|
+
marketIndex: 11,
|
|
123
|
+
oracle: new web3_js_1.PublicKey('8ctSiDhA7eJoii4TkKV8Rx4KFdz3ycsA1FXy9wq56quG'),
|
|
124
|
+
launchTs: 1683125906000,
|
|
125
|
+
oracleSource: __1.OracleSource.PYTH,
|
|
126
|
+
},
|
|
117
127
|
];
|
|
118
128
|
exports.MainnetPerpMarkets = [
|
|
119
129
|
{
|
|
@@ -226,6 +236,16 @@ exports.MainnetPerpMarkets = [
|
|
|
226
236
|
launchTs: 1683125906000,
|
|
227
237
|
oracleSource: __1.OracleSource.PYTH_1M,
|
|
228
238
|
},
|
|
239
|
+
{
|
|
240
|
+
fullName: 'OP',
|
|
241
|
+
category: ['L2', 'Infra'],
|
|
242
|
+
symbol: 'OP-PERP',
|
|
243
|
+
baseAssetSymbol: 'OP',
|
|
244
|
+
marketIndex: 11,
|
|
245
|
+
oracle: new web3_js_1.PublicKey('4o4CUwzFwLqCvmA5x1G4VzoZkAhAcbiuiYyjWX1CVbY2'),
|
|
246
|
+
launchTs: 1683125906000,
|
|
247
|
+
oracleSource: __1.OracleSource.PYTH,
|
|
248
|
+
},
|
|
229
249
|
];
|
|
230
250
|
exports.PerpMarkets = {
|
|
231
251
|
devnet: exports.DevnetPerpMarkets,
|
package/lib/driftClient.js
CHANGED
|
@@ -1389,14 +1389,13 @@ class DriftClient {
|
|
|
1389
1389
|
orderId,
|
|
1390
1390
|
marketIndex,
|
|
1391
1391
|
}, makerInfo, referrerInfo);
|
|
1392
|
-
const lookupTableAccount = await this.fetchMarketLookupTableAccount();
|
|
1393
1392
|
const walletSupportsVersionedTxns =
|
|
1394
1393
|
//@ts-ignore
|
|
1395
1394
|
(_b = (_a = this.wallet.supportedTransactionVersions) === null || _a === void 0 ? void 0 : _a.size) !== null && _b !== void 0 ? _b : 0 > 1;
|
|
1396
1395
|
// use versioned transactions if there is a lookup table account and wallet is compatible
|
|
1397
|
-
if (walletSupportsVersionedTxns &&
|
|
1398
|
-
const versionedMarketOrderTx = await this.
|
|
1399
|
-
const versionedFillTx = await this.
|
|
1396
|
+
if (walletSupportsVersionedTxns && useVersionedTx) {
|
|
1397
|
+
const versionedMarketOrderTx = await this.buildTransaction([placePerpOrderIx].concat(bracketOrderIxs), txParams, 0);
|
|
1398
|
+
const versionedFillTx = await this.buildTransaction([fillPerpOrderIx], txParams, 0);
|
|
1400
1399
|
const [signedVersionedMarketOrderTx, signedVersionedFillTx] = await this.provider.wallet.signAllTransactions([
|
|
1401
1400
|
//@ts-ignore
|
|
1402
1401
|
versionedMarketOrderTx,
|
|
@@ -3040,7 +3039,7 @@ class DriftClient {
|
|
|
3040
3039
|
return this.txSender.send(tx, additionalSigners, opts, preSigned);
|
|
3041
3040
|
}
|
|
3042
3041
|
else {
|
|
3043
|
-
return this.txSender.sendVersionedTransaction(tx, additionalSigners, opts);
|
|
3042
|
+
return this.txSender.sendVersionedTransaction(tx, additionalSigners, opts, preSigned);
|
|
3044
3043
|
}
|
|
3045
3044
|
}
|
|
3046
3045
|
async buildTransaction(instructions, txParams, txVersion, lookupTables) {
|
package/lib/idl/drift.json
CHANGED
|
@@ -14,7 +14,7 @@ export declare class RetryTxSender implements TxSender {
|
|
|
14
14
|
send(tx: Transaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
15
15
|
prepareTx(tx: Transaction, additionalSigners: Array<Signer>, opts: ConfirmOptions): Promise<Transaction>;
|
|
16
16
|
getVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<VersionedTransaction>;
|
|
17
|
-
sendVersionedTransaction(tx: VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<TxSigAndSlot>;
|
|
17
|
+
sendVersionedTransaction(tx: VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
18
18
|
sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
|
|
19
19
|
confirmTransaction(signature: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
|
|
20
20
|
getTimestamp(): number;
|
package/lib/tx/retryTxSender.js
CHANGED
|
@@ -54,10 +54,13 @@ class RetryTxSender {
|
|
|
54
54
|
const tx = new web3_js_1.VersionedTransaction(message);
|
|
55
55
|
return tx;
|
|
56
56
|
}
|
|
57
|
-
async sendVersionedTransaction(tx, additionalSigners, opts) {
|
|
57
|
+
async sendVersionedTransaction(tx, additionalSigners, opts, preSigned) {
|
|
58
58
|
let signedTx;
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if (preSigned) {
|
|
60
|
+
signedTx = tx;
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
}
|
|
63
|
+
else if (this.provider.wallet.payer) {
|
|
61
64
|
// @ts-ignore
|
|
62
65
|
tx.sign((additionalSigners !== null && additionalSigners !== void 0 ? additionalSigners : []).concat(this.provider.wallet.payer));
|
|
63
66
|
signedTx = tx;
|
package/lib/tx/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type TxSigAndSlot = {
|
|
|
8
8
|
export interface TxSender {
|
|
9
9
|
provider: Provider;
|
|
10
10
|
send(tx: Transaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
11
|
-
sendVersionedTransaction(tx: VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<TxSigAndSlot>;
|
|
11
|
+
sendVersionedTransaction(tx: VersionedTransaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
12
12
|
getVersionedTransaction(ixs: TransactionInstruction[], lookupTableAccounts: AddressLookupTableAccount[], additionalSigners?: Array<Signer>, opts?: ConfirmOptions): Promise<VersionedTransaction>;
|
|
13
13
|
sendRawTransaction(rawTransaction: Buffer | Uint8Array, opts: ConfirmOptions): Promise<TxSigAndSlot>;
|
|
14
14
|
}
|
package/package.json
CHANGED
|
@@ -124,6 +124,16 @@ export const DevnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
124
124
|
launchTs: 1683125906000,
|
|
125
125
|
oracleSource: OracleSource.PYTH_1M,
|
|
126
126
|
},
|
|
127
|
+
{
|
|
128
|
+
fullName: 'OP',
|
|
129
|
+
category: ['L2', 'Infra'],
|
|
130
|
+
symbol: 'OP-PERP',
|
|
131
|
+
baseAssetSymbol: 'OP',
|
|
132
|
+
marketIndex: 11,
|
|
133
|
+
oracle: new PublicKey('8ctSiDhA7eJoii4TkKV8Rx4KFdz3ycsA1FXy9wq56quG'),
|
|
134
|
+
launchTs: 1683125906000,
|
|
135
|
+
oracleSource: OracleSource.PYTH,
|
|
136
|
+
},
|
|
127
137
|
];
|
|
128
138
|
|
|
129
139
|
export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
@@ -237,6 +247,16 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
237
247
|
launchTs: 1683125906000,
|
|
238
248
|
oracleSource: OracleSource.PYTH_1M,
|
|
239
249
|
},
|
|
250
|
+
{
|
|
251
|
+
fullName: 'OP',
|
|
252
|
+
category: ['L2', 'Infra'],
|
|
253
|
+
symbol: 'OP-PERP',
|
|
254
|
+
baseAssetSymbol: 'OP',
|
|
255
|
+
marketIndex: 11,
|
|
256
|
+
oracle: new PublicKey('4o4CUwzFwLqCvmA5x1G4VzoZkAhAcbiuiYyjWX1CVbY2'),
|
|
257
|
+
launchTs: 1683125906000,
|
|
258
|
+
oracleSource: OracleSource.PYTH,
|
|
259
|
+
},
|
|
240
260
|
];
|
|
241
261
|
|
|
242
262
|
export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {
|
package/src/driftClient.ts
CHANGED
|
@@ -2369,26 +2369,21 @@ export class DriftClient {
|
|
|
2369
2369
|
referrerInfo
|
|
2370
2370
|
);
|
|
2371
2371
|
|
|
2372
|
-
const lookupTableAccount = await this.fetchMarketLookupTableAccount();
|
|
2373
|
-
|
|
2374
2372
|
const walletSupportsVersionedTxns =
|
|
2375
2373
|
//@ts-ignore
|
|
2376
2374
|
this.wallet.supportedTransactionVersions?.size ?? 0 > 1;
|
|
2377
2375
|
|
|
2378
2376
|
// use versioned transactions if there is a lookup table account and wallet is compatible
|
|
2379
|
-
if (walletSupportsVersionedTxns &&
|
|
2380
|
-
const versionedMarketOrderTx =
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
);
|
|
2387
|
-
const versionedFillTx = await this.txSender.getVersionedTransaction(
|
|
2377
|
+
if (walletSupportsVersionedTxns && useVersionedTx) {
|
|
2378
|
+
const versionedMarketOrderTx = await this.buildTransaction(
|
|
2379
|
+
[placePerpOrderIx].concat(bracketOrderIxs),
|
|
2380
|
+
txParams,
|
|
2381
|
+
0
|
|
2382
|
+
);
|
|
2383
|
+
const versionedFillTx = await this.buildTransaction(
|
|
2388
2384
|
[fillPerpOrderIx],
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
this.opts
|
|
2385
|
+
txParams,
|
|
2386
|
+
0
|
|
2392
2387
|
);
|
|
2393
2388
|
const [signedVersionedMarketOrderTx, signedVersionedFillTx] =
|
|
2394
2389
|
await this.provider.wallet.signAllTransactions([
|
|
@@ -5347,7 +5342,8 @@ export class DriftClient {
|
|
|
5347
5342
|
return this.txSender.sendVersionedTransaction(
|
|
5348
5343
|
tx as VersionedTransaction,
|
|
5349
5344
|
additionalSigners,
|
|
5350
|
-
opts
|
|
5345
|
+
opts,
|
|
5346
|
+
preSigned
|
|
5351
5347
|
);
|
|
5352
5348
|
}
|
|
5353
5349
|
}
|
package/src/idl/drift.json
CHANGED
package/src/tx/retryTxSender.ts
CHANGED
|
@@ -117,11 +117,14 @@ export class RetryTxSender implements TxSender {
|
|
|
117
117
|
async sendVersionedTransaction(
|
|
118
118
|
tx: VersionedTransaction,
|
|
119
119
|
additionalSigners?: Array<Signer>,
|
|
120
|
-
opts?: ConfirmOptions
|
|
120
|
+
opts?: ConfirmOptions,
|
|
121
|
+
preSigned?: boolean
|
|
121
122
|
): Promise<TxSigAndSlot> {
|
|
122
123
|
let signedTx;
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
if (preSigned) {
|
|
125
|
+
signedTx = tx;
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
} else if (this.provider.wallet.payer) {
|
|
125
128
|
// @ts-ignore
|
|
126
129
|
tx.sign((additionalSigners ?? []).concat(this.provider.wallet.payer));
|
|
127
130
|
signedTx = tx;
|
package/src/tx/types.ts
CHANGED