@triadxyz/triad-protocol 0.7.1-beta.devnet → 0.7.3-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.
@@ -36,7 +36,7 @@ const markets = [
36
36
  const ordersHypeAndFloopBot = [
37
37
  {
38
38
  marketId: 0,
39
- amount: 100,
39
+ amount: 1000,
40
40
  direction: {
41
41
  hype: {}
42
42
  },
@@ -47,7 +47,7 @@ const ordersHypeAndFloopBot = [
47
47
  },
48
48
  {
49
49
  marketId: 0,
50
- amount: 300,
50
+ amount: 10000,
51
51
  direction: {
52
52
  flop: {}
53
53
  },
@@ -184,7 +184,6 @@ const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* (
184
184
  });
185
185
  const getOrders = () => __awaiter(void 0, void 0, void 0, function* () {
186
186
  const response = (yield triadProtocol.program.account.userTrade.all()).find((userTrade) => userTrade.account.authority.toBase58() === wallet.publicKey.toBase58());
187
- console.log(response);
188
187
  return response.account.orders.map((order) => order.orderId.toNumber());
189
188
  });
190
189
  const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -210,7 +209,9 @@ const closeOrder = () => __awaiter(void 0, void 0, void 0, function* () {
210
209
  });
211
210
  console.log(response);
212
211
  }
213
- catch (_a) { }
212
+ catch (e) {
213
+ console.log(e);
214
+ }
214
215
  }
215
216
  });
216
217
  const runBot = () => __awaiter(void 0, void 0, void 0, function* () {
package/dist/trade.js CHANGED
@@ -48,6 +48,8 @@ class Trade {
48
48
  */
49
49
  initializeMarket({ marketId, name }, options) {
50
50
  return __awaiter(this, void 0, void 0, function* () {
51
+ const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
52
+ const feeVaultPDA = (0, trade_1.getFeeVaultPDA)(this.program.programId, marketId);
51
53
  const method = this.program.methods
52
54
  .initializeMarket({
53
55
  marketId: new bn_js_1.default(marketId),
@@ -127,10 +129,12 @@ class Trade {
127
129
  closeOrder({ marketId, orderId }, options) {
128
130
  return __awaiter(this, void 0, void 0, function* () {
129
131
  const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
132
+ const userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, this.provider.publicKey);
130
133
  const method = this.program.methods.closeOrder(new bn_js_1.default(orderId)).accounts({
131
134
  signer: this.provider.publicKey,
132
135
  market: marketPDA,
133
- mint: this.mint
136
+ mint: this.mint,
137
+ userTrade: userTradePDA
134
138
  });
135
139
  if (options === null || options === void 0 ? void 0 : options.microLamports) {
136
140
  method.postInstructions([
@@ -1,5 +1,5 @@
1
1
  {
2
- "address": "D6CzYj9FxGa8HeQeF1JYu9hDakEuEeMJkSG2awGPuCXG",
2
+ "address": "4YWv2Ex8WjFGyXmYELD6Xqs1ZsuQujVUzZxbvdvM2tCj",
3
3
  "metadata": {
4
4
  "name": "triad_protocol",
5
5
  "version": "0.1.4",
@@ -353,10 +353,42 @@
353
353
  ]
354
354
  }
355
355
  },
356
+ {
357
+ "name": "fee_ata",
358
+ "writable": true,
359
+ "pda": {
360
+ "seeds": [
361
+ {
362
+ "kind": "account",
363
+ "path": "fee_vault"
364
+ },
365
+ {
366
+ "kind": "account",
367
+ "path": "token_program"
368
+ },
369
+ {
370
+ "kind": "account",
371
+ "path": "mint"
372
+ }
373
+ ],
374
+ "program": {
375
+ "kind": "const",
376
+ "value": [
377
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
378
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
379
+ 219, 233, 248, 89
380
+ ]
381
+ }
382
+ }
383
+ },
356
384
  {
357
385
  "name": "token_program",
358
386
  "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
359
387
  },
388
+ {
389
+ "name": "associated_token_program",
390
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
391
+ },
360
392
  {
361
393
  "name": "system_program",
362
394
  "address": "11111111111111111111111111111111"
@@ -1434,25 +1466,16 @@
1434
1466
  "docs": ["Whether the market is currently active for trading"],
1435
1467
  "type": "bool"
1436
1468
  },
1437
- {
1438
- "name": "is_official",
1439
- "type": "bool"
1440
- },
1441
1469
  {
1442
1470
  "name": "market_price",
1443
1471
  "type": "u64"
1444
1472
  },
1445
1473
  {
1446
- "name": "resolved_questions",
1474
+ "name": "previous_resolved_question",
1447
1475
  "type": {
1448
- "array": [
1449
- {
1450
- "defined": {
1451
- "name": "ResolvedQuestion"
1452
- }
1453
- },
1454
- 4
1455
- ]
1476
+ "defined": {
1477
+ "name": "ResolvedQuestion"
1478
+ }
1456
1479
  }
1457
1480
  },
1458
1481
  {
@@ -1477,13 +1500,13 @@
1477
1500
  "name": "current_question",
1478
1501
  "docs": ["The question or prediction topic for the current week"],
1479
1502
  "type": {
1480
- "array": ["u8", 120]
1503
+ "array": ["u8", 80]
1481
1504
  }
1482
1505
  },
1483
1506
  {
1484
1507
  "name": "padding",
1485
1508
  "type": {
1486
- "array": ["u8", 232]
1509
+ "array": ["u8", 180]
1487
1510
  }
1488
1511
  }
1489
1512
  ]
@@ -1782,7 +1805,7 @@
1782
1805
  "name": "question",
1783
1806
  "docs": ["The question or prediction topic for this week"],
1784
1807
  "type": {
1785
- "array": ["u8", 120]
1808
+ "array": ["u8", 80]
1786
1809
  }
1787
1810
  },
1788
1811
  {
@@ -1831,7 +1854,7 @@
1831
1854
  {
1832
1855
  "name": "padding",
1833
1856
  "type": {
1834
- "array": ["u8", 100]
1857
+ "array": ["u8", 64]
1835
1858
  }
1836
1859
  }
1837
1860
  ]
@@ -21,7 +21,7 @@ export type Market = {
21
21
  isActive: boolean;
22
22
  marketPrice: string;
23
23
  isOfficial: boolean;
24
- resolvedQuestions: ResolvedQuestion[];
24
+ previousResolvedQuestion: ResolvedQuestion;
25
25
  currentQuestionId: string;
26
26
  currentQuestionStart: string;
27
27
  currentQuestionEnd: string;
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/triad_protocol.json`.
6
6
  */
7
7
  export type TriadProtocol = {
8
- address: 'D6CzYj9FxGa8HeQeF1JYu9hDakEuEeMJkSG2awGPuCXG';
8
+ address: '4YWv2Ex8WjFGyXmYELD6Xqs1ZsuQujVUzZxbvdvM2tCj';
9
9
  metadata: {
10
10
  name: 'triadProtocol';
11
11
  version: '0.1.4';
@@ -475,10 +475,71 @@ export type TriadProtocol = {
475
475
  ];
476
476
  };
477
477
  },
478
+ {
479
+ name: 'feeAta';
480
+ writable: true;
481
+ pda: {
482
+ seeds: [
483
+ {
484
+ kind: 'account';
485
+ path: 'feeVault';
486
+ },
487
+ {
488
+ kind: 'account';
489
+ path: 'tokenProgram';
490
+ },
491
+ {
492
+ kind: 'account';
493
+ path: 'mint';
494
+ }
495
+ ];
496
+ program: {
497
+ kind: 'const';
498
+ value: [
499
+ 140,
500
+ 151,
501
+ 37,
502
+ 143,
503
+ 78,
504
+ 36,
505
+ 137,
506
+ 241,
507
+ 187,
508
+ 61,
509
+ 16,
510
+ 41,
511
+ 20,
512
+ 142,
513
+ 13,
514
+ 131,
515
+ 11,
516
+ 90,
517
+ 19,
518
+ 153,
519
+ 218,
520
+ 255,
521
+ 16,
522
+ 132,
523
+ 4,
524
+ 142,
525
+ 123,
526
+ 216,
527
+ 219,
528
+ 233,
529
+ 248,
530
+ 89
531
+ ];
532
+ };
533
+ };
534
+ },
478
535
  {
479
536
  name: 'tokenProgram';
480
537
  address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
481
538
  },
539
+ {
540
+ name: 'associatedTokenProgram';
541
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
542
+ },
482
543
  {
483
544
  name: 'systemProgram';
484
545
  address: '11111111111111111111111111111111';
@@ -1844,25 +1905,16 @@ export type TriadProtocol = {
1844
1905
  docs: ['Whether the market is currently active for trading'];
1845
1906
  type: 'bool';
1846
1907
  },
1847
- {
1848
- name: 'isOfficial';
1849
- type: 'bool';
1850
- },
1851
1908
  {
1852
1909
  name: 'marketPrice';
1853
1910
  type: 'u64';
1854
1911
  },
1855
1912
  {
1856
- name: 'resolvedQuestions';
1913
+ name: 'previousResolvedQuestion';
1857
1914
  type: {
1858
- array: [
1859
- {
1860
- defined: {
1861
- name: 'resolvedQuestion';
1862
- };
1863
- },
1864
- 4
1865
- ];
1915
+ defined: {
1916
+ name: 'resolvedQuestion';
1917
+ };
1866
1918
  };
1867
1919
  },
1868
1920
  {
@@ -1887,13 +1939,13 @@ export type TriadProtocol = {
1887
1939
  name: 'currentQuestion';
1888
1940
  docs: ['The question or prediction topic for the current week'];
1889
1941
  type: {
1890
- array: ['u8', 120];
1942
+ array: ['u8', 80];
1891
1943
  };
1892
1944
  },
1893
1945
  {
1894
1946
  name: 'padding';
1895
1947
  type: {
1896
- array: ['u8', 232];
1948
+ array: ['u8', 180];
1897
1949
  };
1898
1950
  }
1899
1951
  ];
@@ -2192,7 +2244,7 @@ export type TriadProtocol = {
2192
2244
  name: 'question';
2193
2245
  docs: ['The question or prediction topic for this week'];
2194
2246
  type: {
2195
- array: ['u8', 120];
2247
+ array: ['u8', 80];
2196
2248
  };
2197
2249
  },
2198
2250
  {
@@ -2241,7 +2293,7 @@ export type TriadProtocol = {
2241
2293
  {
2242
2294
  name: 'padding';
2243
2295
  type: {
2244
- array: ['u8', 100];
2296
+ array: ['u8', 64];
2245
2297
  };
2246
2298
  }
2247
2299
  ];
@@ -87,7 +87,7 @@ const accountToMarket = (account, address) => {
87
87
  isActive: account.isActive,
88
88
  marketPrice: account.marketPrice.toString(),
89
89
  isOfficial: account.isOfficial,
90
- resolvedQuestions: account.resolvedQuestions.map(accountToResolvedQuestion),
90
+ previousResolvedQuestion: accountToResolvedQuestion(account.previousResolvedQuestion),
91
91
  currentQuestionId: account.currentQuestionId.toString(),
92
92
  currentQuestionStart: account.currentQuestionStart.toString(),
93
93
  currentQuestionEnd: account.currentQuestionEnd.toString(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "0.7.1-beta.devnet",
3
+ "version": "0.7.3-beta.devnet",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",