@triadxyz/triad-protocol 1.2.3-beta → 1.2.5-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.
@@ -25,7 +25,15 @@ const connection = new web3_js_1.Connection('https://triad-solanam-a5ee.mainnet.
25
25
  const wallet = new anchor_1.Wallet(keypair);
26
26
  const triadProtocol = new _1.default(connection, wallet);
27
27
  const mint = new web3_js_1.PublicKey('X41iRJUPkKaEvhqWdxqrS5P7M5d8A9oathki5sT47KR');
28
- const markets = [];
28
+ const markets = [
29
+ {
30
+ marketId: 14,
31
+ name: 'BTC',
32
+ question: 'Will $BTC be above $85k on November 18th?',
33
+ startTime: 1731429209,
34
+ endTime: 1731812400
35
+ }
36
+ ];
29
37
  const ordersHypeAndFloopBot = [
30
38
  {
31
39
  marketId: 7,
@@ -71,6 +79,7 @@ const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
71
79
  const markets = yield triadProtocol.trade.getAllMarkets();
72
80
  console.log(markets);
73
81
  });
82
+ getAllMarkets();
74
83
  const getMarket = () => __awaiter(void 0, void 0, void 0, function* () {
75
84
  const market = yield triadProtocol.trade.getMarketById(12);
76
85
  console.log(market);
@@ -300,8 +309,10 @@ const mintTokens = () => __awaiter(void 0, void 0, void 0, function* () {
300
309
  });
301
310
  const resolveMarket = () => __awaiter(void 0, void 0, void 0, function* () {
302
311
  const marketsToResolve = [
303
- { marketId: 8, winningDirection: { flop: {} } },
304
- { marketId: 9, winningDirection: { flop: {} } }
312
+ { marketId: 10, winningDirection: { hype: {} } },
313
+ { marketId: 11, winningDirection: { flop: {} } },
314
+ { marketId: 12, winningDirection: { hype: {} } },
315
+ { marketId: 13, winningDirection: { hype: {} } }
305
316
  ];
306
317
  for (const market of marketsToResolve) {
307
318
  const response = yield triadProtocol.trade.resolveMarket({
package/dist/trade.d.ts CHANGED
@@ -193,4 +193,16 @@ export default class Trade {
193
193
  feeToSwap: number;
194
194
  lamport: number;
195
195
  }>;
196
+ /**
197
+ * Payout an order
198
+ * @param marketId - The ID of the market
199
+ * @param orderId - The ID of the order to payout
200
+ *
201
+ * @param options - RPC options
202
+ *
203
+ */
204
+ payoutOrder({ marketId, orderId }: {
205
+ marketId: number;
206
+ orderId: number;
207
+ }, options?: RpcOptions): Promise<string>;
196
208
  }
package/dist/trade.js CHANGED
@@ -298,5 +298,25 @@ class Trade {
298
298
  };
299
299
  });
300
300
  }
301
+ /**
302
+ * Payout an order
303
+ * @param marketId - The ID of the market
304
+ * @param orderId - The ID of the order to payout
305
+ *
306
+ * @param options - RPC options
307
+ *
308
+ */
309
+ payoutOrder({ marketId, orderId }, options) {
310
+ return __awaiter(this, void 0, void 0, function* () {
311
+ const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
312
+ const userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, this.provider.publicKey);
313
+ return (0, sendTransactionWithOptions_1.default)(this.program.methods.payoutOrder(new bn_js_1.default(orderId)).accounts({
314
+ signer: this.provider.publicKey,
315
+ userTrade: userTradePDA,
316
+ market: marketPDA,
317
+ mint: this.mint
318
+ }), options);
319
+ });
320
+ }
301
321
  }
302
322
  exports.default = Trade;
@@ -659,6 +659,103 @@
659
659
  }
660
660
  ]
661
661
  },
662
+ {
663
+ "name": "payout_order",
664
+ "discriminator": [247, 233, 158, 228, 63, 32, 236, 113],
665
+ "accounts": [
666
+ {
667
+ "name": "signer",
668
+ "writable": true,
669
+ "signer": true
670
+ },
671
+ {
672
+ "name": "user_trade",
673
+ "writable": true
674
+ },
675
+ {
676
+ "name": "market",
677
+ "writable": true
678
+ },
679
+ {
680
+ "name": "mint",
681
+ "writable": true
682
+ },
683
+ {
684
+ "name": "user_ata",
685
+ "writable": true,
686
+ "pda": {
687
+ "seeds": [
688
+ {
689
+ "kind": "account",
690
+ "path": "signer"
691
+ },
692
+ {
693
+ "kind": "account",
694
+ "path": "token_program"
695
+ },
696
+ {
697
+ "kind": "account",
698
+ "path": "mint"
699
+ }
700
+ ],
701
+ "program": {
702
+ "kind": "const",
703
+ "value": [
704
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
705
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
706
+ 219, 233, 248, 89
707
+ ]
708
+ }
709
+ }
710
+ },
711
+ {
712
+ "name": "market_vault",
713
+ "writable": true,
714
+ "pda": {
715
+ "seeds": [
716
+ {
717
+ "kind": "account",
718
+ "path": "market"
719
+ },
720
+ {
721
+ "kind": "account",
722
+ "path": "token_program"
723
+ },
724
+ {
725
+ "kind": "account",
726
+ "path": "mint"
727
+ }
728
+ ],
729
+ "program": {
730
+ "kind": "const",
731
+ "value": [
732
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
733
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
734
+ 219, 233, 248, 89
735
+ ]
736
+ }
737
+ }
738
+ },
739
+ {
740
+ "name": "token_program",
741
+ "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
742
+ },
743
+ {
744
+ "name": "associated_token_program",
745
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
746
+ },
747
+ {
748
+ "name": "system_program",
749
+ "address": "11111111111111111111111111111111"
750
+ }
751
+ ],
752
+ "args": [
753
+ {
754
+ "name": "order_id",
755
+ "type": "u64"
756
+ }
757
+ ]
758
+ },
662
759
  {
663
760
  "name": "request_withdraw_stake",
664
761
  "discriminator": [175, 9, 77, 31, 145, 136, 30, 207],
@@ -24,6 +24,7 @@ export type Market = {
24
24
  marketEnd: string;
25
25
  question: string;
26
26
  winningDirection: WinningDirection;
27
+ marketLiquidityAtStart: string;
27
28
  };
28
29
  export declare enum WinningDirection {
29
30
  HYPE = "Hype",
@@ -984,6 +984,161 @@ export type TriadProtocol = {
984
984
  }
985
985
  ];
986
986
  },
987
+ {
988
+ name: 'payoutOrder';
989
+ discriminator: [247, 233, 158, 228, 63, 32, 236, 113];
990
+ accounts: [
991
+ {
992
+ name: 'signer';
993
+ writable: true;
994
+ signer: true;
995
+ },
996
+ {
997
+ name: 'userTrade';
998
+ writable: true;
999
+ },
1000
+ {
1001
+ name: 'market';
1002
+ writable: true;
1003
+ },
1004
+ {
1005
+ name: 'mint';
1006
+ writable: true;
1007
+ },
1008
+ {
1009
+ name: 'userAta';
1010
+ writable: true;
1011
+ pda: {
1012
+ seeds: [
1013
+ {
1014
+ kind: 'account';
1015
+ path: 'signer';
1016
+ },
1017
+ {
1018
+ kind: 'account';
1019
+ path: 'tokenProgram';
1020
+ },
1021
+ {
1022
+ kind: 'account';
1023
+ path: 'mint';
1024
+ }
1025
+ ];
1026
+ program: {
1027
+ kind: 'const';
1028
+ value: [
1029
+ 140,
1030
+ 151,
1031
+ 37,
1032
+ 143,
1033
+ 78,
1034
+ 36,
1035
+ 137,
1036
+ 241,
1037
+ 187,
1038
+ 61,
1039
+ 16,
1040
+ 41,
1041
+ 20,
1042
+ 142,
1043
+ 13,
1044
+ 131,
1045
+ 11,
1046
+ 90,
1047
+ 19,
1048
+ 153,
1049
+ 218,
1050
+ 255,
1051
+ 16,
1052
+ 132,
1053
+ 4,
1054
+ 142,
1055
+ 123,
1056
+ 216,
1057
+ 219,
1058
+ 233,
1059
+ 248,
1060
+ 89
1061
+ ];
1062
+ };
1063
+ };
1064
+ },
1065
+ {
1066
+ name: 'marketVault';
1067
+ writable: true;
1068
+ pda: {
1069
+ seeds: [
1070
+ {
1071
+ kind: 'account';
1072
+ path: 'market';
1073
+ },
1074
+ {
1075
+ kind: 'account';
1076
+ path: 'tokenProgram';
1077
+ },
1078
+ {
1079
+ kind: 'account';
1080
+ path: 'mint';
1081
+ }
1082
+ ];
1083
+ program: {
1084
+ kind: 'const';
1085
+ value: [
1086
+ 140,
1087
+ 151,
1088
+ 37,
1089
+ 143,
1090
+ 78,
1091
+ 36,
1092
+ 137,
1093
+ 241,
1094
+ 187,
1095
+ 61,
1096
+ 16,
1097
+ 41,
1098
+ 20,
1099
+ 142,
1100
+ 13,
1101
+ 131,
1102
+ 11,
1103
+ 90,
1104
+ 19,
1105
+ 153,
1106
+ 218,
1107
+ 255,
1108
+ 16,
1109
+ 132,
1110
+ 4,
1111
+ 142,
1112
+ 123,
1113
+ 216,
1114
+ 219,
1115
+ 233,
1116
+ 248,
1117
+ 89
1118
+ ];
1119
+ };
1120
+ };
1121
+ },
1122
+ {
1123
+ name: 'tokenProgram';
1124
+ address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
1125
+ },
1126
+ {
1127
+ name: 'associatedTokenProgram';
1128
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
1129
+ },
1130
+ {
1131
+ name: 'systemProgram';
1132
+ address: '11111111111111111111111111111111';
1133
+ }
1134
+ ];
1135
+ args: [
1136
+ {
1137
+ name: 'orderId';
1138
+ type: 'u64';
1139
+ }
1140
+ ];
1141
+ },
987
1142
  {
988
1143
  name: 'requestWithdrawStake';
989
1144
  discriminator: [175, 9, 77, 31, 145, 136, 30, 207];
@@ -89,7 +89,10 @@ const formatMarket = (account, address) => {
89
89
  nftHoldersFeeClaimed: account.nftHoldersFeeClaimed.toString(),
90
90
  marketFeeAvailable: account.marketFeeAvailable.toString(),
91
91
  marketFeeClaimed: account.marketFeeClaimed.toString(),
92
- winningDirection: trade_1.WinningDirection[Object.keys(account.winningDirection)[0].toUpperCase()]
92
+ winningDirection: trade_1.WinningDirection[Object.keys(account.winningDirection)[0].toUpperCase()],
93
+ marketLiquidityAtStart: account.marketLiquidityAtStart.toString() > 0
94
+ ? account.marketLiquidityAtStart.toString()
95
+ : '500000000'
93
96
  };
94
97
  };
95
98
  exports.formatMarket = formatMarket;
@@ -121,7 +124,8 @@ const accountToMarketV1 = (account, address) => {
121
124
  nftHoldersFeeClaimed: '0',
122
125
  marketFeeAvailable: '0',
123
126
  marketFeeClaimed: '0',
124
- winningDirection: trade_1.WinningDirection[Object.keys(account.previousResolvedQuestion.winningDirection)[0].toUpperCase()]
127
+ winningDirection: trade_1.WinningDirection[Object.keys(account.previousResolvedQuestion.winningDirection)[0].toUpperCase()],
128
+ marketLiquidityAtStart: '0'
125
129
  };
126
130
  };
127
131
  exports.accountToMarketV1 = accountToMarketV1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.2.3-beta",
3
+ "version": "1.2.5-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",