@triadxyz/triad-protocol 0.6.8-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
  {
@@ -1985,6 +1848,48 @@ export type TriadProtocol = {
1985
1848
  name: 'isOfficial';
1986
1849
  type: 'bool';
1987
1850
  },
1851
+ {
1852
+ name: 'marketPrice';
1853
+ type: 'u64';
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
+ },
1988
1893
  {
1989
1894
  name: 'padding';
1990
1895
  type: {
@@ -2011,20 +1916,6 @@ export type TriadProtocol = {
2011
1916
  };
2012
1917
  };
2013
1918
  },
2014
- {
2015
- name: 'orderType';
2016
- type: {
2017
- defined: {
2018
- name: 'orderType';
2019
- };
2020
- };
2021
- },
2022
- {
2023
- name: 'limitPrice';
2024
- type: {
2025
- option: 'u64';
2026
- };
2027
- },
2028
1919
  {
2029
1920
  name: 'comment';
2030
1921
  type: {
@@ -2049,6 +1940,10 @@ export type TriadProtocol = {
2049
1940
  name: 'orderId';
2050
1941
  type: 'u64';
2051
1942
  },
1943
+ {
1944
+ name: 'questionId';
1945
+ type: 'u64';
1946
+ },
2052
1947
  {
2053
1948
  name: 'marketId';
2054
1949
  type: 'u64';
@@ -2071,10 +1966,7 @@ export type TriadProtocol = {
2071
1966
  },
2072
1967
  {
2073
1968
  name: 'totalAmount';
2074
- docs: [
2075
- 'The total amount of TRD committed to this order',
2076
- 'precision: QUOTE_PRECISION'
2077
- ];
1969
+ docs: ['The total amount of TRD committed to this order'];
2078
1970
  type: 'u64';
2079
1971
  },
2080
1972
  {
@@ -2082,19 +1974,6 @@ export type TriadProtocol = {
2082
1974
  docs: ['The total number of shares to be purchased'];
2083
1975
  type: 'u64';
2084
1976
  },
2085
- {
2086
- name: 'filledAmount';
2087
- docs: [
2088
- 'The amount of TRD that has been filled',
2089
- 'precision: QUOTE_PRECISION'
2090
- ];
2091
- type: 'u64';
2092
- },
2093
- {
2094
- name: 'filledShares';
2095
- docs: ['The number of shares that have been filled'];
2096
- type: 'u64';
2097
- },
2098
1977
  {
2099
1978
  name: 'orderType';
2100
1979
  type: {
@@ -2112,17 +1991,16 @@ export type TriadProtocol = {
2112
1991
  };
2113
1992
  },
2114
1993
  {
2115
- name: 'settledPnl';
1994
+ name: 'pnl';
2116
1995
  docs: [
2117
- 'The amount of pnl settled in this market since opening the position (in TRD)',
2118
- 'precision: QUOTE_PRECISION'
1996
+ 'The amount of pnl settled in this market since opening the position (in TRD)'
2119
1997
  ];
2120
1998
  type: 'i64';
2121
1999
  },
2122
2000
  {
2123
2001
  name: 'padding';
2124
2002
  type: {
2125
- array: ['u8', 16];
2003
+ array: ['u8', 32];
2126
2004
  };
2127
2005
  }
2128
2006
  ];
@@ -2153,12 +2031,6 @@ export type TriadProtocol = {
2153
2031
  {
2154
2032
  name: 'open';
2155
2033
  },
2156
- {
2157
- name: 'filled';
2158
- },
2159
- {
2160
- name: 'canceled';
2161
- },
2162
2034
  {
2163
2035
  name: 'closed';
2164
2036
  }
@@ -2171,10 +2043,10 @@ export type TriadProtocol = {
2171
2043
  kind: 'enum';
2172
2044
  variants: [
2173
2045
  {
2174
- name: 'limit';
2046
+ name: 'market';
2175
2047
  },
2176
2048
  {
2177
- name: 'market';
2049
+ name: 'limit';
2178
2050
  }
2179
2051
  ];
2180
2052
  };
@@ -2192,6 +2064,10 @@ export type TriadProtocol = {
2192
2064
  name: 'marketId';
2193
2065
  type: 'u64';
2194
2066
  },
2067
+ {
2068
+ name: 'questionId';
2069
+ type: 'u64';
2070
+ },
2195
2071
  {
2196
2072
  name: 'orderId';
2197
2073
  type: 'u64';
@@ -2228,18 +2104,10 @@ export type TriadProtocol = {
2228
2104
  name: 'totalShares';
2229
2105
  type: 'u64';
2230
2106
  },
2231
- {
2232
- name: 'filledShares';
2233
- type: 'u64';
2234
- },
2235
2107
  {
2236
2108
  name: 'totalAmount';
2237
2109
  type: 'u64';
2238
2110
  },
2239
- {
2240
- name: 'filledAmount';
2241
- type: 'u64';
2242
- },
2243
2111
  {
2244
2112
  name: 'comment';
2245
2113
  type: {
@@ -2254,9 +2122,19 @@ export type TriadProtocol = {
2254
2122
  option: 'u64';
2255
2123
  };
2256
2124
  },
2125
+ {
2126
+ name: 'pnl';
2127
+ type: 'i64';
2128
+ },
2257
2129
  {
2258
2130
  name: 'timestamp';
2259
2131
  type: 'i64';
2132
+ },
2133
+ {
2134
+ name: 'isQuestionWinner';
2135
+ type: {
2136
+ option: 'bool';
2137
+ };
2260
2138
  }
2261
2139
  ];
2262
2140
  };
@@ -2305,6 +2183,70 @@ export type TriadProtocol = {
2305
2183
  ];
2306
2184
  };
2307
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
+ },
2308
2250
  {
2309
2251
  name: 'stakeNftArgs';
2310
2252
  type: {
@@ -2581,14 +2523,9 @@ export type TriadProtocol = {
2581
2523
  type: 'u64';
2582
2524
  },
2583
2525
  {
2584
- name: 'openOrders';
2585
- docs: ['Number of open orders'];
2586
- type: 'u8';
2587
- },
2588
- {
2589
- name: 'hasOpenOrder';
2590
- docs: ['Whether or not user has open order'];
2591
- type: 'bool';
2526
+ name: 'openedOrders';
2527
+ docs: ['The number of orders the user has opened'];
2528
+ type: 'u64';
2592
2529
  },
2593
2530
  {
2594
2531
  name: 'orders';
@@ -2603,18 +2540,31 @@ export type TriadProtocol = {
2603
2540
  ];
2604
2541
  };
2605
2542
  },
2606
- {
2607
- name: 'position';
2608
- type: 'i64';
2609
- },
2610
2543
  {
2611
2544
  name: 'padding';
2612
2545
  type: {
2613
- array: ['u8', 64];
2546
+ array: ['u8', 32];
2614
2547
  };
2615
2548
  }
2616
2549
  ];
2617
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
+ };
2618
2568
  }
2619
2569
  ];
2620
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;