@drift-labs/sdk 2.49.0-beta.3 → 2.49.0-beta.5
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 +1 -1
- package/lib/dlob/DLOB.d.ts +6 -2
- package/lib/dlob/DLOB.js +37 -12
- package/lib/driftClient.d.ts +66 -66
- package/lib/driftClient.js +198 -192
- package/lib/types.d.ts +0 -2
- package/package.json +1 -1
- package/src/dlob/DLOB.ts +55 -15
- package/src/driftClient.ts +418 -270
- package/src/types.ts +0 -2
- package/tests/dlob/helpers.ts +2 -6
- package/tests/dlob/test.ts +190 -0
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.49.0-beta.
|
|
1
|
+
2.49.0-beta.5
|
package/lib/dlob/DLOB.d.ts
CHANGED
|
@@ -68,11 +68,15 @@ export declare class DLOB {
|
|
|
68
68
|
updateRestingLimitOrdersForMarketType(slot: number, marketTypeStr: MarketTypeStr): void;
|
|
69
69
|
getOrder(orderId: number, userAccount: PublicKey): Order | undefined;
|
|
70
70
|
findNodesToFill(marketIndex: number, fallbackBid: BN | undefined, fallbackAsk: BN | undefined, slot: number, ts: number, marketType: MarketType, oraclePriceData: OraclePriceData, stateAccount: StateAccount, marketAccount: PerpMarketAccount | SpotMarketAccount): NodeToFill[];
|
|
71
|
+
getMakerRebate(marketType: MarketType, stateAccount: StateAccount, marketAccount: PerpMarketAccount | SpotMarketAccount): {
|
|
72
|
+
makerRebateNumerator: number;
|
|
73
|
+
makerRebateDenominator: number;
|
|
74
|
+
};
|
|
71
75
|
mergeNodesToFill(restingLimitOrderNodesToFill: NodeToFill[], takingOrderNodesToFill: NodeToFill[]): NodeToFill[];
|
|
72
|
-
findRestingLimitOrderNodesToFill(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, isAmmPaused: boolean, minAuctionDuration: number, fallbackAsk: BN | undefined, fallbackBid: BN | undefined): NodeToFill[];
|
|
76
|
+
findRestingLimitOrderNodesToFill(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, isAmmPaused: boolean, minAuctionDuration: number, makerRebateNumerator: number, makerRebateDenominator: number, fallbackAsk: BN | undefined, fallbackBid: BN | undefined): NodeToFill[];
|
|
73
77
|
findTakingNodesToFill(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, isAmmPaused: boolean, minAuctionDuration: number, fallbackAsk: BN | undefined, fallbackBid?: BN | undefined): NodeToFill[];
|
|
74
78
|
findTakingNodesCrossingMakerNodes(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData, takerNodeGenerator: Generator<DLOBNode>, makerNodeGeneratorFn: (marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData) => Generator<DLOBNode>, doesCross: (takerPrice: BN | undefined, makerPrice: BN) => boolean): NodeToFill[];
|
|
75
|
-
findNodesCrossingFallbackLiquidity(marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, nodeGenerator: Generator<DLOBNode>,
|
|
79
|
+
findNodesCrossingFallbackLiquidity(marketType: MarketType, slot: number, oraclePriceData: OraclePriceData, nodeGenerator: Generator<DLOBNode>, doesCross: (nodePrice: BN | undefined) => boolean, minAuctionDuration: number): NodeToFill[];
|
|
76
80
|
findExpiredNodesToFill(marketIndex: number, ts: number, marketType: MarketType): NodeToFill[];
|
|
77
81
|
findJitAuctionNodesToFill(marketIndex: number, slot: number, oraclePriceData: OraclePriceData, marketType: MarketType): NodeToFill[];
|
|
78
82
|
getTakingBids(marketIndex: number, marketType: MarketType, slot: number, oraclePriceData: OraclePriceData): Generator<DLOBNode>;
|
package/lib/dlob/DLOB.js
CHANGED
|
@@ -304,7 +304,8 @@ class DLOB {
|
|
|
304
304
|
const minAuctionDuration = (0, __1.isVariant)(marketType, 'perp')
|
|
305
305
|
? stateAccount.minPerpAuctionDuration
|
|
306
306
|
: 0;
|
|
307
|
-
const
|
|
307
|
+
const { makerRebateNumerator, makerRebateDenominator } = this.getMakerRebate(marketType, stateAccount, marketAccount);
|
|
308
|
+
const restingLimitOrderNodesToFill = this.findRestingLimitOrderNodesToFill(marketIndex, slot, marketType, oraclePriceData, isAmmPaused, minAuctionDuration, makerRebateNumerator, makerRebateDenominator, fallbackAsk, fallbackBid);
|
|
308
309
|
const takingOrderNodesToFill = this.findTakingNodesToFill(marketIndex, slot, marketType, oraclePriceData, isAmmPaused, minAuctionDuration, fallbackAsk, fallbackBid);
|
|
309
310
|
// get expired market nodes
|
|
310
311
|
const expiredNodesToFill = this.findExpiredNodesToFill(marketIndex, ts, marketType);
|
|
@@ -314,6 +315,28 @@ class DLOB {
|
|
|
314
315
|
}
|
|
315
316
|
return this.mergeNodesToFill(restingLimitOrderNodesToFill, takingOrderNodesToFill).concat(expiredNodesToFill);
|
|
316
317
|
}
|
|
318
|
+
getMakerRebate(marketType, stateAccount, marketAccount) {
|
|
319
|
+
let makerRebateNumerator;
|
|
320
|
+
let makerRebateDenominator;
|
|
321
|
+
if ((0, __1.isVariant)(marketType, 'perp')) {
|
|
322
|
+
makerRebateNumerator =
|
|
323
|
+
stateAccount.perpFeeStructure.feeTiers[0].makerRebateNumerator;
|
|
324
|
+
makerRebateDenominator =
|
|
325
|
+
stateAccount.perpFeeStructure.feeTiers[0].makerRebateDenominator;
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
makerRebateNumerator =
|
|
329
|
+
stateAccount.spotFeeStructure.feeTiers[0].makerRebateNumerator;
|
|
330
|
+
makerRebateDenominator =
|
|
331
|
+
stateAccount.spotFeeStructure.feeTiers[0].makerRebateDenominator;
|
|
332
|
+
}
|
|
333
|
+
// @ts-ignore
|
|
334
|
+
const feeAdjustment = marketAccount.feeAdjustment || 0;
|
|
335
|
+
if (feeAdjustment !== 0) {
|
|
336
|
+
makerRebateNumerator += (makerRebateNumerator * feeAdjustment) / 100;
|
|
337
|
+
}
|
|
338
|
+
return { makerRebateNumerator, makerRebateDenominator };
|
|
339
|
+
}
|
|
317
340
|
mergeNodesToFill(restingLimitOrderNodesToFill, takingOrderNodesToFill) {
|
|
318
341
|
const mergedNodesToFill = new Map();
|
|
319
342
|
const mergeNodesToFillHelper = (nodesToFillArray) => {
|
|
@@ -336,7 +359,7 @@ class DLOB {
|
|
|
336
359
|
mergeNodesToFillHelper(takingOrderNodesToFill);
|
|
337
360
|
return Array.from(mergedNodesToFill.values());
|
|
338
361
|
}
|
|
339
|
-
findRestingLimitOrderNodesToFill(marketIndex, slot, marketType, oraclePriceData, isAmmPaused, minAuctionDuration, fallbackAsk, fallbackBid) {
|
|
362
|
+
findRestingLimitOrderNodesToFill(marketIndex, slot, marketType, oraclePriceData, isAmmPaused, minAuctionDuration, makerRebateNumerator, makerRebateDenominator, fallbackAsk, fallbackBid) {
|
|
340
363
|
const nodesToFill = new Array();
|
|
341
364
|
const crossingNodes = this.findCrossingRestingLimitOrders(marketIndex, slot, marketType, oraclePriceData);
|
|
342
365
|
for (const crossingNode of crossingNodes) {
|
|
@@ -344,8 +367,9 @@ class DLOB {
|
|
|
344
367
|
}
|
|
345
368
|
if (fallbackBid && !isAmmPaused) {
|
|
346
369
|
const askGenerator = this.getRestingLimitAsks(marketIndex, slot, marketType, oraclePriceData);
|
|
347
|
-
const
|
|
348
|
-
|
|
370
|
+
const fallbackBidWithBuffer = fallbackBid.sub(fallbackBid.muln(makerRebateNumerator).divn(makerRebateDenominator));
|
|
371
|
+
const asksCrossingFallback = this.findNodesCrossingFallbackLiquidity(marketType, slot, oraclePriceData, askGenerator, (askPrice) => {
|
|
372
|
+
return askPrice.lte(fallbackBidWithBuffer);
|
|
349
373
|
}, minAuctionDuration);
|
|
350
374
|
for (const askCrossingFallback of asksCrossingFallback) {
|
|
351
375
|
nodesToFill.push(askCrossingFallback);
|
|
@@ -353,8 +377,9 @@ class DLOB {
|
|
|
353
377
|
}
|
|
354
378
|
if (fallbackAsk && !isAmmPaused) {
|
|
355
379
|
const bidGenerator = this.getRestingLimitBids(marketIndex, slot, marketType, oraclePriceData);
|
|
356
|
-
const
|
|
357
|
-
|
|
380
|
+
const fallbackAskWithBuffer = fallbackAsk.add(fallbackAsk.muln(makerRebateNumerator).divn(makerRebateDenominator));
|
|
381
|
+
const bidsCrossingFallback = this.findNodesCrossingFallbackLiquidity(marketType, slot, oraclePriceData, bidGenerator, (bidPrice) => {
|
|
382
|
+
return bidPrice.gte(fallbackAskWithBuffer);
|
|
358
383
|
}, minAuctionDuration);
|
|
359
384
|
for (const bidCrossingFallback of bidsCrossingFallback) {
|
|
360
385
|
nodesToFill.push(bidCrossingFallback);
|
|
@@ -381,8 +406,8 @@ class DLOB {
|
|
|
381
406
|
}
|
|
382
407
|
if (fallbackBid && !isAmmPaused) {
|
|
383
408
|
takingOrderGenerator = this.getTakingAsks(marketIndex, marketType, slot, oraclePriceData);
|
|
384
|
-
const takingAsksCrossingFallback = this.findNodesCrossingFallbackLiquidity(marketType, slot, oraclePriceData, takingOrderGenerator,
|
|
385
|
-
return takerPrice === undefined || takerPrice.lte(
|
|
409
|
+
const takingAsksCrossingFallback = this.findNodesCrossingFallbackLiquidity(marketType, slot, oraclePriceData, takingOrderGenerator, (takerPrice) => {
|
|
410
|
+
return takerPrice === undefined || takerPrice.lte(fallbackBid);
|
|
386
411
|
}, minAuctionDuration);
|
|
387
412
|
for (const takingAskCrossingFallback of takingAsksCrossingFallback) {
|
|
388
413
|
nodesToFill.push(takingAskCrossingFallback);
|
|
@@ -405,8 +430,8 @@ class DLOB {
|
|
|
405
430
|
}
|
|
406
431
|
if (fallbackAsk && !isAmmPaused) {
|
|
407
432
|
takingOrderGenerator = this.getTakingBids(marketIndex, marketType, slot, oraclePriceData);
|
|
408
|
-
const takingBidsCrossingFallback = this.findNodesCrossingFallbackLiquidity(marketType, slot, oraclePriceData, takingOrderGenerator,
|
|
409
|
-
return takerPrice === undefined || takerPrice.gte(
|
|
433
|
+
const takingBidsCrossingFallback = this.findNodesCrossingFallbackLiquidity(marketType, slot, oraclePriceData, takingOrderGenerator, (takerPrice) => {
|
|
434
|
+
return takerPrice === undefined || takerPrice.gte(fallbackAsk);
|
|
410
435
|
}, minAuctionDuration);
|
|
411
436
|
for (const marketBidCrossingFallback of takingBidsCrossingFallback) {
|
|
412
437
|
nodesToFill.push(marketBidCrossingFallback);
|
|
@@ -456,7 +481,7 @@ class DLOB {
|
|
|
456
481
|
}
|
|
457
482
|
return nodesToFill;
|
|
458
483
|
}
|
|
459
|
-
findNodesCrossingFallbackLiquidity(marketType, slot, oraclePriceData, nodeGenerator,
|
|
484
|
+
findNodesCrossingFallbackLiquidity(marketType, slot, oraclePriceData, nodeGenerator, doesCross, minAuctionDuration) {
|
|
460
485
|
var _a;
|
|
461
486
|
const nodesToFill = new Array();
|
|
462
487
|
let nextNode = nodeGenerator.next();
|
|
@@ -468,7 +493,7 @@ class DLOB {
|
|
|
468
493
|
}
|
|
469
494
|
const nodePrice = (0, __1.getLimitPrice)(node.order, oraclePriceData, slot);
|
|
470
495
|
// order crosses if there is no limit price or it crosses fallback price
|
|
471
|
-
const crosses = doesCross(nodePrice
|
|
496
|
+
const crosses = doesCross(nodePrice);
|
|
472
497
|
// fallback is available if auction is complete or it's a spot order
|
|
473
498
|
const fallbackAvailable = (0, __1.isVariant)(marketType, 'spot') ||
|
|
474
499
|
(0, __1.isFallbackAvailableLiquiditySource)(node.order, minAuctionDuration, slot);
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ export declare class DriftClient {
|
|
|
149
149
|
*/
|
|
150
150
|
forceGetUserAccount(subAccountId?: number): Promise<UserAccount | undefined>;
|
|
151
151
|
getUserAccountAndSlot(subAccountId?: number): DataAndSlot<UserAccount> | undefined;
|
|
152
|
-
getSpotPosition(marketIndex: number): SpotPosition | undefined;
|
|
152
|
+
getSpotPosition(marketIndex: number, subAccountId?: number): SpotPosition | undefined;
|
|
153
153
|
getQuoteAssetTokenAmount(): BN;
|
|
154
154
|
/**
|
|
155
155
|
* Returns the token amount for a given market. The spot market precision is based on the token mint decimals.
|
|
@@ -192,8 +192,8 @@ export declare class DriftClient {
|
|
|
192
192
|
spotMarketAccountMap: Map<number, AccountMeta>;
|
|
193
193
|
perpMarketAccountMap: Map<number, AccountMeta>;
|
|
194
194
|
};
|
|
195
|
-
getOrder(orderId: number): Order | undefined;
|
|
196
|
-
getOrderByUserId(userOrderId: number): Order | undefined;
|
|
195
|
+
getOrder(orderId: number, subAccountId?: number): Order | undefined;
|
|
196
|
+
getOrderByUserId(userOrderId: number, subAccountId?: number): Order | undefined;
|
|
197
197
|
/**
|
|
198
198
|
* Get the associated token address for the given spot market
|
|
199
199
|
* @param marketIndex
|
|
@@ -204,11 +204,11 @@ export declare class DriftClient {
|
|
|
204
204
|
/**
|
|
205
205
|
* Deposit funds into the given spot market
|
|
206
206
|
*
|
|
207
|
-
* @param amount
|
|
208
|
-
* @param marketIndex
|
|
207
|
+
* @param amount to deposit
|
|
208
|
+
* @param marketIndex spot market index to deposit into
|
|
209
209
|
* @param associatedTokenAccount can be the wallet public key if using native sol
|
|
210
|
-
* @param subAccountId
|
|
211
|
-
* @param reduceOnly
|
|
210
|
+
* @param subAccountId subaccountId to deposit
|
|
211
|
+
* @param reduceOnly if true, deposit must not increase account risk
|
|
212
212
|
*/
|
|
213
213
|
deposit(amount: BN, marketIndex: number, associatedTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
214
214
|
getDepositInstruction(amount: BN, marketIndex: number, userTokenAccount: PublicKey, subAccountId?: number, reduceOnly?: boolean, userInitialized?: boolean): Promise<TransactionInstruction>;
|
|
@@ -239,8 +239,8 @@ export declare class DriftClient {
|
|
|
239
239
|
* @param associatedTokenAddress - the token account to withdraw to. can be the wallet public key if using native sol
|
|
240
240
|
* @param reduceOnly
|
|
241
241
|
*/
|
|
242
|
-
withdraw(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean): Promise<TransactionSignature>;
|
|
243
|
-
getWithdrawIx(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean): Promise<TransactionInstruction>;
|
|
242
|
+
withdraw(amount: BN, marketIndex: number, associatedTokenAddress: PublicKey, reduceOnly?: boolean, subAccountId?: number): Promise<TransactionSignature>;
|
|
243
|
+
getWithdrawIx(amount: BN, marketIndex: number, userTokenAccount: PublicKey, reduceOnly?: boolean, subAccountId?: number): Promise<TransactionInstruction>;
|
|
244
244
|
/**
|
|
245
245
|
* Withdraws from the fromSubAccount and deposits into the toSubAccount
|
|
246
246
|
* @param amount
|
|
@@ -255,17 +255,17 @@ export declare class DriftClient {
|
|
|
255
255
|
updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
256
256
|
settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
257
257
|
settleLPIx(settleeUserAccountPublicKey: PublicKey, marketIndex: number): Promise<TransactionInstruction>;
|
|
258
|
-
removePerpLpShares(marketIndex: number, sharesToBurn?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
258
|
+
removePerpLpShares(marketIndex: number, sharesToBurn?: BN, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
259
259
|
removePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
260
260
|
getRemovePerpLpSharesInExpiringMarket(marketIndex: number, userAccountPublicKey: PublicKey, sharesToBurn?: BN): Promise<TransactionInstruction>;
|
|
261
|
-
getRemovePerpLpSharesIx(marketIndex: number, sharesToBurn?: BN): Promise<TransactionInstruction>;
|
|
262
|
-
addPerpLpShares(amount: BN, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
263
|
-
getAddPerpLpSharesIx(amount: BN, marketIndex: number): Promise<TransactionInstruction>;
|
|
261
|
+
getRemovePerpLpSharesIx(marketIndex: number, sharesToBurn?: BN, subAccountId?: number): Promise<TransactionInstruction>;
|
|
262
|
+
addPerpLpShares(amount: BN, marketIndex: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
263
|
+
getAddPerpLpSharesIx(amount: BN, marketIndex: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
264
264
|
getQuoteValuePerLpShare(marketIndex: number): BN;
|
|
265
265
|
/**
|
|
266
266
|
* @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
|
|
267
267
|
*/
|
|
268
|
-
openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN): Promise<TransactionSignature>;
|
|
268
|
+
openPosition(direction: PositionDirection, amount: BN, marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
|
|
269
269
|
sendSignedTx(tx: Transaction): Promise<TransactionSignature>;
|
|
270
270
|
/**
|
|
271
271
|
* Sends a market order and returns a signed tx which can fill the order against the vamm, which the caller can use to fill their own order if required.
|
|
@@ -283,35 +283,35 @@ export declare class DriftClient {
|
|
|
283
283
|
signedFillTx?: Transaction;
|
|
284
284
|
signedCancelExistingOrdersTx?: Transaction;
|
|
285
285
|
}>;
|
|
286
|
-
placePerpOrder(orderParams: OptionalOrderParams, txParams?: TxParams): Promise<TransactionSignature>;
|
|
287
|
-
getPlacePerpOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
|
|
286
|
+
placePerpOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
287
|
+
getPlacePerpOrderIx(orderParams: OptionalOrderParams, subAccountId?: number): Promise<TransactionInstruction>;
|
|
288
288
|
updateAMMs(marketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
289
289
|
getUpdateAMMsIx(marketIndexes: number[]): Promise<TransactionInstruction>;
|
|
290
290
|
settleExpiredMarket(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
291
291
|
getSettleExpiredMarketIx(marketIndex: number): Promise<TransactionInstruction>;
|
|
292
292
|
settleExpiredMarketPoolsToRevenuePool(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
293
|
-
cancelOrder(orderId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
294
|
-
getCancelOrderIx(orderId?: number): Promise<TransactionInstruction>;
|
|
295
|
-
cancelOrderByUserId(userOrderId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
296
|
-
getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
|
|
297
|
-
cancelOrdersByIds(orderIds?: number[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
298
|
-
getCancelOrdersByIdsIx(orderIds?: number[]): Promise<TransactionInstruction>;
|
|
299
|
-
cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams): Promise<TransactionSignature>;
|
|
300
|
-
getCancelOrdersIx(marketType: MarketType | null, marketIndex: number | null, direction: PositionDirection | null): Promise<TransactionInstruction>;
|
|
293
|
+
cancelOrder(orderId?: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
294
|
+
getCancelOrderIx(orderId?: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
295
|
+
cancelOrderByUserId(userOrderId: number, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
296
|
+
getCancelOrderByUserIdIx(userOrderId: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
297
|
+
cancelOrdersByIds(orderIds?: number[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
298
|
+
getCancelOrdersByIdsIx(orderIds?: number[], subAccountId?: number): Promise<TransactionInstruction>;
|
|
299
|
+
cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
300
|
+
getCancelOrdersIx(marketType: MarketType | null, marketIndex: number | null, direction: PositionDirection | null, subAccountId?: number): Promise<TransactionInstruction>;
|
|
301
301
|
cancelAndPlaceOrders(cancelOrderParams: {
|
|
302
302
|
marketType?: MarketType;
|
|
303
303
|
marketIndex?: number;
|
|
304
304
|
direction?: PositionDirection;
|
|
305
|
-
}, placeOrderParams: OrderParams[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
306
|
-
placeOrders(params: OrderParams[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
307
|
-
getPlaceOrdersIx(params: OrderParams[]): Promise<TransactionInstruction>;
|
|
308
|
-
fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
309
|
-
getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
310
|
-
getRevertFillIx(): Promise<TransactionInstruction>;
|
|
311
|
-
placeSpotOrder(orderParams: OptionalOrderParams, txParams?: TxParams): Promise<TransactionSignature>;
|
|
312
|
-
getPlaceSpotOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
|
|
305
|
+
}, placeOrderParams: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
306
|
+
placeOrders(params: OrderParams[], txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
307
|
+
getPlaceOrdersIx(params: OrderParams[], subAccountId?: number): Promise<TransactionInstruction>;
|
|
308
|
+
fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams, fillerPublicKey?: number): Promise<TransactionSignature>;
|
|
309
|
+
getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerSubAccountId?: number): Promise<TransactionInstruction>;
|
|
310
|
+
getRevertFillIx(fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
311
|
+
placeSpotOrder(orderParams: OptionalOrderParams, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
312
|
+
getPlaceSpotOrderIx(orderParams: OptionalOrderParams, subAccountId?: number): Promise<TransactionInstruction>;
|
|
313
313
|
fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
314
|
-
getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
314
|
+
getFillSpotOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
315
315
|
addSpotFulfillmentAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount): void;
|
|
316
316
|
addSerumRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: SerumV3FulfillmentConfigAccount): void;
|
|
317
317
|
addPhoenixRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: PhoenixV1FulfillmentConfigAccount): void;
|
|
@@ -412,26 +412,26 @@ export declare class DriftClient {
|
|
|
412
412
|
amount: BN;
|
|
413
413
|
userAccountPublicKey?: PublicKey;
|
|
414
414
|
}): Promise<TransactionInstruction[]>;
|
|
415
|
-
triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, txParams?: TxParams): Promise<TransactionSignature>;
|
|
416
|
-
getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
|
|
417
|
-
forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
418
|
-
getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
|
|
419
|
-
updateUserIdle(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
420
|
-
getUpdateUserIdleIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
|
|
421
|
-
updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
422
|
-
getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
|
|
423
|
-
placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
424
|
-
getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
425
|
-
placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
426
|
-
getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
427
|
-
placeAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
428
|
-
getPlaceAndTakeSpotOrderIx(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
429
|
-
placeAndMakeSpotOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
|
|
430
|
-
getPlaceAndMakeSpotOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
|
|
415
|
+
triggerOrder(userAccountPublicKey: PublicKey, user: UserAccount, order: Order, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
416
|
+
getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
417
|
+
forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
418
|
+
getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
419
|
+
updateUserIdle(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
420
|
+
getUpdateUserIdleIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
421
|
+
updateUserOpenOrdersCount(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams, fillerPublicKey?: PublicKey): Promise<TransactionSignature>;
|
|
422
|
+
getUpdateUserOpenOrdersCountIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
423
|
+
placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
424
|
+
getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
425
|
+
placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
426
|
+
getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
427
|
+
placeAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
428
|
+
getPlaceAndTakeSpotOrderIx(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
429
|
+
placeAndMakeSpotOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
430
|
+
getPlaceAndMakeSpotOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
431
431
|
/**
|
|
432
432
|
* @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
|
|
433
433
|
*/
|
|
434
|
-
closePosition(marketIndex: number, limitPrice?: BN): Promise<TransactionSignature>;
|
|
434
|
+
closePosition(marketIndex: number, limitPrice?: BN, subAccountId?: number): Promise<TransactionSignature>;
|
|
435
435
|
/**
|
|
436
436
|
* Modifies an open order by closing it and replacing it with a new order.
|
|
437
437
|
* @deprecated use modifyOrder instead
|
|
@@ -486,7 +486,7 @@ export declare class DriftClient {
|
|
|
486
486
|
immediateOrCancel?: boolean;
|
|
487
487
|
maxTs?: BN;
|
|
488
488
|
policy?: ModifyOrderPolicy;
|
|
489
|
-
}, txParams?: TxParams): Promise<TransactionSignature>;
|
|
489
|
+
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
490
490
|
getModifyOrderIx({ orderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: {
|
|
491
491
|
orderId: number;
|
|
492
492
|
newDirection?: PositionDirection;
|
|
@@ -503,7 +503,7 @@ export declare class DriftClient {
|
|
|
503
503
|
immediateOrCancel?: boolean;
|
|
504
504
|
maxTs?: BN;
|
|
505
505
|
policy?: ModifyOrderPolicy;
|
|
506
|
-
}): Promise<TransactionInstruction>;
|
|
506
|
+
}, subAccountId?: number): Promise<TransactionInstruction>;
|
|
507
507
|
/**
|
|
508
508
|
* Modifies an open order by closing it and replacing it with a new order.
|
|
509
509
|
* @param orderParams.userOrderId: The open order to modify
|
|
@@ -538,7 +538,7 @@ export declare class DriftClient {
|
|
|
538
538
|
immediateOrCancel?: boolean;
|
|
539
539
|
policy?: ModifyOrderPolicy;
|
|
540
540
|
maxTs?: BN;
|
|
541
|
-
}, txParams?: TxParams): Promise<TransactionSignature>;
|
|
541
|
+
}, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
542
542
|
getModifyOrderByUserIdIx({ userOrderId, newDirection, newBaseAmount, newLimitPrice, newOraclePriceOffset, newTriggerPrice, newTriggerCondition, auctionDuration, auctionStartPrice, auctionEndPrice, reduceOnly, postOnly, immediateOrCancel, maxTs, policy, }: {
|
|
543
543
|
userOrderId: number;
|
|
544
544
|
newDirection?: PositionDirection;
|
|
@@ -556,7 +556,7 @@ export declare class DriftClient {
|
|
|
556
556
|
policy?: ModifyOrderPolicy;
|
|
557
557
|
maxTs?: BN;
|
|
558
558
|
txParams?: TxParams;
|
|
559
|
-
}): Promise<TransactionInstruction>;
|
|
559
|
+
}, subAccountId?: number): Promise<TransactionInstruction>;
|
|
560
560
|
settlePNLs(users: {
|
|
561
561
|
settleeUserAccountPublicKey: PublicKey;
|
|
562
562
|
settleeUserAccount: UserAccount;
|
|
@@ -567,18 +567,18 @@ export declare class DriftClient {
|
|
|
567
567
|
}[], marketIndexes: number[]): Promise<Array<TransactionInstruction>>;
|
|
568
568
|
settlePNL(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
569
569
|
settlePNLIx(settleeUserAccountPublicKey: PublicKey, settleeUserAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
570
|
-
liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
571
|
-
getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN): Promise<TransactionInstruction>;
|
|
572
|
-
liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
573
|
-
getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN): Promise<TransactionInstruction>;
|
|
574
|
-
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
575
|
-
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN): Promise<TransactionInstruction>;
|
|
576
|
-
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, txParams?: TxParams): Promise<TransactionSignature>;
|
|
577
|
-
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN): Promise<TransactionInstruction>;
|
|
578
|
-
resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
579
|
-
getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
580
|
-
resolveSpotBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
581
|
-
getResolveSpotBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number): Promise<TransactionInstruction>;
|
|
570
|
+
liquidatePerp(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
571
|
+
getLiquidatePerpIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, maxBaseAssetAmount: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
572
|
+
liquidateSpot(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
573
|
+
getLiquidateSpotIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, assetMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
574
|
+
liquidateBorrowForPerpPnl(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
575
|
+
getLiquidateBorrowForPerpPnlIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, liabilityMarketIndex: number, maxLiabilityTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
576
|
+
liquidatePerpPnlForDeposit(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
577
|
+
getLiquidatePerpPnlForDepositIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, perpMarketIndex: number, assetMarketIndex: number, maxPnlTransfer: BN, limitPrice?: BN, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
578
|
+
resolvePerpBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
579
|
+
getResolvePerpBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
580
|
+
resolveSpotBankruptcy(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, txParams?: TxParams, liquidatorSubAccountId?: number): Promise<TransactionSignature>;
|
|
581
|
+
getResolveSpotBankruptcyIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, marketIndex: number, liquidatorSubAccountId?: number): Promise<TransactionInstruction>;
|
|
582
582
|
updateFundingRate(perpMarketIndex: number, oracle: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
583
583
|
getUpdateFundingRateIx(perpMarketIndex: number, oracle: PublicKey): Promise<TransactionInstruction>;
|
|
584
584
|
updatePerpBidAskTwap(perpMarketIndex: number, makers: [PublicKey, PublicKey][], txParams?: TxParams): Promise<TransactionSignature>;
|