@triadxyz/triad-protocol 0.6.9-beta.devnet → 0.7.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.
@@ -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: '7nGGR51pBSUrpMPYVf9LWnNwaApz7N9VaJfDAJrihXts';
8
+ address: 'D6CzYj9FxGa8HeQeF1JYu9hDakEuEeMJkSG2awGPuCXG';
9
9
  metadata: {
10
10
  name: 'triadProtocol';
11
11
  version: '0.1.4';
@@ -190,18 +190,6 @@ export type TriadProtocol = {
190
190
  {
191
191
  name: 'userTrade';
192
192
  writable: true;
193
- pda: {
194
- seeds: [
195
- {
196
- kind: 'const';
197
- value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
198
- },
199
- {
200
- kind: 'account';
201
- path: 'signer';
202
- }
203
- ];
204
- };
205
193
  },
206
194
  {
207
195
  name: 'market';
@@ -354,11 +342,6 @@ export type TriadProtocol = {
354
342
  writable: true;
355
343
  signer: true;
356
344
  },
357
- {
358
- name: 'payer';
359
- writable: true;
360
- signer: true;
361
- },
362
345
  {
363
346
  name: 'referral';
364
347
  writable: true;
@@ -379,6 +362,22 @@ export type TriadProtocol = {
379
362
  ];
380
363
  };
381
364
  },
365
+ {
366
+ name: 'userTrade';
367
+ writable: true;
368
+ pda: {
369
+ seeds: [
370
+ {
371
+ kind: 'const';
372
+ value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
373
+ },
374
+ {
375
+ kind: 'account';
376
+ path: 'signer';
377
+ }
378
+ ];
379
+ };
380
+ },
382
381
  {
383
382
  name: 'systemProgram';
384
383
  address: '11111111111111111111111111111111';
@@ -404,6 +403,10 @@ export type TriadProtocol = {
404
403
  writable: true;
405
404
  signer: true;
406
405
  },
406
+ {
407
+ name: 'user';
408
+ writable: true;
409
+ },
407
410
  {
408
411
  name: 'userTrade';
409
412
  writable: true;
@@ -452,6 +455,10 @@ export type TriadProtocol = {
452
455
  ];
453
456
  };
454
457
  },
458
+ {
459
+ name: 'mint';
460
+ writable: true;
461
+ },
455
462
  {
456
463
  name: 'feeVault';
457
464
  writable: true;
@@ -462,81 +469,16 @@ export type TriadProtocol = {
462
469
  value: [102, 101, 101, 95, 118, 97, 117, 108, 116];
463
470
  },
464
471
  {
465
- kind: 'account';
466
- path: 'market';
472
+ kind: 'arg';
473
+ path: 'args.market_id';
467
474
  }
468
475
  ];
469
476
  };
470
477
  },
471
- {
472
- name: 'feeVaultAta';
473
- writable: true;
474
- pda: {
475
- seeds: [
476
- {
477
- kind: 'account';
478
- path: 'feeVault';
479
- },
480
- {
481
- kind: 'account';
482
- path: 'tokenProgram';
483
- },
484
- {
485
- kind: 'account';
486
- path: 'mint';
487
- }
488
- ];
489
- program: {
490
- kind: 'const';
491
- value: [
492
- 140,
493
- 151,
494
- 37,
495
- 143,
496
- 78,
497
- 36,
498
- 137,
499
- 241,
500
- 187,
501
- 61,
502
- 16,
503
- 41,
504
- 20,
505
- 142,
506
- 13,
507
- 131,
508
- 11,
509
- 90,
510
- 19,
511
- 153,
512
- 218,
513
- 255,
514
- 16,
515
- 132,
516
- 4,
517
- 142,
518
- 123,
519
- 216,
520
- 219,
521
- 233,
522
- 248,
523
- 89
524
- ];
525
- };
526
- };
527
- },
528
- {
529
- name: 'mint';
530
- writable: true;
531
- },
532
478
  {
533
479
  name: 'tokenProgram';
534
480
  address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
535
481
  },
536
- {
537
- name: 'associatedTokenProgram';
538
- address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
539
- },
540
482
  {
541
483
  name: 'systemProgram';
542
484
  address: '11111111111111111111111111111111';
@@ -565,18 +507,6 @@ export type TriadProtocol = {
565
507
  {
566
508
  name: 'userTrade';
567
509
  writable: true;
568
- pda: {
569
- seeds: [
570
- {
571
- kind: 'const';
572
- value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
573
- },
574
- {
575
- kind: 'account';
576
- path: 'signer';
577
- }
578
- ];
579
- };
580
510
  },
581
511
  {
582
512
  name: 'market';
@@ -585,18 +515,6 @@ export type TriadProtocol = {
585
515
  {
586
516
  name: 'feeVault';
587
517
  writable: true;
588
- pda: {
589
- seeds: [
590
- {
591
- kind: 'const';
592
- value: [102, 101, 101, 95, 118, 97, 117, 108, 116];
593
- },
594
- {
595
- kind: 'account';
596
- path: 'market';
597
- }
598
- ];
599
- };
600
518
  },
601
519
  {
602
520
  name: 'mint';
@@ -605,59 +523,6 @@ export type TriadProtocol = {
605
523
  {
606
524
  name: 'userFromAta';
607
525
  writable: true;
608
- pda: {
609
- seeds: [
610
- {
611
- kind: 'account';
612
- path: 'signer';
613
- },
614
- {
615
- kind: 'account';
616
- path: 'tokenProgram';
617
- },
618
- {
619
- kind: 'account';
620
- path: 'mint';
621
- }
622
- ];
623
- program: {
624
- kind: 'const';
625
- value: [
626
- 140,
627
- 151,
628
- 37,
629
- 143,
630
- 78,
631
- 36,
632
- 137,
633
- 241,
634
- 187,
635
- 61,
636
- 16,
637
- 41,
638
- 20,
639
- 142,
640
- 13,
641
- 131,
642
- 11,
643
- 90,
644
- 19,
645
- 153,
646
- 218,
647
- 255,
648
- 16,
649
- 132,
650
- 4,
651
- 142,
652
- 123,
653
- 216,
654
- 219,
655
- 233,
656
- 248,
657
- 89
658
- ];
659
- };
660
- };
661
526
  },
662
527
  {
663
528
  name: 'marketToAta';
@@ -1937,7 +1802,7 @@ export type TriadProtocol = {
1937
1802
  },
1938
1803
  {
1939
1804
  name: 'totalVolume';
1940
- docs: ['Total trading volume (in TRD)'];
1805
+ docs: ['Total trading volume (in TRD) for all resolutions'];
1941
1806
  type: 'u64';
1942
1807
  },
1943
1808
  {
@@ -1966,9 +1831,7 @@ export type TriadProtocol = {
1966
1831
  },
1967
1832
  {
1968
1833
  name: 'feeBps';
1969
- docs: [
1970
- 'Fees applied to trades (in basis points, e.g., 300 = 3%) but 2.869 for the protocol; 0.1 NFT Holders; 0.031 Market'
1971
- ];
1834
+ docs: ['Fees applied to trades (in basis points, e.g., 1.131% fee)'];
1972
1835
  type: 'u16';
1973
1836
  },
1974
1837
  {
@@ -1989,10 +1852,48 @@ export type TriadProtocol = {
1989
1852
  name: 'marketPrice';
1990
1853
  type: 'u64';
1991
1854
  },
1855
+ {
1856
+ name: 'resolvedQuestions';
1857
+ type: {
1858
+ array: [
1859
+ {
1860
+ defined: {
1861
+ name: 'resolvedQuestion';
1862
+ };
1863
+ },
1864
+ 4
1865
+ ];
1866
+ };
1867
+ },
1868
+ {
1869
+ name: 'currentQuestionId';
1870
+ docs: [
1871
+ 'Index of the current week in the weekly_results array initialized with default values'
1872
+ ];
1873
+ type: 'u64';
1874
+ },
1875
+ {
1876
+ name: 'currentQuestionStart';
1877
+ docs: [
1878
+ 'Start timestamp of the current week if 7 days have passed since the start of the week'
1879
+ ];
1880
+ type: 'i64';
1881
+ },
1882
+ {
1883
+ name: 'currentQuestionEnd';
1884
+ type: 'i64';
1885
+ },
1886
+ {
1887
+ name: 'currentQuestion';
1888
+ docs: ['The question or prediction topic for the current week'];
1889
+ type: {
1890
+ array: ['u8', 120];
1891
+ };
1892
+ },
1992
1893
  {
1993
1894
  name: 'padding';
1994
1895
  type: {
1995
- array: ['u8', 224];
1896
+ array: ['u8', 232];
1996
1897
  };
1997
1898
  }
1998
1899
  ];
@@ -2015,20 +1916,6 @@ export type TriadProtocol = {
2015
1916
  };
2016
1917
  };
2017
1918
  },
2018
- {
2019
- name: 'orderType';
2020
- type: {
2021
- defined: {
2022
- name: 'orderType';
2023
- };
2024
- };
2025
- },
2026
- {
2027
- name: 'limitPrice';
2028
- type: {
2029
- option: 'u64';
2030
- };
2031
- },
2032
1919
  {
2033
1920
  name: 'comment';
2034
1921
  type: {
@@ -2053,6 +1940,10 @@ export type TriadProtocol = {
2053
1940
  name: 'orderId';
2054
1941
  type: 'u64';
2055
1942
  },
1943
+ {
1944
+ name: 'questionId';
1945
+ type: 'u64';
1946
+ },
2056
1947
  {
2057
1948
  name: 'marketId';
2058
1949
  type: 'u64';
@@ -2075,10 +1966,7 @@ export type TriadProtocol = {
2075
1966
  },
2076
1967
  {
2077
1968
  name: 'totalAmount';
2078
- docs: [
2079
- 'The total amount of TRD committed to this order',
2080
- 'precision: QUOTE_PRECISION'
2081
- ];
1969
+ docs: ['The total amount of TRD committed to this order'];
2082
1970
  type: 'u64';
2083
1971
  },
2084
1972
  {
@@ -2086,19 +1974,6 @@ export type TriadProtocol = {
2086
1974
  docs: ['The total number of shares to be purchased'];
2087
1975
  type: 'u64';
2088
1976
  },
2089
- {
2090
- name: 'filledAmount';
2091
- docs: [
2092
- 'The amount of TRD that has been filled',
2093
- 'precision: QUOTE_PRECISION'
2094
- ];
2095
- type: 'u64';
2096
- },
2097
- {
2098
- name: 'filledShares';
2099
- docs: ['The number of shares that have been filled'];
2100
- type: 'u64';
2101
- },
2102
1977
  {
2103
1978
  name: 'orderType';
2104
1979
  type: {
@@ -2116,17 +1991,16 @@ export type TriadProtocol = {
2116
1991
  };
2117
1992
  },
2118
1993
  {
2119
- name: 'settledPnl';
1994
+ name: 'pnl';
2120
1995
  docs: [
2121
- 'The amount of pnl settled in this market since opening the position (in TRD)',
2122
- 'precision: QUOTE_PRECISION'
1996
+ 'The amount of pnl settled in this market since opening the position (in TRD)'
2123
1997
  ];
2124
1998
  type: 'i64';
2125
1999
  },
2126
2000
  {
2127
2001
  name: 'padding';
2128
2002
  type: {
2129
- array: ['u8', 16];
2003
+ array: ['u8', 32];
2130
2004
  };
2131
2005
  }
2132
2006
  ];
@@ -2157,12 +2031,6 @@ export type TriadProtocol = {
2157
2031
  {
2158
2032
  name: 'open';
2159
2033
  },
2160
- {
2161
- name: 'filled';
2162
- },
2163
- {
2164
- name: 'canceled';
2165
- },
2166
2034
  {
2167
2035
  name: 'closed';
2168
2036
  }
@@ -2175,10 +2043,10 @@ export type TriadProtocol = {
2175
2043
  kind: 'enum';
2176
2044
  variants: [
2177
2045
  {
2178
- name: 'limit';
2046
+ name: 'market';
2179
2047
  },
2180
2048
  {
2181
- name: 'market';
2049
+ name: 'limit';
2182
2050
  }
2183
2051
  ];
2184
2052
  };
@@ -2196,6 +2064,10 @@ export type TriadProtocol = {
2196
2064
  name: 'marketId';
2197
2065
  type: 'u64';
2198
2066
  },
2067
+ {
2068
+ name: 'questionId';
2069
+ type: 'u64';
2070
+ },
2199
2071
  {
2200
2072
  name: 'orderId';
2201
2073
  type: 'u64';
@@ -2232,18 +2104,10 @@ export type TriadProtocol = {
2232
2104
  name: 'totalShares';
2233
2105
  type: 'u64';
2234
2106
  },
2235
- {
2236
- name: 'filledShares';
2237
- type: 'u64';
2238
- },
2239
2107
  {
2240
2108
  name: 'totalAmount';
2241
2109
  type: 'u64';
2242
2110
  },
2243
- {
2244
- name: 'filledAmount';
2245
- type: 'u64';
2246
- },
2247
2111
  {
2248
2112
  name: 'comment';
2249
2113
  type: {
@@ -2258,9 +2122,19 @@ export type TriadProtocol = {
2258
2122
  option: 'u64';
2259
2123
  };
2260
2124
  },
2125
+ {
2126
+ name: 'pnl';
2127
+ type: 'i64';
2128
+ },
2261
2129
  {
2262
2130
  name: 'timestamp';
2263
2131
  type: 'i64';
2132
+ },
2133
+ {
2134
+ name: 'isQuestionWinner';
2135
+ type: {
2136
+ option: 'bool';
2137
+ };
2264
2138
  }
2265
2139
  ];
2266
2140
  };
@@ -2309,6 +2183,70 @@ export type TriadProtocol = {
2309
2183
  ];
2310
2184
  };
2311
2185
  },
2186
+ {
2187
+ name: 'resolvedQuestion';
2188
+ type: {
2189
+ kind: 'struct';
2190
+ fields: [
2191
+ {
2192
+ name: 'question';
2193
+ docs: ['The question or prediction topic for this week'];
2194
+ type: {
2195
+ array: ['u8', 120];
2196
+ };
2197
+ },
2198
+ {
2199
+ name: 'startTime';
2200
+ docs: ['Start timestamp of the week'];
2201
+ type: 'i64';
2202
+ },
2203
+ {
2204
+ name: 'endTime';
2205
+ docs: ['End timestamp of the week'];
2206
+ type: 'i64';
2207
+ },
2208
+ {
2209
+ name: 'hypeLiquidity';
2210
+ docs: ['Total liquidity for Hype (in TRD)'];
2211
+ type: 'u64';
2212
+ },
2213
+ {
2214
+ name: 'flopLiquidity';
2215
+ docs: ['Total liquidity for Flop (in TRD)'];
2216
+ type: 'u64';
2217
+ },
2218
+ {
2219
+ name: 'winningDirection';
2220
+ docs: ['The winning direction (Hype, Flop or None)'];
2221
+ type: {
2222
+ defined: {
2223
+ name: 'winningDirection';
2224
+ };
2225
+ };
2226
+ },
2227
+ {
2228
+ name: 'marketPrice';
2229
+ type: 'u64';
2230
+ },
2231
+ {
2232
+ name: 'finalHypePrice';
2233
+ docs: ['Final price for Hype outcome at the end of the week'];
2234
+ type: 'u64';
2235
+ },
2236
+ {
2237
+ name: 'finalFlopPrice';
2238
+ docs: ['Final price for Flop outcome at the end of the week'];
2239
+ type: 'u64';
2240
+ },
2241
+ {
2242
+ name: 'padding';
2243
+ type: {
2244
+ array: ['u8', 100];
2245
+ };
2246
+ }
2247
+ ];
2248
+ };
2249
+ },
2312
2250
  {
2313
2251
  name: 'stakeNftArgs';
2314
2252
  type: {
@@ -2585,14 +2523,9 @@ export type TriadProtocol = {
2585
2523
  type: 'u64';
2586
2524
  },
2587
2525
  {
2588
- name: 'openOrders';
2589
- docs: ['Number of open orders'];
2590
- type: 'u8';
2591
- },
2592
- {
2593
- name: 'hasOpenOrder';
2594
- docs: ['Whether or not user has open order'];
2595
- type: 'bool';
2526
+ name: 'openedOrders';
2527
+ docs: ['The number of orders the user has opened'];
2528
+ type: 'u64';
2596
2529
  },
2597
2530
  {
2598
2531
  name: 'orders';
@@ -2607,18 +2540,31 @@ export type TriadProtocol = {
2607
2540
  ];
2608
2541
  };
2609
2542
  },
2610
- {
2611
- name: 'position';
2612
- type: 'i64';
2613
- },
2614
2543
  {
2615
2544
  name: 'padding';
2616
2545
  type: {
2617
- array: ['u8', 64];
2546
+ array: ['u8', 32];
2618
2547
  };
2619
2548
  }
2620
2549
  ];
2621
2550
  };
2551
+ },
2552
+ {
2553
+ name: 'winningDirection';
2554
+ type: {
2555
+ kind: 'enum';
2556
+ variants: [
2557
+ {
2558
+ name: 'hype';
2559
+ },
2560
+ {
2561
+ name: 'flop';
2562
+ },
2563
+ {
2564
+ name: 'none';
2565
+ }
2566
+ ];
2567
+ };
2622
2568
  }
2623
2569
  ];
2624
2570
  };
@@ -0,0 +1,3 @@
1
+ import { BN } from '@coral-xyz/anchor';
2
+ declare const formatNumber: (number: bigint | BN, decimals?: number) => number;
3
+ export default formatNumber;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const formatNumber = (number, decimals = 6) => {
4
+ return Number(number.toString()) / Math.pow(10, decimals);
5
+ };
6
+ exports.default = formatNumber;
@@ -1,5 +1,6 @@
1
- export declare const getRarityRank: (ranks: {
1
+ declare const getRarityRank: (ranks: {
2
2
  onchainId: string;
3
3
  name: string;
4
4
  rarityRankHrtt: number;
5
5
  }[], onchainId: string, name: string) => number;
6
+ export default getRarityRank;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRarityRank = void 0;
4
3
  const getRarityRank = (ranks, onchainId, name) => {
5
4
  const item = ranks.find((entry) => entry.onchainId === onchainId || entry.name === name);
6
5
  return item ? item.rarityRankHrtt : 963;
7
6
  };
8
- exports.getRarityRank = getRarityRank;
7
+ exports.default = getRarityRank;
@@ -1,28 +1,7 @@
1
- import { COLLECTION_MUlTIPLIER, StakeResponse, StakeVaultResponse, UserResponse } from './../types/stake';
2
- import { PublicKey } from '@solana/web3.js';
3
- import BN from 'bn.js';
4
- export declare const getTickerAddressSync: (programId: PublicKey, tickerName: string) => PublicKey;
1
+ import { Stake, StakeVault } from './../types/stake';
2
+ import { User } from './../types';
5
3
  export declare const encodeString: (value: string, alloc?: number) => number[];
6
4
  export declare const decodeString: (bytes: number[]) => string;
7
- export declare const getMarketAddressSync: (programId: PublicKey, marketId: number) => PublicKey;
8
- export declare const getFeeVaultAddressSync: (programId: PublicKey, market: PublicKey) => PublicKey;
9
- export declare const getUserTradeAddressSync: (programId: PublicKey, wallet: PublicKey) => PublicKey;
10
- export declare const getStakeVaultAddressSync: (programId: PublicKey, vaultName: string) => PublicKey;
11
- export declare const getStakeAddressSync: (programId: PublicKey, wallet: PublicKey, name: string) => PublicKey;
12
- export declare const getNFTRewardsAddressSync: (programId: PublicKey, stake: PublicKey) => PublicKey;
13
- export declare const getATASync: (address: PublicKey, Mint: PublicKey) => PublicKey;
14
- export declare const getUserAddressSync: (programId: PublicKey, wallet: PublicKey) => PublicKey;
15
- export declare const formatNumber: (number: bigint | BN, decimals?: number) => number;
16
- export declare const formatStakeVault: (stakeVault: any) => StakeVaultResponse;
17
- export declare const formatStake: (stake: any) => StakeResponse;
18
- export declare const formatUser: (user: any) => UserResponse;
19
- export declare const calculateTotalMultiplier: (collections: COLLECTION_MUlTIPLIER[], rank: {
20
- max: number;
21
- currentPosition: number;
22
- }) => number;
23
- export declare const calculateAPR: ({ rewards, rate, amount, baseRewards }: {
24
- rewards: number;
25
- rate: number;
26
- amount: number;
27
- baseRewards: number;
28
- }) => number;
5
+ export declare const formatStakeVault: (stakeVault: any) => StakeVault;
6
+ export declare const formatStake: (stake: any) => Stake;
7
+ export declare const formatUser: (user: any) => User;