@drift-labs/jit-proxy 0.4.0 → 0.5.0
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 +2 -1
- package/lib/jitProxyClient.js +4 -3
- package/lib/jitter.d.ts +1 -0
- package/lib/jitter.js +1 -0
- package/package.json +1 -1
- package/src/jitProxyClient.ts +5 -2
- package/src/jitter.ts +3 -0
package/lib/jitProxyClient.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare type JitIxParams = {
|
|
|
14
14
|
postOnly: PostOnlyParams | null;
|
|
15
15
|
priceType?: PriceType;
|
|
16
16
|
referrerInfo?: ReferrerInfo;
|
|
17
|
+
subAccountId?: number;
|
|
17
18
|
};
|
|
18
19
|
export declare class PriceType {
|
|
19
20
|
static readonly LIMIT: {
|
|
@@ -31,5 +32,5 @@ export declare class JitProxyClient {
|
|
|
31
32
|
programId: PublicKey;
|
|
32
33
|
});
|
|
33
34
|
jit(params: JitIxParams, txParams?: TxParams): Promise<TxSigAndSlot>;
|
|
34
|
-
getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, }: JitIxParams): Promise<TransactionInstruction>;
|
|
35
|
+
getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly, priceType, referrerInfo, subAccountId }: JitIxParams): Promise<TransactionInstruction>;
|
|
35
36
|
}
|
package/lib/jitProxyClient.js
CHANGED
|
@@ -19,10 +19,11 @@ class JitProxyClient {
|
|
|
19
19
|
const tx = await this.driftClient.buildTransaction([ix], txParams);
|
|
20
20
|
return await this.driftClient.sendTransaction(tx);
|
|
21
21
|
}
|
|
22
|
-
async getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly = null, priceType = PriceType.LIMIT, referrerInfo, }) {
|
|
22
|
+
async getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, minPosition, bid, ask, postOnly = null, priceType = PriceType.LIMIT, referrerInfo, subAccountId }) {
|
|
23
|
+
subAccountId = subAccountId || this.driftClient.activeSubAccountId;
|
|
23
24
|
const order = taker.orders.find((order) => order.orderId === takerOrderId);
|
|
24
25
|
const remainingAccounts = this.driftClient.getRemainingAccounts({
|
|
25
|
-
userAccounts: [taker, this.driftClient.getUserAccount()],
|
|
26
|
+
userAccounts: [taker, this.driftClient.getUserAccount(subAccountId)],
|
|
26
27
|
writableSpotMarketIndexes: sdk_1.isVariant(order.marketType, 'spot')
|
|
27
28
|
? [order.marketIndex, sdk_1.QUOTE_SPOT_MARKET_INDEX]
|
|
28
29
|
: [],
|
|
@@ -69,7 +70,7 @@ class JitProxyClient {
|
|
|
69
70
|
taker: takerKey,
|
|
70
71
|
takerStats: takerStatsKey,
|
|
71
72
|
state: await this.driftClient.getStatePublicKey(),
|
|
72
|
-
user: await this.driftClient.getUserAccountPublicKey(),
|
|
73
|
+
user: await this.driftClient.getUserAccountPublicKey(subAccountId),
|
|
73
74
|
userStats: this.driftClient.getUserStatsAccountPublicKey(),
|
|
74
75
|
driftProgram: this.driftClient.program.programId,
|
|
75
76
|
})
|
package/lib/jitter.d.ts
CHANGED
package/lib/jitter.js
CHANGED
package/package.json
CHANGED
package/src/jitProxyClient.ts
CHANGED
|
@@ -25,6 +25,7 @@ export type JitIxParams = {
|
|
|
25
25
|
postOnly: PostOnlyParams | null;
|
|
26
26
|
priceType?: PriceType;
|
|
27
27
|
referrerInfo?: ReferrerInfo;
|
|
28
|
+
subAccountId?: number;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
export class PriceType {
|
|
@@ -68,10 +69,12 @@ export class JitProxyClient {
|
|
|
68
69
|
postOnly = null,
|
|
69
70
|
priceType = PriceType.LIMIT,
|
|
70
71
|
referrerInfo,
|
|
72
|
+
subAccountId
|
|
71
73
|
}: JitIxParams): Promise<TransactionInstruction> {
|
|
74
|
+
subAccountId = subAccountId || this.driftClient.activeSubAccountId;
|
|
72
75
|
const order = taker.orders.find((order) => order.orderId === takerOrderId);
|
|
73
76
|
const remainingAccounts = this.driftClient.getRemainingAccounts({
|
|
74
|
-
userAccounts: [taker, this.driftClient.getUserAccount()],
|
|
77
|
+
userAccounts: [taker, this.driftClient.getUserAccount(subAccountId)],
|
|
75
78
|
writableSpotMarketIndexes: isVariant(order.marketType, 'spot')
|
|
76
79
|
? [order.marketIndex, QUOTE_SPOT_MARKET_INDEX]
|
|
77
80
|
: [],
|
|
@@ -122,7 +125,7 @@ export class JitProxyClient {
|
|
|
122
125
|
taker: takerKey,
|
|
123
126
|
takerStats: takerStatsKey,
|
|
124
127
|
state: await this.driftClient.getStatePublicKey(),
|
|
125
|
-
user: await this.driftClient.getUserAccountPublicKey(),
|
|
128
|
+
user: await this.driftClient.getUserAccountPublicKey(subAccountId),
|
|
126
129
|
userStats: this.driftClient.getUserStatsAccountPublicKey(),
|
|
127
130
|
driftProgram: this.driftClient.program.programId,
|
|
128
131
|
})
|
package/src/jitter.ts
CHANGED
|
@@ -16,12 +16,14 @@ export type UserFilter = (
|
|
|
16
16
|
userKey: string,
|
|
17
17
|
order: Order
|
|
18
18
|
) => boolean;
|
|
19
|
+
|
|
19
20
|
export type JitParams = {
|
|
20
21
|
bid: BN;
|
|
21
22
|
ask: BN;
|
|
22
23
|
minPosition: BN;
|
|
23
24
|
maxPosition;
|
|
24
25
|
priceType: PriceType;
|
|
26
|
+
subAccountId?: number;
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
export class Jitter {
|
|
@@ -159,6 +161,7 @@ export class Jitter {
|
|
|
159
161
|
postOnly: null,
|
|
160
162
|
priceType: params.priceType,
|
|
161
163
|
referrerInfo,
|
|
164
|
+
subAccountId: params.subAccountId,
|
|
162
165
|
});
|
|
163
166
|
|
|
164
167
|
console.log(`Filled ${orderSignature} txSig ${txSig}`);
|