@drift-labs/jit-proxy 0.4.0 → 0.5.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.
@@ -14,6 +14,7 @@ export declare type JitIxParams = {
14
14
  postOnly: PostOnlyParams | null;
15
15
  priceType?: PriceType;
16
16
  referrerInfo?: ReferrerInfo;
17
+ subAccountId?: number;
17
18
  };
18
19
  export declare class PriceType {
19
20
  static readonly LIMIT: {
@@ -31,5 +32,5 @@ export declare class JitProxyClient {
31
32
  programId: PublicKey;
32
33
  });
33
34
  jit(params: JitIxParams, txParams?: TxParams): Promise<TxSigAndSlot>;
34
- getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, }: JitIxParams): Promise<TransactionInstruction>;
35
+ getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, subAccountId }: JitIxParams): Promise<TransactionInstruction>;
35
36
  }
@@ -19,10 +19,11 @@ class JitProxyClient {
19
19
  const tx = await this.driftClient.buildTransaction([ix], txParams);
20
20
  return await this.driftClient.sendTransaction(tx);
21
21
  }
22
- async getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly = null, priceType = PriceType.LIMIT, referrerInfo, }) {
22
+ async getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly = null, priceType = PriceType.LIMIT, referrerInfo, subAccountId }) {
23
+ subAccountId = subAccountId || this.driftClient.activeSubAccountId;
23
24
  const order = taker.orders.find((order) => order.orderId === takerOrderId);
24
25
  const remainingAccounts = this.driftClient.getRemainingAccounts({
25
- userAccounts: [taker, this.driftClient.getUserAccount()],
26
+ userAccounts: [taker, this.driftClient.getUserAccount(subAccountId)],
26
27
  writableSpotMarketIndexes: sdk_1.isVariant(order.marketType, 'spot')
27
28
  ? [order.marketIndex, sdk_1.QUOTE_SPOT_MARKET_INDEX]
28
29
  : [],
@@ -69,7 +70,7 @@ class JitProxyClient {
69
70
  taker: takerKey,
70
71
  takerStats: takerStatsKey,
71
72
  state: await this.driftClient.getStatePublicKey(),
72
- user: await this.driftClient.getUserAccountPublicKey(),
73
+ user: await this.driftClient.getUserAccountPublicKey(subAccountId),
73
74
  userStats: this.driftClient.getUserStatsAccountPublicKey(),
74
75
  driftProgram: this.driftClient.program.programId,
75
76
  })
package/lib/jitter.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare type JitParams = {
9
9
  minPosition: BN;
10
10
  maxPosition: any;
11
11
  priceType: PriceType;
12
+ subAccountId?: number;
12
13
  };
13
14
  export declare class Jitter {
14
15
  auctionSubscriber: AuctionSubscriber;
package/lib/jitter.js CHANGED
@@ -80,6 +80,7 @@ class Jitter {
80
80
  postOnly: null,
81
81
  priceType: params.priceType,
82
82
  referrerInfo,
83
+ subAccountId: params.subAccountId,
83
84
  });
84
85
  console.log(`Filled ${orderSignature} txSig ${txSig}`);
85
86
  await sleep(10000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/jit-proxy",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "dependencies": {
5
5
  "@coral-xyz/anchor": "^0.26.0",
6
6
  "@solana/web3.js": "1.73.2",
@@ -25,6 +25,7 @@ export type JitIxParams = {
25
25
  postOnly: PostOnlyParams | null;
26
26
  priceType?: PriceType;
27
27
  referrerInfo?: ReferrerInfo;
28
+ subAccountId?: number;
28
29
  };
29
30
 
30
31
  export class PriceType {
@@ -68,10 +69,12 @@ export class JitProxyClient {
68
69
  postOnly = null,
69
70
  priceType = PriceType.LIMIT,
70
71
  referrerInfo,
72
+ subAccountId
71
73
  }: JitIxParams): Promise<TransactionInstruction> {
74
+ subAccountId = subAccountId || this.driftClient.activeSubAccountId;
72
75
  const order = taker.orders.find((order) => order.orderId === takerOrderId);
73
76
  const remainingAccounts = this.driftClient.getRemainingAccounts({
74
- userAccounts: [taker, this.driftClient.getUserAccount()],
77
+ userAccounts: [taker, this.driftClient.getUserAccount(subAccountId)],
75
78
  writableSpotMarketIndexes: isVariant(order.marketType, 'spot')
76
79
  ? [order.marketIndex, QUOTE_SPOT_MARKET_INDEX]
77
80
  : [],
@@ -122,7 +125,7 @@ export class JitProxyClient {
122
125
  taker: takerKey,
123
126
  takerStats: takerStatsKey,
124
127
  state: await this.driftClient.getStatePublicKey(),
125
- user: await this.driftClient.getUserAccountPublicKey(),
128
+ user: await this.driftClient.getUserAccountPublicKey(subAccountId),
126
129
  userStats: this.driftClient.getUserStatsAccountPublicKey(),
127
130
  driftProgram: this.driftClient.program.programId,
128
131
  })
package/src/jitter.ts CHANGED
@@ -16,12 +16,14 @@ export type UserFilter = (
16
16
  userKey: string,
17
17
  order: Order
18
18
  ) => boolean;
19
+
19
20
  export type JitParams = {
20
21
  bid: BN;
21
22
  ask: BN;
22
23
  minPosition: BN;
23
24
  maxPosition;
24
25
  priceType: PriceType;
26
+ subAccountId?: number;
25
27
  };
26
28
 
27
29
  export class Jitter {
@@ -159,6 +161,7 @@ export class Jitter {
159
161
  postOnly: null,
160
162
  priceType: params.priceType,
161
163
  referrerInfo,
164
+ subAccountId: params.subAccountId,
162
165
  });
163
166
 
164
167
  console.log(`Filled ${orderSignature} txSig ${txSig}`);