@drift-labs/sdk 2.19.0 → 2.20.0-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.
@@ -186,8 +186,8 @@ export declare class DriftClient {
186
186
  getCancelOrderByUserIdIx(userOrderId: number): Promise<TransactionInstruction>;
187
187
  cancelOrders(marketType?: MarketType, marketIndex?: number, direction?: PositionDirection, txParams?: TxParams): Promise<TransactionSignature>;
188
188
  getCancelOrdersIx(marketType: MarketType | null, marketIndex: number | null, direction: PositionDirection | null): Promise<TransactionInstruction>;
189
- fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
190
- getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
189
+ fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
190
+ getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo): Promise<TransactionInstruction>;
191
191
  placeSpotOrder(orderParams: OptionalOrderParams, txParams?: TxParams): Promise<TransactionSignature>;
192
192
  getPlaceSpotOrderIx(orderParams: OptionalOrderParams): Promise<TransactionInstruction>;
193
193
  fillSpotOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Order, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, makerInfo?: MakerInfo, referrerInfo?: ReferrerInfo, txParams?: TxParams): Promise<TransactionSignature>;
@@ -1261,41 +1261,49 @@ class DriftClient {
1261
1261
  const marketIndex = order
1262
1262
  ? order.marketIndex
1263
1263
  : userAccount.orders.find((order) => order.orderId === userAccount.nextOrderId - 1).marketIndex;
1264
+ makerInfo = Array.isArray(makerInfo)
1265
+ ? makerInfo
1266
+ : makerInfo
1267
+ ? [makerInfo]
1268
+ : [];
1264
1269
  const userAccounts = [userAccount];
1265
- if (makerInfo !== undefined) {
1266
- userAccounts.push(makerInfo.makerUserAccount);
1270
+ for (const maker of makerInfo) {
1271
+ userAccounts.push(maker.makerUserAccount);
1267
1272
  }
1268
1273
  const remainingAccounts = this.getRemainingAccounts({
1269
1274
  userAccounts,
1270
1275
  writablePerpMarketIndexes: [marketIndex],
1271
1276
  });
1272
- if (makerInfo) {
1277
+ for (const maker of makerInfo) {
1273
1278
  remainingAccounts.push({
1274
- pubkey: makerInfo.maker,
1279
+ pubkey: maker.maker,
1275
1280
  isWritable: true,
1276
1281
  isSigner: false,
1277
1282
  });
1278
1283
  remainingAccounts.push({
1279
- pubkey: makerInfo.makerStats,
1284
+ pubkey: maker.makerStats,
1280
1285
  isWritable: true,
1281
1286
  isSigner: false,
1282
1287
  });
1283
1288
  }
1284
1289
  if (referrerInfo) {
1285
- remainingAccounts.push({
1286
- pubkey: referrerInfo.referrer,
1287
- isWritable: true,
1288
- isSigner: false,
1289
- });
1290
- remainingAccounts.push({
1291
- pubkey: referrerInfo.referrerStats,
1292
- isWritable: true,
1293
- isSigner: false,
1294
- });
1290
+ const referrerIsMaker = makerInfo.find((maker) => maker.maker.equals(referrerInfo.referrer)) !==
1291
+ undefined;
1292
+ if (!referrerIsMaker) {
1293
+ remainingAccounts.push({
1294
+ pubkey: referrerInfo.referrer,
1295
+ isWritable: true,
1296
+ isSigner: false,
1297
+ });
1298
+ remainingAccounts.push({
1299
+ pubkey: referrerInfo.referrerStats,
1300
+ isWritable: true,
1301
+ isSigner: false,
1302
+ });
1303
+ }
1295
1304
  }
1296
1305
  const orderId = order.orderId;
1297
- const makerOrderId = makerInfo ? makerInfo.order.orderId : null;
1298
- return await this.program.instruction.fillPerpOrder(orderId, makerOrderId, {
1306
+ return await this.program.instruction.fillPerpOrder(orderId, null, {
1299
1307
  accounts: {
1300
1308
  state: await this.getStatePublicKey(),
1301
1309
  filler: fillerPublicKey,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.19.0",
2
+ "version": "2.20.0-beta.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -6207,6 +6207,7 @@
6207
6207
  {
6208
6208
  "name": "Match",
6209
6209
  "fields": [
6210
+ "publicKey",
6210
6211
  {
6211
6212
  "defined": "usize"
6212
6213
  }
@@ -8604,6 +8605,56 @@
8604
8605
  "code": 6227,
8605
8606
  "name": "TierViolationLiquidatingPerpPnl",
8606
8607
  "msg": "TierViolationLiquidatingPerpPnl"
8608
+ },
8609
+ {
8610
+ "code": 6228,
8611
+ "name": "CouldNotLoadUserData",
8612
+ "msg": "CouldNotLoadUserData"
8613
+ },
8614
+ {
8615
+ "code": 6229,
8616
+ "name": "UserWrongMutability",
8617
+ "msg": "UserWrongMutability"
8618
+ },
8619
+ {
8620
+ "code": 6230,
8621
+ "name": "InvalidUserAccount",
8622
+ "msg": "InvalidUserAccount"
8623
+ },
8624
+ {
8625
+ "code": 6231,
8626
+ "name": "CouldNotLoadUserStatsData",
8627
+ "msg": "CouldNotLoadUserData"
8628
+ },
8629
+ {
8630
+ "code": 6232,
8631
+ "name": "UserStatsWrongMutability",
8632
+ "msg": "UserWrongMutability"
8633
+ },
8634
+ {
8635
+ "code": 6233,
8636
+ "name": "InvalidUserStatsAccount",
8637
+ "msg": "InvalidUserAccount"
8638
+ },
8639
+ {
8640
+ "code": 6234,
8641
+ "name": "UserNotFound",
8642
+ "msg": "UserNotFound"
8643
+ },
8644
+ {
8645
+ "code": 6235,
8646
+ "name": "UnableToLoadUserAccount",
8647
+ "msg": "UnableToLoadUserAccount"
8648
+ },
8649
+ {
8650
+ "code": 6236,
8651
+ "name": "UserStatsNotFound",
8652
+ "msg": "UserStatsNotFound"
8653
+ },
8654
+ {
8655
+ "code": 6237,
8656
+ "name": "UnableToLoadUserStatsAccount",
8657
+ "msg": "UnableToLoadUserStatsAccount"
8607
8658
  }
8608
8659
  ]
8609
8660
  }
package/lib/types.d.ts CHANGED
@@ -928,7 +928,7 @@ export declare type MakerInfo = {
928
928
  maker: PublicKey;
929
929
  makerStats: PublicKey;
930
930
  makerUserAccount: UserAccount;
931
- order: Order;
931
+ order?: Order;
932
932
  };
933
933
  export declare type TakerInfo = {
934
934
  taker: PublicKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.19.0",
3
+ "version": "2.20.0-beta.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -2214,7 +2214,7 @@ export class DriftClient {
2214
2214
  userAccountPublicKey: PublicKey,
2215
2215
  user: UserAccount,
2216
2216
  order?: Pick<Order, 'marketIndex' | 'orderId'>,
2217
- makerInfo?: MakerInfo,
2217
+ makerInfo?: MakerInfo | MakerInfo[],
2218
2218
  referrerInfo?: ReferrerInfo,
2219
2219
  txParams?: TxParams
2220
2220
  ): Promise<TransactionSignature> {
@@ -2240,7 +2240,7 @@ export class DriftClient {
2240
2240
  userAccountPublicKey: PublicKey,
2241
2241
  userAccount: UserAccount,
2242
2242
  order: Pick<Order, 'marketIndex' | 'orderId'>,
2243
- makerInfo?: MakerInfo,
2243
+ makerInfo?: MakerInfo | MakerInfo[],
2244
2244
  referrerInfo?: ReferrerInfo
2245
2245
  ): Promise<TransactionInstruction> {
2246
2246
  const userStatsPublicKey = getUserStatsAccountPublicKey(
@@ -2257,45 +2257,54 @@ export class DriftClient {
2257
2257
  (order) => order.orderId === userAccount.nextOrderId - 1
2258
2258
  ).marketIndex;
2259
2259
 
2260
+ makerInfo = Array.isArray(makerInfo)
2261
+ ? makerInfo
2262
+ : makerInfo
2263
+ ? [makerInfo]
2264
+ : [];
2265
+
2260
2266
  const userAccounts = [userAccount];
2261
- if (makerInfo !== undefined) {
2262
- userAccounts.push(makerInfo.makerUserAccount);
2267
+ for (const maker of makerInfo) {
2268
+ userAccounts.push(maker.makerUserAccount);
2263
2269
  }
2264
2270
  const remainingAccounts = this.getRemainingAccounts({
2265
2271
  userAccounts,
2266
2272
  writablePerpMarketIndexes: [marketIndex],
2267
2273
  });
2268
2274
 
2269
- if (makerInfo) {
2275
+ for (const maker of makerInfo) {
2270
2276
  remainingAccounts.push({
2271
- pubkey: makerInfo.maker,
2277
+ pubkey: maker.maker,
2272
2278
  isWritable: true,
2273
2279
  isSigner: false,
2274
2280
  });
2275
2281
  remainingAccounts.push({
2276
- pubkey: makerInfo.makerStats,
2282
+ pubkey: maker.makerStats,
2277
2283
  isWritable: true,
2278
2284
  isSigner: false,
2279
2285
  });
2280
2286
  }
2281
2287
 
2282
2288
  if (referrerInfo) {
2283
- remainingAccounts.push({
2284
- pubkey: referrerInfo.referrer,
2285
- isWritable: true,
2286
- isSigner: false,
2287
- });
2288
- remainingAccounts.push({
2289
- pubkey: referrerInfo.referrerStats,
2290
- isWritable: true,
2291
- isSigner: false,
2292
- });
2289
+ const referrerIsMaker =
2290
+ makerInfo.find((maker) => maker.maker.equals(referrerInfo.referrer)) !==
2291
+ undefined;
2292
+ if (!referrerIsMaker) {
2293
+ remainingAccounts.push({
2294
+ pubkey: referrerInfo.referrer,
2295
+ isWritable: true,
2296
+ isSigner: false,
2297
+ });
2298
+ remainingAccounts.push({
2299
+ pubkey: referrerInfo.referrerStats,
2300
+ isWritable: true,
2301
+ isSigner: false,
2302
+ });
2303
+ }
2293
2304
  }
2294
2305
 
2295
2306
  const orderId = order.orderId;
2296
- const makerOrderId = makerInfo ? makerInfo.order.orderId : null;
2297
-
2298
- return await this.program.instruction.fillPerpOrder(orderId, makerOrderId, {
2307
+ return await this.program.instruction.fillPerpOrder(orderId, null, {
2299
2308
  accounts: {
2300
2309
  state: await this.getStatePublicKey(),
2301
2310
  filler: fillerPublicKey,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.19.0",
2
+ "version": "2.20.0-beta.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -6207,6 +6207,7 @@
6207
6207
  {
6208
6208
  "name": "Match",
6209
6209
  "fields": [
6210
+ "publicKey",
6210
6211
  {
6211
6212
  "defined": "usize"
6212
6213
  }
@@ -8604,6 +8605,56 @@
8604
8605
  "code": 6227,
8605
8606
  "name": "TierViolationLiquidatingPerpPnl",
8606
8607
  "msg": "TierViolationLiquidatingPerpPnl"
8608
+ },
8609
+ {
8610
+ "code": 6228,
8611
+ "name": "CouldNotLoadUserData",
8612
+ "msg": "CouldNotLoadUserData"
8613
+ },
8614
+ {
8615
+ "code": 6229,
8616
+ "name": "UserWrongMutability",
8617
+ "msg": "UserWrongMutability"
8618
+ },
8619
+ {
8620
+ "code": 6230,
8621
+ "name": "InvalidUserAccount",
8622
+ "msg": "InvalidUserAccount"
8623
+ },
8624
+ {
8625
+ "code": 6231,
8626
+ "name": "CouldNotLoadUserStatsData",
8627
+ "msg": "CouldNotLoadUserData"
8628
+ },
8629
+ {
8630
+ "code": 6232,
8631
+ "name": "UserStatsWrongMutability",
8632
+ "msg": "UserWrongMutability"
8633
+ },
8634
+ {
8635
+ "code": 6233,
8636
+ "name": "InvalidUserStatsAccount",
8637
+ "msg": "InvalidUserAccount"
8638
+ },
8639
+ {
8640
+ "code": 6234,
8641
+ "name": "UserNotFound",
8642
+ "msg": "UserNotFound"
8643
+ },
8644
+ {
8645
+ "code": 6235,
8646
+ "name": "UnableToLoadUserAccount",
8647
+ "msg": "UnableToLoadUserAccount"
8648
+ },
8649
+ {
8650
+ "code": 6236,
8651
+ "name": "UserStatsNotFound",
8652
+ "msg": "UserStatsNotFound"
8653
+ },
8654
+ {
8655
+ "code": 6237,
8656
+ "name": "UnableToLoadUserStatsAccount",
8657
+ "msg": "UnableToLoadUserStatsAccount"
8607
8658
  }
8608
8659
  ]
8609
8660
  }
package/src/types.ts CHANGED
@@ -902,7 +902,7 @@ export type MakerInfo = {
902
902
  maker: PublicKey;
903
903
  makerStats: PublicKey;
904
904
  makerUserAccount: UserAccount;
905
- order: Order;
905
+ order?: Order;
906
906
  };
907
907
 
908
908
  export type TakerInfo = {