@drift-labs/jit-proxy 0.13.49 → 0.13.50
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 +20 -13
- package/package.json +1 -1
- package/src/jitter/baseJitter.ts +25 -12
package/lib/jitter/baseJitter.js
CHANGED
|
@@ -85,9 +85,16 @@ 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, _h, _j, _k, _l;
|
|
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
|
+
const signedMsgOrderParamsBufHex = Buffer.from(orderMessageRaw['order_message']);
|
|
91
98
|
const takerSubaccountId = signedMsgOrderParamsMessage.subAccountId;
|
|
92
99
|
const takerAuthority = new web3_js_1.PublicKey(orderMessageRaw['taker_authority']);
|
|
93
100
|
const signingAuthority = new web3_js_1.PublicKey(orderMessageRaw['signing_authority']);
|
|
@@ -102,19 +109,19 @@ class BaseJitter {
|
|
|
102
109
|
slot: new sdk_1.BN(orderSlot),
|
|
103
110
|
marketIndex: signedMsgOrderParams.marketIndex,
|
|
104
111
|
marketType: sdk_1.MarketType.PERP,
|
|
105
|
-
baseAssetAmount: signedMsgOrderParams.baseAssetAmount,
|
|
106
|
-
auctionDuration: signedMsgOrderParams.auctionDuration,
|
|
107
|
-
auctionStartPrice: signedMsgOrderParams.auctionStartPrice,
|
|
108
|
-
auctionEndPrice: signedMsgOrderParams.auctionEndPrice,
|
|
109
|
-
immediateOrCancel: signedMsgOrderParams.immediateOrCancel,
|
|
112
|
+
baseAssetAmount: (_a = signedMsgOrderParams.baseAssetAmount) !== null && _a !== void 0 ? _a : sdk_1.ZERO,
|
|
113
|
+
auctionDuration: (_b = signedMsgOrderParams.auctionDuration) !== null && _b !== void 0 ? _b : 0,
|
|
114
|
+
auctionStartPrice: (_c = signedMsgOrderParams.auctionStartPrice) !== null && _c !== void 0 ? _c : sdk_1.ZERO,
|
|
115
|
+
auctionEndPrice: (_d = signedMsgOrderParams.auctionEndPrice) !== null && _d !== void 0 ? _d : sdk_1.ZERO,
|
|
116
|
+
immediateOrCancel: (_e = signedMsgOrderParams.immediateOrCancel) !== null && _e !== void 0 ? _e : false,
|
|
110
117
|
direction: signedMsgOrderParams.direction,
|
|
111
118
|
postOnly: false,
|
|
112
|
-
oraclePriceOffset: (
|
|
113
|
-
maxTs: (
|
|
114
|
-
reduceOnly: signedMsgOrderParams.reduceOnly,
|
|
115
|
-
triggerCondition: signedMsgOrderParams.triggerCondition,
|
|
116
|
-
price: signedMsgOrderParams.price,
|
|
117
|
-
userOrderId: signedMsgOrderParams.userOrderId,
|
|
119
|
+
oraclePriceOffset: (_f = signedMsgOrderParams.oraclePriceOffset) !== null && _f !== void 0 ? _f : 0,
|
|
120
|
+
maxTs: (_g = signedMsgOrderParams.maxTs) !== null && _g !== void 0 ? _g : sdk_1.ZERO,
|
|
121
|
+
reduceOnly: (_h = signedMsgOrderParams.reduceOnly) !== null && _h !== void 0 ? _h : false,
|
|
122
|
+
triggerCondition: (_j = signedMsgOrderParams.triggerCondition) !== null && _j !== void 0 ? _j : sdk_1.OrderTriggerCondition.ABOVE,
|
|
123
|
+
price: (_k = signedMsgOrderParams.price) !== null && _k !== void 0 ? _k : sdk_1.ZERO,
|
|
124
|
+
userOrderId: (_l = signedMsgOrderParams.userOrderId) !== null && _l !== void 0 ? _l : 0,
|
|
118
125
|
// Rest are not necessary and set for type conforming
|
|
119
126
|
existingPositionDirection: sdk_1.PositionDirection.LONG,
|
|
120
127
|
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,22 @@ 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
|
+
|
|
208
221
|
const signedMsgOrderParamsBufHex = Buffer.from(
|
|
209
222
|
orderMessageRaw['order_message']
|
|
210
223
|
);
|
|
211
|
-
const signedMsgOrderParams =
|
|
212
|
-
signedMsgOrderParamsMessage.signedMsgOrderParams;
|
|
213
224
|
const takerSubaccountId = signedMsgOrderParamsMessage.subAccountId;
|
|
214
225
|
|
|
215
226
|
const takerAuthority = new PublicKey(
|
|
@@ -241,19 +252,21 @@ export abstract class BaseJitter {
|
|
|
241
252
|
slot: new BN(orderSlot),
|
|
242
253
|
marketIndex: signedMsgOrderParams.marketIndex,
|
|
243
254
|
marketType: MarketType.PERP,
|
|
244
|
-
baseAssetAmount: signedMsgOrderParams.baseAssetAmount,
|
|
245
|
-
auctionDuration: signedMsgOrderParams.auctionDuration
|
|
246
|
-
auctionStartPrice: signedMsgOrderParams.auctionStartPrice
|
|
247
|
-
auctionEndPrice: signedMsgOrderParams.auctionEndPrice
|
|
248
|
-
immediateOrCancel: signedMsgOrderParams.immediateOrCancel,
|
|
255
|
+
baseAssetAmount: signedMsgOrderParams.baseAssetAmount ?? ZERO,
|
|
256
|
+
auctionDuration: signedMsgOrderParams.auctionDuration ?? 0,
|
|
257
|
+
auctionStartPrice: signedMsgOrderParams.auctionStartPrice ?? ZERO,
|
|
258
|
+
auctionEndPrice: signedMsgOrderParams.auctionEndPrice ?? ZERO,
|
|
259
|
+
immediateOrCancel: signedMsgOrderParams.immediateOrCancel ?? false,
|
|
249
260
|
direction: signedMsgOrderParams.direction,
|
|
250
261
|
postOnly: false,
|
|
251
262
|
oraclePriceOffset: signedMsgOrderParams.oraclePriceOffset ?? 0,
|
|
252
263
|
maxTs: signedMsgOrderParams.maxTs ?? ZERO,
|
|
253
|
-
reduceOnly: signedMsgOrderParams.reduceOnly,
|
|
254
|
-
triggerCondition:
|
|
255
|
-
|
|
256
|
-
|
|
264
|
+
reduceOnly: signedMsgOrderParams.reduceOnly ?? false,
|
|
265
|
+
triggerCondition:
|
|
266
|
+
signedMsgOrderParams.triggerCondition ??
|
|
267
|
+
OrderTriggerCondition.ABOVE,
|
|
268
|
+
price: signedMsgOrderParams.price ?? ZERO,
|
|
269
|
+
userOrderId: signedMsgOrderParams.userOrderId ?? 0,
|
|
257
270
|
// Rest are not necessary and set for type conforming
|
|
258
271
|
existingPositionDirection: PositionDirection.LONG,
|
|
259
272
|
triggerPrice: ZERO,
|