@drift-labs/sdk 2.100.0-beta.13 → 2.100.0-beta.15

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.100.0-beta.13
1
+ 2.100.0-beta.15
@@ -507,7 +507,7 @@ export declare class DriftClient {
507
507
  getUpdateUserStatsReferrerStatusIx(userAuthority: PublicKey): Promise<TransactionInstruction>;
508
508
  updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
509
509
  getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
510
- placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
510
+ placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
511
511
  preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean): Promise<{
512
512
  placeAndTakeTx: Transaction | VersionedTransaction;
513
513
  cancelExistingOrdersTx: Transaction | VersionedTransaction;
@@ -518,7 +518,7 @@ export declare class DriftClient {
518
518
  signedCancelExistingOrdersTx?: Transaction;
519
519
  signedSettlePnlTx?: Transaction;
520
520
  }>;
521
- getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, subAccountId?: number): Promise<TransactionInstruction>;
521
+ getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, subAccountId?: number): Promise<TransactionInstruction>;
522
522
  placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
523
523
  getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
524
524
  encodeSwiftServerMessage(message: SwiftServerMessage): Buffer;
@@ -82,7 +82,7 @@ class DriftClient {
82
82
  this._isSubscribed = val;
83
83
  }
84
84
  constructor(config) {
85
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
85
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
86
86
  this.users = new Map();
87
87
  this._isSubscribed = false;
88
88
  this.perpMarketLastSlotCache = new Map();
@@ -93,24 +93,27 @@ class DriftClient {
93
93
  this.wallet = config.wallet;
94
94
  this.opts = config.opts || {
95
95
  ...config_1.DEFAULT_CONFIRMATION_OPTS,
96
- commitment: (_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.commitment,
97
- preflightCommitment: (_b = config === null || config === void 0 ? void 0 : config.connection) === null || _b === void 0 ? void 0 : _b.commitment, // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
98
96
  };
97
+ if ((_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.commitment) {
98
+ // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
99
+ this.opts.commitment = config.connection.commitment;
100
+ this.opts.preflightCommitment = config.connection.commitment;
101
+ }
99
102
  this.provider = new anchor_1.AnchorProvider(config.connection,
100
103
  // @ts-ignore
101
104
  config.wallet, this.opts);
102
- this.program = new anchor_1.Program(drift_json_1.default, (_c = config.programID) !== null && _c !== void 0 ? _c : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
103
- this.swiftID = (_d = config.swiftID) !== null && _d !== void 0 ? _d : new web3_js_1.PublicKey(config_1.SWIFT_ID);
104
- this.authority = (_e = config.authority) !== null && _e !== void 0 ? _e : this.wallet.publicKey;
105
- this.activeSubAccountId = (_f = config.activeSubAccountId) !== null && _f !== void 0 ? _f : 0;
106
- this.skipLoadUsers = (_g = config.skipLoadUsers) !== null && _g !== void 0 ? _g : false;
107
- this.txVersion = (_h = config.txVersion) !== null && _h !== void 0 ? _h : 'legacy';
105
+ this.program = new anchor_1.Program(drift_json_1.default, (_b = config.programID) !== null && _b !== void 0 ? _b : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
106
+ this.swiftID = (_c = config.swiftID) !== null && _c !== void 0 ? _c : new web3_js_1.PublicKey(config_1.SWIFT_ID);
107
+ this.authority = (_d = config.authority) !== null && _d !== void 0 ? _d : this.wallet.publicKey;
108
+ this.activeSubAccountId = (_e = config.activeSubAccountId) !== null && _e !== void 0 ? _e : 0;
109
+ this.skipLoadUsers = (_f = config.skipLoadUsers) !== null && _f !== void 0 ? _f : false;
110
+ this.txVersion = (_g = config.txVersion) !== null && _g !== void 0 ? _g : 'legacy';
108
111
  this.txParams = {
109
- computeUnits: (_k = (_j = config.txParams) === null || _j === void 0 ? void 0 : _j.computeUnits) !== null && _k !== void 0 ? _k : 600000,
110
- computeUnitsPrice: (_m = (_l = config.txParams) === null || _l === void 0 ? void 0 : _l.computeUnitsPrice) !== null && _m !== void 0 ? _m : 0,
112
+ computeUnits: (_j = (_h = config.txParams) === null || _h === void 0 ? void 0 : _h.computeUnits) !== null && _j !== void 0 ? _j : 600000,
113
+ computeUnitsPrice: (_l = (_k = config.txParams) === null || _k === void 0 ? void 0 : _k.computeUnitsPrice) !== null && _l !== void 0 ? _l : 0,
111
114
  };
112
115
  this.txHandler =
113
- (_o = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _o !== void 0 ? _o : new txHandler_1.TxHandler({
116
+ (_m = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _m !== void 0 ? _m : new txHandler_1.TxHandler({
114
117
  connection: this.connection,
115
118
  // @ts-ignore
116
119
  wallet: this.provider.wallet,
@@ -136,8 +139,8 @@ class DriftClient {
136
139
  : config.subAccountIds
137
140
  ? new Map([[this.authority.toString(), config.subAccountIds]])
138
141
  : new Map();
139
- this.includeDelegates = (_p = config.includeDelegates) !== null && _p !== void 0 ? _p : false;
140
- if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'polling') {
142
+ this.includeDelegates = (_o = config.includeDelegates) !== null && _o !== void 0 ? _o : false;
143
+ if (((_p = config.accountSubscription) === null || _p === void 0 ? void 0 : _p.type) === 'polling') {
141
144
  this.userAccountSubscriptionConfig = {
142
145
  type: 'polling',
143
146
  accountLoader: config.accountSubscription.accountLoader,
@@ -147,32 +150,32 @@ class DriftClient {
147
150
  accountLoader: config.accountSubscription.accountLoader,
148
151
  };
149
152
  }
150
- else if (((_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.type) === 'grpc') {
153
+ else if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'grpc') {
151
154
  this.userAccountSubscriptionConfig = {
152
155
  type: 'grpc',
153
- resubTimeoutMs: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.resubTimeoutMs,
154
- logResubMessages: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.logResubMessages,
155
- grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
156
+ resubTimeoutMs: (_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.resubTimeoutMs,
157
+ logResubMessages: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.logResubMessages,
158
+ grpcConfigs: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.grpcConfigs,
156
159
  };
157
160
  this.userStatsAccountSubscriptionConfig = {
158
161
  type: 'grpc',
159
- grpcConfigs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.grpcConfigs,
160
- resubTimeoutMs: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.resubTimeoutMs,
161
- logResubMessages: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.logResubMessages,
162
+ grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
163
+ resubTimeoutMs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.resubTimeoutMs,
164
+ logResubMessages: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.logResubMessages,
162
165
  };
163
166
  }
164
167
  else {
165
168
  this.userAccountSubscriptionConfig = {
166
169
  type: 'websocket',
167
- resubTimeoutMs: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.resubTimeoutMs,
168
- logResubMessages: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.logResubMessages,
169
- commitment: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.commitment,
170
+ resubTimeoutMs: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.resubTimeoutMs,
171
+ logResubMessages: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.logResubMessages,
172
+ commitment: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.commitment,
170
173
  };
171
174
  this.userStatsAccountSubscriptionConfig = {
172
175
  type: 'websocket',
173
- resubTimeoutMs: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.resubTimeoutMs,
174
- logResubMessages: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.logResubMessages,
175
- commitment: (_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.commitment,
176
+ resubTimeoutMs: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.resubTimeoutMs,
177
+ logResubMessages: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.logResubMessages,
178
+ commitment: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.commitment,
176
179
  };
177
180
  }
178
181
  if (config.userStats) {
@@ -190,20 +193,20 @@ class DriftClient {
190
193
  const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
191
194
  config.spotMarketIndexes === undefined &&
192
195
  config.oracleInfos === undefined;
193
- if (((_4 = config.accountSubscription) === null || _4 === void 0 ? void 0 : _4.type) === 'polling') {
194
- this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_5 = config.perpMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.spotMarketIndexes) !== null && _6 !== void 0 ? _6 : [], (_7 = config.oracleInfos) !== null && _7 !== void 0 ? _7 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
196
+ if (((_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.type) === 'polling') {
197
+ this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_4 = config.perpMarketIndexes) !== null && _4 !== void 0 ? _4 : [], (_5 = config.spotMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.oracleInfos) !== null && _6 !== void 0 ? _6 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
195
198
  }
196
- else if (((_8 = config.accountSubscription) === null || _8 === void 0 ? void 0 : _8.type) === 'grpc') {
197
- this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_9 = config.perpMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.spotMarketIndexes) !== null && _10 !== void 0 ? _10 : [], (_11 = config.oracleInfos) !== null && _11 !== void 0 ? _11 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
198
- resubTimeoutMs: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.resubTimeoutMs,
199
- logResubMessages: (_13 = config.accountSubscription) === null || _13 === void 0 ? void 0 : _13.logResubMessages,
199
+ else if (((_7 = config.accountSubscription) === null || _7 === void 0 ? void 0 : _7.type) === 'grpc') {
200
+ this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_8 = config.perpMarketIndexes) !== null && _8 !== void 0 ? _8 : [], (_9 = config.spotMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.oracleInfos) !== null && _10 !== void 0 ? _10 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
201
+ resubTimeoutMs: (_11 = config.accountSubscription) === null || _11 === void 0 ? void 0 : _11.resubTimeoutMs,
202
+ logResubMessages: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.logResubMessages,
200
203
  });
201
204
  }
202
205
  else {
203
- this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_14 = config.perpMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.spotMarketIndexes) !== null && _15 !== void 0 ? _15 : [], (_16 = config.oracleInfos) !== null && _16 !== void 0 ? _16 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
204
- resubTimeoutMs: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.resubTimeoutMs,
205
- logResubMessages: (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.logResubMessages,
206
- }, (_19 = config.accountSubscription) === null || _19 === void 0 ? void 0 : _19.commitment);
206
+ this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_13 = config.perpMarketIndexes) !== null && _13 !== void 0 ? _13 : [], (_14 = config.spotMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.oracleInfos) !== null && _15 !== void 0 ? _15 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
207
+ resubTimeoutMs: (_16 = config.accountSubscription) === null || _16 === void 0 ? void 0 : _16.resubTimeoutMs,
208
+ logResubMessages: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.logResubMessages,
209
+ }, (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.commitment);
207
210
  }
208
211
  this.eventEmitter = this.accountSubscriber.eventEmitter;
209
212
  this.metricsEventEmitter = new events_1.EventEmitter();
@@ -211,14 +214,14 @@ class DriftClient {
211
214
  this.enableMetricsEvents = true;
212
215
  }
213
216
  this.txSender =
214
- (_20 = config.txSender) !== null && _20 !== void 0 ? _20 : new retryTxSender_1.RetryTxSender({
217
+ (_19 = config.txSender) !== null && _19 !== void 0 ? _19 : new retryTxSender_1.RetryTxSender({
215
218
  connection: this.connection,
216
219
  wallet: this.wallet,
217
220
  opts: this.opts,
218
221
  txHandler: this.txHandler,
219
222
  });
220
223
  this.sbOnDemandProgramdId =
221
- config_1.configs[(_21 = config.env) !== null && _21 !== void 0 ? _21 : 'mainnet-beta'].SB_ON_DEMAND_PID;
224
+ config_1.configs[(_20 = config.env) !== null && _20 !== void 0 ? _20 : 'mainnet-beta'].SB_ON_DEMAND_PID;
222
225
  }
223
226
  getUserMapKey(subAccountId, authority) {
224
227
  return `${subAccountId}_${authority.toString()}`;
@@ -1720,7 +1723,7 @@ class DriftClient {
1720
1723
  direction,
1721
1724
  baseAssetAmount: amount,
1722
1725
  price: limitPrice,
1723
- }, undefined, undefined, undefined, undefined, subAccountId);
1726
+ }, undefined, undefined, undefined, undefined, undefined, subAccountId);
1724
1727
  }
1725
1728
  async sendSignedTx(tx, opts) {
1726
1729
  const { txSig } = await this.sendTransaction(tx, undefined, opts !== null && opts !== void 0 ? opts : this.opts, true);
@@ -2873,8 +2876,8 @@ class DriftClient {
2873
2876
  remainingAccounts,
2874
2877
  });
2875
2878
  }
2876
- async placeAndTakePerpOrder(orderParams, makerInfo, referrerInfo, successCondition, txParams, subAccountId) {
2877
- const { txSig, slot } = await this.sendTransaction(await this.buildTransaction(await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, successCondition, subAccountId), txParams), [], this.opts);
2879
+ async placeAndTakePerpOrder(orderParams, makerInfo, referrerInfo, successCondition, auctionDurationPercentage, txParams, subAccountId) {
2880
+ const { txSig, slot } = await this.sendTransaction(await this.buildTransaction(await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, successCondition, auctionDurationPercentage, subAccountId), txParams), [], this.opts);
2878
2881
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
2879
2882
  return txSig;
2880
2883
  }
@@ -2890,7 +2893,7 @@ class DriftClient {
2890
2893
  let earlyExitFailedPlaceAndTakeSim = false;
2891
2894
  const prepPlaceAndTakeTx = async () => {
2892
2895
  var _a;
2893
- const placeAndTakeIx = await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, undefined, subAccountId);
2896
+ const placeAndTakeIx = await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, undefined, undefined, subAccountId);
2894
2897
  placeAndTakeIxs.push(placeAndTakeIx);
2895
2898
  if (bracketOrdersParams.length > 0) {
2896
2899
  const bracketOrdersIx = await this.getPlaceOrdersIx(bracketOrdersParams, subAccountId);
@@ -2960,7 +2963,7 @@ class DriftClient {
2960
2963
  signedSettlePnlTx: signedTxs.settlePnlTx,
2961
2964
  };
2962
2965
  }
2963
- async getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, successCondition, subAccountId) {
2966
+ async getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, successCondition, auctionDurationPercentage, subAccountId) {
2964
2967
  orderParams = (0, orderParams_1.getOrderParams)(orderParams, { marketType: types_1.MarketType.PERP });
2965
2968
  const userStatsPublicKey = await this.getUserStatsAccountPublicKey();
2966
2969
  const user = await this.getUserAccountPublicKey(subAccountId);
@@ -3006,7 +3009,12 @@ class DriftClient {
3006
3009
  });
3007
3010
  }
3008
3011
  }
3009
- return await this.program.instruction.placeAndTakePerpOrder(orderParams, successCondition !== null && successCondition !== void 0 ? successCondition : null, {
3012
+ let optionalParams = null;
3013
+ if (auctionDurationPercentage || successCondition) {
3014
+ optionalParams =
3015
+ ((successCondition !== null && successCondition !== void 0 ? successCondition : 0) << 8) | (auctionDurationPercentage !== null && auctionDurationPercentage !== void 0 ? auctionDurationPercentage : 100);
3016
+ }
3017
+ return await this.program.instruction.placeAndTakePerpOrder(orderParams, optionalParams, {
3010
3018
  accounts: {
3011
3019
  state: await this.getStatePublicKey(),
3012
3020
  user,
@@ -3356,7 +3364,7 @@ class DriftClient {
3356
3364
  baseAssetAmount: userPosition.baseAssetAmount.abs(),
3357
3365
  reduceOnly: true,
3358
3366
  price: limitPrice,
3359
- }, undefined, undefined, undefined, undefined, subAccountId);
3367
+ }, undefined, undefined, undefined, undefined, undefined, subAccountId);
3360
3368
  }
3361
3369
  /**
3362
3370
  * Modifies an open order by closing it and replacing it with a new order.
@@ -507,7 +507,7 @@ export declare class DriftClient {
507
507
  getUpdateUserStatsReferrerStatusIx(userAuthority: PublicKey): Promise<TransactionInstruction>;
508
508
  updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
509
509
  getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
510
- placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
510
+ placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
511
511
  preparePlaceAndTakePerpOrderWithAdditionalOrders(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, bracketOrdersParams?: OptionalOrderParams[], txParams?: TxParams, subAccountId?: number, cancelExistingOrders?: boolean, settlePnl?: boolean, exitEarlyIfSimFails?: boolean): Promise<{
512
512
  placeAndTakeTx: Transaction | VersionedTransaction;
513
513
  cancelExistingOrdersTx: Transaction | VersionedTransaction;
@@ -518,7 +518,7 @@ export declare class DriftClient {
518
518
  signedCancelExistingOrdersTx?: Transaction;
519
519
  signedSettlePnlTx?: Transaction;
520
520
  }>;
521
- getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, subAccountId?: number): Promise<TransactionInstruction>;
521
+ getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, successCondition?: PlaceAndTakeOrderSuccessCondition, auctionDurationPercentage?: number, subAccountId?: number): Promise<TransactionInstruction>;
522
522
  placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
523
523
  getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
524
524
  encodeSwiftServerMessage(message: SwiftServerMessage): Buffer;
@@ -82,7 +82,7 @@ class DriftClient {
82
82
  this._isSubscribed = val;
83
83
  }
84
84
  constructor(config) {
85
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
85
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20;
86
86
  this.users = new Map();
87
87
  this._isSubscribed = false;
88
88
  this.perpMarketLastSlotCache = new Map();
@@ -93,24 +93,27 @@ class DriftClient {
93
93
  this.wallet = config.wallet;
94
94
  this.opts = config.opts || {
95
95
  ...config_1.DEFAULT_CONFIRMATION_OPTS,
96
- commitment: (_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.commitment,
97
- preflightCommitment: (_b = config === null || config === void 0 ? void 0 : config.connection) === null || _b === void 0 ? void 0 : _b.commitment, // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
98
96
  };
97
+ if ((_a = config === null || config === void 0 ? void 0 : config.connection) === null || _a === void 0 ? void 0 : _a.commitment) {
98
+ // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
99
+ this.opts.commitment = config.connection.commitment;
100
+ this.opts.preflightCommitment = config.connection.commitment;
101
+ }
99
102
  this.provider = new anchor_1.AnchorProvider(config.connection,
100
103
  // @ts-ignore
101
104
  config.wallet, this.opts);
102
- this.program = new anchor_1.Program(drift_json_1.default, (_c = config.programID) !== null && _c !== void 0 ? _c : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
103
- this.swiftID = (_d = config.swiftID) !== null && _d !== void 0 ? _d : new web3_js_1.PublicKey(config_1.SWIFT_ID);
104
- this.authority = (_e = config.authority) !== null && _e !== void 0 ? _e : this.wallet.publicKey;
105
- this.activeSubAccountId = (_f = config.activeSubAccountId) !== null && _f !== void 0 ? _f : 0;
106
- this.skipLoadUsers = (_g = config.skipLoadUsers) !== null && _g !== void 0 ? _g : false;
107
- this.txVersion = (_h = config.txVersion) !== null && _h !== void 0 ? _h : 'legacy';
105
+ this.program = new anchor_1.Program(drift_json_1.default, (_b = config.programID) !== null && _b !== void 0 ? _b : new web3_js_1.PublicKey(config_1.DRIFT_PROGRAM_ID), this.provider);
106
+ this.swiftID = (_c = config.swiftID) !== null && _c !== void 0 ? _c : new web3_js_1.PublicKey(config_1.SWIFT_ID);
107
+ this.authority = (_d = config.authority) !== null && _d !== void 0 ? _d : this.wallet.publicKey;
108
+ this.activeSubAccountId = (_e = config.activeSubAccountId) !== null && _e !== void 0 ? _e : 0;
109
+ this.skipLoadUsers = (_f = config.skipLoadUsers) !== null && _f !== void 0 ? _f : false;
110
+ this.txVersion = (_g = config.txVersion) !== null && _g !== void 0 ? _g : 'legacy';
108
111
  this.txParams = {
109
- computeUnits: (_k = (_j = config.txParams) === null || _j === void 0 ? void 0 : _j.computeUnits) !== null && _k !== void 0 ? _k : 600000,
110
- computeUnitsPrice: (_m = (_l = config.txParams) === null || _l === void 0 ? void 0 : _l.computeUnitsPrice) !== null && _m !== void 0 ? _m : 0,
112
+ computeUnits: (_j = (_h = config.txParams) === null || _h === void 0 ? void 0 : _h.computeUnits) !== null && _j !== void 0 ? _j : 600000,
113
+ computeUnitsPrice: (_l = (_k = config.txParams) === null || _k === void 0 ? void 0 : _k.computeUnitsPrice) !== null && _l !== void 0 ? _l : 0,
111
114
  };
112
115
  this.txHandler =
113
- (_o = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _o !== void 0 ? _o : new txHandler_1.TxHandler({
116
+ (_m = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _m !== void 0 ? _m : new txHandler_1.TxHandler({
114
117
  connection: this.connection,
115
118
  // @ts-ignore
116
119
  wallet: this.provider.wallet,
@@ -136,8 +139,8 @@ class DriftClient {
136
139
  : config.subAccountIds
137
140
  ? new Map([[this.authority.toString(), config.subAccountIds]])
138
141
  : new Map();
139
- this.includeDelegates = (_p = config.includeDelegates) !== null && _p !== void 0 ? _p : false;
140
- if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'polling') {
142
+ this.includeDelegates = (_o = config.includeDelegates) !== null && _o !== void 0 ? _o : false;
143
+ if (((_p = config.accountSubscription) === null || _p === void 0 ? void 0 : _p.type) === 'polling') {
141
144
  this.userAccountSubscriptionConfig = {
142
145
  type: 'polling',
143
146
  accountLoader: config.accountSubscription.accountLoader,
@@ -147,32 +150,32 @@ class DriftClient {
147
150
  accountLoader: config.accountSubscription.accountLoader,
148
151
  };
149
152
  }
150
- else if (((_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.type) === 'grpc') {
153
+ else if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'grpc') {
151
154
  this.userAccountSubscriptionConfig = {
152
155
  type: 'grpc',
153
- resubTimeoutMs: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.resubTimeoutMs,
154
- logResubMessages: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.logResubMessages,
155
- grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
156
+ resubTimeoutMs: (_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.resubTimeoutMs,
157
+ logResubMessages: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.logResubMessages,
158
+ grpcConfigs: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.grpcConfigs,
156
159
  };
157
160
  this.userStatsAccountSubscriptionConfig = {
158
161
  type: 'grpc',
159
- grpcConfigs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.grpcConfigs,
160
- resubTimeoutMs: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.resubTimeoutMs,
161
- logResubMessages: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.logResubMessages,
162
+ grpcConfigs: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcConfigs,
163
+ resubTimeoutMs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.resubTimeoutMs,
164
+ logResubMessages: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.logResubMessages,
162
165
  };
163
166
  }
164
167
  else {
165
168
  this.userAccountSubscriptionConfig = {
166
169
  type: 'websocket',
167
- resubTimeoutMs: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.resubTimeoutMs,
168
- logResubMessages: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.logResubMessages,
169
- commitment: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.commitment,
170
+ resubTimeoutMs: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.resubTimeoutMs,
171
+ logResubMessages: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.logResubMessages,
172
+ commitment: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.commitment,
170
173
  };
171
174
  this.userStatsAccountSubscriptionConfig = {
172
175
  type: 'websocket',
173
- resubTimeoutMs: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.resubTimeoutMs,
174
- logResubMessages: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.logResubMessages,
175
- commitment: (_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.commitment,
176
+ resubTimeoutMs: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.resubTimeoutMs,
177
+ logResubMessages: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.logResubMessages,
178
+ commitment: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.commitment,
176
179
  };
177
180
  }
178
181
  if (config.userStats) {
@@ -190,20 +193,20 @@ class DriftClient {
190
193
  const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
191
194
  config.spotMarketIndexes === undefined &&
192
195
  config.oracleInfos === undefined;
193
- if (((_4 = config.accountSubscription) === null || _4 === void 0 ? void 0 : _4.type) === 'polling') {
194
- this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_5 = config.perpMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.spotMarketIndexes) !== null && _6 !== void 0 ? _6 : [], (_7 = config.oracleInfos) !== null && _7 !== void 0 ? _7 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
196
+ if (((_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.type) === 'polling') {
197
+ this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_4 = config.perpMarketIndexes) !== null && _4 !== void 0 ? _4 : [], (_5 = config.spotMarketIndexes) !== null && _5 !== void 0 ? _5 : [], (_6 = config.oracleInfos) !== null && _6 !== void 0 ? _6 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
195
198
  }
196
- else if (((_8 = config.accountSubscription) === null || _8 === void 0 ? void 0 : _8.type) === 'grpc') {
197
- this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_9 = config.perpMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.spotMarketIndexes) !== null && _10 !== void 0 ? _10 : [], (_11 = config.oracleInfos) !== null && _11 !== void 0 ? _11 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
198
- resubTimeoutMs: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.resubTimeoutMs,
199
- logResubMessages: (_13 = config.accountSubscription) === null || _13 === void 0 ? void 0 : _13.logResubMessages,
199
+ else if (((_7 = config.accountSubscription) === null || _7 === void 0 ? void 0 : _7.type) === 'grpc') {
200
+ this.accountSubscriber = new grpcDriftClientAccountSubscriber_1.gprcDriftClientAccountSubscriber(config.accountSubscription.grpcConfigs, this.program, (_8 = config.perpMarketIndexes) !== null && _8 !== void 0 ? _8 : [], (_9 = config.spotMarketIndexes) !== null && _9 !== void 0 ? _9 : [], (_10 = config.oracleInfos) !== null && _10 !== void 0 ? _10 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
201
+ resubTimeoutMs: (_11 = config.accountSubscription) === null || _11 === void 0 ? void 0 : _11.resubTimeoutMs,
202
+ logResubMessages: (_12 = config.accountSubscription) === null || _12 === void 0 ? void 0 : _12.logResubMessages,
200
203
  });
201
204
  }
202
205
  else {
203
- this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_14 = config.perpMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.spotMarketIndexes) !== null && _15 !== void 0 ? _15 : [], (_16 = config.oracleInfos) !== null && _16 !== void 0 ? _16 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
204
- resubTimeoutMs: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.resubTimeoutMs,
205
- logResubMessages: (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.logResubMessages,
206
- }, (_19 = config.accountSubscription) === null || _19 === void 0 ? void 0 : _19.commitment);
206
+ this.accountSubscriber = new webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber(this.program, (_13 = config.perpMarketIndexes) !== null && _13 !== void 0 ? _13 : [], (_14 = config.spotMarketIndexes) !== null && _14 !== void 0 ? _14 : [], (_15 = config.oracleInfos) !== null && _15 !== void 0 ? _15 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
207
+ resubTimeoutMs: (_16 = config.accountSubscription) === null || _16 === void 0 ? void 0 : _16.resubTimeoutMs,
208
+ logResubMessages: (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.logResubMessages,
209
+ }, (_18 = config.accountSubscription) === null || _18 === void 0 ? void 0 : _18.commitment);
207
210
  }
208
211
  this.eventEmitter = this.accountSubscriber.eventEmitter;
209
212
  this.metricsEventEmitter = new events_1.EventEmitter();
@@ -211,14 +214,14 @@ class DriftClient {
211
214
  this.enableMetricsEvents = true;
212
215
  }
213
216
  this.txSender =
214
- (_20 = config.txSender) !== null && _20 !== void 0 ? _20 : new retryTxSender_1.RetryTxSender({
217
+ (_19 = config.txSender) !== null && _19 !== void 0 ? _19 : new retryTxSender_1.RetryTxSender({
215
218
  connection: this.connection,
216
219
  wallet: this.wallet,
217
220
  opts: this.opts,
218
221
  txHandler: this.txHandler,
219
222
  });
220
223
  this.sbOnDemandProgramdId =
221
- config_1.configs[(_21 = config.env) !== null && _21 !== void 0 ? _21 : 'mainnet-beta'].SB_ON_DEMAND_PID;
224
+ config_1.configs[(_20 = config.env) !== null && _20 !== void 0 ? _20 : 'mainnet-beta'].SB_ON_DEMAND_PID;
222
225
  }
223
226
  getUserMapKey(subAccountId, authority) {
224
227
  return `${subAccountId}_${authority.toString()}`;
@@ -1720,7 +1723,7 @@ class DriftClient {
1720
1723
  direction,
1721
1724
  baseAssetAmount: amount,
1722
1725
  price: limitPrice,
1723
- }, undefined, undefined, undefined, undefined, subAccountId);
1726
+ }, undefined, undefined, undefined, undefined, undefined, subAccountId);
1724
1727
  }
1725
1728
  async sendSignedTx(tx, opts) {
1726
1729
  const { txSig } = await this.sendTransaction(tx, undefined, opts !== null && opts !== void 0 ? opts : this.opts, true);
@@ -2873,8 +2876,8 @@ class DriftClient {
2873
2876
  remainingAccounts,
2874
2877
  });
2875
2878
  }
2876
- async placeAndTakePerpOrder(orderParams, makerInfo, referrerInfo, successCondition, txParams, subAccountId) {
2877
- const { txSig, slot } = await this.sendTransaction(await this.buildTransaction(await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, successCondition, subAccountId), txParams), [], this.opts);
2879
+ async placeAndTakePerpOrder(orderParams, makerInfo, referrerInfo, successCondition, auctionDurationPercentage, txParams, subAccountId) {
2880
+ const { txSig, slot } = await this.sendTransaction(await this.buildTransaction(await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, successCondition, auctionDurationPercentage, subAccountId), txParams), [], this.opts);
2878
2881
  this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
2879
2882
  return txSig;
2880
2883
  }
@@ -2890,7 +2893,7 @@ class DriftClient {
2890
2893
  let earlyExitFailedPlaceAndTakeSim = false;
2891
2894
  const prepPlaceAndTakeTx = async () => {
2892
2895
  var _a;
2893
- const placeAndTakeIx = await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, undefined, subAccountId);
2896
+ const placeAndTakeIx = await this.getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, undefined, undefined, subAccountId);
2894
2897
  placeAndTakeIxs.push(placeAndTakeIx);
2895
2898
  if (bracketOrdersParams.length > 0) {
2896
2899
  const bracketOrdersIx = await this.getPlaceOrdersIx(bracketOrdersParams, subAccountId);
@@ -2960,7 +2963,7 @@ class DriftClient {
2960
2963
  signedSettlePnlTx: signedTxs.settlePnlTx,
2961
2964
  };
2962
2965
  }
2963
- async getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, successCondition, subAccountId) {
2966
+ async getPlaceAndTakePerpOrderIx(orderParams, makerInfo, referrerInfo, successCondition, auctionDurationPercentage, subAccountId) {
2964
2967
  orderParams = (0, orderParams_1.getOrderParams)(orderParams, { marketType: types_1.MarketType.PERP });
2965
2968
  const userStatsPublicKey = await this.getUserStatsAccountPublicKey();
2966
2969
  const user = await this.getUserAccountPublicKey(subAccountId);
@@ -3006,7 +3009,12 @@ class DriftClient {
3006
3009
  });
3007
3010
  }
3008
3011
  }
3009
- return await this.program.instruction.placeAndTakePerpOrder(orderParams, successCondition !== null && successCondition !== void 0 ? successCondition : null, {
3012
+ let optionalParams = null;
3013
+ if (auctionDurationPercentage || successCondition) {
3014
+ optionalParams =
3015
+ ((successCondition !== null && successCondition !== void 0 ? successCondition : 0) << 8) | (auctionDurationPercentage !== null && auctionDurationPercentage !== void 0 ? auctionDurationPercentage : 100);
3016
+ }
3017
+ return await this.program.instruction.placeAndTakePerpOrder(orderParams, optionalParams, {
3010
3018
  accounts: {
3011
3019
  state: await this.getStatePublicKey(),
3012
3020
  user,
@@ -3356,7 +3364,7 @@ class DriftClient {
3356
3364
  baseAssetAmount: userPosition.baseAssetAmount.abs(),
3357
3365
  reduceOnly: true,
3358
3366
  price: limitPrice,
3359
- }, undefined, undefined, undefined, undefined, subAccountId);
3367
+ }, undefined, undefined, undefined, undefined, undefined, subAccountId);
3360
3368
  }
3361
3369
  /**
3362
3370
  * Modifies an open order by closing it and replacing it with a new order.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.100.0-beta.13",
3
+ "version": "2.100.0-beta.15",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -243,9 +243,12 @@ export class DriftClient {
243
243
  this.wallet = config.wallet;
244
244
  this.opts = config.opts || {
245
245
  ...DEFAULT_CONFIRMATION_OPTS,
246
- commitment: config?.connection?.commitment,
247
- preflightCommitment: config?.connection?.commitment, // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
248
246
  };
247
+ if (config?.connection?.commitment) {
248
+ // At the moment this ensures that our transaction simulations (which use Connection object) will use the same commitment level as our Transaction blockhashes (which use these opts)
249
+ this.opts.commitment = config.connection.commitment;
250
+ this.opts.preflightCommitment = config.connection.commitment;
251
+ }
249
252
  this.provider = new AnchorProvider(
250
253
  config.connection,
251
254
  // @ts-ignore
@@ -3223,6 +3226,7 @@ export class DriftClient {
3223
3226
  undefined,
3224
3227
  undefined,
3225
3228
  undefined,
3229
+ undefined,
3226
3230
  subAccountId
3227
3231
  );
3228
3232
  }
@@ -5268,6 +5272,7 @@ export class DriftClient {
5268
5272
  makerInfo?: MakerInfo | MakerInfo[],
5269
5273
  referrerInfo?: ReferrerInfo,
5270
5274
  successCondition?: PlaceAndTakeOrderSuccessCondition,
5275
+ auctionDurationPercentage?: number,
5271
5276
  txParams?: TxParams,
5272
5277
  subAccountId?: number
5273
5278
  ): Promise<TransactionSignature> {
@@ -5278,6 +5283,7 @@ export class DriftClient {
5278
5283
  makerInfo,
5279
5284
  referrerInfo,
5280
5285
  successCondition,
5286
+ auctionDurationPercentage,
5281
5287
  subAccountId
5282
5288
  ),
5283
5289
  txParams
@@ -5326,6 +5332,7 @@ export class DriftClient {
5326
5332
  makerInfo,
5327
5333
  referrerInfo,
5328
5334
  undefined,
5335
+ undefined,
5329
5336
  subAccountId
5330
5337
  );
5331
5338
 
@@ -5517,6 +5524,7 @@ export class DriftClient {
5517
5524
  makerInfo?: MakerInfo | MakerInfo[],
5518
5525
  referrerInfo?: ReferrerInfo,
5519
5526
  successCondition?: PlaceAndTakeOrderSuccessCondition,
5527
+ auctionDurationPercentage?: number,
5520
5528
  subAccountId?: number
5521
5529
  ): Promise<TransactionInstruction> {
5522
5530
  orderParams = getOrderParams(orderParams, { marketType: MarketType.PERP });
@@ -5571,9 +5579,15 @@ export class DriftClient {
5571
5579
  }
5572
5580
  }
5573
5581
 
5582
+ let optionalParams = null;
5583
+ if (auctionDurationPercentage || successCondition) {
5584
+ optionalParams =
5585
+ ((successCondition ?? 0) << 8) | (auctionDurationPercentage ?? 100);
5586
+ }
5587
+
5574
5588
  return await this.program.instruction.placeAndTakePerpOrder(
5575
5589
  orderParams,
5576
- successCondition ?? null,
5590
+ optionalParams,
5577
5591
  {
5578
5592
  accounts: {
5579
5593
  state: await this.getStatePublicKey(),
@@ -6253,6 +6267,7 @@ export class DriftClient {
6253
6267
  undefined,
6254
6268
  undefined,
6255
6269
  undefined,
6270
+ undefined,
6256
6271
  subAccountId
6257
6272
  );
6258
6273
  }