@triadxyz/triad-protocol 1.6.8-beta → 1.7.0-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.
@@ -13,26 +13,6 @@ export type TriadProtocol = {
13
13
  description: 'Triad protocol, trade solana projects';
14
14
  };
15
15
  instructions: [
16
- {
17
- name: 'addDefaultPoseidon';
18
- discriminator: [121, 129, 69, 151, 102, 241, 191, 34];
19
- accounts: [
20
- {
21
- name: 'signer';
22
- writable: true;
23
- signer: true;
24
- },
25
- {
26
- name: 'userTrade';
27
- writable: true;
28
- },
29
- {
30
- name: 'systemProgram';
31
- address: '11111111111111111111111111111111';
32
- }
33
- ];
34
- args: [];
35
- },
36
16
  {
37
17
  name: 'addTraderPoseidon';
38
18
  discriminator: [34, 241, 88, 67, 66, 83, 83, 134];
@@ -592,8 +572,8 @@ export type TriadProtocol = {
592
572
  args: [];
593
573
  },
594
574
  {
595
- name: 'createSubUserTrade';
596
- discriminator: [77, 201, 111, 73, 47, 229, 244, 161];
575
+ name: 'createCustomer';
576
+ discriminator: [120, 122, 113, 216, 95, 207, 252, 147];
597
577
  accounts: [
598
578
  {
599
579
  name: 'signer';
@@ -601,33 +581,17 @@ export type TriadProtocol = {
601
581
  signer: true;
602
582
  },
603
583
  {
604
- name: 'userTrade';
605
- writable: true;
606
- pda: {
607
- seeds: [
608
- {
609
- kind: 'const';
610
- value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
611
- },
612
- {
613
- kind: 'account';
614
- path: 'signer';
615
- }
616
- ];
617
- };
618
- },
619
- {
620
- name: 'subUserTrade';
584
+ name: 'customer';
621
585
  writable: true;
622
586
  pda: {
623
587
  seeds: [
624
588
  {
625
589
  kind: 'const';
626
- value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
590
+ value: [99, 117, 115, 116, 111, 109, 101, 114];
627
591
  },
628
592
  {
629
593
  kind: 'arg';
630
- path: 'subUserKey';
594
+ path: 'args.id';
631
595
  }
632
596
  ];
633
597
  };
@@ -639,46 +603,18 @@ export type TriadProtocol = {
639
603
  ];
640
604
  args: [
641
605
  {
642
- name: 'subUserKey';
643
- type: 'pubkey';
644
- }
645
- ];
646
- },
647
- {
648
- name: 'createUserTrade';
649
- discriminator: [232, 235, 58, 194, 135, 248, 153, 1];
650
- accounts: [
651
- {
652
- name: 'signer';
653
- writable: true;
654
- signer: true;
655
- },
656
- {
657
- name: 'userTrade';
658
- writable: true;
659
- pda: {
660
- seeds: [
661
- {
662
- kind: 'const';
663
- value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
664
- },
665
- {
666
- kind: 'account';
667
- path: 'signer';
668
- }
669
- ];
606
+ name: 'args';
607
+ type: {
608
+ defined: {
609
+ name: 'createCustomerArgs';
610
+ };
670
611
  };
671
- },
672
- {
673
- name: 'systemProgram';
674
- address: '11111111111111111111111111111111';
675
612
  }
676
613
  ];
677
- args: [];
678
614
  },
679
615
  {
680
- name: 'forceCancelOrder';
681
- discriminator: [10, 45, 231, 51, 229, 251, 182, 45];
616
+ name: 'createMarket';
617
+ discriminator: [103, 226, 97, 235, 200, 188, 251, 254];
682
618
  accounts: [
683
619
  {
684
620
  name: 'signer';
@@ -686,80 +622,37 @@ export type TriadProtocol = {
686
622
  signer: true;
687
623
  },
688
624
  {
689
- name: 'user';
625
+ name: 'squads';
690
626
  writable: true;
627
+ address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
691
628
  },
692
629
  {
693
- name: 'userTrade';
630
+ name: 'customer';
694
631
  writable: true;
632
+ optional: true;
695
633
  },
696
634
  {
697
635
  name: 'market';
698
636
  writable: true;
699
- },
700
- {
701
- name: 'mint';
702
- writable: true;
703
- },
704
- {
705
- name: 'userAta';
706
- writable: true;
707
637
  pda: {
708
638
  seeds: [
709
639
  {
710
- kind: 'account';
711
- path: 'user';
712
- },
713
- {
714
- kind: 'account';
715
- path: 'tokenProgram';
640
+ kind: 'const';
641
+ value: [109, 97, 114, 107, 101, 116];
716
642
  },
717
643
  {
718
- kind: 'account';
719
- path: 'mint';
644
+ kind: 'arg';
645
+ path: 'args.market_id';
720
646
  }
721
647
  ];
722
- program: {
723
- kind: 'const';
724
- value: [
725
- 140,
726
- 151,
727
- 37,
728
- 143,
729
- 78,
730
- 36,
731
- 137,
732
- 241,
733
- 187,
734
- 61,
735
- 16,
736
- 41,
737
- 20,
738
- 142,
739
- 13,
740
- 131,
741
- 11,
742
- 90,
743
- 19,
744
- 153,
745
- 218,
746
- 255,
747
- 16,
748
- 132,
749
- 4,
750
- 142,
751
- 123,
752
- 216,
753
- 219,
754
- 233,
755
- 248,
756
- 89
757
- ];
758
- };
759
648
  };
760
649
  },
761
650
  {
762
- name: 'marketVault';
651
+ name: 'mint';
652
+ writable: true;
653
+ },
654
+ {
655
+ name: 'marketToAta';
763
656
  writable: true;
764
657
  pda: {
765
658
  seeds: [
@@ -817,7 +710,6 @@ export type TriadProtocol = {
817
710
  },
818
711
  {
819
712
  name: 'tokenProgram';
820
- address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
821
713
  },
822
714
  {
823
715
  name: 'associatedTokenProgram';
@@ -830,14 +722,18 @@ export type TriadProtocol = {
830
722
  ];
831
723
  args: [
832
724
  {
833
- name: 'orderId';
834
- type: 'u64';
725
+ name: 'args';
726
+ type: {
727
+ defined: {
728
+ name: 'createMarketArgs';
729
+ };
730
+ };
835
731
  }
836
732
  ];
837
733
  },
838
734
  {
839
- name: 'initializeMarket';
840
- discriminator: [35, 35, 189, 193, 155, 48, 170, 203];
735
+ name: 'createSubUserTrade';
736
+ discriminator: [77, 201, 111, 73, 47, 229, 244, 161];
841
737
  accounts: [
842
738
  {
843
739
  name: 'signer';
@@ -845,90 +741,37 @@ export type TriadProtocol = {
845
741
  signer: true;
846
742
  },
847
743
  {
848
- name: 'market';
744
+ name: 'userTrade';
849
745
  writable: true;
850
746
  pda: {
851
747
  seeds: [
852
748
  {
853
749
  kind: 'const';
854
- value: [109, 97, 114, 107, 101, 116];
750
+ value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
855
751
  },
856
752
  {
857
- kind: 'arg';
858
- path: 'args.market_id';
753
+ kind: 'account';
754
+ path: 'signer';
859
755
  }
860
756
  ];
861
757
  };
862
758
  },
863
759
  {
864
- name: 'mint';
865
- writable: true;
866
- },
867
- {
868
- name: 'marketAta';
760
+ name: 'subUserTrade';
869
761
  writable: true;
870
762
  pda: {
871
763
  seeds: [
872
764
  {
873
- kind: 'account';
874
- path: 'market';
875
- },
876
- {
877
- kind: 'account';
878
- path: 'tokenProgram';
765
+ kind: 'const';
766
+ value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
879
767
  },
880
768
  {
881
- kind: 'account';
882
- path: 'mint';
769
+ kind: 'arg';
770
+ path: 'subUserKey';
883
771
  }
884
772
  ];
885
- program: {
886
- kind: 'const';
887
- value: [
888
- 140,
889
- 151,
890
- 37,
891
- 143,
892
- 78,
893
- 36,
894
- 137,
895
- 241,
896
- 187,
897
- 61,
898
- 16,
899
- 41,
900
- 20,
901
- 142,
902
- 13,
903
- 131,
904
- 11,
905
- 90,
906
- 19,
907
- 153,
908
- 218,
909
- 255,
910
- 16,
911
- 132,
912
- 4,
913
- 142,
914
- 123,
915
- 216,
916
- 219,
917
- 233,
918
- 248,
919
- 89
920
- ];
921
- };
922
773
  };
923
774
  },
924
- {
925
- name: 'tokenProgram';
926
- address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
927
- },
928
- {
929
- name: 'associatedTokenProgram';
930
- address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
931
- },
932
775
  {
933
776
  name: 'systemProgram';
934
777
  address: '11111111111111111111111111111111';
@@ -936,14 +779,42 @@ export type TriadProtocol = {
936
779
  ];
937
780
  args: [
938
781
  {
939
- name: 'args';
940
- type: {
941
- defined: {
942
- name: 'initializeMarketArgs';
943
- };
782
+ name: 'subUserKey';
783
+ type: 'pubkey';
784
+ }
785
+ ];
786
+ },
787
+ {
788
+ name: 'createUserTrade';
789
+ discriminator: [232, 235, 58, 194, 135, 248, 153, 1];
790
+ accounts: [
791
+ {
792
+ name: 'signer';
793
+ writable: true;
794
+ signer: true;
795
+ },
796
+ {
797
+ name: 'userTrade';
798
+ writable: true;
799
+ pda: {
800
+ seeds: [
801
+ {
802
+ kind: 'const';
803
+ value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
804
+ },
805
+ {
806
+ kind: 'account';
807
+ path: 'signer';
808
+ }
809
+ ];
944
810
  };
811
+ },
812
+ {
813
+ name: 'systemProgram';
814
+ address: '11111111111111111111111111111111';
945
815
  }
946
816
  ];
817
+ args: [];
947
818
  },
948
819
  {
949
820
  name: 'openOrder';
@@ -1999,6 +1870,10 @@ export type TriadProtocol = {
1999
1870
  name: 'collection';
2000
1871
  discriminator: [48, 160, 232, 205, 191, 207, 26, 141];
2001
1872
  },
1873
+ {
1874
+ name: 'customer';
1875
+ discriminator: [112, 147, 140, 31, 93, 186, 103, 18];
1876
+ },
2002
1877
  {
2003
1878
  name: 'marketV2';
2004
1879
  discriminator: [27, 60, 50, 75, 191, 193, 86, 227];
@@ -2143,6 +2018,16 @@ export type TriadProtocol = {
2143
2018
  code: 6020;
2144
2019
  name: 'notLinked';
2145
2020
  msg: 'Not linked';
2021
+ },
2022
+ {
2023
+ code: 6021;
2024
+ name: 'invalidCustomer';
2025
+ msg: 'Invalid customer';
2026
+ },
2027
+ {
2028
+ code: 6022;
2029
+ name: 'invalidMint';
2030
+ msg: 'Invalid mint';
2146
2031
  }
2147
2032
  ];
2148
2033
  types: [
@@ -2275,7 +2160,27 @@ export type TriadProtocol = {
2275
2160
  };
2276
2161
  },
2277
2162
  {
2278
- name: 'initializeMarketArgs';
2163
+ name: 'createCustomerArgs';
2164
+ type: {
2165
+ kind: 'struct';
2166
+ fields: [
2167
+ {
2168
+ name: 'name';
2169
+ type: 'string';
2170
+ },
2171
+ {
2172
+ name: 'authority';
2173
+ type: 'pubkey';
2174
+ },
2175
+ {
2176
+ name: 'id';
2177
+ type: 'u16';
2178
+ }
2179
+ ];
2180
+ };
2181
+ },
2182
+ {
2183
+ name: 'createMarketArgs';
2279
2184
  type: {
2280
2185
  kind: 'struct';
2281
2186
  fields: [
@@ -2296,6 +2201,40 @@ export type TriadProtocol = {
2296
2201
  {
2297
2202
  name: 'marketEnd';
2298
2203
  type: 'i64';
2204
+ },
2205
+ {
2206
+ name: 'feeBps';
2207
+ type: 'u8';
2208
+ }
2209
+ ];
2210
+ };
2211
+ },
2212
+ {
2213
+ name: 'customer';
2214
+ type: {
2215
+ kind: 'struct';
2216
+ fields: [
2217
+ {
2218
+ name: 'bump';
2219
+ type: 'u8';
2220
+ },
2221
+ {
2222
+ name: 'id';
2223
+ type: 'u16';
2224
+ },
2225
+ {
2226
+ name: 'authority';
2227
+ type: 'pubkey';
2228
+ },
2229
+ {
2230
+ name: 'name';
2231
+ type: 'string';
2232
+ },
2233
+ {
2234
+ name: 'padding';
2235
+ type: {
2236
+ array: ['u8', 64];
2237
+ };
2299
2238
  }
2300
2239
  ];
2301
2240
  };
@@ -2331,6 +2270,10 @@ export type TriadProtocol = {
2331
2270
  type: {
2332
2271
  kind: 'struct';
2333
2272
  fields: [
2273
+ {
2274
+ name: 'authority';
2275
+ type: 'pubkey';
2276
+ },
2334
2277
  {
2335
2278
  name: 'marketId';
2336
2279
  type: 'u64';
@@ -2363,6 +2306,10 @@ export type TriadProtocol = {
2363
2306
  name: 'volume';
2364
2307
  type: 'u64';
2365
2308
  },
2309
+ {
2310
+ name: 'mint';
2311
+ type: 'pubkey';
2312
+ },
2366
2313
  {
2367
2314
  name: 'updateTs';
2368
2315
  type: 'i64';
@@ -2375,6 +2322,28 @@ export type TriadProtocol = {
2375
2322
  name: 'nextOrderId';
2376
2323
  type: 'u64';
2377
2324
  },
2325
+ {
2326
+ name: 'feeBps';
2327
+ type: 'u16';
2328
+ },
2329
+ {
2330
+ name: 'isAllowedToPayout';
2331
+ type: 'bool';
2332
+ },
2333
+ {
2334
+ name: 'marketStart';
2335
+ type: 'i64';
2336
+ },
2337
+ {
2338
+ name: 'marketEnd';
2339
+ type: 'i64';
2340
+ },
2341
+ {
2342
+ name: 'question';
2343
+ type: {
2344
+ array: ['u8', 80];
2345
+ };
2346
+ },
2378
2347
  {
2379
2348
  name: 'winningDirection';
2380
2349
  type: {
@@ -2384,19 +2353,23 @@ export type TriadProtocol = {
2384
2353
  };
2385
2354
  },
2386
2355
  {
2387
- name: 'marketStart';
2388
- type: 'i64';
2356
+ name: 'marketLiquidityAtStart';
2357
+ type: 'u64';
2389
2358
  },
2390
2359
  {
2391
- name: 'marketEnd';
2392
- type: 'i64';
2360
+ name: 'creatorFeeAvailable';
2361
+ type: 'u64';
2393
2362
  },
2394
2363
  {
2395
- name: 'isAllowedToPayout';
2396
- type: 'bool';
2364
+ name: 'creatorFeeClaimed';
2365
+ type: 'u64';
2397
2366
  },
2398
2367
  {
2399
- name: 'marketLiquidityAtStart';
2368
+ name: 'marketFeeAvailable';
2369
+ type: 'u64';
2370
+ },
2371
+ {
2372
+ name: 'marketFeeClaimed';
2400
2373
  type: 'u64';
2401
2374
  }
2402
2375
  ];
@@ -2468,11 +2441,11 @@ export type TriadProtocol = {
2468
2441
  type: 'u16';
2469
2442
  },
2470
2443
  {
2471
- name: 'nftHoldersFeeAvailable';
2444
+ name: 'creatorFeeAvailable';
2472
2445
  type: 'u64';
2473
2446
  },
2474
2447
  {
2475
- name: 'nftHoldersFeeClaimed';
2448
+ name: 'creatorFeeClaimed';
2476
2449
  type: 'u64';
2477
2450
  },
2478
2451
  {
@@ -2513,10 +2486,14 @@ export type TriadProtocol = {
2513
2486
  name: 'marketLiquidityAtStart';
2514
2487
  type: 'u64';
2515
2488
  },
2489
+ {
2490
+ name: 'customerId';
2491
+ type: 'u16';
2492
+ },
2516
2493
  {
2517
2494
  name: 'padding';
2518
2495
  type: {
2519
- array: ['u8', 92];
2496
+ array: ['u8', 90];
2520
2497
  };
2521
2498
  }
2522
2499
  ];
@@ -9,3 +9,4 @@ export declare const formatMarket: (account: any, address: PublicKey) => Market;
9
9
  export declare const formatOrder: (order: any) => Order;
10
10
  export declare const formatUserTrade: (account: any, publicKey: PublicKey) => UserTrade;
11
11
  export declare const calculateStakeRewards: (stake: Stake, multiplier: number) => number;
12
+ export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateStakeRewards = exports.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.getTokenProgram = exports.calculateStakeRewards = exports.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const trade_1 = require("../types/trade");
5
5
  const constants_1 = require("./constants");
6
+ const spl_token_1 = require("@solana/spl-token");
7
+ const spl_token_2 = require("@solana/spl-token");
6
8
  const encodeString = (value, alloc = 32) => {
7
9
  const buffer = Buffer.alloc(alloc, 32);
8
10
  buffer.write(value);
@@ -72,14 +74,15 @@ const formatMarket = (account, address) => {
72
74
  marketStart: account.marketStart.toString(),
73
75
  marketEnd: account.marketEnd.toString(),
74
76
  question: Buffer.from(account.question).toString().replace(/\0+$/, ''),
75
- nftHoldersFeeAvailable: account.nftHoldersFeeAvailable.toString(),
76
- nftHoldersFeeClaimed: account.nftHoldersFeeClaimed.toString(),
77
+ creatorFeeAvailable: account.creatorFeeAvailable.toString(),
78
+ creatorFeeClaimed: account.creatorFeeClaimed.toString(),
77
79
  marketFeeAvailable: account.marketFeeAvailable.toString(),
78
80
  marketFeeClaimed: account.marketFeeClaimed.toString(),
79
81
  winningDirection: trade_1.WinningDirection[Object.keys(account.winningDirection)[0].toUpperCase()],
80
82
  marketLiquidityAtStart: account.marketLiquidityAtStart.toString() > 0
81
83
  ? account.marketLiquidityAtStart.toString()
82
- : '500000000'
84
+ : '500000000',
85
+ customer: account.customer ? account.customer.toString() : 'Triad'
83
86
  };
84
87
  };
85
88
  exports.formatMarket = formatMarket;
@@ -133,3 +136,10 @@ const calculateStakeRewards = (stake, multiplier) => {
133
136
  return (rewards + stake.available) / Math.pow(10, constants_1.TRD_DECIMALS);
134
137
  };
135
138
  exports.calculateStakeRewards = calculateStakeRewards;
139
+ const getTokenProgram = (mint) => {
140
+ if (mint.toBase58() === constants_1.TRD_MINT.toBase58()) {
141
+ return spl_token_1.TOKEN_2022_PROGRAM_ID;
142
+ }
143
+ return spl_token_2.TOKEN_PROGRAM_ID;
144
+ };
145
+ exports.getTokenProgram = getTokenProgram;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.6.8-beta",
3
+ "version": "1.7.0-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",