@drift-labs/jit-proxy 0.13.18 → 0.13.20
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/jitProxyClient.d.ts +3 -3
- package/lib/jitProxyClient.js +5 -5
- package/lib/jitter/baseJitter.d.ts +1 -1
- package/lib/jitter/baseJitter.js +17 -18
- package/lib/jitter/jitterShotgun.d.ts +1 -1
- package/lib/jitter/jitterShotgun.js +2 -2
- package/lib/jitter/jitterSniper.d.ts +1 -1
- package/lib/jitter/jitterSniper.js +2 -2
- package/package.json +2 -2
- package/src/jitProxyClient.ts +8 -8
- package/src/jitter/baseJitter.ts +29 -20
- package/src/jitter/jitterShotgun.ts +2 -2
- package/src/jitter/jitterSniper.ts +2 -2
package/lib/jitProxyClient.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export type JitIxParams = {
|
|
|
17
17
|
referrerInfo?: ReferrerInfo;
|
|
18
18
|
subAccountId?: number;
|
|
19
19
|
};
|
|
20
|
-
export type
|
|
20
|
+
export type JitSignedMsgIxParams = JitIxParams & {
|
|
21
21
|
authorityToUse: PublicKey;
|
|
22
22
|
signedMsgOrderParams: SignedMsgOrderParams;
|
|
23
23
|
uuid: Uint8Array;
|
|
@@ -45,12 +45,12 @@ export declare class JitProxyClient {
|
|
|
45
45
|
programId: PublicKey;
|
|
46
46
|
});
|
|
47
47
|
jit(params: JitIxParams, txParams?: TxParams): Promise<TxSigAndSlot>;
|
|
48
|
-
|
|
48
|
+
jitSignedMsg(params: JitSignedMsgIxParams, computeBudgetParams?: {
|
|
49
49
|
computeUnits: number;
|
|
50
50
|
computeUnitsPrice: number;
|
|
51
51
|
}): Promise<TxSigAndSlot>;
|
|
52
52
|
getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, subAccountId, }: JitIxParams): Promise<TransactionInstruction>;
|
|
53
|
-
|
|
53
|
+
getJitSignedMsgIx({ takerKey, takerStatsKey, taker, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, subAccountId, uuid, marketIndex, }: JitSignedMsgIxParams): Promise<TransactionInstruction>;
|
|
54
54
|
getCheckOrderConstraintIx({ subAccountId, orderConstraints, }: {
|
|
55
55
|
subAccountId: number;
|
|
56
56
|
orderConstraints: OrderConstraint[];
|
package/lib/jitProxyClient.js
CHANGED
|
@@ -21,7 +21,7 @@ class JitProxyClient {
|
|
|
21
21
|
const tx = await this.driftClient.buildTransaction([ix], txParams);
|
|
22
22
|
return await this.driftClient.sendTransaction(tx);
|
|
23
23
|
}
|
|
24
|
-
async
|
|
24
|
+
async jitSignedMsg(params, computeBudgetParams) {
|
|
25
25
|
const ixs = [
|
|
26
26
|
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
27
27
|
units: (computeBudgetParams === null || computeBudgetParams === void 0 ? void 0 : computeBudgetParams.computeUnits) || exports.DEFAULT_CU_LIMIT,
|
|
@@ -30,14 +30,14 @@ class JitProxyClient {
|
|
|
30
30
|
microLamports: (computeBudgetParams === null || computeBudgetParams === void 0 ? void 0 : computeBudgetParams.computeUnitsPrice) || 0,
|
|
31
31
|
}),
|
|
32
32
|
];
|
|
33
|
-
const
|
|
33
|
+
const signedMsgTakerIxs = await this.driftClient.getPlaceSignedMsgTakerPerpOrderIxs(params.signedMsgOrderParams, params.marketIndex, {
|
|
34
34
|
taker: params.takerKey,
|
|
35
35
|
takerStats: params.takerStatsKey,
|
|
36
36
|
takerUserAccount: params.taker,
|
|
37
37
|
signingAuthority: params.authorityToUse,
|
|
38
38
|
}, ixs);
|
|
39
|
-
ixs.push(...
|
|
40
|
-
const ix = await this.
|
|
39
|
+
ixs.push(...signedMsgTakerIxs);
|
|
40
|
+
const ix = await this.getJitSignedMsgIx(params);
|
|
41
41
|
ixs.push(ix);
|
|
42
42
|
const v0Message = new web3_js_1.TransactionMessage({
|
|
43
43
|
instructions: ixs,
|
|
@@ -108,7 +108,7 @@ class JitProxyClient {
|
|
|
108
108
|
.remainingAccounts(remainingAccounts)
|
|
109
109
|
.instruction();
|
|
110
110
|
}
|
|
111
|
-
async
|
|
111
|
+
async getJitSignedMsgIx({ takerKey, takerStatsKey, taker, maxPosition, minPosition, bid, ask, postOnly = null, priceType = PriceType.LIMIT, referrerInfo, subAccountId, uuid, marketIndex, }) {
|
|
112
112
|
subAccountId =
|
|
113
113
|
subAccountId !== undefined
|
|
114
114
|
? subAccountId
|
|
@@ -36,7 +36,7 @@ export declare abstract class BaseJitter {
|
|
|
36
36
|
});
|
|
37
37
|
subscribe(): Promise<void>;
|
|
38
38
|
createTryFill(taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string): () => Promise<void>;
|
|
39
|
-
|
|
39
|
+
createTrySignedMsgFill(authorityToUse: PublicKey, signedMsgOrderParams: SignedMsgOrderParams, uuid: Uint8Array, taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string, marketIndex: number): () => Promise<void>;
|
|
40
40
|
deleteOnGoingAuction(orderSignature: string): void;
|
|
41
41
|
getOrderSignatures(takerKey: string, orderId: number): string;
|
|
42
42
|
private convertUuidToNumber;
|
package/lib/jitter/baseJitter.js
CHANGED
|
@@ -19,7 +19,7 @@ class BaseJitter {
|
|
|
19
19
|
this.slotSubscriber = slotSubscriber;
|
|
20
20
|
this.signedMsgOrderSubscriber = signedMsgOrderSubscriber;
|
|
21
21
|
if (this.signedMsgOrderSubscriber && !this.slotSubscriber) {
|
|
22
|
-
throw new Error('Slot subscriber is required for
|
|
22
|
+
throw new Error('Slot subscriber is required for signedMsg order subscriber');
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
async subscribe() {
|
|
@@ -78,21 +78,21 @@ class BaseJitter {
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
await ((_a = this.slotSubscriber) === null || _a === void 0 ? void 0 : _a.subscribe());
|
|
81
|
-
await ((_b = this.signedMsgOrderSubscriber) === null || _b === void 0 ? void 0 : _b.subscribe(async (orderMessageRaw,
|
|
81
|
+
await ((_b = this.signedMsgOrderSubscriber) === null || _b === void 0 ? void 0 : _b.subscribe(async (orderMessageRaw, signedMsgOrderParamsMessage) => {
|
|
82
82
|
var _a, _b, _c;
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const { signedMsgOrderParams, subAccountId: takerSubaccountId, } = this.driftClient.decodeSignedMsgOrderParamsMessage(
|
|
83
|
+
const signedMsgOrderParamsBufHex = Buffer.from(orderMessageRaw['order_message']);
|
|
84
|
+
const signedMsgOrderParamsBuf = Buffer.from(orderMessageRaw['order_message'], 'hex');
|
|
85
|
+
const { signedMsgOrderParams, subAccountId: takerSubaccountId, } = this.driftClient.decodeSignedMsgOrderParamsMessage(signedMsgOrderParamsBuf);
|
|
86
86
|
const takerAuthority = new web3_js_1.PublicKey(orderMessageRaw['taker_authority']);
|
|
87
87
|
const signingAuthority = new web3_js_1.PublicKey(orderMessageRaw['signing_authority']);
|
|
88
88
|
const takerUserPubkey = await (0, sdk_1.getUserAccountPublicKey)(this.driftClient.program.programId, takerAuthority, takerSubaccountId);
|
|
89
89
|
const takerUserPubkeyString = takerUserPubkey.toBase58();
|
|
90
90
|
const takerUserAccount = (await this.signedMsgOrderSubscriber.userMap.mustGet(takerUserPubkey.toString())).getUserAccount();
|
|
91
|
-
const
|
|
91
|
+
const signedMsgOrder = {
|
|
92
92
|
status: sdk_1.OrderStatus.OPEN,
|
|
93
93
|
orderType: signedMsgOrderParams.orderType,
|
|
94
94
|
orderId: this.convertUuidToNumber(orderMessageRaw['uuid']),
|
|
95
|
-
slot:
|
|
95
|
+
slot: signedMsgOrderParamsMessage.slot,
|
|
96
96
|
marketIndex: signedMsgOrderParams.marketIndex,
|
|
97
97
|
marketType: sdk_1.MarketType.PERP,
|
|
98
98
|
baseAssetAmount: signedMsgOrderParams.baseAssetAmount,
|
|
@@ -116,14 +116,13 @@ class BaseJitter {
|
|
|
116
116
|
userOrderId: 0,
|
|
117
117
|
postedSlotTail: 0,
|
|
118
118
|
};
|
|
119
|
-
|
|
120
|
-
.price);
|
|
119
|
+
signedMsgOrder.price = (0, sdk_1.getAuctionPrice)(signedMsgOrder, (_c = this.slotSubscriber) === null || _c === void 0 ? void 0 : _c.getSlot(), this.driftClient.getOracleDataForPerpMarket(signedMsgOrder.marketIndex).price);
|
|
121
120
|
if (this.userFilter) {
|
|
122
|
-
if (this.userFilter(takerUserAccount, takerUserPubkeyString,
|
|
121
|
+
if (this.userFilter(takerUserAccount, takerUserPubkeyString, signedMsgOrder)) {
|
|
123
122
|
return;
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
|
-
const orderSignature = this.getOrderSignatures(takerUserPubkeyString,
|
|
125
|
+
const orderSignature = this.getOrderSignatures(takerUserPubkeyString, signedMsgOrder.orderId);
|
|
127
126
|
if (this.seenOrders.has(orderSignature)) {
|
|
128
127
|
return;
|
|
129
128
|
}
|
|
@@ -131,24 +130,24 @@ class BaseJitter {
|
|
|
131
130
|
if (this.onGoingAuctions.has(orderSignature)) {
|
|
132
131
|
return;
|
|
133
132
|
}
|
|
134
|
-
if (!this.perpParams.has(
|
|
133
|
+
if (!this.perpParams.has(signedMsgOrder.marketIndex)) {
|
|
135
134
|
return;
|
|
136
135
|
}
|
|
137
|
-
const perpMarketAccount = this.driftClient.getPerpMarketAccount(
|
|
138
|
-
if (
|
|
136
|
+
const perpMarketAccount = this.driftClient.getPerpMarketAccount(signedMsgOrder.marketIndex);
|
|
137
|
+
if (signedMsgOrder.baseAssetAmount.lt(perpMarketAccount.amm.minOrderSize)) {
|
|
139
138
|
return;
|
|
140
139
|
}
|
|
141
|
-
const promise = this.
|
|
142
|
-
orderParams:
|
|
140
|
+
const promise = this.createTrySignedMsgFill(signingAuthority, {
|
|
141
|
+
orderParams: signedMsgOrderParamsBufHex,
|
|
143
142
|
signature: Buffer.from(orderMessageRaw['order_signature'], 'base64'),
|
|
144
|
-
}, (0, tweetnacl_util_1.decodeUTF8)(orderMessageRaw['uuid']), takerUserAccount, takerUserPubkey, (0, sdk_1.getUserStatsAccountPublicKey)(this.driftClient.program.programId, takerUserAccount.authority),
|
|
143
|
+
}, (0, tweetnacl_util_1.decodeUTF8)(orderMessageRaw['uuid']), takerUserAccount, takerUserPubkey, (0, sdk_1.getUserStatsAccountPublicKey)(this.driftClient.program.programId, takerUserAccount.authority), signedMsgOrder, orderSignature, orderMessageRaw['market_index']).bind(this)();
|
|
145
144
|
this.onGoingAuctions.set(orderSignature, promise);
|
|
146
145
|
}));
|
|
147
146
|
}
|
|
148
147
|
createTryFill(taker, takerKey, takerStatsKey, order, orderSignature) {
|
|
149
148
|
throw new Error('Not implemented');
|
|
150
149
|
}
|
|
151
|
-
|
|
150
|
+
createTrySignedMsgFill(authorityToUse, signedMsgOrderParams, uuid, taker, takerKey, takerStatsKey, order, orderSignature, marketIndex) {
|
|
152
151
|
throw new Error('Not implemented');
|
|
153
152
|
}
|
|
154
153
|
deleteOnGoingAuction(orderSignature) {
|
|
@@ -12,5 +12,5 @@ export declare class JitterShotgun extends BaseJitter {
|
|
|
12
12
|
slotSubscriber?: SlotSubscriber;
|
|
13
13
|
});
|
|
14
14
|
createTryFill(taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string): () => Promise<void>;
|
|
15
|
-
|
|
15
|
+
createTrySignedMsgFill(authorityToUse: PublicKey, signedMsgOrderParams: SignedMsgOrderParams, uuid: Uint8Array, taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string, marketIndex: number): () => Promise<void>;
|
|
16
16
|
}
|
|
@@ -74,7 +74,7 @@ class JitterShotgun extends baseJitter_1.BaseJitter {
|
|
|
74
74
|
this.deleteOnGoingAuction(orderSignature);
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
createTrySignedMsgFill(authorityToUse, signedMsgOrderParams, uuid, taker, takerKey, takerStatsKey, order, orderSignature, marketIndex) {
|
|
78
78
|
return async () => {
|
|
79
79
|
var _a;
|
|
80
80
|
let i = 0;
|
|
@@ -93,7 +93,7 @@ class JitterShotgun extends baseJitter_1.BaseJitter {
|
|
|
93
93
|
};
|
|
94
94
|
console.log(`Trying to fill ${orderSignature}`);
|
|
95
95
|
try {
|
|
96
|
-
const { txSig } = await this.jitProxyClient.
|
|
96
|
+
const { txSig } = await this.jitProxyClient.jitSignedMsg({
|
|
97
97
|
takerKey,
|
|
98
98
|
takerStatsKey,
|
|
99
99
|
taker,
|
|
@@ -24,7 +24,7 @@ export declare class JitterSniper extends BaseJitter {
|
|
|
24
24
|
signedMsgOrderSubscriber?: SignedMsgOrderSubscriber;
|
|
25
25
|
});
|
|
26
26
|
createTryFill(taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string): () => Promise<void>;
|
|
27
|
-
|
|
27
|
+
createTrySignedMsgFill(authorityToUse: PublicKey, signedMsgOrderParams: SignedMsgOrderParams, uuid: Uint8Array, taker: UserAccount, takerKey: PublicKey, takerStatsKey: PublicKey, order: Order, orderSignature: string, marketIndex: number): () => Promise<void>;
|
|
28
28
|
getAuctionAndOrderDetails(order: Order): AuctionAndOrderDetails;
|
|
29
29
|
waitForSlotOrCrossOrExpiry(targetSlot: number, order: Order, initialDetails: AuctionAndOrderDetails): Promise<{
|
|
30
30
|
slot: number;
|
|
@@ -144,7 +144,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
|
|
|
144
144
|
this.deleteOnGoingAuction(orderSignature);
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
createTrySignedMsgFill(authorityToUse, signedMsgOrderParams, uuid, taker, takerKey, takerStatsKey, order, orderSignature, marketIndex) {
|
|
148
148
|
return async () => {
|
|
149
149
|
const params = this.perpParams.get(order.marketIndex);
|
|
150
150
|
if (!params) {
|
|
@@ -230,7 +230,7 @@ class JitterSniper extends baseJitter_1.BaseJitter {
|
|
|
230
230
|
computeUnits: this.computeUnits,
|
|
231
231
|
computeUnitsPrice: this.computeUnitsPrice,
|
|
232
232
|
};
|
|
233
|
-
const { txSig } = await this.jitProxyClient.
|
|
233
|
+
const { txSig } = await this.jitProxyClient.jitSignedMsg({
|
|
234
234
|
takerKey,
|
|
235
235
|
takerStatsKey,
|
|
236
236
|
taker,
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drift-labs/jit-proxy",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.20",
|
|
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.110.0-beta.
|
|
10
|
+
"@drift-labs/sdk": "2.110.0-beta.17",
|
|
11
11
|
"@solana/web3.js": "1.91.7",
|
|
12
12
|
"tweetnacl-util": "^0.15.1"
|
|
13
13
|
},
|
package/src/jitProxyClient.ts
CHANGED
|
@@ -40,7 +40,7 @@ export type JitIxParams = {
|
|
|
40
40
|
subAccountId?: number;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
export type
|
|
43
|
+
export type JitSignedMsgIxParams = JitIxParams & {
|
|
44
44
|
authorityToUse: PublicKey;
|
|
45
45
|
signedMsgOrderParams: SignedMsgOrderParams;
|
|
46
46
|
uuid: Uint8Array;
|
|
@@ -83,8 +83,8 @@ export class JitProxyClient {
|
|
|
83
83
|
return await this.driftClient.sendTransaction(tx);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
public async
|
|
87
|
-
params:
|
|
86
|
+
public async jitSignedMsg(
|
|
87
|
+
params: JitSignedMsgIxParams,
|
|
88
88
|
computeBudgetParams?: {
|
|
89
89
|
computeUnits: number;
|
|
90
90
|
computeUnitsPrice: number;
|
|
@@ -99,7 +99,7 @@ export class JitProxyClient {
|
|
|
99
99
|
}),
|
|
100
100
|
];
|
|
101
101
|
|
|
102
|
-
const
|
|
102
|
+
const signedMsgTakerIxs =
|
|
103
103
|
await this.driftClient.getPlaceSignedMsgTakerPerpOrderIxs(
|
|
104
104
|
params.signedMsgOrderParams,
|
|
105
105
|
params.marketIndex,
|
|
@@ -111,9 +111,9 @@ export class JitProxyClient {
|
|
|
111
111
|
},
|
|
112
112
|
ixs
|
|
113
113
|
);
|
|
114
|
-
ixs.push(...
|
|
114
|
+
ixs.push(...signedMsgTakerIxs);
|
|
115
115
|
|
|
116
|
-
const ix = await this.
|
|
116
|
+
const ix = await this.getJitSignedMsgIx(params);
|
|
117
117
|
ixs.push(ix);
|
|
118
118
|
|
|
119
119
|
const v0Message = new TransactionMessage({
|
|
@@ -207,7 +207,7 @@ export class JitProxyClient {
|
|
|
207
207
|
.instruction();
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
public async
|
|
210
|
+
public async getJitSignedMsgIx({
|
|
211
211
|
takerKey,
|
|
212
212
|
takerStatsKey,
|
|
213
213
|
taker,
|
|
@@ -221,7 +221,7 @@ export class JitProxyClient {
|
|
|
221
221
|
subAccountId,
|
|
222
222
|
uuid,
|
|
223
223
|
marketIndex,
|
|
224
|
-
}:
|
|
224
|
+
}: JitSignedMsgIxParams): Promise<TransactionInstruction> {
|
|
225
225
|
subAccountId =
|
|
226
226
|
subAccountId !== undefined
|
|
227
227
|
? subAccountId
|
package/src/jitter/baseJitter.ts
CHANGED
|
@@ -89,7 +89,9 @@ export abstract class BaseJitter {
|
|
|
89
89
|
this.signedMsgOrderSubscriber = signedMsgOrderSubscriber;
|
|
90
90
|
|
|
91
91
|
if (this.signedMsgOrderSubscriber && !this.slotSubscriber) {
|
|
92
|
-
throw new Error(
|
|
92
|
+
throw new Error(
|
|
93
|
+
'Slot subscriber is required for signedMsg order subscriber'
|
|
94
|
+
);
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
|
|
@@ -189,11 +191,11 @@ export abstract class BaseJitter {
|
|
|
189
191
|
);
|
|
190
192
|
await this.slotSubscriber?.subscribe();
|
|
191
193
|
await this.signedMsgOrderSubscriber?.subscribe(
|
|
192
|
-
async (orderMessageRaw,
|
|
193
|
-
const
|
|
194
|
+
async (orderMessageRaw, signedMsgOrderParamsMessage) => {
|
|
195
|
+
const signedMsgOrderParamsBufHex = Buffer.from(
|
|
194
196
|
orderMessageRaw['order_message']
|
|
195
197
|
);
|
|
196
|
-
const
|
|
198
|
+
const signedMsgOrderParamsBuf = Buffer.from(
|
|
197
199
|
orderMessageRaw['order_message'],
|
|
198
200
|
'hex'
|
|
199
201
|
);
|
|
@@ -202,7 +204,7 @@ export abstract class BaseJitter {
|
|
|
202
204
|
subAccountId: takerSubaccountId,
|
|
203
205
|
}: SignedMsgOrderParamsMessage =
|
|
204
206
|
this.driftClient.decodeSignedMsgOrderParamsMessage(
|
|
205
|
-
|
|
207
|
+
signedMsgOrderParamsBuf
|
|
206
208
|
);
|
|
207
209
|
|
|
208
210
|
const takerAuthority = new PublicKey(
|
|
@@ -223,11 +225,11 @@ export abstract class BaseJitter {
|
|
|
223
225
|
)
|
|
224
226
|
).getUserAccount();
|
|
225
227
|
|
|
226
|
-
const
|
|
228
|
+
const signedMsgOrder: Order = {
|
|
227
229
|
status: OrderStatus.OPEN,
|
|
228
230
|
orderType: signedMsgOrderParams.orderType,
|
|
229
231
|
orderId: this.convertUuidToNumber(orderMessageRaw['uuid']),
|
|
230
|
-
slot:
|
|
232
|
+
slot: signedMsgOrderParamsMessage.slot,
|
|
231
233
|
marketIndex: signedMsgOrderParams.marketIndex,
|
|
232
234
|
marketType: MarketType.PERP,
|
|
233
235
|
baseAssetAmount: signedMsgOrderParams.baseAssetAmount,
|
|
@@ -251,16 +253,21 @@ export abstract class BaseJitter {
|
|
|
251
253
|
userOrderId: 0,
|
|
252
254
|
postedSlotTail: 0,
|
|
253
255
|
};
|
|
254
|
-
|
|
255
|
-
|
|
256
|
+
signedMsgOrder.price = getAuctionPrice(
|
|
257
|
+
signedMsgOrder,
|
|
256
258
|
this.slotSubscriber?.getSlot(),
|
|
257
|
-
this.driftClient.getOracleDataForPerpMarket(
|
|
258
|
-
.
|
|
259
|
+
this.driftClient.getOracleDataForPerpMarket(
|
|
260
|
+
signedMsgOrder.marketIndex
|
|
261
|
+
).price
|
|
259
262
|
);
|
|
260
263
|
|
|
261
264
|
if (this.userFilter) {
|
|
262
265
|
if (
|
|
263
|
-
this.userFilter(
|
|
266
|
+
this.userFilter(
|
|
267
|
+
takerUserAccount,
|
|
268
|
+
takerUserPubkeyString,
|
|
269
|
+
signedMsgOrder
|
|
270
|
+
)
|
|
264
271
|
) {
|
|
265
272
|
return;
|
|
266
273
|
}
|
|
@@ -268,7 +275,7 @@ export abstract class BaseJitter {
|
|
|
268
275
|
|
|
269
276
|
const orderSignature = this.getOrderSignatures(
|
|
270
277
|
takerUserPubkeyString,
|
|
271
|
-
|
|
278
|
+
signedMsgOrder.orderId
|
|
272
279
|
);
|
|
273
280
|
|
|
274
281
|
if (this.seenOrders.has(orderSignature)) {
|
|
@@ -280,21 +287,23 @@ export abstract class BaseJitter {
|
|
|
280
287
|
return;
|
|
281
288
|
}
|
|
282
289
|
|
|
283
|
-
if (!this.perpParams.has(
|
|
290
|
+
if (!this.perpParams.has(signedMsgOrder.marketIndex)) {
|
|
284
291
|
return;
|
|
285
292
|
}
|
|
286
293
|
|
|
287
294
|
const perpMarketAccount = this.driftClient.getPerpMarketAccount(
|
|
288
|
-
|
|
295
|
+
signedMsgOrder.marketIndex
|
|
289
296
|
);
|
|
290
|
-
if (
|
|
297
|
+
if (
|
|
298
|
+
signedMsgOrder.baseAssetAmount.lt(perpMarketAccount.amm.minOrderSize)
|
|
299
|
+
) {
|
|
291
300
|
return;
|
|
292
301
|
}
|
|
293
302
|
|
|
294
|
-
const promise = this.
|
|
303
|
+
const promise = this.createTrySignedMsgFill(
|
|
295
304
|
signingAuthority,
|
|
296
305
|
{
|
|
297
|
-
orderParams:
|
|
306
|
+
orderParams: signedMsgOrderParamsBufHex,
|
|
298
307
|
signature: Buffer.from(
|
|
299
308
|
orderMessageRaw['order_signature'],
|
|
300
309
|
'base64'
|
|
@@ -307,7 +316,7 @@ export abstract class BaseJitter {
|
|
|
307
316
|
this.driftClient.program.programId,
|
|
308
317
|
takerUserAccount.authority
|
|
309
318
|
),
|
|
310
|
-
|
|
319
|
+
signedMsgOrder,
|
|
311
320
|
orderSignature,
|
|
312
321
|
orderMessageRaw['market_index']
|
|
313
322
|
).bind(this)();
|
|
@@ -326,7 +335,7 @@ export abstract class BaseJitter {
|
|
|
326
335
|
throw new Error('Not implemented');
|
|
327
336
|
}
|
|
328
337
|
|
|
329
|
-
|
|
338
|
+
createTrySignedMsgFill(
|
|
330
339
|
authorityToUse: PublicKey,
|
|
331
340
|
signedMsgOrderParams: SignedMsgOrderParams,
|
|
332
341
|
uuid: Uint8Array,
|
|
@@ -114,7 +114,7 @@ export class JitterShotgun extends BaseJitter {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
createTrySignedMsgFill(
|
|
118
118
|
authorityToUse: PublicKey,
|
|
119
119
|
signedMsgOrderParams: SignedMsgOrderParams,
|
|
120
120
|
uuid: Uint8Array,
|
|
@@ -148,7 +148,7 @@ export class JitterShotgun extends BaseJitter {
|
|
|
148
148
|
|
|
149
149
|
console.log(`Trying to fill ${orderSignature}`);
|
|
150
150
|
try {
|
|
151
|
-
const { txSig } = await this.jitProxyClient.
|
|
151
|
+
const { txSig } = await this.jitProxyClient.jitSignedMsg(
|
|
152
152
|
{
|
|
153
153
|
takerKey,
|
|
154
154
|
takerStatsKey,
|
|
@@ -245,7 +245,7 @@ export class JitterSniper extends BaseJitter {
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
createTrySignedMsgFill(
|
|
249
249
|
authorityToUse: PublicKey,
|
|
250
250
|
signedMsgOrderParams: SignedMsgOrderParams,
|
|
251
251
|
uuid: Uint8Array,
|
|
@@ -386,7 +386,7 @@ export class JitterSniper extends BaseJitter {
|
|
|
386
386
|
computeUnits: this.computeUnits,
|
|
387
387
|
computeUnitsPrice: this.computeUnitsPrice,
|
|
388
388
|
};
|
|
389
|
-
const { txSig } = await this.jitProxyClient.
|
|
389
|
+
const { txSig } = await this.jitProxyClient.jitSignedMsg(
|
|
390
390
|
{
|
|
391
391
|
takerKey,
|
|
392
392
|
takerStatsKey,
|