@triadxyz/triad-protocol 0.5.9-beta.devnet → 0.6.0-beta.devnet
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/dist/local-test.js +6 -1
- package/dist/trade.js +3 -5
- package/dist/types/idl_triad_protocol.json +30 -6
- package/dist/types/triad_protocol.d.ts +59 -35
- package/package.json +1 -1
package/dist/local-test.js
CHANGED
|
@@ -17,6 +17,7 @@ const index_1 = __importDefault(require("./index"));
|
|
|
17
17
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
18
18
|
const axios_1 = __importDefault(require("axios"));
|
|
19
19
|
const web3_js_1 = require("@solana/web3.js");
|
|
20
|
+
const helpers_1 = require("./utils/helpers");
|
|
20
21
|
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/id.json');
|
|
21
22
|
const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc-devnet.txt');
|
|
22
23
|
const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
|
|
@@ -76,6 +77,7 @@ const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
const userTradePDA = (0, helpers_1.getUserTradeAddressSync)(triadProtocol.program.programId, wallet.publicKey);
|
|
79
81
|
const response = yield triadProtocol.trade.openOrder(0, {
|
|
80
82
|
amount: 100,
|
|
81
83
|
direction: {
|
|
@@ -84,7 +86,10 @@ const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
84
86
|
orderType: {
|
|
85
87
|
market: {}
|
|
86
88
|
},
|
|
87
|
-
comment: 'test'
|
|
89
|
+
comment: 'test',
|
|
90
|
+
limitPrice: 10
|
|
91
|
+
}, {
|
|
92
|
+
skipPreflight: true
|
|
88
93
|
});
|
|
89
94
|
console.log(response);
|
|
90
95
|
});
|
package/dist/trade.js
CHANGED
|
@@ -114,7 +114,7 @@ class Trade {
|
|
|
114
114
|
const ixs = [];
|
|
115
115
|
try {
|
|
116
116
|
const userTradePDA = (0, helpers_1.getUserTradeAddressSync)(this.program.programId, this.provider.publicKey);
|
|
117
|
-
this.program.account.userTrade.fetch(userTradePDA);
|
|
117
|
+
yield this.program.account.userTrade.fetch(userTradePDA);
|
|
118
118
|
}
|
|
119
119
|
catch (_a) {
|
|
120
120
|
ixs.push(yield this.program.methods
|
|
@@ -129,10 +129,8 @@ class Trade {
|
|
|
129
129
|
amount: new bn_js_1.default(args.amount / Math.pow(10, constants_1.TRD_DECIMALS)),
|
|
130
130
|
direction: args.direction,
|
|
131
131
|
orderType: args.orderType,
|
|
132
|
-
limitPrice: args.limitPrice
|
|
133
|
-
|
|
134
|
-
: undefined,
|
|
135
|
-
comment: args.comment ? (0, helpers_1.encodeString)(args.comment, 64) : undefined
|
|
132
|
+
limitPrice: new bn_js_1.default(args.limitPrice / Math.pow(10, constants_1.TRD_DECIMALS)),
|
|
133
|
+
comment: (0, helpers_1.encodeString)(args.comment, 64)
|
|
136
134
|
})
|
|
137
135
|
.accounts({
|
|
138
136
|
signer: this.provider.publicKey,
|
|
@@ -237,6 +237,34 @@
|
|
|
237
237
|
]
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
|
+
{
|
|
241
|
+
"name": "fee_vault_token_account",
|
|
242
|
+
"writable": true,
|
|
243
|
+
"pda": {
|
|
244
|
+
"seeds": [
|
|
245
|
+
{
|
|
246
|
+
"kind": "account",
|
|
247
|
+
"path": "fee_vault"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"kind": "account",
|
|
251
|
+
"path": "token_program"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
"kind": "account",
|
|
255
|
+
"path": "mint"
|
|
256
|
+
}
|
|
257
|
+
],
|
|
258
|
+
"program": {
|
|
259
|
+
"kind": "const",
|
|
260
|
+
"value": [
|
|
261
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
262
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
263
|
+
219, 233, 248, 89
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
},
|
|
240
268
|
{
|
|
241
269
|
"name": "mint",
|
|
242
270
|
"writable": true
|
|
@@ -408,12 +436,8 @@
|
|
|
408
436
|
"path": "fee_vault"
|
|
409
437
|
},
|
|
410
438
|
{
|
|
411
|
-
"kind": "
|
|
412
|
-
"
|
|
413
|
-
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206,
|
|
414
|
-
235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140,
|
|
415
|
-
245, 133, 126, 255, 0, 169
|
|
416
|
-
]
|
|
439
|
+
"kind": "account",
|
|
440
|
+
"path": "token_program"
|
|
417
441
|
},
|
|
418
442
|
{
|
|
419
443
|
"kind": "account",
|
|
@@ -301,6 +301,63 @@ export type TriadProtocol = {
|
|
|
301
301
|
];
|
|
302
302
|
};
|
|
303
303
|
},
|
|
304
|
+
{
|
|
305
|
+
name: 'feeVaultTokenAccount';
|
|
306
|
+
writable: true;
|
|
307
|
+
pda: {
|
|
308
|
+
seeds: [
|
|
309
|
+
{
|
|
310
|
+
kind: 'account';
|
|
311
|
+
path: 'feeVault';
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
kind: 'account';
|
|
315
|
+
path: 'tokenProgram';
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
kind: 'account';
|
|
319
|
+
path: 'mint';
|
|
320
|
+
}
|
|
321
|
+
];
|
|
322
|
+
program: {
|
|
323
|
+
kind: 'const';
|
|
324
|
+
value: [
|
|
325
|
+
140,
|
|
326
|
+
151,
|
|
327
|
+
37,
|
|
328
|
+
143,
|
|
329
|
+
78,
|
|
330
|
+
36,
|
|
331
|
+
137,
|
|
332
|
+
241,
|
|
333
|
+
187,
|
|
334
|
+
61,
|
|
335
|
+
16,
|
|
336
|
+
41,
|
|
337
|
+
20,
|
|
338
|
+
142,
|
|
339
|
+
13,
|
|
340
|
+
131,
|
|
341
|
+
11,
|
|
342
|
+
90,
|
|
343
|
+
19,
|
|
344
|
+
153,
|
|
345
|
+
218,
|
|
346
|
+
255,
|
|
347
|
+
16,
|
|
348
|
+
132,
|
|
349
|
+
4,
|
|
350
|
+
142,
|
|
351
|
+
123,
|
|
352
|
+
216,
|
|
353
|
+
219,
|
|
354
|
+
233,
|
|
355
|
+
248,
|
|
356
|
+
89
|
|
357
|
+
];
|
|
358
|
+
};
|
|
359
|
+
};
|
|
360
|
+
},
|
|
304
361
|
{
|
|
305
362
|
name: 'mint';
|
|
306
363
|
writable: true;
|
|
@@ -559,41 +616,8 @@ export type TriadProtocol = {
|
|
|
559
616
|
path: 'feeVault';
|
|
560
617
|
},
|
|
561
618
|
{
|
|
562
|
-
kind: '
|
|
563
|
-
|
|
564
|
-
6,
|
|
565
|
-
221,
|
|
566
|
-
246,
|
|
567
|
-
225,
|
|
568
|
-
215,
|
|
569
|
-
101,
|
|
570
|
-
161,
|
|
571
|
-
147,
|
|
572
|
-
217,
|
|
573
|
-
203,
|
|
574
|
-
225,
|
|
575
|
-
70,
|
|
576
|
-
206,
|
|
577
|
-
235,
|
|
578
|
-
121,
|
|
579
|
-
172,
|
|
580
|
-
28,
|
|
581
|
-
180,
|
|
582
|
-
133,
|
|
583
|
-
237,
|
|
584
|
-
95,
|
|
585
|
-
91,
|
|
586
|
-
55,
|
|
587
|
-
145,
|
|
588
|
-
58,
|
|
589
|
-
140,
|
|
590
|
-
245,
|
|
591
|
-
133,
|
|
592
|
-
126,
|
|
593
|
-
255,
|
|
594
|
-
0,
|
|
595
|
-
169
|
|
596
|
-
];
|
|
619
|
+
kind: 'account';
|
|
620
|
+
path: 'tokenProgram';
|
|
597
621
|
},
|
|
598
622
|
{
|
|
599
623
|
kind: 'account';
|