@drift-labs/jit-proxy 0.13.65 → 0.13.66
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.d.ts +6 -6
- package/lib/jitter/baseJitter.js +8 -8
- package/lib/jitter/jitterShotgun.d.ts +4 -4
- package/lib/jitter/jitterShotgun.js +3 -3
- package/lib/jitter/jitterSniper.d.ts +4 -4
- package/lib/jitter/jitterSniper.js +3 -3
- package/package.json +1 -1
- package/src/jitter/baseJitter.ts +14 -14
- package/src/jitter/jitterShotgun.ts +7 -7
- package/src/jitter/jitterSniper.ts +7 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { JitProxyClient, PriceType } from '../jitProxyClient';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { AuctionSubscriber, BN, DriftClient, Order, PostOnlyParams,
|
|
4
|
+
import { AuctionSubscriber, BN, DriftClient, Order, PostOnlyParams, SwiftOrderSubscriber, SlotSubscriber, SignedMsgOrderParams, UserAccount, UserStatsMap } from '@drift-labs/sdk';
|
|
5
5
|
export type UserFilter = (userAccount: UserAccount, userKey: string, order: Order) => boolean;
|
|
6
6
|
export type JitParams = {
|
|
7
7
|
bid: BN;
|
|
@@ -14,11 +14,11 @@ export type JitParams = {
|
|
|
14
14
|
};
|
|
15
15
|
export declare abstract class BaseJitter {
|
|
16
16
|
auctionSubscriber: AuctionSubscriber;
|
|
17
|
-
|
|
17
|
+
swiftOrderSubscriber: SwiftOrderSubscriber;
|
|
18
18
|
slotSubscriber: SlotSubscriber;
|
|
19
19
|
driftClient: DriftClient;
|
|
20
20
|
jitProxyClient: JitProxyClient;
|
|
21
|
-
|
|
21
|
+
auctionSubscriberIgnoresSwiftOrders?: boolean;
|
|
22
22
|
userStatsMap: UserStatsMap;
|
|
23
23
|
perpParams: Map<number, JitParams>;
|
|
24
24
|
spotParams: Map<number, JitParams>;
|
|
@@ -27,14 +27,14 @@ export declare abstract class BaseJitter {
|
|
|
27
27
|
userFilter: UserFilter;
|
|
28
28
|
computeUnits: number;
|
|
29
29
|
computeUnitsPrice: number;
|
|
30
|
-
constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap,
|
|
30
|
+
constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap, swiftOrderSubscriber, slotSubscriber, auctionSubscriberIgnoresSwiftOrders, }: {
|
|
31
31
|
driftClient: DriftClient;
|
|
32
32
|
auctionSubscriber: AuctionSubscriber;
|
|
33
33
|
jitProxyClient: JitProxyClient;
|
|
34
34
|
userStatsMap: UserStatsMap;
|
|
35
|
-
|
|
35
|
+
swiftOrderSubscriber?: SwiftOrderSubscriber;
|
|
36
36
|
slotSubscriber?: SlotSubscriber;
|
|
37
|
-
|
|
37
|
+
auctionSubscriberIgnoresSwiftOrders?: boolean;
|
|
38
38
|
});
|
|
39
39
|
subscribe(): Promise<void>;
|
|
40
40
|
createTryFill(taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string): () => Promise<void>;
|
package/lib/jitter/baseJitter.js
CHANGED
|
@@ -5,7 +5,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
5
5
|
const sdk_1 = require("@drift-labs/sdk");
|
|
6
6
|
const tweetnacl_util_1 = require("tweetnacl-util");
|
|
7
7
|
class BaseJitter {
|
|
8
|
-
constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap,
|
|
8
|
+
constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap, swiftOrderSubscriber, slotSubscriber, auctionSubscriberIgnoresSwiftOrders, }) {
|
|
9
9
|
this.perpParams = new Map();
|
|
10
10
|
this.spotParams = new Map();
|
|
11
11
|
this.seenOrders = new Set();
|
|
@@ -17,10 +17,10 @@ class BaseJitter {
|
|
|
17
17
|
userStatsMap ||
|
|
18
18
|
new sdk_1.UserStatsMap(this.driftClient, new sdk_1.BulkAccountLoader(this.driftClient.connection, 'confirmed', 0));
|
|
19
19
|
this.slotSubscriber = slotSubscriber;
|
|
20
|
-
this.
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
if (this.
|
|
20
|
+
this.swiftOrderSubscriber = swiftOrderSubscriber;
|
|
21
|
+
this.auctionSubscriberIgnoresSwiftOrders =
|
|
22
|
+
auctionSubscriberIgnoresSwiftOrders;
|
|
23
|
+
if (this.swiftOrderSubscriber && !this.slotSubscriber) {
|
|
24
24
|
throw new Error('Slot subscriber is required for signedMsg order subscriber');
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -38,7 +38,7 @@ class BaseJitter {
|
|
|
38
38
|
if (!(0, sdk_1.hasAuctionPrice)(order, slot)) {
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
|
-
if (this.
|
|
41
|
+
if (this.auctionSubscriberIgnoresSwiftOrders &&
|
|
42
42
|
(0, sdk_1.isSignedMsgOrder)(order)) {
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
@@ -84,7 +84,7 @@ class BaseJitter {
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
await ((_a = this.slotSubscriber) === null || _a === void 0 ? void 0 : _a.subscribe());
|
|
87
|
-
await ((_b = this.
|
|
87
|
+
await ((_b = this.swiftOrderSubscriber) === null || _b === void 0 ? void 0 : _b.subscribe(async (orderMessageRaw, signedMsgOrderParamsMessage) => {
|
|
88
88
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
89
89
|
const signedMsgOrderParams = signedMsgOrderParamsMessage.signedMsgOrderParams;
|
|
90
90
|
if (!signedMsgOrderParams.auctionDuration ||
|
|
@@ -103,7 +103,7 @@ class BaseJitter {
|
|
|
103
103
|
const signingAuthority = new web3_js_1.PublicKey(orderMessageRaw['signing_authority']);
|
|
104
104
|
const takerUserPubkey = await (0, sdk_1.getUserAccountPublicKey)(this.driftClient.program.programId, takerAuthority, takerSubaccountId);
|
|
105
105
|
const takerUserPubkeyString = takerUserPubkey.toBase58();
|
|
106
|
-
const takerUserAccount = (await this.
|
|
106
|
+
const takerUserAccount = (await this.swiftOrderSubscriber.userMap.mustGet(takerUserPubkey.toString())).getUserAccount();
|
|
107
107
|
const orderSlot = Math.min(signedMsgOrderParamsMessage.slot.toNumber(), this.slotSubscriber.getSlot());
|
|
108
108
|
const signedMsgOrder = {
|
|
109
109
|
status: sdk_1.OrderStatus.OPEN,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { JitProxyClient } from '../jitProxyClient';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
import { AuctionSubscriber, DriftClient, Order, SlotSubscriber, SignedMsgOrderParams,
|
|
3
|
+
import { AuctionSubscriber, DriftClient, Order, SlotSubscriber, SignedMsgOrderParams, SwiftOrderSubscriber, UserAccount, UserStatsMap } from '@drift-labs/sdk';
|
|
4
4
|
import { BaseJitter } from './baseJitter';
|
|
5
5
|
export declare class JitterShotgun extends BaseJitter {
|
|
6
|
-
constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap,
|
|
6
|
+
constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap, swiftOrderSubscriber, slotSubscriber, auctionSubscriberIgnoresSwiftOrders, }: {
|
|
7
7
|
driftClient: DriftClient;
|
|
8
8
|
auctionSubscriber: AuctionSubscriber;
|
|
9
9
|
jitProxyClient: JitProxyClient;
|
|
10
10
|
userStatsMap?: UserStatsMap;
|
|
11
|
-
|
|
11
|
+
swiftOrderSubscriber?: SwiftOrderSubscriber;
|
|
12
12
|
slotSubscriber?: SlotSubscriber;
|
|
13
|
-
|
|
13
|
+
auctionSubscriberIgnoresSwiftOrders?: boolean;
|
|
14
14
|
});
|
|
15
15
|
createTryFill(taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string): () => Promise<void>;
|
|
16
16
|
createTrySignedMsgFill(authorityToUse: PublicKey, signedMsgOrderParams: SignedMsgOrderParams, uuid: Uint8Array, taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string, marketIndex: number): () => Promise<void>;
|
|
@@ -4,15 +4,15 @@ exports.JitterShotgun = void 0;
|
|
|
4
4
|
const sdk_1 = require("@drift-labs/sdk");
|
|
5
5
|
const baseJitter_1 = require("./baseJitter");
|
|
6
6
|
class JitterShotgun extends baseJitter_1.BaseJitter {
|
|
7
|
-
constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap,
|
|
7
|
+
constructor({ auctionSubscriber, jitProxyClient, driftClient, userStatsMap, swiftOrderSubscriber, slotSubscriber, auctionSubscriberIgnoresSwiftOrders, }) {
|
|
8
8
|
super({
|
|
9
9
|
auctionSubscriber,
|
|
10
10
|
jitProxyClient,
|
|
11
11
|
driftClient,
|
|
12
12
|
userStatsMap,
|
|
13
|
-
|
|
13
|
+
swiftOrderSubscriber,
|
|
14
14
|
slotSubscriber,
|
|
15
|
-
|
|
15
|
+
auctionSubscriberIgnoresSwiftOrders,
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
createTryFill(taker, takerKey, takerStatsKey, order, orderSignature) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JitProxyClient } from '../jitProxyClient';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
import { AuctionSubscriber, DriftClient, OraclePriceData, Order, SignedMsgOrderParams,
|
|
3
|
+
import { AuctionSubscriber, DriftClient, OraclePriceData, Order, SignedMsgOrderParams, SwiftOrderSubscriber, SlotSubscriber, UserAccount, UserStatsMap } from '@drift-labs/sdk';
|
|
4
4
|
import { BaseJitter } from './baseJitter';
|
|
5
5
|
type AuctionAndOrderDetails = {
|
|
6
6
|
slotsTilCross: number;
|
|
@@ -15,14 +15,14 @@ type AuctionAndOrderDetails = {
|
|
|
15
15
|
export declare class JitterSniper extends BaseJitter {
|
|
16
16
|
slotSubscriber: SlotSubscriber;
|
|
17
17
|
userStatsMap: UserStatsMap;
|
|
18
|
-
constructor({ auctionSubscriber, slotSubscriber, jitProxyClient, driftClient, userStatsMap,
|
|
18
|
+
constructor({ auctionSubscriber, slotSubscriber, jitProxyClient, driftClient, userStatsMap, swiftOrderSubscriber, auctionSubscriberIgnoresSwiftOrders, }: {
|
|
19
19
|
driftClient: DriftClient;
|
|
20
20
|
slotSubscriber: SlotSubscriber;
|
|
21
21
|
auctionSubscriber: AuctionSubscriber;
|
|
22
22
|
jitProxyClient: JitProxyClient;
|
|
23
23
|
userStatsMap?: UserStatsMap;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
swiftOrderSubscriber?: SwiftOrderSubscriber;
|
|
25
|
+
auctionSubscriberIgnoresSwiftOrders?: boolean;
|
|
26
26
|
});
|
|
27
27
|
createTryFill(taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string): () => Promise<void>;
|
|
28
28
|
createTrySignedMsgFill(authorityToUse: PublicKey, signedMsgOrderParams: SignedMsgOrderParams, uuid: Uint8Array, taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string, marketIndex: number): () => Promise<void>;
|
|
@@ -4,15 +4,15 @@ exports.JitterSniper = void 0;
|
|
|
4
4
|
const sdk_1 = require("@drift-labs/sdk");
|
|
5
5
|
const baseJitter_1 = require("./baseJitter");
|
|
6
6
|
class JitterSniper extends baseJitter_1.BaseJitter {
|
|
7
|
-
constructor({ auctionSubscriber, slotSubscriber, jitProxyClient, driftClient, userStatsMap,
|
|
7
|
+
constructor({ auctionSubscriber, slotSubscriber, jitProxyClient, driftClient, userStatsMap, swiftOrderSubscriber, auctionSubscriberIgnoresSwiftOrders, }) {
|
|
8
8
|
super({
|
|
9
9
|
auctionSubscriber,
|
|
10
10
|
jitProxyClient,
|
|
11
11
|
driftClient,
|
|
12
12
|
userStatsMap,
|
|
13
|
-
|
|
13
|
+
swiftOrderSubscriber,
|
|
14
14
|
slotSubscriber,
|
|
15
|
-
|
|
15
|
+
auctionSubscriberIgnoresSwiftOrders,
|
|
16
16
|
});
|
|
17
17
|
this.slotSubscriber = slotSubscriber;
|
|
18
18
|
}
|
package/package.json
CHANGED
package/src/jitter/baseJitter.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
OrderStatus,
|
|
17
17
|
PositionDirection,
|
|
18
18
|
PostOnlyParams,
|
|
19
|
-
|
|
19
|
+
SwiftOrderSubscriber,
|
|
20
20
|
SlotSubscriber,
|
|
21
21
|
SignedMsgOrderParams,
|
|
22
22
|
UserAccount,
|
|
@@ -45,11 +45,11 @@ export type JitParams = {
|
|
|
45
45
|
|
|
46
46
|
export abstract class BaseJitter {
|
|
47
47
|
auctionSubscriber: AuctionSubscriber;
|
|
48
|
-
|
|
48
|
+
swiftOrderSubscriber: SwiftOrderSubscriber;
|
|
49
49
|
slotSubscriber: SlotSubscriber;
|
|
50
50
|
driftClient: DriftClient;
|
|
51
51
|
jitProxyClient: JitProxyClient;
|
|
52
|
-
|
|
52
|
+
auctionSubscriberIgnoresSwiftOrders?: boolean;
|
|
53
53
|
userStatsMap: UserStatsMap;
|
|
54
54
|
|
|
55
55
|
perpParams = new Map<number, JitParams>();
|
|
@@ -68,17 +68,17 @@ export abstract class BaseJitter {
|
|
|
68
68
|
jitProxyClient,
|
|
69
69
|
driftClient,
|
|
70
70
|
userStatsMap,
|
|
71
|
-
|
|
71
|
+
swiftOrderSubscriber,
|
|
72
72
|
slotSubscriber,
|
|
73
|
-
|
|
73
|
+
auctionSubscriberIgnoresSwiftOrders,
|
|
74
74
|
}: {
|
|
75
75
|
driftClient: DriftClient;
|
|
76
76
|
auctionSubscriber: AuctionSubscriber;
|
|
77
77
|
jitProxyClient: JitProxyClient;
|
|
78
78
|
userStatsMap: UserStatsMap;
|
|
79
|
-
|
|
79
|
+
swiftOrderSubscriber?: SwiftOrderSubscriber;
|
|
80
80
|
slotSubscriber?: SlotSubscriber;
|
|
81
|
-
|
|
81
|
+
auctionSubscriberIgnoresSwiftOrders?: boolean;
|
|
82
82
|
}) {
|
|
83
83
|
this.auctionSubscriber = auctionSubscriber;
|
|
84
84
|
this.driftClient = driftClient;
|
|
@@ -90,11 +90,11 @@ export abstract class BaseJitter {
|
|
|
90
90
|
new BulkAccountLoader(this.driftClient.connection, 'confirmed', 0)
|
|
91
91
|
);
|
|
92
92
|
this.slotSubscriber = slotSubscriber;
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
|
|
93
|
+
this.swiftOrderSubscriber = swiftOrderSubscriber;
|
|
94
|
+
this.auctionSubscriberIgnoresSwiftOrders =
|
|
95
|
+
auctionSubscriberIgnoresSwiftOrders;
|
|
96
96
|
|
|
97
|
-
if (this.
|
|
97
|
+
if (this.swiftOrderSubscriber && !this.slotSubscriber) {
|
|
98
98
|
throw new Error(
|
|
99
99
|
'Slot subscriber is required for signedMsg order subscriber'
|
|
100
100
|
);
|
|
@@ -124,7 +124,7 @@ export abstract class BaseJitter {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
if (
|
|
127
|
-
this.
|
|
127
|
+
this.auctionSubscriberIgnoresSwiftOrders &&
|
|
128
128
|
isSignedMsgOrder(order)
|
|
129
129
|
) {
|
|
130
130
|
continue;
|
|
@@ -203,7 +203,7 @@ export abstract class BaseJitter {
|
|
|
203
203
|
}
|
|
204
204
|
);
|
|
205
205
|
await this.slotSubscriber?.subscribe();
|
|
206
|
-
await this.
|
|
206
|
+
await this.swiftOrderSubscriber?.subscribe(
|
|
207
207
|
async (orderMessageRaw, signedMsgOrderParamsMessage) => {
|
|
208
208
|
const signedMsgOrderParams =
|
|
209
209
|
signedMsgOrderParamsMessage.signedMsgOrderParams;
|
|
@@ -240,7 +240,7 @@ export abstract class BaseJitter {
|
|
|
240
240
|
);
|
|
241
241
|
const takerUserPubkeyString = takerUserPubkey.toBase58();
|
|
242
242
|
const takerUserAccount = (
|
|
243
|
-
await this.
|
|
243
|
+
await this.swiftOrderSubscriber.userMap.mustGet(
|
|
244
244
|
takerUserPubkey.toString()
|
|
245
245
|
)
|
|
246
246
|
).getUserAccount();
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
PostOnlyParams,
|
|
8
8
|
SlotSubscriber,
|
|
9
9
|
SignedMsgOrderParams,
|
|
10
|
-
|
|
10
|
+
SwiftOrderSubscriber,
|
|
11
11
|
UserAccount,
|
|
12
12
|
UserStatsMap,
|
|
13
13
|
} from '@drift-labs/sdk';
|
|
@@ -19,26 +19,26 @@ export class JitterShotgun extends BaseJitter {
|
|
|
19
19
|
jitProxyClient,
|
|
20
20
|
driftClient,
|
|
21
21
|
userStatsMap,
|
|
22
|
-
|
|
22
|
+
swiftOrderSubscriber,
|
|
23
23
|
slotSubscriber,
|
|
24
|
-
|
|
24
|
+
auctionSubscriberIgnoresSwiftOrders,
|
|
25
25
|
}: {
|
|
26
26
|
driftClient: DriftClient;
|
|
27
27
|
auctionSubscriber: AuctionSubscriber;
|
|
28
28
|
jitProxyClient: JitProxyClient;
|
|
29
29
|
userStatsMap?: UserStatsMap;
|
|
30
|
-
|
|
30
|
+
swiftOrderSubscriber?: SwiftOrderSubscriber;
|
|
31
31
|
slotSubscriber?: SlotSubscriber;
|
|
32
|
-
|
|
32
|
+
auctionSubscriberIgnoresSwiftOrders?: boolean;
|
|
33
33
|
}) {
|
|
34
34
|
super({
|
|
35
35
|
auctionSubscriber,
|
|
36
36
|
jitProxyClient,
|
|
37
37
|
driftClient,
|
|
38
38
|
userStatsMap,
|
|
39
|
-
|
|
39
|
+
swiftOrderSubscriber,
|
|
40
40
|
slotSubscriber,
|
|
41
|
-
|
|
41
|
+
auctionSubscriberIgnoresSwiftOrders,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
PostOnlyParams,
|
|
15
15
|
PRICE_PRECISION,
|
|
16
16
|
SignedMsgOrderParams,
|
|
17
|
-
|
|
17
|
+
SwiftOrderSubscriber,
|
|
18
18
|
SlotSubscriber,
|
|
19
19
|
UserAccount,
|
|
20
20
|
UserStatsMap,
|
|
@@ -43,25 +43,25 @@ export class JitterSniper extends BaseJitter {
|
|
|
43
43
|
jitProxyClient,
|
|
44
44
|
driftClient,
|
|
45
45
|
userStatsMap,
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
swiftOrderSubscriber,
|
|
47
|
+
auctionSubscriberIgnoresSwiftOrders,
|
|
48
48
|
}: {
|
|
49
49
|
driftClient: DriftClient;
|
|
50
50
|
slotSubscriber: SlotSubscriber;
|
|
51
51
|
auctionSubscriber: AuctionSubscriber;
|
|
52
52
|
jitProxyClient: JitProxyClient;
|
|
53
53
|
userStatsMap?: UserStatsMap;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
swiftOrderSubscriber?: SwiftOrderSubscriber;
|
|
55
|
+
auctionSubscriberIgnoresSwiftOrders?: boolean;
|
|
56
56
|
}) {
|
|
57
57
|
super({
|
|
58
58
|
auctionSubscriber,
|
|
59
59
|
jitProxyClient,
|
|
60
60
|
driftClient,
|
|
61
61
|
userStatsMap,
|
|
62
|
-
|
|
62
|
+
swiftOrderSubscriber,
|
|
63
63
|
slotSubscriber,
|
|
64
|
-
|
|
64
|
+
auctionSubscriberIgnoresSwiftOrders,
|
|
65
65
|
});
|
|
66
66
|
this.slotSubscriber = slotSubscriber;
|
|
67
67
|
}
|