@triadxyz/triad-protocol 1.2.5-beta → 1.2.7-beta

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
  /// <reference types="bn.js" />
2
- import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
2
+ import { AnchorProvider, BN, Program, Wallet } from '@coral-xyz/anchor';
3
3
  import { Connection, PublicKey } from '@solana/web3.js';
4
4
  import { TriadProtocol } from './types/triad_protocol';
5
5
  import Trade from './trade';
6
6
  import Stake from './stake';
7
- import { CreateUserArgs, RpcOptions } from './types';
7
+ import { CreateUserArgs, MintTicketArgs, RpcOptions } from './types';
8
8
  export default class TriadProtocolClient {
9
9
  program: Program<TriadProtocol>;
10
10
  provider: AnchorProvider;
@@ -51,21 +51,21 @@ export default class TriadProtocolClient {
51
51
  *
52
52
  */
53
53
  getUserPositionsWithAmount(wallet: PublicKey): Promise<{
54
- ts: import("bn.js");
54
+ ts: BN;
55
55
  bump: number;
56
- totalDeposited: import("bn.js");
57
- totalWithdrawn: import("bn.js");
58
- lpShare: import("bn.js");
56
+ totalDeposited: BN;
57
+ totalWithdrawn: BN;
58
+ lpShare: BN;
59
59
  totalPositions: number;
60
60
  ticker: PublicKey;
61
61
  authority: PublicKey;
62
62
  positions: {
63
- amount: import("bn.js");
64
- entryPrice: import("bn.js");
65
- ts: import("bn.js");
63
+ amount: BN;
64
+ entryPrice: BN;
65
+ ts: BN;
66
66
  isLong: boolean;
67
67
  isOpen: boolean;
68
- pnl: import("bn.js");
68
+ pnl: BN;
69
69
  }[];
70
70
  }[]>;
71
71
  withdrawV1({ wallet, ticker, positionIndex }: {
@@ -73,4 +73,10 @@ export default class TriadProtocolClient {
73
73
  ticker: PublicKey;
74
74
  positionIndex: number;
75
75
  }, options?: RpcOptions): Promise<any>;
76
+ createCollection(args: {
77
+ collectionName: string;
78
+ collectionSymbol: string;
79
+ supply: number;
80
+ }, options?: RpcOptions): Promise<string>;
81
+ mintTicket({ discount, isBoosted, rarity, verifier, nftMint }: MintTicketArgs, options?: RpcOptions): Promise<string>;
76
82
  }
package/dist/index.js CHANGED
@@ -22,6 +22,9 @@ const pda_1 = require("./utils/pda");
22
22
  const stake_1 = __importDefault(require("./stake"));
23
23
  const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
24
24
  const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
25
+ const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
26
+ const constants_1 = require("./utils/constants");
27
+ const convertSecretKeyToKeypair_1 = require("./utils/convertSecretKeyToKeypair");
25
28
  class TriadProtocolClient {
26
29
  constructor(connection, wallet) {
27
30
  this.provider = new anchor_1.AnchorProvider(connection, wallet, {
@@ -150,5 +153,49 @@ class TriadProtocolClient {
150
153
  }), options);
151
154
  });
152
155
  }
156
+ createCollection(args, options) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ const keyPair = web3_js_1.Keypair.generate();
159
+ const ix = yield this.program.methods
160
+ .createCollection({
161
+ supply: new anchor_1.BN(args.supply),
162
+ name: args.collectionName,
163
+ symbol: args.collectionSymbol
164
+ })
165
+ .accounts({
166
+ signer: this.provider.wallet.publicKey,
167
+ coreCollection: keyPair.publicKey
168
+ })
169
+ .instruction();
170
+ return (0, sendVersionedTransaction_1.default)(this.provider, [ix], options, keyPair);
171
+ });
172
+ }
173
+ mintTicket({ discount, isBoosted, rarity, verifier, nftMint }, options) {
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ const asset = web3_js_1.Keypair.generate();
176
+ const userNftAta = (0, pda_1.getTokenATA)(this.provider.wallet.publicKey, nftMint);
177
+ const collectionSymbol = 'PTCKT';
178
+ const [collection] = yield this.program.account.collection.all();
179
+ const ix = yield this.program.methods
180
+ .mintTicket({
181
+ number: new anchor_1.BN(collection.account.minted),
182
+ collectionSymbol,
183
+ discount: new anchor_1.BN(discount),
184
+ isBoosted,
185
+ rarity
186
+ })
187
+ .accounts({
188
+ signer: this.provider.wallet.publicKey,
189
+ asset: asset.publicKey,
190
+ nftMint,
191
+ userNftAta,
192
+ trdMint: constants_1.TRD_MINT,
193
+ verifier: constants_1.VERIFIER,
194
+ coreCollection: constants_1.TICKET_CORE_COLLECTION
195
+ })
196
+ .instruction();
197
+ return (0, sendVersionedTransaction_1.default)(this.provider, [ix], options, asset, [], (0, convertSecretKeyToKeypair_1.convertSecretKeyToKeypair)(verifier));
198
+ });
199
+ }
153
200
  }
154
201
  exports.default = TriadProtocolClient;
@@ -27,11 +27,11 @@ const triadProtocol = new _1.default(connection, wallet);
27
27
  const mint = new web3_js_1.PublicKey('X41iRJUPkKaEvhqWdxqrS5P7M5d8A9oathki5sT47KR');
28
28
  const markets = [
29
29
  {
30
- marketId: 14,
31
- name: 'BTC',
32
- question: 'Will $BTC be above $85k on November 18th?',
33
- startTime: 1731429209,
34
- endTime: 1731812400
30
+ marketId: 16,
31
+ name: 'MIKExJAKE',
32
+ question: 'Jake Paul vs. Mike Tyson: Who wins today?',
33
+ startTime: 1731682800,
34
+ endTime: 1731715200
35
35
  }
36
36
  ];
37
37
  const ordersHypeAndFloopBot = [
@@ -46,7 +46,7 @@ const ordersHypeAndFloopBot = [
46
46
  const updateStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
47
47
  const response = yield triadProtocol.stake.updateStakeVault({
48
48
  wallet: wallet.publicKey,
49
- amount: new anchor_1.BN(10000 * Math.pow(10, 6)),
49
+ amount: new anchor_1.BN(8000 * Math.pow(10, 6)),
50
50
  isLocked: false
51
51
  });
52
52
  console.log(response);
@@ -79,7 +79,6 @@ const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
79
79
  const markets = yield triadProtocol.trade.getAllMarkets();
80
80
  console.log(markets);
81
81
  });
82
- getAllMarkets();
83
82
  const getMarket = () => __awaiter(void 0, void 0, void 0, function* () {
84
83
  const market = yield triadProtocol.trade.getMarketById(12);
85
84
  console.log(market);
@@ -105,7 +104,7 @@ const getOrders = (walletAddress) => __awaiter(void 0, void 0, void 0, function*
105
104
  continue;
106
105
  }
107
106
  orders.push({
108
- marketId: order.marketId,
107
+ marketId: order.marketId.toNumber(),
109
108
  orderId: order.orderId.toNumber(),
110
109
  totalShares: order.totalShares.toString(),
111
110
  amount: order.totalAmount.toString(),
@@ -118,7 +117,6 @@ const getOrders = (walletAddress) => __awaiter(void 0, void 0, void 0, function*
118
117
  console.log(orders);
119
118
  return orders;
120
119
  });
121
- // getOrders(new PublicKey('HjJQdfTHgC3EBX3471w4st8BXbBmtbaMyCAXNgcUb7dq'))
122
120
  const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function* () {
123
121
  const response = yield triadProtocol.program.account.userTrade.all();
124
122
  const allMarkets = yield triadProtocol.trade.getAllMarkets();
@@ -226,6 +224,9 @@ const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function*
226
224
  };
227
225
  for (const market of allMarkets) {
228
226
  let currentMarket = liquidityToRecovery[market.marketId];
227
+ if (!currentMarket) {
228
+ continue;
229
+ }
229
230
  if ('flop' in currentMarket.direction) {
230
231
  let shares = parseFloat(market.flopShares.toString()) / Math.pow(10, 6);
231
232
  currentMarket.medPrice =
@@ -246,6 +247,9 @@ const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function*
246
247
  for (const userTrade of response) {
247
248
  for (const order of userTrade.account.orders) {
248
249
  const market = liquidityToRecovery[order.marketId.toNumber()];
250
+ if (!market) {
251
+ continue;
252
+ }
249
253
  if (Object.keys(order.direction)[0] === Object.keys(market.direction)[0]) {
250
254
  market.openOrders += 1;
251
255
  }
@@ -308,12 +312,7 @@ const mintTokens = () => __awaiter(void 0, void 0, void 0, function* () {
308
312
  console.log(mintTx);
309
313
  });
310
314
  const resolveMarket = () => __awaiter(void 0, void 0, void 0, function* () {
311
- const marketsToResolve = [
312
- { marketId: 10, winningDirection: { hype: {} } },
313
- { marketId: 11, winningDirection: { flop: {} } },
314
- { marketId: 12, winningDirection: { hype: {} } },
315
- { marketId: 13, winningDirection: { hype: {} } }
316
- ];
315
+ const marketsToResolve = [{ marketId: 16, winningDirection: { flop: {} } }];
317
316
  for (const market of marketsToResolve) {
318
317
  const response = yield triadProtocol.trade.resolveMarket({
319
318
  marketId: market.marketId,
@@ -345,7 +344,8 @@ const collectFees = () => __awaiter(void 0, void 0, void 0, function* () {
345
344
  marketId: Number(market.marketId),
346
345
  vault: new web3_js_1.PublicKey('6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq')
347
346
  }, {
348
- microLamports: 70000
347
+ microLamports: 90000,
348
+ skipPreflight: true
349
349
  });
350
350
  console.log(response);
351
351
  }
@@ -355,3 +355,15 @@ const collectFees = () => __awaiter(void 0, void 0, void 0, function* () {
355
355
  }
356
356
  fs_1.default.writeFileSync(`fees-collected.json`, JSON.stringify(currentFees, null, 2));
357
357
  });
358
+ const mintTicket = () => __awaiter(void 0, void 0, void 0, function* () {
359
+ console.log(wallet.publicKey.toBase58());
360
+ const response = yield triadProtocol.mintTicket({
361
+ discount: 0,
362
+ isBoosted: false,
363
+ rarity: { uncommon: {} },
364
+ verifier: '',
365
+ nftMint: new web3_js_1.PublicKey('')
366
+ });
367
+ console.log(response);
368
+ });
369
+ mintTicket();
@@ -396,6 +396,64 @@
396
396
  ],
397
397
  "args": []
398
398
  },
399
+ {
400
+ "name": "create_collection",
401
+ "discriminator": [156, 251, 92, 54, 233, 2, 16, 82],
402
+ "accounts": [
403
+ {
404
+ "name": "signer",
405
+ "writable": true,
406
+ "signer": true
407
+ },
408
+ {
409
+ "name": "core_collection",
410
+ "writable": true,
411
+ "signer": true
412
+ },
413
+ {
414
+ "name": "collection",
415
+ "writable": true,
416
+ "pda": {
417
+ "seeds": [
418
+ {
419
+ "kind": "const",
420
+ "value": [99, 111, 108, 108, 101, 99, 116, 105, 111, 110]
421
+ },
422
+ {
423
+ "kind": "arg",
424
+ "path": "args.symbol"
425
+ }
426
+ ]
427
+ }
428
+ },
429
+ {
430
+ "name": "metaplex_program",
431
+ "address": "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d"
432
+ },
433
+ {
434
+ "name": "token_program",
435
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
436
+ },
437
+ {
438
+ "name": "associated_token_program",
439
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
440
+ },
441
+ {
442
+ "name": "system_program",
443
+ "address": "11111111111111111111111111111111"
444
+ }
445
+ ],
446
+ "args": [
447
+ {
448
+ "name": "args",
449
+ "type": {
450
+ "defined": {
451
+ "name": "CreateCollectionArgs"
452
+ }
453
+ }
454
+ }
455
+ ]
456
+ },
399
457
  {
400
458
  "name": "create_user",
401
459
  "discriminator": [108, 227, 130, 130, 252, 109, 75, 218],
@@ -558,6 +616,129 @@
558
616
  }
559
617
  ]
560
618
  },
619
+ {
620
+ "name": "mint_ticket",
621
+ "discriminator": [159, 167, 223, 60, 138, 6, 23, 29],
622
+ "accounts": [
623
+ {
624
+ "name": "signer",
625
+ "writable": true,
626
+ "signer": true
627
+ },
628
+ {
629
+ "name": "nft",
630
+ "writable": true,
631
+ "pda": {
632
+ "seeds": [
633
+ {
634
+ "kind": "const",
635
+ "value": [110, 102, 116]
636
+ },
637
+ {
638
+ "kind": "arg",
639
+ "path": "args.number"
640
+ }
641
+ ]
642
+ }
643
+ },
644
+ {
645
+ "name": "verifier",
646
+ "writable": true,
647
+ "signer": true
648
+ },
649
+ {
650
+ "name": "asset",
651
+ "writable": true,
652
+ "signer": true
653
+ },
654
+ {
655
+ "name": "nft_mint",
656
+ "writable": true
657
+ },
658
+ {
659
+ "name": "collection",
660
+ "writable": true,
661
+ "pda": {
662
+ "seeds": [
663
+ {
664
+ "kind": "const",
665
+ "value": [99, 111, 108, 108, 101, 99, 116, 105, 111, 110]
666
+ },
667
+ {
668
+ "kind": "arg",
669
+ "path": "args.collection_symbol"
670
+ }
671
+ ]
672
+ }
673
+ },
674
+ {
675
+ "name": "core_collection",
676
+ "writable": true
677
+ },
678
+ {
679
+ "name": "trd_mint",
680
+ "writable": true
681
+ },
682
+ {
683
+ "name": "user_trd_ata",
684
+ "writable": true,
685
+ "pda": {
686
+ "seeds": [
687
+ {
688
+ "kind": "account",
689
+ "path": "signer"
690
+ },
691
+ {
692
+ "kind": "account",
693
+ "path": "token_program"
694
+ },
695
+ {
696
+ "kind": "account",
697
+ "path": "trd_mint"
698
+ }
699
+ ],
700
+ "program": {
701
+ "kind": "const",
702
+ "value": [
703
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
704
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
705
+ 219, 233, 248, 89
706
+ ]
707
+ }
708
+ }
709
+ },
710
+ {
711
+ "name": "user_nft_ata",
712
+ "writable": true
713
+ },
714
+ {
715
+ "name": "metaplex_program",
716
+ "address": "CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d"
717
+ },
718
+ {
719
+ "name": "token_program",
720
+ "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
721
+ },
722
+ {
723
+ "name": "associated_token_program",
724
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
725
+ },
726
+ {
727
+ "name": "system_program",
728
+ "address": "11111111111111111111111111111111"
729
+ }
730
+ ],
731
+ "args": [
732
+ {
733
+ "name": "args",
734
+ "type": {
735
+ "defined": {
736
+ "name": "MintTicketArgs"
737
+ }
738
+ }
739
+ }
740
+ ]
741
+ },
561
742
  {
562
743
  "name": "open_order",
563
744
  "discriminator": [206, 88, 88, 143, 38, 136, 50, 224],
@@ -821,6 +1002,35 @@
821
1002
  }
822
1003
  ]
823
1004
  },
1005
+ {
1006
+ "name": "resolve_market_v1",
1007
+ "discriminator": [67, 202, 40, 49, 111, 136, 234, 183],
1008
+ "accounts": [
1009
+ {
1010
+ "name": "signer",
1011
+ "writable": true,
1012
+ "signer": true
1013
+ },
1014
+ {
1015
+ "name": "market",
1016
+ "writable": true
1017
+ },
1018
+ {
1019
+ "name": "system_program",
1020
+ "address": "11111111111111111111111111111111"
1021
+ }
1022
+ ],
1023
+ "args": [
1024
+ {
1025
+ "name": "winning_direction",
1026
+ "type": {
1027
+ "defined": {
1028
+ "name": "WinningDirection"
1029
+ }
1030
+ }
1031
+ }
1032
+ ]
1033
+ },
824
1034
  {
825
1035
  "name": "settle_order",
826
1036
  "discriminator": [80, 74, 204, 34, 12, 183, 66, 66],
@@ -1327,6 +1537,14 @@
1327
1537
  }
1328
1538
  ],
1329
1539
  "accounts": [
1540
+ {
1541
+ "name": "BaseCollectionV1",
1542
+ "discriminator": [0, 0, 0, 0, 0, 0, 0, 0]
1543
+ },
1544
+ {
1545
+ "name": "Collection",
1546
+ "discriminator": [48, 160, 232, 205, 191, 207, 26, 141]
1547
+ },
1330
1548
  {
1331
1549
  "name": "Market",
1332
1550
  "discriminator": [219, 190, 213, 55, 0, 227, 198, 154]
@@ -1335,6 +1553,10 @@
1335
1553
  "name": "MarketV2",
1336
1554
  "discriminator": [27, 60, 50, 75, 191, 193, 86, 227]
1337
1555
  },
1556
+ {
1557
+ "name": "Nft",
1558
+ "discriminator": [88, 10, 146, 176, 101, 11, 40, 217]
1559
+ },
1338
1560
  {
1339
1561
  "name": "StakeV2",
1340
1562
  "discriminator": [207, 98, 130, 13, 118, 181, 238, 47]
@@ -1478,6 +1700,11 @@
1478
1700
  "code": 6019,
1479
1701
  "name": "ConcurrentTransaction",
1480
1702
  "msg": "Concurrent transaction"
1703
+ },
1704
+ {
1705
+ "code": 6020,
1706
+ "name": "CollectionFull",
1707
+ "msg": "Collection is full"
1481
1708
  }
1482
1709
  ],
1483
1710
  "types": [
@@ -1501,6 +1728,42 @@
1501
1728
  ]
1502
1729
  }
1503
1730
  },
1731
+ {
1732
+ "name": "BaseCollectionV1",
1733
+ "type": {
1734
+ "kind": "struct",
1735
+ "fields": [
1736
+ {
1737
+ "name": "key",
1738
+ "type": {
1739
+ "defined": {
1740
+ "name": "Key"
1741
+ }
1742
+ }
1743
+ },
1744
+ {
1745
+ "name": "update_authority",
1746
+ "type": "pubkey"
1747
+ },
1748
+ {
1749
+ "name": "name",
1750
+ "type": "string"
1751
+ },
1752
+ {
1753
+ "name": "uri",
1754
+ "type": "string"
1755
+ },
1756
+ {
1757
+ "name": "num_minted",
1758
+ "type": "u32"
1759
+ },
1760
+ {
1761
+ "name": "current_size",
1762
+ "type": "u32"
1763
+ }
1764
+ ]
1765
+ }
1766
+ },
1504
1767
  {
1505
1768
  "name": "ClaimStakeRewardsArgs",
1506
1769
  "type": {
@@ -1517,6 +1780,60 @@
1517
1780
  ]
1518
1781
  }
1519
1782
  },
1783
+ {
1784
+ "name": "Collection",
1785
+ "type": {
1786
+ "kind": "struct",
1787
+ "fields": [
1788
+ {
1789
+ "name": "authority",
1790
+ "type": "pubkey"
1791
+ },
1792
+ {
1793
+ "name": "bump",
1794
+ "type": "u8"
1795
+ },
1796
+ {
1797
+ "name": "symbol",
1798
+ "type": "string"
1799
+ },
1800
+ {
1801
+ "name": "minted",
1802
+ "type": "u64"
1803
+ },
1804
+ {
1805
+ "name": "supply",
1806
+ "type": "u64"
1807
+ },
1808
+ {
1809
+ "name": "padding",
1810
+ "type": {
1811
+ "array": ["u8", 64]
1812
+ }
1813
+ }
1814
+ ]
1815
+ }
1816
+ },
1817
+ {
1818
+ "name": "CreateCollectionArgs",
1819
+ "type": {
1820
+ "kind": "struct",
1821
+ "fields": [
1822
+ {
1823
+ "name": "name",
1824
+ "type": "string"
1825
+ },
1826
+ {
1827
+ "name": "symbol",
1828
+ "type": "string"
1829
+ },
1830
+ {
1831
+ "name": "supply",
1832
+ "type": "u64"
1833
+ }
1834
+ ]
1835
+ }
1836
+ },
1520
1837
  {
1521
1838
  "name": "CreateUserArgs",
1522
1839
  "type": {
@@ -1559,6 +1876,32 @@
1559
1876
  ]
1560
1877
  }
1561
1878
  },
1879
+ {
1880
+ "name": "Key",
1881
+ "type": {
1882
+ "kind": "enum",
1883
+ "variants": [
1884
+ {
1885
+ "name": "Uninitialized"
1886
+ },
1887
+ {
1888
+ "name": "AssetV1"
1889
+ },
1890
+ {
1891
+ "name": "HashedAssetV1"
1892
+ },
1893
+ {
1894
+ "name": "PluginHeaderV1"
1895
+ },
1896
+ {
1897
+ "name": "PluginRegistryV1"
1898
+ },
1899
+ {
1900
+ "name": "CollectionV1"
1901
+ }
1902
+ ]
1903
+ }
1904
+ },
1562
1905
  {
1563
1906
  "name": "Market",
1564
1907
  "type": {
@@ -1907,6 +2250,45 @@
1907
2250
  ]
1908
2251
  }
1909
2252
  },
2253
+ {
2254
+ "name": "MintTicketArgs",
2255
+ "type": {
2256
+ "kind": "struct",
2257
+ "fields": [
2258
+ {
2259
+ "name": "collection_symbol",
2260
+ "type": "string"
2261
+ },
2262
+ {
2263
+ "name": "discount",
2264
+ "type": "u64"
2265
+ },
2266
+ {
2267
+ "name": "is_boosted",
2268
+ "type": "bool"
2269
+ },
2270
+ {
2271
+ "name": "number",
2272
+ "type": "u64"
2273
+ },
2274
+ {
2275
+ "name": "rarity",
2276
+ "type": {
2277
+ "defined": {
2278
+ "name": "Rarity"
2279
+ }
2280
+ }
2281
+ }
2282
+ ]
2283
+ }
2284
+ },
2285
+ {
2286
+ "name": "Nft",
2287
+ "type": {
2288
+ "kind": "struct",
2289
+ "fields": []
2290
+ }
2291
+ },
1910
2292
  {
1911
2293
  "name": "OpenOrderArgs",
1912
2294
  "type": {
@@ -2191,6 +2573,32 @@
2191
2573
  ]
2192
2574
  }
2193
2575
  },
2576
+ {
2577
+ "name": "Rarity",
2578
+ "type": {
2579
+ "kind": "enum",
2580
+ "variants": [
2581
+ {
2582
+ "name": "Common"
2583
+ },
2584
+ {
2585
+ "name": "Uncommon"
2586
+ },
2587
+ {
2588
+ "name": "Rare"
2589
+ },
2590
+ {
2591
+ "name": "Epic"
2592
+ },
2593
+ {
2594
+ "name": "Legendary"
2595
+ },
2596
+ {
2597
+ "name": "Mythic"
2598
+ }
2599
+ ]
2600
+ }
2601
+ },
2194
2602
  {
2195
2603
  "name": "ResolvedQuestion",
2196
2604
  "type": {
@@ -8,6 +8,25 @@ export type CreateUserArgs = {
8
8
  name: string;
9
9
  referral?: PublicKey;
10
10
  };
11
+ export type MintTicketArgs = {
12
+ discount: number;
13
+ isBoosted: boolean;
14
+ rarity: {
15
+ common: {};
16
+ } | {
17
+ uncommon: {};
18
+ } | {
19
+ rare: {};
20
+ } | {
21
+ legendary: {};
22
+ } | {
23
+ epic: {};
24
+ } | {
25
+ mythic: {};
26
+ };
27
+ verifier: string;
28
+ nftMint: PublicKey;
29
+ };
11
30
  export type User = {
12
31
  ts: number;
13
32
  authority: string;
@@ -634,6 +634,64 @@ export type TriadProtocol = {
634
634
  ];
635
635
  args: [];
636
636
  },
637
+ {
638
+ name: 'createCollection';
639
+ discriminator: [156, 251, 92, 54, 233, 2, 16, 82];
640
+ accounts: [
641
+ {
642
+ name: 'signer';
643
+ writable: true;
644
+ signer: true;
645
+ },
646
+ {
647
+ name: 'coreCollection';
648
+ writable: true;
649
+ signer: true;
650
+ },
651
+ {
652
+ name: 'collection';
653
+ writable: true;
654
+ pda: {
655
+ seeds: [
656
+ {
657
+ kind: 'const';
658
+ value: [99, 111, 108, 108, 101, 99, 116, 105, 111, 110];
659
+ },
660
+ {
661
+ kind: 'arg';
662
+ path: 'args.symbol';
663
+ }
664
+ ];
665
+ };
666
+ },
667
+ {
668
+ name: 'metaplexProgram';
669
+ address: 'CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d';
670
+ },
671
+ {
672
+ name: 'tokenProgram';
673
+ address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
674
+ },
675
+ {
676
+ name: 'associatedTokenProgram';
677
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
678
+ },
679
+ {
680
+ name: 'systemProgram';
681
+ address: '11111111111111111111111111111111';
682
+ }
683
+ ];
684
+ args: [
685
+ {
686
+ name: 'args';
687
+ type: {
688
+ defined: {
689
+ name: 'createCollectionArgs';
690
+ };
691
+ };
692
+ }
693
+ ];
694
+ },
637
695
  {
638
696
  name: 'createUser';
639
697
  discriminator: [108, 227, 130, 130, 252, 109, 75, 218];
@@ -825,6 +883,158 @@ export type TriadProtocol = {
825
883
  }
826
884
  ];
827
885
  },
886
+ {
887
+ name: 'mintTicket';
888
+ discriminator: [159, 167, 223, 60, 138, 6, 23, 29];
889
+ accounts: [
890
+ {
891
+ name: 'signer';
892
+ writable: true;
893
+ signer: true;
894
+ },
895
+ {
896
+ name: 'nft';
897
+ writable: true;
898
+ pda: {
899
+ seeds: [
900
+ {
901
+ kind: 'const';
902
+ value: [110, 102, 116];
903
+ },
904
+ {
905
+ kind: 'arg';
906
+ path: 'args.number';
907
+ }
908
+ ];
909
+ };
910
+ },
911
+ {
912
+ name: 'verifier';
913
+ writable: true;
914
+ signer: true;
915
+ },
916
+ {
917
+ name: 'asset';
918
+ writable: true;
919
+ signer: true;
920
+ },
921
+ {
922
+ name: 'nftMint';
923
+ writable: true;
924
+ },
925
+ {
926
+ name: 'collection';
927
+ writable: true;
928
+ pda: {
929
+ seeds: [
930
+ {
931
+ kind: 'const';
932
+ value: [99, 111, 108, 108, 101, 99, 116, 105, 111, 110];
933
+ },
934
+ {
935
+ kind: 'arg';
936
+ path: 'args.collection_symbol';
937
+ }
938
+ ];
939
+ };
940
+ },
941
+ {
942
+ name: 'coreCollection';
943
+ writable: true;
944
+ },
945
+ {
946
+ name: 'trdMint';
947
+ writable: true;
948
+ },
949
+ {
950
+ name: 'userTrdAta';
951
+ writable: true;
952
+ pda: {
953
+ seeds: [
954
+ {
955
+ kind: 'account';
956
+ path: 'signer';
957
+ },
958
+ {
959
+ kind: 'account';
960
+ path: 'tokenProgram';
961
+ },
962
+ {
963
+ kind: 'account';
964
+ path: 'trdMint';
965
+ }
966
+ ];
967
+ program: {
968
+ kind: 'const';
969
+ value: [
970
+ 140,
971
+ 151,
972
+ 37,
973
+ 143,
974
+ 78,
975
+ 36,
976
+ 137,
977
+ 241,
978
+ 187,
979
+ 61,
980
+ 16,
981
+ 41,
982
+ 20,
983
+ 142,
984
+ 13,
985
+ 131,
986
+ 11,
987
+ 90,
988
+ 19,
989
+ 153,
990
+ 218,
991
+ 255,
992
+ 16,
993
+ 132,
994
+ 4,
995
+ 142,
996
+ 123,
997
+ 216,
998
+ 219,
999
+ 233,
1000
+ 248,
1001
+ 89
1002
+ ];
1003
+ };
1004
+ };
1005
+ },
1006
+ {
1007
+ name: 'userNftAta';
1008
+ writable: true;
1009
+ },
1010
+ {
1011
+ name: 'metaplexProgram';
1012
+ address: 'CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d';
1013
+ },
1014
+ {
1015
+ name: 'tokenProgram';
1016
+ address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
1017
+ },
1018
+ {
1019
+ name: 'associatedTokenProgram';
1020
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
1021
+ },
1022
+ {
1023
+ name: 'systemProgram';
1024
+ address: '11111111111111111111111111111111';
1025
+ }
1026
+ ];
1027
+ args: [
1028
+ {
1029
+ name: 'args';
1030
+ type: {
1031
+ defined: {
1032
+ name: 'mintTicketArgs';
1033
+ };
1034
+ };
1035
+ }
1036
+ ];
1037
+ },
828
1038
  {
829
1039
  name: 'openOrder';
830
1040
  discriminator: [206, 88, 88, 143, 38, 136, 50, 224];
@@ -1204,6 +1414,35 @@ export type TriadProtocol = {
1204
1414
  }
1205
1415
  ];
1206
1416
  },
1417
+ {
1418
+ name: 'resolveMarketV1';
1419
+ discriminator: [67, 202, 40, 49, 111, 136, 234, 183];
1420
+ accounts: [
1421
+ {
1422
+ name: 'signer';
1423
+ writable: true;
1424
+ signer: true;
1425
+ },
1426
+ {
1427
+ name: 'market';
1428
+ writable: true;
1429
+ },
1430
+ {
1431
+ name: 'systemProgram';
1432
+ address: '11111111111111111111111111111111';
1433
+ }
1434
+ ];
1435
+ args: [
1436
+ {
1437
+ name: 'winningDirection';
1438
+ type: {
1439
+ defined: {
1440
+ name: 'winningDirection';
1441
+ };
1442
+ };
1443
+ }
1444
+ ];
1445
+ },
1207
1446
  {
1208
1447
  name: 'settleOrder';
1209
1448
  discriminator: [80, 74, 204, 34, 12, 183, 66, 66];
@@ -1942,6 +2181,14 @@ export type TriadProtocol = {
1942
2181
  }
1943
2182
  ];
1944
2183
  accounts: [
2184
+ {
2185
+ name: 'baseCollectionV1';
2186
+ discriminator: [0, 0, 0, 0, 0, 0, 0, 0];
2187
+ },
2188
+ {
2189
+ name: 'collection';
2190
+ discriminator: [48, 160, 232, 205, 191, 207, 26, 141];
2191
+ },
1945
2192
  {
1946
2193
  name: 'market';
1947
2194
  discriminator: [219, 190, 213, 55, 0, 227, 198, 154];
@@ -1950,6 +2197,10 @@ export type TriadProtocol = {
1950
2197
  name: 'marketV2';
1951
2198
  discriminator: [27, 60, 50, 75, 191, 193, 86, 227];
1952
2199
  },
2200
+ {
2201
+ name: 'nft';
2202
+ discriminator: [88, 10, 146, 176, 101, 11, 40, 217];
2203
+ },
1953
2204
  {
1954
2205
  name: 'stakeV2';
1955
2206
  discriminator: [207, 98, 130, 13, 118, 181, 238, 47];
@@ -2093,6 +2344,11 @@ export type TriadProtocol = {
2093
2344
  code: 6019;
2094
2345
  name: 'concurrentTransaction';
2095
2346
  msg: 'Concurrent transaction';
2347
+ },
2348
+ {
2349
+ code: 6020;
2350
+ name: 'collectionFull';
2351
+ msg: 'Collection is full';
2096
2352
  }
2097
2353
  ];
2098
2354
  types: [
@@ -2116,6 +2372,42 @@ export type TriadProtocol = {
2116
2372
  ];
2117
2373
  };
2118
2374
  },
2375
+ {
2376
+ name: 'baseCollectionV1';
2377
+ type: {
2378
+ kind: 'struct';
2379
+ fields: [
2380
+ {
2381
+ name: 'key';
2382
+ type: {
2383
+ defined: {
2384
+ name: 'key';
2385
+ };
2386
+ };
2387
+ },
2388
+ {
2389
+ name: 'updateAuthority';
2390
+ type: 'pubkey';
2391
+ },
2392
+ {
2393
+ name: 'name';
2394
+ type: 'string';
2395
+ },
2396
+ {
2397
+ name: 'uri';
2398
+ type: 'string';
2399
+ },
2400
+ {
2401
+ name: 'numMinted';
2402
+ type: 'u32';
2403
+ },
2404
+ {
2405
+ name: 'currentSize';
2406
+ type: 'u32';
2407
+ }
2408
+ ];
2409
+ };
2410
+ },
2119
2411
  {
2120
2412
  name: 'claimStakeRewardsArgs';
2121
2413
  type: {
@@ -2132,6 +2424,60 @@ export type TriadProtocol = {
2132
2424
  ];
2133
2425
  };
2134
2426
  },
2427
+ {
2428
+ name: 'collection';
2429
+ type: {
2430
+ kind: 'struct';
2431
+ fields: [
2432
+ {
2433
+ name: 'authority';
2434
+ type: 'pubkey';
2435
+ },
2436
+ {
2437
+ name: 'bump';
2438
+ type: 'u8';
2439
+ },
2440
+ {
2441
+ name: 'symbol';
2442
+ type: 'string';
2443
+ },
2444
+ {
2445
+ name: 'minted';
2446
+ type: 'u64';
2447
+ },
2448
+ {
2449
+ name: 'supply';
2450
+ type: 'u64';
2451
+ },
2452
+ {
2453
+ name: 'padding';
2454
+ type: {
2455
+ array: ['u8', 64];
2456
+ };
2457
+ }
2458
+ ];
2459
+ };
2460
+ },
2461
+ {
2462
+ name: 'createCollectionArgs';
2463
+ type: {
2464
+ kind: 'struct';
2465
+ fields: [
2466
+ {
2467
+ name: 'name';
2468
+ type: 'string';
2469
+ },
2470
+ {
2471
+ name: 'symbol';
2472
+ type: 'string';
2473
+ },
2474
+ {
2475
+ name: 'supply';
2476
+ type: 'u64';
2477
+ }
2478
+ ];
2479
+ };
2480
+ },
2135
2481
  {
2136
2482
  name: 'createUserArgs';
2137
2483
  type: {
@@ -2174,6 +2520,32 @@ export type TriadProtocol = {
2174
2520
  ];
2175
2521
  };
2176
2522
  },
2523
+ {
2524
+ name: 'key';
2525
+ type: {
2526
+ kind: 'enum';
2527
+ variants: [
2528
+ {
2529
+ name: 'uninitialized';
2530
+ },
2531
+ {
2532
+ name: 'assetV1';
2533
+ },
2534
+ {
2535
+ name: 'hashedAssetV1';
2536
+ },
2537
+ {
2538
+ name: 'pluginHeaderV1';
2539
+ },
2540
+ {
2541
+ name: 'pluginRegistryV1';
2542
+ },
2543
+ {
2544
+ name: 'collectionV1';
2545
+ }
2546
+ ];
2547
+ };
2548
+ },
2177
2549
  {
2178
2550
  name: 'market';
2179
2551
  type: {
@@ -2518,6 +2890,45 @@ export type TriadProtocol = {
2518
2890
  ];
2519
2891
  };
2520
2892
  },
2893
+ {
2894
+ name: 'mintTicketArgs';
2895
+ type: {
2896
+ kind: 'struct';
2897
+ fields: [
2898
+ {
2899
+ name: 'collectionSymbol';
2900
+ type: 'string';
2901
+ },
2902
+ {
2903
+ name: 'discount';
2904
+ type: 'u64';
2905
+ },
2906
+ {
2907
+ name: 'isBoosted';
2908
+ type: 'bool';
2909
+ },
2910
+ {
2911
+ name: 'number';
2912
+ type: 'u64';
2913
+ },
2914
+ {
2915
+ name: 'rarity';
2916
+ type: {
2917
+ defined: {
2918
+ name: 'rarity';
2919
+ };
2920
+ };
2921
+ }
2922
+ ];
2923
+ };
2924
+ },
2925
+ {
2926
+ name: 'nft';
2927
+ type: {
2928
+ kind: 'struct';
2929
+ fields: [];
2930
+ };
2931
+ },
2521
2932
  {
2522
2933
  name: 'openOrderArgs';
2523
2934
  type: {
@@ -2802,6 +3213,32 @@ export type TriadProtocol = {
2802
3213
  ];
2803
3214
  };
2804
3215
  },
3216
+ {
3217
+ name: 'rarity';
3218
+ type: {
3219
+ kind: 'enum';
3220
+ variants: [
3221
+ {
3222
+ name: 'common';
3223
+ },
3224
+ {
3225
+ name: 'uncommon';
3226
+ },
3227
+ {
3228
+ name: 'rare';
3229
+ },
3230
+ {
3231
+ name: 'epic';
3232
+ },
3233
+ {
3234
+ name: 'legendary';
3235
+ },
3236
+ {
3237
+ name: 'mythic';
3238
+ }
3239
+ ];
3240
+ };
3241
+ },
2805
3242
  {
2806
3243
  name: 'resolvedQuestion';
2807
3244
  type: {
@@ -5,3 +5,4 @@ export declare const VERIFIER: PublicKey;
5
5
  export declare const TRD_MINT: PublicKey;
6
6
  export declare const TRIAD_ADMIN: PublicKey;
7
7
  export declare const SOL_MINT: PublicKey;
8
+ export declare const TICKET_CORE_COLLECTION: PublicKey;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = exports.STAKE_VAULT_NAME = void 0;
3
+ exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = exports.STAKE_VAULT_NAME = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  exports.STAKE_VAULT_NAME = 'Triad Share 1';
6
6
  exports.TRD_DECIMALS = 6;
@@ -8,3 +8,4 @@ exports.VERIFIER = new web3_js_1.PublicKey('42n6BHufivUKrb5Bi6tXbMZvM8NHovrDLX1R
8
8
  exports.TRD_MINT = new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV');
9
9
  exports.TRIAD_ADMIN = new web3_js_1.PublicKey('82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR');
10
10
  exports.SOL_MINT = new web3_js_1.PublicKey('So11111111111111111111111111111111111111112');
11
+ exports.TICKET_CORE_COLLECTION = new web3_js_1.PublicKey('BaqopH1VXYUCT6VsojbTibVcd3k5jpGGT6296HFb6fVa');
@@ -18,7 +18,7 @@ const web3_js_1 = require("@solana/web3.js");
18
18
  const jupSwap = ({ connection, wallet, inToken, outToken, amount }) => __awaiter(void 0, void 0, void 0, function* () {
19
19
  var _a;
20
20
  try {
21
- const quoteResponse = yield axios_1.default.get(`https://quote-api.jup.ag/v6/quote?inputMint=${inToken}&outputMint=${outToken}&amount=${amount}&slippageBps=10`);
21
+ const quoteResponse = yield axios_1.default.get(`https://quote-api.jup.ag/v6/quote?inputMint=${inToken}&outputMint=${outToken}&amount=${amount}&slippageBps=100`);
22
22
  const { data: quoteData } = quoteResponse;
23
23
  const swapResponse = yield axios_1.default.post('https://quote-api.jup.ag/v6/swap-instructions', {
24
24
  userPublicKey: wallet,
@@ -3,5 +3,5 @@ import { RpcOptions } from '../types';
3
3
  import { AddressLookupTableAccount } from '@solana/web3.js';
4
4
  import { AnchorProvider } from '@coral-xyz/anchor';
5
5
  import { Keypair } from '@solana/web3.js';
6
- declare const sendVersionedTransaction: (provider: AnchorProvider, ixs: TransactionInstruction[], options?: RpcOptions, payer?: Keypair, addressLookupTableAccounts?: AddressLookupTableAccount[]) => Promise<string>;
6
+ declare const sendVersionedTransaction: (provider: AnchorProvider, ixs: TransactionInstruction[], options?: RpcOptions, payer?: Keypair, addressLookupTableAccounts?: AddressLookupTableAccount[], verifier?: Keypair) => Promise<string>;
7
7
  export default sendVersionedTransaction;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const web3_js_1 = require("@solana/web3.js");
13
- const sendVersionedTransaction = (provider, ixs, options, payer, addressLookupTableAccounts) => __awaiter(void 0, void 0, void 0, function* () {
13
+ const sendVersionedTransaction = (provider, ixs, options, payer, addressLookupTableAccounts, verifier) => __awaiter(void 0, void 0, void 0, function* () {
14
14
  if (options === null || options === void 0 ? void 0 : options.microLamports) {
15
15
  ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
16
16
  microLamports: options.microLamports
@@ -22,10 +22,16 @@ const sendVersionedTransaction = (provider, ixs, options, payer, addressLookupTa
22
22
  recentBlockhash: blockhash,
23
23
  payerKey: provider.publicKey
24
24
  }).compileToV0Message(addressLookupTableAccounts));
25
+ let signers = [];
25
26
  if (payer) {
26
27
  tx.sign([payer]);
28
+ signers.push(payer);
27
29
  }
28
- return provider.sendAndConfirm(tx, payer ? [payer] : [], {
30
+ if (verifier) {
31
+ tx.sign([verifier]);
32
+ signers.push(verifier);
33
+ }
34
+ return provider.sendAndConfirm(tx, signers, {
29
35
  skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
30
36
  commitment: 'confirmed'
31
37
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.2.5-beta",
3
+ "version": "1.2.7-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",