@drift-labs/jit-proxy 0.10.202 → 0.10.203

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.
@@ -18,6 +18,7 @@ export declare abstract class BaseJitter {
18
18
  userStatsMap: UserStatsMap;
19
19
  perpParams: Map<number, JitParams>;
20
20
  spotParams: Map<number, JitParams>;
21
+ seenOrders: Set<string>;
21
22
  onGoingAuctions: Map<string, Promise<void>>;
22
23
  userFilter: UserFilter;
23
24
  computeUnits: number;
@@ -30,6 +31,7 @@ export declare abstract class BaseJitter {
30
31
  });
31
32
  subscribe(): Promise<void>;
32
33
  createTryFill(taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string): () => Promise<void>;
34
+ deleteOnGoingAuction(orderSignature: string): void;
33
35
  getOrderSignatures(takerKey: string, orderId: number): string;
34
36
  updatePerpParams(marketIndex: number, params: JitParams): void;
35
37
  updateSpotParams(marketIndex: number, params: JitParams): void;
@@ -6,6 +6,7 @@ class BaseJitter {
6
6
  constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap, }) {
7
7
  this.perpParams = new Map();
8
8
  this.spotParams = new Map();
9
+ this.seenOrders = new Set();
9
10
  this.onGoingAuctions = new Map();
10
11
  this.auctionSubscriber = auctionSubscriber;
11
12
  this.driftClient = driftClient;
@@ -33,6 +34,10 @@ class BaseJitter {
33
34
  }
34
35
  }
35
36
  const orderSignature = this.getOrderSignatures(takerKeyString, order.orderId);
37
+ if (this.seenOrders.has(orderSignature)) {
38
+ continue;
39
+ }
40
+ this.seenOrders.add(orderSignature);
36
41
  if (this.onGoingAuctions.has(orderSignature)) {
37
42
  continue;
38
43
  }
@@ -68,6 +73,10 @@ class BaseJitter {
68
73
  createTryFill(taker, takerKey, takerStatsKey, order, orderSignature) {
69
74
  throw new Error('Not implemented');
70
75
  }
76
+ deleteOnGoingAuction(orderSignature) {
77
+ this.onGoingAuctions.delete(orderSignature);
78
+ this.seenOrders.delete(orderSignature);
79
+ }
71
80
  getOrderSignatures(takerKey, orderId) {
72
81
  return `${takerKey}-${orderId}`;
73
82
  }
@@ -17,7 +17,7 @@ class JitterShotgun extends baseJitter_1.BaseJitter {
17
17
  while (i < 10) {
18
18
  const params = this.perpParams.get(order.marketIndex);
19
19
  if (!params) {
20
- this.onGoingAuctions.delete(orderSignature);
20
+ this.deleteOnGoingAuction(orderSignature);
21
21
  return;
22
22
  }
23
23
  const takerStats = await this.userStatsMap.mustGet(taker.authority.toString());
@@ -44,7 +44,7 @@ class JitterShotgun extends baseJitter_1.BaseJitter {
44
44
  }, txParams);
45
45
  console.log(`Filled ${orderSignature} txSig ${txSig}`);
46
46
  await sleep(10000);
47
- this.onGoingAuctions.delete(orderSignature);
47
+ this.deleteOnGoingAuction(orderSignature);
48
48
  return;
49
49
  }
50
50
  catch (e) {
@@ -60,14 +60,14 @@ class JitterShotgun extends baseJitter_1.BaseJitter {
60
60
  }
61
61
  else {
62
62
  await sleep(10000);
63
- this.onGoingAuctions.delete(orderSignature);
63
+ this.deleteOnGoingAuction(orderSignature);
64
64
  return;
65
65
  }
66
66
  }
67
67
  await sleep(200);
68
68
  i++;
69
69
  }
70
- this.onGoingAuctions.delete(orderSignature);
70
+ this.deleteOnGoingAuction(orderSignature);
71
71
  };
72
72
  }
73
73
  }
@@ -17,7 +17,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
17
17
  return async () => {
18
18
  const params = this.perpParams.get(order.marketIndex);
19
19
  if (!params) {
20
- this.onGoingAuctions.delete(orderSignature);
20
+ this.deleteOnGoingAuction(orderSignature);
21
21
  return;
22
22
  }
23
23
  const takerStats = await this.userStatsMap.mustGet(taker.authority.toString());
@@ -32,7 +32,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
32
32
  (0, sdk_1.isVariant)(order.direction, 'short')) {
33
33
  if (currPerpPos.baseAssetAmount.lte(params.minPosition)) {
34
34
  console.log(`Order would increase existing short (mkt ${(0, sdk_1.getVariant)(order.marketType)}-${order.marketIndex}) too much`);
35
- this.onGoingAuctions.delete(orderSignature);
35
+ this.deleteOnGoingAuction(orderSignature);
36
36
  return;
37
37
  }
38
38
  }
@@ -40,7 +40,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
40
40
  (0, sdk_1.isVariant)(order.direction, 'long')) {
41
41
  if (currPerpPos.baseAssetAmount.gte(params.maxPosition)) {
42
42
  console.log(`Order would increase existing long (mkt ${(0, sdk_1.getVariant)(order.marketType)}-${order.marketIndex}) too much`);
43
- this.onGoingAuctions.delete(orderSignature);
43
+ this.deleteOnGoingAuction(orderSignature);
44
44
  return;
45
45
  }
46
46
  }
@@ -67,7 +67,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
67
67
  }).then(async ({ slot, updatedDetails }) => {
68
68
  if (slot === -1) {
69
69
  console.log('Auction expired without crossing');
70
- this.onGoingAuctions.delete(orderSignature);
70
+ this.deleteOnGoingAuction(orderSignature);
71
71
  return;
72
72
  }
73
73
  const params = (0, sdk_1.isVariant)(order.marketType, 'perp')
@@ -115,7 +115,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
115
115
  }, txParams);
116
116
  console.log(`Filled ${orderSignature} txSig ${txSig}`);
117
117
  await sleep(3000);
118
- this.onGoingAuctions.delete(orderSignature);
118
+ this.deleteOnGoingAuction(orderSignature);
119
119
  return;
120
120
  }
121
121
  catch (e) {
@@ -131,7 +131,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
131
131
  }
132
132
  else {
133
133
  await sleep(3000);
134
- this.onGoingAuctions.delete(orderSignature);
134
+ this.deleteOnGoingAuction(orderSignature);
135
135
  return;
136
136
  }
137
137
  }
@@ -139,7 +139,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
139
139
  i++;
140
140
  }
141
141
  });
142
- this.onGoingAuctions.delete(orderSignature);
142
+ this.deleteOnGoingAuction(orderSignature);
143
143
  };
144
144
  }
145
145
  getAuctionAndOrderDetails(order) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/jit-proxy",
3
- "version": "0.10.202",
3
+ "version": "0.10.203",
4
4
  "scripts": {
5
5
  "clean": "rm -rf lib",
6
6
  "build": "yarn clean && tsc"
@@ -44,6 +44,7 @@ export abstract class BaseJitter {
44
44
  perpParams = new Map<number, JitParams>();
45
45
  spotParams = new Map<number, JitParams>();
46
46
 
47
+ seenOrders = new Set<string>();
47
48
  onGoingAuctions = new Map<string, Promise<void>>();
48
49
 
49
50
  userFilter: UserFilter;
@@ -107,6 +108,11 @@ export abstract class BaseJitter {
107
108
  order.orderId
108
109
  );
109
110
 
111
+ if (this.seenOrders.has(orderSignature)) {
112
+ continue;
113
+ }
114
+ this.seenOrders.add(orderSignature);
115
+
110
116
  if (this.onGoingAuctions.has(orderSignature)) {
111
117
  continue;
112
118
  }
@@ -175,6 +181,11 @@ export abstract class BaseJitter {
175
181
  throw new Error('Not implemented');
176
182
  }
177
183
 
184
+ deleteOnGoingAuction(orderSignature: string): void {
185
+ this.onGoingAuctions.delete(orderSignature);
186
+ this.seenOrders.delete(orderSignature);
187
+ }
188
+
178
189
  getOrderSignatures(takerKey: string, orderId: number): string {
179
190
  return `${takerKey}-${orderId}`;
180
191
  }
@@ -57,7 +57,7 @@ export class JitterShotgun extends BaseJitter {
57
57
  while (i < 10) {
58
58
  const params = this.perpParams.get(order.marketIndex);
59
59
  if (!params) {
60
- this.onGoingAuctions.delete(orderSignature);
60
+ this.deleteOnGoingAuction(orderSignature);
61
61
  return;
62
62
  }
63
63
 
@@ -90,7 +90,7 @@ export class JitterShotgun extends BaseJitter {
90
90
 
91
91
  console.log(`Filled ${orderSignature} txSig ${txSig}`);
92
92
  await sleep(10000);
93
- this.onGoingAuctions.delete(orderSignature);
93
+ this.deleteOnGoingAuction(orderSignature);
94
94
  return;
95
95
  } catch (e) {
96
96
  console.error(`Failed to fill ${orderSignature}`);
@@ -102,7 +102,7 @@ export class JitterShotgun extends BaseJitter {
102
102
  console.log('Oracle invalid, retrying');
103
103
  } else {
104
104
  await sleep(10000);
105
- this.onGoingAuctions.delete(orderSignature);
105
+ this.deleteOnGoingAuction(orderSignature);
106
106
  return;
107
107
  }
108
108
  }
@@ -110,7 +110,7 @@ export class JitterShotgun extends BaseJitter {
110
110
  i++;
111
111
  }
112
112
 
113
- this.onGoingAuctions.delete(orderSignature);
113
+ this.deleteOnGoingAuction(orderSignature);
114
114
  };
115
115
  }
116
116
  }
@@ -65,7 +65,7 @@ export class JitterSniper extends BaseJitter {
65
65
  return async () => {
66
66
  const params = this.perpParams.get(order.marketIndex);
67
67
  if (!params) {
68
- this.onGoingAuctions.delete(orderSignature);
68
+ this.deleteOnGoingAuction(orderSignature);
69
69
  return;
70
70
  }
71
71
 
@@ -100,7 +100,7 @@ export class JitterSniper extends BaseJitter {
100
100
  order.marketType
101
101
  )}-${order.marketIndex}) too much`
102
102
  );
103
- this.onGoingAuctions.delete(orderSignature);
103
+ this.deleteOnGoingAuction(orderSignature);
104
104
  return;
105
105
  }
106
106
  } else if (
@@ -113,7 +113,7 @@ export class JitterSniper extends BaseJitter {
113
113
  order.marketType
114
114
  )}-${order.marketIndex}) too much`
115
115
  );
116
- this.onGoingAuctions.delete(orderSignature);
116
+ this.deleteOnGoingAuction(orderSignature);
117
117
  return;
118
118
  }
119
119
  }
@@ -152,7 +152,7 @@ export class JitterSniper extends BaseJitter {
152
152
  ).then(async ({ slot, updatedDetails }) => {
153
153
  if (slot === -1) {
154
154
  console.log('Auction expired without crossing');
155
- this.onGoingAuctions.delete(orderSignature);
155
+ this.deleteOnGoingAuction(orderSignature);
156
156
  return;
157
157
  }
158
158
 
@@ -209,7 +209,7 @@ export class JitterSniper extends BaseJitter {
209
209
 
210
210
  console.log(`Filled ${orderSignature} txSig ${txSig}`);
211
211
  await sleep(3000);
212
- this.onGoingAuctions.delete(orderSignature);
212
+ this.deleteOnGoingAuction(orderSignature);
213
213
  return;
214
214
  } catch (e) {
215
215
  console.error(`Failed to fill ${orderSignature}`);
@@ -221,7 +221,7 @@ export class JitterSniper extends BaseJitter {
221
221
  console.log('Oracle invalid');
222
222
  } else {
223
223
  await sleep(3000);
224
- this.onGoingAuctions.delete(orderSignature);
224
+ this.deleteOnGoingAuction(orderSignature);
225
225
  return;
226
226
  }
227
227
  }
@@ -229,7 +229,7 @@ export class JitterSniper extends BaseJitter {
229
229
  i++;
230
230
  }
231
231
  });
232
- this.onGoingAuctions.delete(orderSignature);
232
+ this.deleteOnGoingAuction(orderSignature);
233
233
  };
234
234
  }
235
235