@drift-labs/jit-proxy 0.21.35 → 0.21.37

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.
@@ -64,7 +64,7 @@ export declare class JitProxyClient {
64
64
  computeUnitsPrice: number;
65
65
  }): Promise<TxSigAndSlot>;
66
66
  getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, subAccountId, }: JitIxParams): Promise<TransactionInstruction>;
67
- getJitSignedMsgIx({ takerKey, takerStatsKey, taker, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, subAccountId, uuid, marketIndex, }: JitSignedMsgIxParams): Promise<TransactionInstruction>;
67
+ getJitSignedMsgIx({ takerKey, takerStatsKey, taker, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, subAccountId, uuid, marketIndex, signedMsgOrderParams, authorityToUse, }: JitSignedMsgIxParams): Promise<TransactionInstruction>;
68
68
  getCheckOrderConstraintIx({ subAccountId, orderConstraints, }: {
69
69
  subAccountId: number;
70
70
  orderConstraints: OrderConstraint[];
@@ -134,6 +134,15 @@ class JitProxyClient {
134
134
  isSigner: false,
135
135
  });
136
136
  }
137
+ else {
138
+ if ((0, sdk_1.hasBuilder)(order)) {
139
+ remainingAccounts.push({
140
+ pubkey: (0, sdk_1.getRevenueShareEscrowAccountPublicKey)(this.program.programId, taker.authority),
141
+ isWritable: true,
142
+ isSigner: false,
143
+ });
144
+ }
145
+ }
137
146
  const jitParams = {
138
147
  takerOrderId,
139
148
  maxPosition,
@@ -156,7 +165,7 @@ class JitProxyClient {
156
165
  .remainingAccounts(remainingAccounts)
157
166
  .instruction();
158
167
  }
159
- async getJitSignedMsgIx({ takerKey, takerStatsKey, taker, maxPosition, minPosition, bid, ask, postOnly = null, priceType = PriceType.LIMIT, referrerInfo, subAccountId, uuid, marketIndex, }) {
168
+ async getJitSignedMsgIx({ takerKey, takerStatsKey, taker, maxPosition, minPosition, bid, ask, postOnly = null, priceType = PriceType.LIMIT, referrerInfo, subAccountId, uuid, marketIndex, signedMsgOrderParams, authorityToUse, }) {
160
169
  subAccountId =
161
170
  subAccountId !== undefined
162
171
  ? subAccountId
@@ -178,6 +187,17 @@ class JitProxyClient {
178
187
  isSigner: false,
179
188
  });
180
189
  }
190
+ const isDelegateSigner = authorityToUse.equals(taker.delegate);
191
+ const borshBuf = Buffer.from(signedMsgOrderParams.orderParams.toString(), 'hex');
192
+ const signedMessage = this.driftClient.decodeSignedMsgOrderParamsMessage(borshBuf, isDelegateSigner);
193
+ if (signedMessage.builderFeeTenthBps !== null &&
194
+ signedMessage.builderIdx !== null) {
195
+ remainingAccounts.push({
196
+ pubkey: (0, sdk_1.getRevenueShareEscrowAccountPublicKey)(this.program.programId, taker.authority),
197
+ isWritable: true,
198
+ isSigner: false,
199
+ });
200
+ }
181
201
  const jitSignedMsgParams = {
182
202
  signedMsgOrderUuid: Array.from(uuid),
183
203
  maxPosition,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@drift-labs/jit-proxy",
3
- "version": "0.21.35",
3
+ "version": "0.21.37",
4
4
  "scripts": {
5
5
  "clean": "rm -rf lib",
6
6
  "build": "yarn clean && tsc"
7
7
  },
8
8
  "dependencies": {
9
9
  "@coral-xyz/anchor": "0.29.0",
10
- "@drift-labs/sdk": "2.141.0-beta.7",
10
+ "@drift-labs/sdk": "2.141.0-beta.8",
11
11
  "@solana/web3.js": "1.98.0",
12
12
  "tweetnacl-util": "^0.15.1",
13
13
  "typescript": "5.4.5"
@@ -11,6 +11,8 @@ import {
11
11
  SignedMsgOrderParams,
12
12
  TxParams,
13
13
  UserAccount,
14
+ hasBuilder,
15
+ getRevenueShareEscrowAccountPublicKey,
14
16
  } from '@drift-labs/sdk';
15
17
  import { IDL, JitProxy } from './types/jit_proxy';
16
18
  import {
@@ -239,6 +241,17 @@ export class JitProxyClient {
239
241
  isWritable: false,
240
242
  isSigner: false,
241
243
  });
244
+ } else {
245
+ if (hasBuilder(order)) {
246
+ remainingAccounts.push({
247
+ pubkey: getRevenueShareEscrowAccountPublicKey(
248
+ this.program.programId,
249
+ taker.authority
250
+ ),
251
+ isWritable: true,
252
+ isSigner: false,
253
+ });
254
+ }
242
255
  }
243
256
 
244
257
  const jitParams = {
@@ -279,6 +292,8 @@ export class JitProxyClient {
279
292
  subAccountId,
280
293
  uuid,
281
294
  marketIndex,
295
+ signedMsgOrderParams,
296
+ authorityToUse,
282
297
  }: JitSignedMsgIxParams): Promise<TransactionInstruction> {
283
298
  subAccountId =
284
299
  subAccountId !== undefined
@@ -303,6 +318,30 @@ export class JitProxyClient {
303
318
  });
304
319
  }
305
320
 
321
+ const isDelegateSigner = authorityToUse.equals(taker.delegate);
322
+ const borshBuf = Buffer.from(
323
+ signedMsgOrderParams.orderParams.toString(),
324
+ 'hex'
325
+ );
326
+
327
+ const signedMessage = this.driftClient.decodeSignedMsgOrderParamsMessage(
328
+ borshBuf,
329
+ isDelegateSigner
330
+ );
331
+ if (
332
+ signedMessage.builderFeeTenthBps !== null &&
333
+ signedMessage.builderIdx !== null
334
+ ) {
335
+ remainingAccounts.push({
336
+ pubkey: getRevenueShareEscrowAccountPublicKey(
337
+ this.program.programId,
338
+ taker.authority
339
+ ),
340
+ isWritable: true,
341
+ isSigner: false,
342
+ });
343
+ }
344
+
306
345
  const jitSignedMsgParams = {
307
346
  signedMsgOrderUuid: Array.from(uuid),
308
347
  maxPosition,