@triadxyz/triad-protocol 0.1.0-alpha.2

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.
@@ -0,0 +1,629 @@
1
+ export type TriadProtocol = {
2
+ version: '0.1.0';
3
+ name: 'triad_protocol';
4
+ instructions: [
5
+ {
6
+ name: 'createUser';
7
+ accounts: [
8
+ {
9
+ name: 'signer';
10
+ isMut: true;
11
+ isSigner: true;
12
+ },
13
+ {
14
+ name: 'user';
15
+ isMut: true;
16
+ isSigner: false;
17
+ },
18
+ {
19
+ name: 'systemProgram';
20
+ isMut: false;
21
+ isSigner: false;
22
+ }
23
+ ];
24
+ args: [
25
+ {
26
+ name: 'arg';
27
+ type: {
28
+ defined: 'CreateUserArgs';
29
+ };
30
+ }
31
+ ];
32
+ },
33
+ {
34
+ name: 'createTicker';
35
+ accounts: [
36
+ {
37
+ name: 'signer';
38
+ isMut: true;
39
+ isSigner: true;
40
+ },
41
+ {
42
+ name: 'vault';
43
+ isMut: true;
44
+ isSigner: false;
45
+ },
46
+ {
47
+ name: 'ticker';
48
+ isMut: true;
49
+ isSigner: false;
50
+ },
51
+ {
52
+ name: 'systemProgram';
53
+ isMut: false;
54
+ isSigner: false;
55
+ }
56
+ ];
57
+ args: [
58
+ {
59
+ name: 'arg';
60
+ type: {
61
+ defined: 'CreateTickerArgs';
62
+ };
63
+ }
64
+ ];
65
+ },
66
+ {
67
+ name: 'updateTickerPrice';
68
+ accounts: [
69
+ {
70
+ name: 'signer';
71
+ isMut: true;
72
+ isSigner: true;
73
+ },
74
+ {
75
+ name: 'ticker';
76
+ isMut: true;
77
+ isSigner: false;
78
+ },
79
+ {
80
+ name: 'systemProgram';
81
+ isMut: false;
82
+ isSigner: false;
83
+ }
84
+ ];
85
+ args: [
86
+ {
87
+ name: 'args';
88
+ type: {
89
+ defined: 'UpdateTickerPriceArgs';
90
+ };
91
+ }
92
+ ];
93
+ },
94
+ {
95
+ name: 'createVault';
96
+ accounts: [
97
+ {
98
+ name: 'signer';
99
+ isMut: true;
100
+ isSigner: true;
101
+ },
102
+ {
103
+ name: 'ticker';
104
+ isMut: true;
105
+ isSigner: false;
106
+ },
107
+ {
108
+ name: 'vault';
109
+ isMut: true;
110
+ isSigner: false;
111
+ },
112
+ {
113
+ name: 'payerTokenMint';
114
+ isMut: false;
115
+ isSigner: false;
116
+ },
117
+ {
118
+ name: 'tokenAccount';
119
+ isMut: true;
120
+ isSigner: false;
121
+ },
122
+ {
123
+ name: 'systemProgram';
124
+ isMut: false;
125
+ isSigner: false;
126
+ },
127
+ {
128
+ name: 'tokenProgram';
129
+ isMut: false;
130
+ isSigner: false;
131
+ }
132
+ ];
133
+ args: [];
134
+ },
135
+ {
136
+ name: 'openPosition';
137
+ accounts: [
138
+ {
139
+ name: 'signer';
140
+ isMut: true;
141
+ isSigner: true;
142
+ },
143
+ {
144
+ name: 'ticker';
145
+ isMut: true;
146
+ isSigner: false;
147
+ },
148
+ {
149
+ name: 'vault';
150
+ isMut: true;
151
+ isSigner: false;
152
+ },
153
+ {
154
+ name: 'user';
155
+ isMut: true;
156
+ isSigner: false;
157
+ },
158
+ {
159
+ name: 'vaultTokenAccount';
160
+ isMut: true;
161
+ isSigner: false;
162
+ },
163
+ {
164
+ name: 'userTokenAccount';
165
+ isMut: true;
166
+ isSigner: false;
167
+ },
168
+ {
169
+ name: 'systemProgram';
170
+ isMut: false;
171
+ isSigner: false;
172
+ },
173
+ {
174
+ name: 'tokenProgram';
175
+ isMut: false;
176
+ isSigner: false;
177
+ }
178
+ ];
179
+ args: [
180
+ {
181
+ name: 'args';
182
+ type: {
183
+ defined: 'OpenPositionArgs';
184
+ };
185
+ }
186
+ ];
187
+ },
188
+ {
189
+ name: 'closePosition';
190
+ accounts: [
191
+ {
192
+ name: 'signer';
193
+ isMut: true;
194
+ isSigner: true;
195
+ },
196
+ {
197
+ name: 'vault';
198
+ isMut: true;
199
+ isSigner: false;
200
+ },
201
+ {
202
+ name: 'user';
203
+ isMut: true;
204
+ isSigner: false;
205
+ },
206
+ {
207
+ name: 'vaultTokenAccount';
208
+ isMut: true;
209
+ isSigner: false;
210
+ },
211
+ {
212
+ name: 'userTokenAccount';
213
+ isMut: true;
214
+ isSigner: false;
215
+ },
216
+ {
217
+ name: 'systemProgram';
218
+ isMut: false;
219
+ isSigner: false;
220
+ },
221
+ {
222
+ name: 'tokenProgram';
223
+ isMut: false;
224
+ isSigner: false;
225
+ }
226
+ ];
227
+ args: [
228
+ {
229
+ name: 'args';
230
+ type: {
231
+ defined: 'ClosePositionArgs';
232
+ };
233
+ }
234
+ ];
235
+ }
236
+ ];
237
+ accounts: [
238
+ {
239
+ name: 'ticker';
240
+ type: {
241
+ kind: 'struct';
242
+ fields: [
243
+ {
244
+ name: 'initTs';
245
+ docs: ['timestamp of the creation of the ticker'];
246
+ type: 'i64';
247
+ },
248
+ {
249
+ name: 'updatedTs';
250
+ docs: ['timestamp of the last update of the ticker'];
251
+ type: 'i64';
252
+ },
253
+ {
254
+ name: 'bump';
255
+ docs: ['The bump for the ticker pda'];
256
+ type: 'u8';
257
+ },
258
+ {
259
+ name: 'authority';
260
+ docs: ['authority for the ticker'];
261
+ type: 'publicKey';
262
+ },
263
+ {
264
+ name: 'name';
265
+ docs: ['name of the ticekt'];
266
+ type: 'string';
267
+ },
268
+ {
269
+ name: 'protocolProgramId';
270
+ docs: [
271
+ 'protocol program id like dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH to get data info'
272
+ ];
273
+ type: 'publicKey';
274
+ },
275
+ {
276
+ name: 'price';
277
+ docs: ['ticker price'];
278
+ type: 'u64';
279
+ },
280
+ {
281
+ name: 'vault';
282
+ docs: ['Vault PDA'];
283
+ type: 'publicKey';
284
+ }
285
+ ];
286
+ };
287
+ },
288
+ {
289
+ name: 'user';
290
+ type: {
291
+ kind: 'struct';
292
+ fields: [
293
+ {
294
+ name: 'ts';
295
+ docs: ['timestamp'];
296
+ type: 'i64';
297
+ },
298
+ {
299
+ name: 'name';
300
+ docs: ["user's name"];
301
+ type: 'string';
302
+ },
303
+ {
304
+ name: 'bump';
305
+ docs: ['bump seed'];
306
+ type: 'u8';
307
+ },
308
+ {
309
+ name: 'authority';
310
+ docs: ["user's authority"];
311
+ type: 'publicKey';
312
+ },
313
+ {
314
+ name: 'referrer';
315
+ docs: ['referrer of the user'];
316
+ type: 'string';
317
+ },
318
+ {
319
+ name: 'community';
320
+ docs: ['community the user is part of'];
321
+ type: 'string';
322
+ },
323
+ {
324
+ name: 'netDeposits';
325
+ docs: ['lifetime net deposits of user'];
326
+ type: 'i64';
327
+ },
328
+ {
329
+ name: 'netWithdraws';
330
+ docs: ['lifetime net withdraws of user'];
331
+ type: 'i64';
332
+ },
333
+ {
334
+ name: 'totalDeposits';
335
+ docs: ['lifetime total deposits'];
336
+ type: 'u64';
337
+ },
338
+ {
339
+ name: 'totalWithdraws';
340
+ docs: ['lifetime total withdraws'];
341
+ type: 'u64';
342
+ },
343
+ {
344
+ name: 'lpShares';
345
+ docs: ['total available balance'];
346
+ type: 'u64';
347
+ }
348
+ ];
349
+ };
350
+ },
351
+ {
352
+ name: 'vault';
353
+ type: {
354
+ kind: 'struct';
355
+ fields: [
356
+ {
357
+ name: 'bump';
358
+ docs: ['The bump for the vault pda'];
359
+ type: 'u8';
360
+ },
361
+ {
362
+ name: 'authority';
363
+ docs: ['authority for the vault'];
364
+ type: 'publicKey';
365
+ },
366
+ {
367
+ name: 'name';
368
+ docs: ['name of the vault'];
369
+ type: 'string';
370
+ },
371
+ {
372
+ name: 'tokenAccount';
373
+ docs: ['token account for the vault e.g. tDRIFT'];
374
+ type: 'publicKey';
375
+ },
376
+ {
377
+ name: 'tickerAddress';
378
+ docs: ['ticker address'];
379
+ type: 'publicKey';
380
+ },
381
+ {
382
+ name: 'totalDeposits';
383
+ docs: ['lifetime total deposits'];
384
+ type: 'u64';
385
+ },
386
+ {
387
+ name: 'totalWithdraws';
388
+ docs: ['lifetime total withdraws'];
389
+ type: 'u64';
390
+ },
391
+ {
392
+ name: 'initTs';
393
+ docs: ['timestamp vault initialized'];
394
+ type: 'i64';
395
+ },
396
+ {
397
+ name: 'netDeposits';
398
+ docs: ['lifetime net deposits'];
399
+ type: 'u64';
400
+ },
401
+ {
402
+ name: 'netWithdraws';
403
+ docs: ['lifetime net withdraws'];
404
+ type: 'u64';
405
+ },
406
+ {
407
+ name: 'longBalance';
408
+ docs: ['Long bet balance'];
409
+ type: 'u64';
410
+ },
411
+ {
412
+ name: 'shortBalance';
413
+ docs: ['Short bet balance'];
414
+ type: 'u64';
415
+ },
416
+ {
417
+ name: 'longPositionsOpened';
418
+ docs: ['Opened long positions'];
419
+ type: 'u64';
420
+ },
421
+ {
422
+ name: 'shortPositionsOpened';
423
+ docs: ['Opened short positions'];
424
+ type: 'u64';
425
+ },
426
+ {
427
+ name: 'ticker';
428
+ docs: ['Ticker PDA'];
429
+ type: 'publicKey';
430
+ }
431
+ ];
432
+ };
433
+ }
434
+ ];
435
+ types: [
436
+ {
437
+ name: 'CreateTickerArgs';
438
+ type: {
439
+ kind: 'struct';
440
+ fields: [
441
+ {
442
+ name: 'name';
443
+ type: 'string';
444
+ },
445
+ {
446
+ name: 'protocolProgramId';
447
+ type: 'publicKey';
448
+ }
449
+ ];
450
+ };
451
+ },
452
+ {
453
+ name: 'UpdateTickerPriceArgs';
454
+ type: {
455
+ kind: 'struct';
456
+ fields: [
457
+ {
458
+ name: 'alphaApiKey';
459
+ type: {
460
+ array: ['u8', 64];
461
+ };
462
+ },
463
+ {
464
+ name: 'price';
465
+ type: 'u64';
466
+ }
467
+ ];
468
+ };
469
+ },
470
+ {
471
+ name: 'Position';
472
+ type: {
473
+ kind: 'struct';
474
+ fields: [
475
+ {
476
+ name: 'pubkey';
477
+ type: 'publicKey';
478
+ },
479
+ {
480
+ name: 'ticker';
481
+ type: 'publicKey';
482
+ },
483
+ {
484
+ name: 'amount';
485
+ type: 'u64';
486
+ },
487
+ {
488
+ name: 'leverage';
489
+ type: 'u64';
490
+ },
491
+ {
492
+ name: 'entryPrice';
493
+ type: 'u64';
494
+ },
495
+ {
496
+ name: 'ts';
497
+ type: 'i64';
498
+ },
499
+ {
500
+ name: 'isLong';
501
+ type: 'bool';
502
+ },
503
+ {
504
+ name: 'isOpen';
505
+ type: 'bool';
506
+ },
507
+ {
508
+ name: 'pnl';
509
+ type: 'i64';
510
+ }
511
+ ];
512
+ };
513
+ },
514
+ {
515
+ name: 'CreateUserArgs';
516
+ type: {
517
+ kind: 'struct';
518
+ fields: [
519
+ {
520
+ name: 'name';
521
+ type: 'string';
522
+ },
523
+ {
524
+ name: 'referrer';
525
+ type: 'string';
526
+ },
527
+ {
528
+ name: 'community';
529
+ type: 'string';
530
+ }
531
+ ];
532
+ };
533
+ },
534
+ {
535
+ name: 'OpenPositionArgs';
536
+ type: {
537
+ kind: 'struct';
538
+ fields: [
539
+ {
540
+ name: 'amount';
541
+ type: 'u64';
542
+ },
543
+ {
544
+ name: 'isLong';
545
+ type: 'bool';
546
+ }
547
+ ];
548
+ };
549
+ },
550
+ {
551
+ name: 'ClosePositionArgs';
552
+ type: {
553
+ kind: 'struct';
554
+ fields: [
555
+ {
556
+ name: 'amount';
557
+ type: 'u64';
558
+ },
559
+ {
560
+ name: 'isLong';
561
+ type: 'bool';
562
+ },
563
+ {
564
+ name: 'pubkey';
565
+ type: 'publicKey';
566
+ }
567
+ ];
568
+ };
569
+ }
570
+ ];
571
+ errors: [
572
+ {
573
+ code: 6000;
574
+ name: 'UnauthorizedToDeleteProject';
575
+ msg: 'Unauthorized to delete the project';
576
+ },
577
+ {
578
+ code: 6001;
579
+ name: 'InvalidShadowAccount';
580
+ msg: 'Invalid shadow account';
581
+ },
582
+ {
583
+ code: 6002;
584
+ name: 'InvalidAccount';
585
+ msg: 'Invalid account';
586
+ },
587
+ {
588
+ code: 6003;
589
+ name: 'Unauthorized';
590
+ msg: 'Unauthorized access';
591
+ },
592
+ {
593
+ code: 6004;
594
+ name: 'AlphaVantageApiError';
595
+ msg: 'Failed to get data from Vybe Network';
596
+ },
597
+ {
598
+ code: 6005;
599
+ name: 'DepositFailed';
600
+ msg: 'Failed to deposit';
601
+ },
602
+ {
603
+ code: 6006;
604
+ name: 'InvalidOwnerAuthority';
605
+ msg: 'Invalid Owner authority';
606
+ },
607
+ {
608
+ code: 6007;
609
+ name: 'InvalidMintAddress';
610
+ msg: 'Invalid Mint address';
611
+ },
612
+ {
613
+ code: 6008;
614
+ name: 'InvalidProfitShare';
615
+ msg: 'Invalid Profit Share';
616
+ },
617
+ {
618
+ code: 6009;
619
+ name: 'InvalidDepositAmount';
620
+ msg: 'Invalid Deposit Amount';
621
+ },
622
+ {
623
+ code: 6010;
624
+ name: 'InvalidWithdrawAmount';
625
+ msg: 'Invalid Withdraw Amount';
626
+ }
627
+ ];
628
+ };
629
+ export declare const IDL: TriadProtocol;