@drift-labs/sdk 2.31.1-beta.9 → 2.32.1-beta.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/VERSION CHANGED
@@ -1 +1 @@
1
- 2.31.1-beta.9
1
+ 2.32.1-beta.0
@@ -124,6 +124,16 @@ exports.DevnetPerpMarkets = [
124
124
  launchTs: 1683125906000,
125
125
  oracleSource: __1.OracleSource.PYTH,
126
126
  },
127
+ {
128
+ fullName: 'RNDR',
129
+ category: ['Infra'],
130
+ symbol: 'RNDR-PERP',
131
+ baseAssetSymbol: 'RNDR',
132
+ marketIndex: 12,
133
+ oracle: new web3_js_1.PublicKey('C2QvUPBiU3fViSyqA4nZgGyYqLgYf9PRpd8B8oLoo48w'),
134
+ launchTs: 1683125906000,
135
+ oracleSource: __1.OracleSource.PYTH,
136
+ },
127
137
  ];
128
138
  exports.MainnetPerpMarkets = [
129
139
  {
@@ -246,6 +256,16 @@ exports.MainnetPerpMarkets = [
246
256
  launchTs: 1683125906000,
247
257
  oracleSource: __1.OracleSource.PYTH,
248
258
  },
259
+ {
260
+ fullName: 'RNDR',
261
+ category: ['Infra'],
262
+ symbol: 'RNDR-PERP',
263
+ baseAssetSymbol: 'RNDR',
264
+ marketIndex: 12,
265
+ oracle: new web3_js_1.PublicKey('CYGfrBJB9HgLf9iZyN4aH5HvUAi2htQ4MjPxeXMf4Egn'),
266
+ launchTs: 1683125906000,
267
+ oracleSource: __1.OracleSource.PYTH,
268
+ },
249
269
  ];
250
270
  exports.PerpMarkets = {
251
271
  devnet: exports.DevnetPerpMarkets,
@@ -92,7 +92,7 @@ function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now, })
92
92
  pegMultiplier: updatedAmm.pegMultiplier,
93
93
  };
94
94
  const getL2Bids = function* () {
95
- while (numBids < numOrders) {
95
+ while (numBids < numOrders && baseSize.gt(__1.ZERO)) {
96
96
  const [afterSwapQuoteReserves, afterSwapBaseReserves] = (0, __1.calculateAmmReservesAfterSwap)(bidAmm, 'base', baseSize, __1.SwapDirection.ADD);
97
97
  const quoteSwapped = (0, __1.calculateQuoteAssetAmountSwapped)(bidAmm.quoteAssetReserve.sub(afterSwapQuoteReserves).abs(), bidAmm.pegMultiplier, __1.SwapDirection.ADD);
98
98
  const price = quoteSwapped.mul(__1.BASE_PRECISION).div(baseSize);
@@ -115,7 +115,7 @@ function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now, })
115
115
  pegMultiplier: updatedAmm.pegMultiplier,
116
116
  };
117
117
  const getL2Asks = function* () {
118
- while (numAsks < numOrders) {
118
+ while (numAsks < numOrders && askSize.gt(__1.ZERO)) {
119
119
  const [afterSwapQuoteReserves, afterSwapBaseReserves] = (0, __1.calculateAmmReservesAfterSwap)(askAmm, 'base', askSize, __1.SwapDirection.REMOVE);
120
120
  const quoteSwapped = (0, __1.calculateQuoteAssetAmountSwapped)(askAmm.quoteAssetReserve.sub(afterSwapQuoteReserves).abs(), askAmm.pegMultiplier, __1.SwapDirection.REMOVE);
121
121
  const price = quoteSwapped.mul(__1.BASE_PRECISION).div(askSize);
@@ -19,7 +19,7 @@ type RemainingAccountParams = {
19
19
  userAccounts: UserAccount[];
20
20
  writablePerpMarketIndexes?: number[];
21
21
  writableSpotMarketIndexes?: number[];
22
- readablePerpMarketIndex?: number;
22
+ readablePerpMarketIndex?: number | number[];
23
23
  readableSpotMarketIndexes?: number[];
24
24
  useMarketLastSlotCache?: boolean;
25
25
  };
@@ -44,6 +44,8 @@ export declare class DriftClient {
44
44
  txSender: TxSender;
45
45
  perpMarketLastSlotCache: Map<number, number>;
46
46
  spotMarketLastSlotCache: Map<number, number>;
47
+ mustIncludePerpMarketIndexes: Set<number>;
48
+ mustIncludeSpotMarketIndexes: Set<number>;
47
49
  authority: PublicKey;
48
50
  marketLookupTable: PublicKey;
49
51
  lookupTableAccount: AddressLookupTableAccount;
@@ -114,6 +116,7 @@ export declare class DriftClient {
114
116
  initializeReferrerName(name: string): Promise<TransactionSignature>;
115
117
  updateUserName(name: string, subAccountId?: number): Promise<TransactionSignature>;
116
118
  updateUserCustomMarginRatio(marginRatio: number, subAccountId?: number): Promise<TransactionSignature>;
119
+ getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
117
120
  updateUserMarginTradingEnabled(marginTradingEnabled: boolean, subAccountId?: number): Promise<TransactionSignature>;
118
121
  updateUserDelegate(delegate: PublicKey, subAccountId?: number): Promise<TransactionSignature>;
119
122
  fetchAllUserAccounts(includeIdle?: boolean): Promise<ProgramAccount<UserAccount>[]>;
@@ -162,7 +165,20 @@ export declare class DriftClient {
162
165
  * @param amount
163
166
  */
164
167
  convertToPricePrecision(amount: BN | number): BN;
168
+ /**
169
+ * Each drift instruction must include perp and sport market accounts in the ix remaining accounts.
170
+ * Use this function to force a subset of markets to be included in the remaining accounts for every ix
171
+ *
172
+ * @param perpMarketIndexes
173
+ * @param spotMarketIndexes
174
+ */
175
+ mustIncludeMarketsInIx({ perpMarketIndexes, spotMarketIndexes, }: {
176
+ perpMarketIndexes: number[];
177
+ spotMarketIndexes: number[];
178
+ }): void;
165
179
  getRemainingAccounts(params: RemainingAccountParams): AccountMeta[];
180
+ addPerpMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>, perpMarketAccountMap: Map<number, AccountMeta>): void;
181
+ addSpotMarketToRemainingAccountMaps(marketIndex: number, writable: boolean, oracleAccountMap: Map<string, AccountMeta>, spotMarketAccountMap: Map<number, AccountMeta>): void;
166
182
  getRemainingAccountMapsForUsers(userAccounts: UserAccount[]): {
167
183
  oracleAccountMap: Map<string, AccountMeta>;
168
184
  spotMarketAccountMap: Map<number, AccountMeta>;
@@ -189,7 +205,11 @@ export declare class DriftClient {
189
205
  deposit(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
190
206
  getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
191
207
  private checkIfAccountExists;
192
- private getWrappedSolAccountCreationIxs;
208
+ getWrappedSolAccountCreationIxs(amount: BN, includeRent?: boolean): Promise<{
209
+ ixs: anchor.web3.TransactionInstruction[];
210
+ signers: Signer[];
211
+ pubkey: PublicKey;
212
+ }>;
193
213
  getAssociatedTokenAccountCreationIx(tokenMintAddress: PublicKey, associatedTokenAddress: PublicKey): anchor.web3.TransactionInstruction;
194
214
  /**
195
215
  * Creates the User account for a user, and deposits some initial collateral
@@ -253,7 +273,6 @@ export declare class DriftClient {
253
273
  signedFillTx: Transaction;
254
274
  }>;
255
275
  placePerpOrder(orderParams: OptionalOrderParams, txParams?: TxParams): Promise<TransactionSignature>;
256
- getOrderParams(optionalOrderParams: OptionalOrderParams, marketType: MarketType): OrderParams;
257
276
  getPlacePerpOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
258
277
  updateAMMs(marketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
259
278
  getUpdateAMMsIx(marketIndexes: number[]): Promise<TransactionInstruction>;
@@ -271,6 +290,8 @@ export declare class DriftClient {
271
290
  marketIndex?: number;
272
291
  direction?: PositionDirection;
273
292
  }, placeOrderParams: OrderParams[], txParams?: TxParams): Promise<TransactionSignature>;
293
+ placeOrders(params: OrderParams[], txParams?: TxParams): Promise<TransactionSignature>;
294
+ getPlaceOrdersIx(params: OrderParams[]): Promise<TransactionInstruction>;
274
295
  fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
275
296
  getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
276
297
  getRevertFillIx(): Promise<TransactionInstruction>;
@@ -306,6 +327,22 @@ export declare class DriftClient {
306
327
  reduceOnly?: SwapReduceOnly;
307
328
  txParams?: TxParams;
308
329
  }): Promise<TransactionSignature>;
330
+ getJupiterSwapIx({ jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, route, reduceOnly, userAccountPublicKey, }: {
331
+ jupiterClient: JupiterClient;
332
+ outMarketIndex: number;
333
+ inMarketIndex: number;
334
+ outAssociatedTokenAccount?: PublicKey;
335
+ inAssociatedTokenAccount?: PublicKey;
336
+ amount: BN;
337
+ slippageBps?: number;
338
+ swapMode?: SwapMode;
339
+ route?: Route;
340
+ reduceOnly?: SwapReduceOnly;
341
+ userAccountPublicKey?: PublicKey;
342
+ }): Promise<{
343
+ ixs: TransactionInstruction[];
344
+ lookupTables: AddressLookupTableAccount[];
345
+ }>;
309
346
  /**
310
347
  * Get the drift begin_swap and end_swap instructions
311
348
  *
@@ -315,8 +352,10 @@ export declare class DriftClient {
315
352
  * @param inTokenAccount the token account to move the tokens being sold
316
353
  * @param outTokenAccount the token account to receive the tokens being bought
317
354
  * @param limitPrice the limit price of the swap
355
+ * @param reduceOnly
356
+ * @param userAccountPublicKey optional, specify a custom userAccountPublicKey to use instead of getting the current user account; can be helpful if the account is being created within the current tx
318
357
  */
319
- getSwapIx({ outMarketIndex, inMarketIndex, amountIn, inTokenAccount, outTokenAccount, limitPrice, reduceOnly, }: {
358
+ getSwapIx({ outMarketIndex, inMarketIndex, amountIn, inTokenAccount, outTokenAccount, limitPrice, reduceOnly, userAccountPublicKey, }: {
320
359
  outMarketIndex: number;
321
360
  inMarketIndex: number;
322
361
  amountIn: BN;
@@ -324,10 +363,18 @@ export declare class DriftClient {
324
363
  outTokenAccount: PublicKey;
325
364
  limitPrice?: BN;
326
365
  reduceOnly?: SwapReduceOnly;
366
+ userAccountPublicKey?: PublicKey;
327
367
  }): Promise<{
328
368
  beginSwapIx: TransactionInstruction;
329
369
  endSwapIx: TransactionInstruction;
330
370
  }>;
371
+ stakeForMSOL({ amount }: {
372
+ amount: BN;
373
+ }): Promise<TxSigAndSlot>;
374
+ getStakeForMSOLIx({ amount, userAccountPublicKey, }: {
375
+ amount: BN;
376
+ userAccountPublicKey?: PublicKey;
377
+ }): Promise<TransactionInstruction[]>;
331
378
  triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, txParams?: TxParams): Promise<TransactionSignature>;
332
379
  getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
333
380
  forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;