@drift-labs/jit-proxy 0.1.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/index.d.ts +2 -0
- package/lib/index.js +14 -0
- package/lib/jitProxyClient.d.ts +23 -0
- package/lib/jitProxyClient.js +48 -0
- package/lib/types/jit_proxy.d.ts +114 -0
- package/lib/types/jit_proxy.js +116 -0
- package/package.json +12 -0
- package/src/index.js +14 -0
- package/src/index.ts +2 -0
- package/src/jitProxyClient.ts +89 -0
- package/src/types/jit_proxy.js +116 -0
- package/src/types/jit_proxy.ts +227 -0
- package/tsconfig.json +13 -0
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./types/jit_proxy"), exports);
|
|
14
|
+
__exportStar(require("./jitProxyClient"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN, DriftClient, PostOnlyParams, TxParams, UserAccount } from '@drift-labs/sdk';
|
|
3
|
+
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
4
|
+
import { TxSigAndSlot } from '@drift-labs/sdk/lib/tx/types';
|
|
5
|
+
export declare type JitIxParams = {
|
|
6
|
+
takerKey: PublicKey;
|
|
7
|
+
takerStatsKey: PublicKey;
|
|
8
|
+
taker: UserAccount;
|
|
9
|
+
takerOrderId: number;
|
|
10
|
+
maxPosition: BN;
|
|
11
|
+
worstPrice: BN;
|
|
12
|
+
postOnly: PostOnlyParams | null;
|
|
13
|
+
};
|
|
14
|
+
export declare class JitProxyClient {
|
|
15
|
+
private driftClient;
|
|
16
|
+
private program;
|
|
17
|
+
constructor({ driftClient, programId, }: {
|
|
18
|
+
driftClient: DriftClient;
|
|
19
|
+
programId: PublicKey;
|
|
20
|
+
});
|
|
21
|
+
jit(params: JitIxParams, txParams?: TxParams): Promise<TxSigAndSlot>;
|
|
22
|
+
getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, worstPrice, postOnly, }: JitIxParams): Promise<TransactionInstruction>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JitProxyClient = void 0;
|
|
4
|
+
const sdk_1 = require("@drift-labs/sdk");
|
|
5
|
+
const jit_proxy_1 = require("./types/jit_proxy");
|
|
6
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
7
|
+
class JitProxyClient {
|
|
8
|
+
constructor({ driftClient, programId, }) {
|
|
9
|
+
this.driftClient = driftClient;
|
|
10
|
+
this.program = new anchor_1.Program(jit_proxy_1.IDL, programId, driftClient.provider);
|
|
11
|
+
}
|
|
12
|
+
async jit(params, txParams) {
|
|
13
|
+
const ix = await this.getJitIx(params);
|
|
14
|
+
const tx = await this.driftClient.buildTransaction([ix], txParams);
|
|
15
|
+
return await this.driftClient.sendTransaction(tx);
|
|
16
|
+
}
|
|
17
|
+
async getJitIx({ takerKey, takerStatsKey, taker, takerOrderId, maxPosition, worstPrice, postOnly = null, }) {
|
|
18
|
+
const order = taker.orders.find((order) => order.orderId === takerOrderId);
|
|
19
|
+
const remainingAccounts = this.driftClient.getRemainingAccounts({
|
|
20
|
+
userAccounts: [taker, this.driftClient.getUserAccount()],
|
|
21
|
+
writableSpotMarketIndexes: sdk_1.isVariant(order.marketType, 'spot')
|
|
22
|
+
? [order.marketIndex, sdk_1.QUOTE_SPOT_MARKET_INDEX]
|
|
23
|
+
: [],
|
|
24
|
+
writablePerpMarketIndexes: sdk_1.isVariant(order.marketType, 'perp')
|
|
25
|
+
? [order.marketIndex]
|
|
26
|
+
: [],
|
|
27
|
+
});
|
|
28
|
+
const jitParams = {
|
|
29
|
+
takerOrderId,
|
|
30
|
+
maxPosition,
|
|
31
|
+
worstPrice,
|
|
32
|
+
postOnly,
|
|
33
|
+
};
|
|
34
|
+
return this.program.methods
|
|
35
|
+
.jit(jitParams)
|
|
36
|
+
.accounts({
|
|
37
|
+
taker: takerKey,
|
|
38
|
+
takerStats: takerStatsKey,
|
|
39
|
+
state: await this.driftClient.getStatePublicKey(),
|
|
40
|
+
user: await this.driftClient.getUserAccountPublicKey(),
|
|
41
|
+
userStats: this.driftClient.getUserStatsAccountPublicKey(),
|
|
42
|
+
driftProgram: this.driftClient.program.programId,
|
|
43
|
+
})
|
|
44
|
+
.remainingAccounts(remainingAccounts)
|
|
45
|
+
.instruction();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.JitProxyClient = JitProxyClient;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export declare type JitProxy = {
|
|
2
|
+
version: '0.1.0';
|
|
3
|
+
name: 'jit_proxy';
|
|
4
|
+
instructions: [
|
|
5
|
+
{
|
|
6
|
+
name: 'jit';
|
|
7
|
+
accounts: [
|
|
8
|
+
{
|
|
9
|
+
name: 'state';
|
|
10
|
+
isMut: false;
|
|
11
|
+
isSigner: false;
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'user';
|
|
15
|
+
isMut: true;
|
|
16
|
+
isSigner: false;
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'userStats';
|
|
20
|
+
isMut: true;
|
|
21
|
+
isSigner: false;
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'taker';
|
|
25
|
+
isMut: true;
|
|
26
|
+
isSigner: false;
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'takerStats';
|
|
30
|
+
isMut: true;
|
|
31
|
+
isSigner: false;
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'authority';
|
|
35
|
+
isMut: false;
|
|
36
|
+
isSigner: true;
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'driftProgram';
|
|
40
|
+
isMut: false;
|
|
41
|
+
isSigner: false;
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
args: [
|
|
45
|
+
{
|
|
46
|
+
name: 'params';
|
|
47
|
+
type: {
|
|
48
|
+
defined: 'JitParams';
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
types: [
|
|
55
|
+
{
|
|
56
|
+
name: 'JitParams';
|
|
57
|
+
type: {
|
|
58
|
+
kind: 'struct';
|
|
59
|
+
fields: [
|
|
60
|
+
{
|
|
61
|
+
name: 'takerOrderId';
|
|
62
|
+
type: 'u32';
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'maxPosition';
|
|
66
|
+
type: 'i64';
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'worstPrice';
|
|
70
|
+
type: 'u64';
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'postOnly';
|
|
74
|
+
type: {
|
|
75
|
+
option: {
|
|
76
|
+
defined: 'PostOnlyParam';
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'PostOnlyParam';
|
|
85
|
+
type: {
|
|
86
|
+
kind: 'enum';
|
|
87
|
+
variants: [
|
|
88
|
+
{
|
|
89
|
+
name: 'None';
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'MustPostOnly';
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'TryPostOnly';
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
errors: [
|
|
102
|
+
{
|
|
103
|
+
code: 6000;
|
|
104
|
+
name: 'WorstPriceExceeded';
|
|
105
|
+
msg: 'WorstPriceExceeded';
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
code: 6001;
|
|
109
|
+
name: 'TakerOrderNotFound';
|
|
110
|
+
msg: 'TakerOrderNotFound';
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
};
|
|
114
|
+
export declare const IDL: JitProxy;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IDL = void 0;
|
|
4
|
+
exports.IDL = {
|
|
5
|
+
version: '0.1.0',
|
|
6
|
+
name: 'jit_proxy',
|
|
7
|
+
instructions: [
|
|
8
|
+
{
|
|
9
|
+
name: 'jit',
|
|
10
|
+
accounts: [
|
|
11
|
+
{
|
|
12
|
+
name: 'state',
|
|
13
|
+
isMut: false,
|
|
14
|
+
isSigner: false,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'user',
|
|
18
|
+
isMut: true,
|
|
19
|
+
isSigner: false,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: 'userStats',
|
|
23
|
+
isMut: true,
|
|
24
|
+
isSigner: false,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'taker',
|
|
28
|
+
isMut: true,
|
|
29
|
+
isSigner: false,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'takerStats',
|
|
33
|
+
isMut: true,
|
|
34
|
+
isSigner: false,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'authority',
|
|
38
|
+
isMut: false,
|
|
39
|
+
isSigner: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'driftProgram',
|
|
43
|
+
isMut: false,
|
|
44
|
+
isSigner: false,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
args: [
|
|
48
|
+
{
|
|
49
|
+
name: 'params',
|
|
50
|
+
type: {
|
|
51
|
+
defined: 'JitParams',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
types: [
|
|
58
|
+
{
|
|
59
|
+
name: 'JitParams',
|
|
60
|
+
type: {
|
|
61
|
+
kind: 'struct',
|
|
62
|
+
fields: [
|
|
63
|
+
{
|
|
64
|
+
name: 'takerOrderId',
|
|
65
|
+
type: 'u32',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'maxPosition',
|
|
69
|
+
type: 'i64',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'worstPrice',
|
|
73
|
+
type: 'u64',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'postOnly',
|
|
77
|
+
type: {
|
|
78
|
+
option: {
|
|
79
|
+
defined: 'PostOnlyParam',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'PostOnlyParam',
|
|
88
|
+
type: {
|
|
89
|
+
kind: 'enum',
|
|
90
|
+
variants: [
|
|
91
|
+
{
|
|
92
|
+
name: 'None',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'MustPostOnly',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'TryPostOnly',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
errors: [
|
|
105
|
+
{
|
|
106
|
+
code: 6000,
|
|
107
|
+
name: 'WorstPriceExceeded',
|
|
108
|
+
msg: 'WorstPriceExceeded',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
code: 6001,
|
|
112
|
+
name: 'TakerOrderNotFound',
|
|
113
|
+
msg: 'TakerOrderNotFound',
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
package/package.json
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./types/jit_proxy"), exports);
|
|
14
|
+
__exportStar(require("./jitProxyClient"), exports);
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BN,
|
|
3
|
+
DriftClient,
|
|
4
|
+
isVariant,
|
|
5
|
+
PostOnlyParams,
|
|
6
|
+
QUOTE_SPOT_MARKET_INDEX,
|
|
7
|
+
TxParams,
|
|
8
|
+
UserAccount,
|
|
9
|
+
} from '@drift-labs/sdk';
|
|
10
|
+
import { IDL, JitProxy } from './types/jit_proxy';
|
|
11
|
+
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
12
|
+
import { Program } from '@coral-xyz/anchor';
|
|
13
|
+
import { TxSigAndSlot } from '@drift-labs/sdk/lib/tx/types';
|
|
14
|
+
|
|
15
|
+
export type JitIxParams = {
|
|
16
|
+
takerKey: PublicKey;
|
|
17
|
+
takerStatsKey: PublicKey;
|
|
18
|
+
taker: UserAccount;
|
|
19
|
+
takerOrderId: number;
|
|
20
|
+
maxPosition: BN;
|
|
21
|
+
worstPrice: BN;
|
|
22
|
+
postOnly: PostOnlyParams | null;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export class JitProxyClient {
|
|
26
|
+
private driftClient: DriftClient;
|
|
27
|
+
private program: Program<JitProxy>;
|
|
28
|
+
|
|
29
|
+
constructor({
|
|
30
|
+
driftClient,
|
|
31
|
+
programId,
|
|
32
|
+
}: {
|
|
33
|
+
driftClient: DriftClient;
|
|
34
|
+
programId: PublicKey;
|
|
35
|
+
}) {
|
|
36
|
+
this.driftClient = driftClient;
|
|
37
|
+
this.program = new Program(IDL, programId, driftClient.provider);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public async jit(
|
|
41
|
+
params: JitIxParams,
|
|
42
|
+
txParams?: TxParams
|
|
43
|
+
): Promise<TxSigAndSlot> {
|
|
44
|
+
const ix = await this.getJitIx(params);
|
|
45
|
+
const tx = await this.driftClient.buildTransaction([ix], txParams);
|
|
46
|
+
return await this.driftClient.sendTransaction(tx);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public async getJitIx({
|
|
50
|
+
takerKey,
|
|
51
|
+
takerStatsKey,
|
|
52
|
+
taker,
|
|
53
|
+
takerOrderId,
|
|
54
|
+
maxPosition,
|
|
55
|
+
worstPrice,
|
|
56
|
+
postOnly = null,
|
|
57
|
+
}: JitIxParams): Promise<TransactionInstruction> {
|
|
58
|
+
const order = taker.orders.find((order) => order.orderId === takerOrderId);
|
|
59
|
+
const remainingAccounts = this.driftClient.getRemainingAccounts({
|
|
60
|
+
userAccounts: [taker, this.driftClient.getUserAccount()],
|
|
61
|
+
writableSpotMarketIndexes: isVariant(order.marketType, 'spot')
|
|
62
|
+
? [order.marketIndex, QUOTE_SPOT_MARKET_INDEX]
|
|
63
|
+
: [],
|
|
64
|
+
writablePerpMarketIndexes: isVariant(order.marketType, 'perp')
|
|
65
|
+
? [order.marketIndex]
|
|
66
|
+
: [],
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const jitParams = {
|
|
70
|
+
takerOrderId,
|
|
71
|
+
maxPosition,
|
|
72
|
+
worstPrice,
|
|
73
|
+
postOnly,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return this.program.methods
|
|
77
|
+
.jit(jitParams)
|
|
78
|
+
.accounts({
|
|
79
|
+
taker: takerKey,
|
|
80
|
+
takerStats: takerStatsKey,
|
|
81
|
+
state: await this.driftClient.getStatePublicKey(),
|
|
82
|
+
user: await this.driftClient.getUserAccountPublicKey(),
|
|
83
|
+
userStats: this.driftClient.getUserStatsAccountPublicKey(),
|
|
84
|
+
driftProgram: this.driftClient.program.programId,
|
|
85
|
+
})
|
|
86
|
+
.remainingAccounts(remainingAccounts)
|
|
87
|
+
.instruction();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IDL = void 0;
|
|
4
|
+
exports.IDL = {
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"name": "jit_proxy",
|
|
7
|
+
"instructions": [
|
|
8
|
+
{
|
|
9
|
+
"name": "jit",
|
|
10
|
+
"accounts": [
|
|
11
|
+
{
|
|
12
|
+
"name": "state",
|
|
13
|
+
"isMut": false,
|
|
14
|
+
"isSigner": false
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "user",
|
|
18
|
+
"isMut": true,
|
|
19
|
+
"isSigner": false
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "userStats",
|
|
23
|
+
"isMut": true,
|
|
24
|
+
"isSigner": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "taker",
|
|
28
|
+
"isMut": true,
|
|
29
|
+
"isSigner": false
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "takerStats",
|
|
33
|
+
"isMut": true,
|
|
34
|
+
"isSigner": false
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "authority",
|
|
38
|
+
"isMut": false,
|
|
39
|
+
"isSigner": true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "driftProgram",
|
|
43
|
+
"isMut": false,
|
|
44
|
+
"isSigner": false
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"args": [
|
|
48
|
+
{
|
|
49
|
+
"name": "params",
|
|
50
|
+
"type": {
|
|
51
|
+
"defined": "JitParams"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
],
|
|
57
|
+
"types": [
|
|
58
|
+
{
|
|
59
|
+
"name": "JitParams",
|
|
60
|
+
"type": {
|
|
61
|
+
"kind": "struct",
|
|
62
|
+
"fields": [
|
|
63
|
+
{
|
|
64
|
+
"name": "takerOrderId",
|
|
65
|
+
"type": "u32"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"name": "maxPosition",
|
|
69
|
+
"type": "i64"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "worstPrice",
|
|
73
|
+
"type": "u64"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"name": "postOnly",
|
|
77
|
+
"type": {
|
|
78
|
+
"option": {
|
|
79
|
+
"defined": "PostOnlyParam"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "PostOnlyParam",
|
|
88
|
+
"type": {
|
|
89
|
+
"kind": "enum",
|
|
90
|
+
"variants": [
|
|
91
|
+
{
|
|
92
|
+
"name": "None"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "MustPostOnly"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "TryPostOnly"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"errors": [
|
|
105
|
+
{
|
|
106
|
+
"code": 6000,
|
|
107
|
+
"name": "WorstPriceExceeded",
|
|
108
|
+
"msg": "WorstPriceExceeded"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"code": 6001,
|
|
112
|
+
"name": "TakerOrderNotFound",
|
|
113
|
+
"msg": "TakerOrderNotFound"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
};
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
export type JitProxy = {
|
|
2
|
+
version: '0.1.0';
|
|
3
|
+
name: 'jit_proxy';
|
|
4
|
+
instructions: [
|
|
5
|
+
{
|
|
6
|
+
name: 'jit';
|
|
7
|
+
accounts: [
|
|
8
|
+
{
|
|
9
|
+
name: 'state';
|
|
10
|
+
isMut: false;
|
|
11
|
+
isSigner: false;
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: 'user';
|
|
15
|
+
isMut: true;
|
|
16
|
+
isSigner: false;
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'userStats';
|
|
20
|
+
isMut: true;
|
|
21
|
+
isSigner: false;
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'taker';
|
|
25
|
+
isMut: true;
|
|
26
|
+
isSigner: false;
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'takerStats';
|
|
30
|
+
isMut: true;
|
|
31
|
+
isSigner: false;
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'authority';
|
|
35
|
+
isMut: false;
|
|
36
|
+
isSigner: true;
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'driftProgram';
|
|
40
|
+
isMut: false;
|
|
41
|
+
isSigner: false;
|
|
42
|
+
}
|
|
43
|
+
];
|
|
44
|
+
args: [
|
|
45
|
+
{
|
|
46
|
+
name: 'params';
|
|
47
|
+
type: {
|
|
48
|
+
defined: 'JitParams';
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
types: [
|
|
55
|
+
{
|
|
56
|
+
name: 'JitParams';
|
|
57
|
+
type: {
|
|
58
|
+
kind: 'struct';
|
|
59
|
+
fields: [
|
|
60
|
+
{
|
|
61
|
+
name: 'takerOrderId';
|
|
62
|
+
type: 'u32';
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'maxPosition';
|
|
66
|
+
type: 'i64';
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'worstPrice';
|
|
70
|
+
type: 'u64';
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'postOnly';
|
|
74
|
+
type: {
|
|
75
|
+
option: {
|
|
76
|
+
defined: 'PostOnlyParam';
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: 'PostOnlyParam';
|
|
85
|
+
type: {
|
|
86
|
+
kind: 'enum';
|
|
87
|
+
variants: [
|
|
88
|
+
{
|
|
89
|
+
name: 'None';
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'MustPostOnly';
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'TryPostOnly';
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
errors: [
|
|
102
|
+
{
|
|
103
|
+
code: 6000;
|
|
104
|
+
name: 'WorstPriceExceeded';
|
|
105
|
+
msg: 'WorstPriceExceeded';
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
code: 6001;
|
|
109
|
+
name: 'TakerOrderNotFound';
|
|
110
|
+
msg: 'TakerOrderNotFound';
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const IDL: JitProxy = {
|
|
116
|
+
version: '0.1.0',
|
|
117
|
+
name: 'jit_proxy',
|
|
118
|
+
instructions: [
|
|
119
|
+
{
|
|
120
|
+
name: 'jit',
|
|
121
|
+
accounts: [
|
|
122
|
+
{
|
|
123
|
+
name: 'state',
|
|
124
|
+
isMut: false,
|
|
125
|
+
isSigner: false,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'user',
|
|
129
|
+
isMut: true,
|
|
130
|
+
isSigner: false,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'userStats',
|
|
134
|
+
isMut: true,
|
|
135
|
+
isSigner: false,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'taker',
|
|
139
|
+
isMut: true,
|
|
140
|
+
isSigner: false,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'takerStats',
|
|
144
|
+
isMut: true,
|
|
145
|
+
isSigner: false,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'authority',
|
|
149
|
+
isMut: false,
|
|
150
|
+
isSigner: true,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'driftProgram',
|
|
154
|
+
isMut: false,
|
|
155
|
+
isSigner: false,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
args: [
|
|
159
|
+
{
|
|
160
|
+
name: 'params',
|
|
161
|
+
type: {
|
|
162
|
+
defined: 'JitParams',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
types: [
|
|
169
|
+
{
|
|
170
|
+
name: 'JitParams',
|
|
171
|
+
type: {
|
|
172
|
+
kind: 'struct',
|
|
173
|
+
fields: [
|
|
174
|
+
{
|
|
175
|
+
name: 'takerOrderId',
|
|
176
|
+
type: 'u32',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'maxPosition',
|
|
180
|
+
type: 'i64',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'worstPrice',
|
|
184
|
+
type: 'u64',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: 'postOnly',
|
|
188
|
+
type: {
|
|
189
|
+
option: {
|
|
190
|
+
defined: 'PostOnlyParam',
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'PostOnlyParam',
|
|
199
|
+
type: {
|
|
200
|
+
kind: 'enum',
|
|
201
|
+
variants: [
|
|
202
|
+
{
|
|
203
|
+
name: 'None',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'MustPostOnly',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'TryPostOnly',
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
errors: [
|
|
216
|
+
{
|
|
217
|
+
code: 6000,
|
|
218
|
+
name: 'WorstPriceExceeded',
|
|
219
|
+
msg: 'WorstPriceExceeded',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
code: 6001,
|
|
223
|
+
name: 'TakerOrderNotFound',
|
|
224
|
+
msg: 'TakerOrderNotFound',
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"target": "ES2019",
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"outDir": "./lib",
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"skipLibCheck": true
|
|
10
|
+
},
|
|
11
|
+
"include": ["src"],
|
|
12
|
+
"exclude": ["node_modules", "tests"]
|
|
13
|
+
}
|