@drift-labs/jit-proxy 0.13.49 → 0.13.51
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 +19 -9
- package/package.json +1 -1
- package/src/jitter/baseJitter.ts +28 -11
package/lib/jitter/baseJitter.js
CHANGED
|
@@ -85,9 +85,19 @@ class BaseJitter {
|
|
|
85
85
|
});
|
|
86
86
|
await ((_a = this.slotSubscriber) === null || _a === void 0 ? void 0 : _a.subscribe());
|
|
87
87
|
await ((_b = this.fastlaneOrderSubscriber) === null || _b === void 0 ? void 0 : _b.subscribe(async (orderMessageRaw, signedMsgOrderParamsMessage) => {
|
|
88
|
-
var _a, _b;
|
|
89
|
-
const signedMsgOrderParamsBufHex = Buffer.from(orderMessageRaw['order_message']);
|
|
88
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
90
89
|
const signedMsgOrderParams = signedMsgOrderParamsMessage.signedMsgOrderParams;
|
|
90
|
+
if (!signedMsgOrderParams.auctionDuration ||
|
|
91
|
+
!signedMsgOrderParams.auctionStartPrice ||
|
|
92
|
+
!signedMsgOrderParams.auctionEndPrice ||
|
|
93
|
+
signedMsgOrderParams.auctionStartPrice.eq(sdk_1.ZERO) ||
|
|
94
|
+
signedMsgOrderParams.auctionEndPrice.eq(sdk_1.ZERO)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (signedMsgOrderParams.baseAssetAmount.eq(sdk_1.ZERO)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const signedMsgOrderParamsBufHex = Buffer.from(orderMessageRaw['order_message']);
|
|
91
101
|
const takerSubaccountId = signedMsgOrderParamsMessage.subAccountId;
|
|
92
102
|
const takerAuthority = new web3_js_1.PublicKey(orderMessageRaw['taker_authority']);
|
|
93
103
|
const signingAuthority = new web3_js_1.PublicKey(orderMessageRaw['signing_authority']);
|
|
@@ -106,15 +116,15 @@ class BaseJitter {
|
|
|
106
116
|
auctionDuration: signedMsgOrderParams.auctionDuration,
|
|
107
117
|
auctionStartPrice: signedMsgOrderParams.auctionStartPrice,
|
|
108
118
|
auctionEndPrice: signedMsgOrderParams.auctionEndPrice,
|
|
109
|
-
immediateOrCancel: signedMsgOrderParams.immediateOrCancel,
|
|
119
|
+
immediateOrCancel: (_a = signedMsgOrderParams.immediateOrCancel) !== null && _a !== void 0 ? _a : false,
|
|
110
120
|
direction: signedMsgOrderParams.direction,
|
|
111
121
|
postOnly: false,
|
|
112
|
-
oraclePriceOffset: (
|
|
113
|
-
maxTs: (
|
|
114
|
-
reduceOnly: signedMsgOrderParams.reduceOnly,
|
|
115
|
-
triggerCondition: signedMsgOrderParams.triggerCondition,
|
|
116
|
-
price: signedMsgOrderParams.price,
|
|
117
|
-
userOrderId: signedMsgOrderParams.userOrderId,
|
|
122
|
+
oraclePriceOffset: (_b = signedMsgOrderParams.oraclePriceOffset) !== null && _b !== void 0 ? _b : 0,
|
|
123
|
+
maxTs: (_c = signedMsgOrderParams.maxTs) !== null && _c !== void 0 ? _c : sdk_1.ZERO,
|
|
124
|
+
reduceOnly: (_d = signedMsgOrderParams.reduceOnly) !== null && _d !== void 0 ? _d : false,
|
|
125
|
+
triggerCondition: (_e = signedMsgOrderParams.triggerCondition) !== null && _e !== void 0 ? _e : sdk_1.OrderTriggerCondition.ABOVE,
|
|
126
|
+
price: (_f = signedMsgOrderParams.price) !== null && _f !== void 0 ? _f : sdk_1.ZERO,
|
|
127
|
+
userOrderId: (_g = signedMsgOrderParams.userOrderId) !== null && _g !== void 0 ? _g : 0,
|
|
118
128
|
// Rest are not necessary and set for type conforming
|
|
119
129
|
existingPositionDirection: sdk_1.PositionDirection.LONG,
|
|
120
130
|
triggerPrice: sdk_1.ZERO,
|
package/package.json
CHANGED
package/src/jitter/baseJitter.ts
CHANGED
|
@@ -22,8 +22,8 @@ import {
|
|
|
22
22
|
UserAccount,
|
|
23
23
|
UserStatsMap,
|
|
24
24
|
ZERO,
|
|
25
|
-
SignedMsgOrderParamsMessage,
|
|
26
25
|
isSignedMsgOrder,
|
|
26
|
+
OrderTriggerCondition,
|
|
27
27
|
} from '@drift-labs/sdk';
|
|
28
28
|
import { decodeUTF8 } from 'tweetnacl-util';
|
|
29
29
|
|
|
@@ -205,11 +205,26 @@ export abstract class BaseJitter {
|
|
|
205
205
|
await this.slotSubscriber?.subscribe();
|
|
206
206
|
await this.fastlaneOrderSubscriber?.subscribe(
|
|
207
207
|
async (orderMessageRaw, signedMsgOrderParamsMessage) => {
|
|
208
|
+
const signedMsgOrderParams =
|
|
209
|
+
signedMsgOrderParamsMessage.signedMsgOrderParams;
|
|
210
|
+
|
|
211
|
+
if (
|
|
212
|
+
!signedMsgOrderParams.auctionDuration ||
|
|
213
|
+
!signedMsgOrderParams.auctionStartPrice ||
|
|
214
|
+
!signedMsgOrderParams.auctionEndPrice ||
|
|
215
|
+
signedMsgOrderParams.auctionStartPrice.eq(ZERO) ||
|
|
216
|
+
signedMsgOrderParams.auctionEndPrice.eq(ZERO)
|
|
217
|
+
) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (signedMsgOrderParams.baseAssetAmount.eq(ZERO)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
208
225
|
const signedMsgOrderParamsBufHex = Buffer.from(
|
|
209
226
|
orderMessageRaw['order_message']
|
|
210
227
|
);
|
|
211
|
-
const signedMsgOrderParams =
|
|
212
|
-
signedMsgOrderParamsMessage.signedMsgOrderParams;
|
|
213
228
|
const takerSubaccountId = signedMsgOrderParamsMessage.subAccountId;
|
|
214
229
|
|
|
215
230
|
const takerAuthority = new PublicKey(
|
|
@@ -242,18 +257,20 @@ export abstract class BaseJitter {
|
|
|
242
257
|
marketIndex: signedMsgOrderParams.marketIndex,
|
|
243
258
|
marketType: MarketType.PERP,
|
|
244
259
|
baseAssetAmount: signedMsgOrderParams.baseAssetAmount,
|
|
245
|
-
auctionDuration: signedMsgOrderParams.auctionDuration
|
|
246
|
-
auctionStartPrice: signedMsgOrderParams.auctionStartPrice
|
|
247
|
-
auctionEndPrice: signedMsgOrderParams.auctionEndPrice
|
|
248
|
-
immediateOrCancel: signedMsgOrderParams.immediateOrCancel,
|
|
260
|
+
auctionDuration: signedMsgOrderParams.auctionDuration,
|
|
261
|
+
auctionStartPrice: signedMsgOrderParams.auctionStartPrice,
|
|
262
|
+
auctionEndPrice: signedMsgOrderParams.auctionEndPrice,
|
|
263
|
+
immediateOrCancel: signedMsgOrderParams.immediateOrCancel ?? false,
|
|
249
264
|
direction: signedMsgOrderParams.direction,
|
|
250
265
|
postOnly: false,
|
|
251
266
|
oraclePriceOffset: signedMsgOrderParams.oraclePriceOffset ?? 0,
|
|
252
267
|
maxTs: signedMsgOrderParams.maxTs ?? ZERO,
|
|
253
|
-
reduceOnly: signedMsgOrderParams.reduceOnly,
|
|
254
|
-
triggerCondition:
|
|
255
|
-
|
|
256
|
-
|
|
268
|
+
reduceOnly: signedMsgOrderParams.reduceOnly ?? false,
|
|
269
|
+
triggerCondition:
|
|
270
|
+
signedMsgOrderParams.triggerCondition ??
|
|
271
|
+
OrderTriggerCondition.ABOVE,
|
|
272
|
+
price: signedMsgOrderParams.price ?? ZERO,
|
|
273
|
+
userOrderId: signedMsgOrderParams.userOrderId ?? 0,
|
|
257
274
|
// Rest are not necessary and set for type conforming
|
|
258
275
|
existingPositionDirection: PositionDirection.LONG,
|
|
259
276
|
triggerPrice: ZERO,
|