@drift-labs/sdk 2.20.0-beta.3 → 2.20.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.
@@ -200,8 +200,8 @@ export declare class DriftClient {
200
200
  getTriggerOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Order): Promise<TransactionInstruction>;
201
201
  forceCancelOrders(userAccountPublicKey: PublicKey, user: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
202
202
  getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<TransactionInstruction>;
203
- placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
204
- getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
203
+ placeAndTakePerpOrder(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
204
+ getPlaceAndTakePerpOrderIx(orderParams: OptionalOrderParams, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
205
205
  placeAndMakePerpOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
206
206
  getPlaceAndMakePerpOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
207
207
  placeAndTakeSpotOrder(orderParams: OptionalOrderParams, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
@@ -1587,42 +1587,49 @@ class DriftClient {
1587
1587
  orderParams = this.getOrderParams(orderParams, types_1.MarketType.PERP);
1588
1588
  const userStatsPublicKey = await this.getUserStatsAccountPublicKey();
1589
1589
  const userAccountPublicKey = await this.getUserAccountPublicKey();
1590
+ makerInfo = Array.isArray(makerInfo)
1591
+ ? makerInfo
1592
+ : makerInfo
1593
+ ? [makerInfo]
1594
+ : [];
1590
1595
  const userAccounts = [this.getUserAccount()];
1591
- if (makerInfo !== undefined) {
1592
- userAccounts.push(makerInfo.makerUserAccount);
1596
+ for (const maker of makerInfo) {
1597
+ userAccounts.push(maker.makerUserAccount);
1593
1598
  }
1594
1599
  const remainingAccounts = this.getRemainingAccounts({
1595
1600
  userAccounts,
1596
1601
  useMarketLastSlotCache: true,
1597
1602
  writablePerpMarketIndexes: [orderParams.marketIndex],
1598
1603
  });
1599
- let makerOrderId = null;
1600
- if (makerInfo) {
1601
- makerOrderId = makerInfo.order.orderId;
1602
- remainingAccounts.push({
1603
- pubkey: makerInfo.maker,
1604
- isSigner: false,
1605
- isWritable: true,
1606
- });
1607
- remainingAccounts.push({
1608
- pubkey: makerInfo.makerStats,
1609
- isSigner: false,
1610
- isWritable: true,
1611
- });
1612
- }
1613
- if (referrerInfo) {
1604
+ for (const maker of makerInfo) {
1614
1605
  remainingAccounts.push({
1615
- pubkey: referrerInfo.referrer,
1606
+ pubkey: maker.maker,
1616
1607
  isWritable: true,
1617
1608
  isSigner: false,
1618
1609
  });
1619
1610
  remainingAccounts.push({
1620
- pubkey: referrerInfo.referrerStats,
1611
+ pubkey: maker.makerStats,
1621
1612
  isWritable: true,
1622
1613
  isSigner: false,
1623
1614
  });
1624
1615
  }
1625
- return await this.program.instruction.placeAndTakePerpOrder(orderParams, makerOrderId, {
1616
+ if (referrerInfo) {
1617
+ const referrerIsMaker = makerInfo.find((maker) => maker.maker.equals(referrerInfo.referrer)) !==
1618
+ undefined;
1619
+ if (!referrerIsMaker) {
1620
+ remainingAccounts.push({
1621
+ pubkey: referrerInfo.referrer,
1622
+ isWritable: true,
1623
+ isSigner: false,
1624
+ });
1625
+ remainingAccounts.push({
1626
+ pubkey: referrerInfo.referrerStats,
1627
+ isWritable: true,
1628
+ isSigner: false,
1629
+ });
1630
+ }
1631
+ }
1632
+ return await this.program.instruction.placeAndTakePerpOrder(orderParams, null, {
1626
1633
  accounts: {
1627
1634
  state: await this.getStatePublicKey(),
1628
1635
  user: userAccountPublicKey,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.20.0-beta.3",
2
+ "version": "2.20.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.20.0-beta.3",
3
+ "version": "2.20.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -2736,7 +2736,7 @@ export class DriftClient {
2736
2736
 
2737
2737
  public async placeAndTakePerpOrder(
2738
2738
  orderParams: OptionalOrderParams,
2739
- makerInfo?: MakerInfo,
2739
+ makerInfo?: MakerInfo | MakerInfo[],
2740
2740
  referrerInfo?: ReferrerInfo,
2741
2741
  txParams?: TxParams
2742
2742
  ): Promise<TransactionSignature> {
@@ -2759,54 +2759,64 @@ export class DriftClient {
2759
2759
 
2760
2760
  public async getPlaceAndTakePerpOrderIx(
2761
2761
  orderParams: OptionalOrderParams,
2762
- makerInfo?: MakerInfo,
2762
+ makerInfo?: MakerInfo | MakerInfo[],
2763
2763
  referrerInfo?: ReferrerInfo
2764
2764
  ): Promise<TransactionInstruction> {
2765
2765
  orderParams = this.getOrderParams(orderParams, MarketType.PERP);
2766
2766
  const userStatsPublicKey = await this.getUserStatsAccountPublicKey();
2767
2767
  const userAccountPublicKey = await this.getUserAccountPublicKey();
2768
2768
 
2769
+ makerInfo = Array.isArray(makerInfo)
2770
+ ? makerInfo
2771
+ : makerInfo
2772
+ ? [makerInfo]
2773
+ : [];
2774
+
2769
2775
  const userAccounts = [this.getUserAccount()];
2770
- if (makerInfo !== undefined) {
2771
- userAccounts.push(makerInfo.makerUserAccount);
2776
+ for (const maker of makerInfo) {
2777
+ userAccounts.push(maker.makerUserAccount);
2772
2778
  }
2779
+
2773
2780
  const remainingAccounts = this.getRemainingAccounts({
2774
2781
  userAccounts,
2775
2782
  useMarketLastSlotCache: true,
2776
2783
  writablePerpMarketIndexes: [orderParams.marketIndex],
2777
2784
  });
2778
2785
 
2779
- let makerOrderId = null;
2780
- if (makerInfo) {
2781
- makerOrderId = makerInfo.order.orderId;
2786
+ for (const maker of makerInfo) {
2782
2787
  remainingAccounts.push({
2783
- pubkey: makerInfo.maker,
2784
- isSigner: false,
2788
+ pubkey: maker.maker,
2785
2789
  isWritable: true,
2790
+ isSigner: false,
2786
2791
  });
2787
2792
  remainingAccounts.push({
2788
- pubkey: makerInfo.makerStats,
2789
- isSigner: false,
2793
+ pubkey: maker.makerStats,
2790
2794
  isWritable: true,
2795
+ isSigner: false,
2791
2796
  });
2792
2797
  }
2793
2798
 
2794
2799
  if (referrerInfo) {
2795
- remainingAccounts.push({
2796
- pubkey: referrerInfo.referrer,
2797
- isWritable: true,
2798
- isSigner: false,
2799
- });
2800
- remainingAccounts.push({
2801
- pubkey: referrerInfo.referrerStats,
2802
- isWritable: true,
2803
- isSigner: false,
2804
- });
2800
+ const referrerIsMaker =
2801
+ makerInfo.find((maker) => maker.maker.equals(referrerInfo.referrer)) !==
2802
+ undefined;
2803
+ if (!referrerIsMaker) {
2804
+ remainingAccounts.push({
2805
+ pubkey: referrerInfo.referrer,
2806
+ isWritable: true,
2807
+ isSigner: false,
2808
+ });
2809
+ remainingAccounts.push({
2810
+ pubkey: referrerInfo.referrerStats,
2811
+ isWritable: true,
2812
+ isSigner: false,
2813
+ });
2814
+ }
2805
2815
  }
2806
2816
 
2807
2817
  return await this.program.instruction.placeAndTakePerpOrder(
2808
2818
  orderParams,
2809
- makerOrderId,
2819
+ null,
2810
2820
  {
2811
2821
  accounts: {
2812
2822
  state: await this.getStatePublicKey(),
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.20.0-beta.3",
2
+ "version": "2.20.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {