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