@drift-labs/jit-proxy 0.15.6 → 0.15.7
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/lib/jitter/baseJitter.js +6 -5
- package/package.json +2 -2
- package/src/jitter/baseJitter.ts +12 -10
package/lib/jitter/baseJitter.js
CHANGED
|
@@ -87,9 +87,9 @@ class BaseJitter {
|
|
|
87
87
|
}
|
|
88
88
|
});
|
|
89
89
|
await ((_a = this.slotSubscriber) === null || _a === void 0 ? void 0 : _a.subscribe());
|
|
90
|
-
await ((_b = this.swiftOrderSubscriber) === null || _b === void 0 ? void 0 : _b.subscribe(async (orderMessageRaw,
|
|
90
|
+
await ((_b = this.swiftOrderSubscriber) === null || _b === void 0 ? void 0 : _b.subscribe(async (orderMessageRaw, signedMessage, isDelegateSigner) => {
|
|
91
91
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
92
|
-
const signedMsgOrderParams =
|
|
92
|
+
const signedMsgOrderParams = signedMessage.signedMsgOrderParams;
|
|
93
93
|
if (!signedMsgOrderParams.auctionDuration ||
|
|
94
94
|
!signedMsgOrderParams.auctionStartPrice ||
|
|
95
95
|
!signedMsgOrderParams.auctionEndPrice ||
|
|
@@ -101,13 +101,14 @@ class BaseJitter {
|
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
const signedMsgOrderParamsBufHex = Buffer.from(orderMessageRaw['order_message']);
|
|
104
|
-
const takerSubaccountId = signedMsgOrderParamsMessage.subAccountId;
|
|
105
104
|
const takerAuthority = new web3_js_1.PublicKey(orderMessageRaw['taker_authority']);
|
|
106
105
|
const signingAuthority = new web3_js_1.PublicKey(orderMessageRaw['signing_authority']);
|
|
107
|
-
const takerUserPubkey =
|
|
106
|
+
const takerUserPubkey = isDelegateSigner
|
|
107
|
+
? signedMessage.takerPubkey
|
|
108
|
+
: await (0, sdk_1.getUserAccountPublicKey)(this.driftClient.program.programId, takerAuthority, signedMessage.subAccountId);
|
|
108
109
|
const takerUserPubkeyString = takerUserPubkey.toBase58();
|
|
109
110
|
const takerUserAccount = await this.swiftOrderSubscriber.userAccountGetter.mustGetUserAccount(takerUserPubkey.toString());
|
|
110
|
-
const orderSlot = Math.min(
|
|
111
|
+
const orderSlot = Math.min(signedMessage.slot.toNumber(), this.slotSubscriber.getSlot());
|
|
111
112
|
/**
|
|
112
113
|
* Base asset amount equalling u64::max is a special case that signals to program
|
|
113
114
|
* to bring taker to max leverage. Program will calculate the max base asset amount to do this
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drift-labs/jit-proxy",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.7",
|
|
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.26.0",
|
|
10
|
-
"@drift-labs/sdk": "2.117.0-beta.
|
|
10
|
+
"@drift-labs/sdk": "2.117.0-beta.4",
|
|
11
11
|
"@solana/web3.js": "1.91.7",
|
|
12
12
|
"tweetnacl-util": "^0.15.1"
|
|
13
13
|
},
|
package/src/jitter/baseJitter.ts
CHANGED
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
ZERO,
|
|
25
25
|
isSignedMsgOrder,
|
|
26
26
|
OrderTriggerCondition,
|
|
27
|
+
SignedMsgOrderParamsDelegateMessage,
|
|
28
|
+
SignedMsgOrderParamsMessage,
|
|
27
29
|
} from '@drift-labs/sdk';
|
|
28
30
|
import { decodeUTF8 } from 'tweetnacl-util';
|
|
29
31
|
|
|
@@ -210,9 +212,8 @@ export abstract class BaseJitter {
|
|
|
210
212
|
);
|
|
211
213
|
await this.slotSubscriber?.subscribe();
|
|
212
214
|
await this.swiftOrderSubscriber?.subscribe(
|
|
213
|
-
async (orderMessageRaw,
|
|
214
|
-
const signedMsgOrderParams =
|
|
215
|
-
signedMsgOrderParamsMessage.signedMsgOrderParams;
|
|
215
|
+
async (orderMessageRaw, signedMessage, isDelegateSigner) => {
|
|
216
|
+
const signedMsgOrderParams = signedMessage.signedMsgOrderParams;
|
|
216
217
|
|
|
217
218
|
if (
|
|
218
219
|
!signedMsgOrderParams.auctionDuration ||
|
|
@@ -231,7 +232,6 @@ export abstract class BaseJitter {
|
|
|
231
232
|
const signedMsgOrderParamsBufHex = Buffer.from(
|
|
232
233
|
orderMessageRaw['order_message']
|
|
233
234
|
);
|
|
234
|
-
const takerSubaccountId = signedMsgOrderParamsMessage.subAccountId;
|
|
235
235
|
|
|
236
236
|
const takerAuthority = new PublicKey(
|
|
237
237
|
orderMessageRaw['taker_authority']
|
|
@@ -239,18 +239,20 @@ export abstract class BaseJitter {
|
|
|
239
239
|
const signingAuthority = new PublicKey(
|
|
240
240
|
orderMessageRaw['signing_authority']
|
|
241
241
|
);
|
|
242
|
-
const takerUserPubkey =
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
242
|
+
const takerUserPubkey = isDelegateSigner
|
|
243
|
+
? (signedMessage as SignedMsgOrderParamsDelegateMessage).takerPubkey
|
|
244
|
+
: await getUserAccountPublicKey(
|
|
245
|
+
this.driftClient.program.programId,
|
|
246
|
+
takerAuthority,
|
|
247
|
+
(signedMessage as SignedMsgOrderParamsMessage).subAccountId
|
|
248
|
+
);
|
|
247
249
|
const takerUserPubkeyString = takerUserPubkey.toBase58();
|
|
248
250
|
const takerUserAccount =
|
|
249
251
|
await this.swiftOrderSubscriber.userAccountGetter.mustGetUserAccount(
|
|
250
252
|
takerUserPubkey.toString()
|
|
251
253
|
);
|
|
252
254
|
const orderSlot = Math.min(
|
|
253
|
-
|
|
255
|
+
signedMessage.slot.toNumber(),
|
|
254
256
|
this.slotSubscriber.getSlot()
|
|
255
257
|
);
|
|
256
258
|
|