@triadxyz/triad-protocol 2.2.7-beta → 2.2.9-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/trade.d.ts CHANGED
@@ -8,6 +8,11 @@ export default class Trade {
8
8
  private program;
9
9
  decimals: number;
10
10
  constructor(program: Program<TriadProtocol>);
11
+ /**
12
+ * Get All Pools
13
+ *
14
+ */
15
+ getAllPools(): Promise<import("./types/trade").Pool[]>;
11
16
  /**
12
17
  * Get All Markets
13
18
  *
@@ -25,6 +30,12 @@ export default class Trade {
25
30
  *
26
31
  */
27
32
  getUserOrders(user: PublicKey): Promise<Order[]>;
33
+ /**
34
+ * Get Pool By ID
35
+ * @param poolId - The ID of the pool
36
+ *
37
+ */
38
+ getPoolById(poolId: number): Promise<import("./types/trade").Pool>;
28
39
  /**
29
40
  * Get Market By ID
30
41
  * @param marketId - The ID of the market
@@ -48,7 +59,7 @@ export default class Trade {
48
59
  authority: PublicKey;
49
60
  totalDeposits: BN;
50
61
  totalWithdraws: BN;
51
- version: BN;
62
+ padding1: number[];
52
63
  orders: {
53
64
  ts: BN;
54
65
  orderId: BN;
@@ -104,7 +115,7 @@ export default class Trade {
104
115
  waiting: Record<string, never>;
105
116
  });
106
117
  price: BN;
107
- version: BN;
118
+ padding1: number[];
108
119
  totalShares: BN;
109
120
  orderType: ({
110
121
  limit?: never;
@@ -152,6 +163,7 @@ export default class Trade {
152
163
  * @param args.question - question (max 80 characters)
153
164
  * @param args.liquidityAtStart - liquidity at start
154
165
  * @param args.payoutFee - payout fee (to add affiliate system)
166
+ * @param args.currentMarketId - if fast market, we need check the pool parameters
155
167
  *
156
168
  * @param options - RPC options
157
169
  *
@@ -165,7 +177,7 @@ export default class Trade {
165
177
  *
166
178
  * @param options - RPC options
167
179
  */
168
- createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
180
+ createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
169
181
  /**
170
182
  * Open Order
171
183
  * @param args.marketId - The ID of the Market
@@ -200,8 +212,9 @@ export default class Trade {
200
212
  * @param options - RPC options
201
213
  *
202
214
  */
203
- resolveMarket({ marketId, winningDirection }: {
215
+ resolveMarket({ marketId, poolId, winningDirection }: {
204
216
  marketId: number;
217
+ poolId?: number;
205
218
  winningDirection: {
206
219
  hype: {};
207
220
  } | {
package/dist/trade.js CHANGED
@@ -27,6 +27,16 @@ class Trade {
27
27
  this.program = program;
28
28
  this.decimals = constants_1.TRD_DECIMALS; // We're using only TRD or USDC so we can use the same decimals 6
29
29
  }
30
+ /**
31
+ * Get All Pools
32
+ *
33
+ */
34
+ getAllPools() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const poolV2 = yield this.program.account.pool.all();
37
+ return poolV2.map(({ account, publicKey }) => (0, helpers_1.formatPool)(account, publicKey));
38
+ });
39
+ }
30
40
  /**
31
41
  * Get All Markets
32
42
  *
@@ -66,6 +76,18 @@ class Trade {
66
76
  return myUserTrades.flatMap((userTrade) => userTrade.orders);
67
77
  });
68
78
  }
79
+ /**
80
+ * Get Pool By ID
81
+ * @param poolId - The ID of the pool
82
+ *
83
+ */
84
+ getPoolById(poolId) {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
87
+ const response = yield this.program.account.pool.fetch(poolPDA);
88
+ return (0, helpers_1.formatPool)(response, poolPDA);
89
+ });
90
+ }
69
91
  /**
70
92
  * Get Market By ID
71
93
  * @param marketId - The ID of the market
@@ -113,6 +135,7 @@ class Trade {
113
135
  * @param args.question - question (max 80 characters)
114
136
  * @param args.liquidityAtStart - liquidity at start
115
137
  * @param args.payoutFee - payout fee (to add affiliate system)
138
+ * @param args.currentMarketId - if fast market, we need check the pool parameters
116
139
  *
117
140
  * @param options - RPC options
118
141
  *
@@ -129,7 +152,8 @@ class Trade {
129
152
  }
130
153
  let userTrade = null;
131
154
  try {
132
- userTrade = yield this.getUserTrade(this.program.provider.publicKey);
155
+ yield this.getUserTrade(this.program.provider.publicKey);
156
+ userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
133
157
  }
134
158
  catch (_a) { }
135
159
  ixs.push(yield this.program.methods
@@ -161,7 +185,7 @@ class Trade {
161
185
  *
162
186
  * @param options - RPC options
163
187
  */
164
- createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee }, options) {
188
+ createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }, options) {
165
189
  return __awaiter(this, void 0, void 0, function* () {
166
190
  if (question.length > 80) {
167
191
  throw new Error('Pool question must be less than 80 characters');
@@ -171,7 +195,8 @@ class Trade {
171
195
  ixs.push(yield this.program.methods
172
196
  .createPool({
173
197
  poolId: new bn_js_1.default(poolId),
174
- question: (0, helpers_1.encodeString)(question, 80)
198
+ question: (0, helpers_1.encodeString)(question, 80),
199
+ isFast
175
200
  })
176
201
  .accounts({
177
202
  signer: this.program.provider.publicKey
@@ -289,9 +314,13 @@ class Trade {
289
314
  * @param options - RPC options
290
315
  *
291
316
  */
292
- resolveMarket({ marketId, winningDirection }, options) {
317
+ resolveMarket({ marketId, poolId, winningDirection }, options) {
293
318
  return __awaiter(this, void 0, void 0, function* () {
294
319
  const ixs = [];
320
+ let poolPDA = null;
321
+ if (poolId) {
322
+ poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
323
+ }
295
324
  ixs.push(yield this.program.methods
296
325
  .updateMarket({
297
326
  winningDirection,
@@ -300,7 +329,8 @@ class Trade {
300
329
  })
301
330
  .accounts({
302
331
  signer: this.program.provider.publicKey,
303
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
332
+ market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
333
+ pool: poolPDA
304
334
  })
305
335
  .instruction());
306
336
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
@@ -1299,21 +1299,25 @@
1299
1299
  "writable": true,
1300
1300
  "signer": true
1301
1301
  },
1302
+ {
1303
+ "name": "market",
1304
+ "writable": true
1305
+ },
1302
1306
  {
1303
1307
  "name": "squads",
1304
1308
  "writable": true,
1305
1309
  "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
1306
1310
  },
1307
1311
  {
1308
- "name": "seller_trade",
1312
+ "name": "buyer_authority",
1309
1313
  "writable": true
1310
1314
  },
1311
1315
  {
1312
- "name": "buyer_trade",
1316
+ "name": "seller_trade",
1313
1317
  "writable": true
1314
1318
  },
1315
1319
  {
1316
- "name": "market",
1320
+ "name": "buyer_trade",
1317
1321
  "writable": true
1318
1322
  },
1319
1323
  {
@@ -1348,6 +1352,34 @@
1348
1352
  }
1349
1353
  }
1350
1354
  },
1355
+ {
1356
+ "name": "buyer_ata",
1357
+ "writable": true,
1358
+ "pda": {
1359
+ "seeds": [
1360
+ {
1361
+ "kind": "account",
1362
+ "path": "buyer_authority"
1363
+ },
1364
+ {
1365
+ "kind": "account",
1366
+ "path": "token_program"
1367
+ },
1368
+ {
1369
+ "kind": "account",
1370
+ "path": "mint"
1371
+ }
1372
+ ],
1373
+ "program": {
1374
+ "kind": "const",
1375
+ "value": [
1376
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
1377
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
1378
+ 219, 233, 248, 89
1379
+ ]
1380
+ }
1381
+ }
1382
+ },
1351
1383
  {
1352
1384
  "name": "market_ata",
1353
1385
  "writable": true
@@ -1364,7 +1396,16 @@
1364
1396
  "address": "11111111111111111111111111111111"
1365
1397
  }
1366
1398
  ],
1367
- "args": []
1399
+ "args": [
1400
+ {
1401
+ "name": "args",
1402
+ "type": {
1403
+ "defined": {
1404
+ "name": "MarketAskOrderArgs"
1405
+ }
1406
+ }
1407
+ }
1408
+ ]
1368
1409
  },
1369
1410
  {
1370
1411
  "name": "market_bid_order",
@@ -1404,10 +1445,6 @@
1404
1445
  "name": "buyer_ata",
1405
1446
  "writable": true
1406
1447
  },
1407
- {
1408
- "name": "market_ata",
1409
- "writable": true
1410
- },
1411
1448
  {
1412
1449
  "name": "seller_ata",
1413
1450
  "writable": true,
@@ -1436,6 +1473,10 @@
1436
1473
  }
1437
1474
  }
1438
1475
  },
1476
+ {
1477
+ "name": "market_ata",
1478
+ "writable": true
1479
+ },
1439
1480
  {
1440
1481
  "name": "token_program"
1441
1482
  },
@@ -2052,6 +2093,11 @@
2052
2093
  "name": "market",
2053
2094
  "writable": true
2054
2095
  },
2096
+ {
2097
+ "name": "pool",
2098
+ "writable": true,
2099
+ "optional": true
2100
+ },
2055
2101
  {
2056
2102
  "name": "system_program",
2057
2103
  "address": "11111111111111111111111111111111"
@@ -2555,8 +2601,18 @@
2555
2601
  },
2556
2602
  {
2557
2603
  "code": 6030,
2604
+ "name": "CurrentFastPoolMarketStillActive",
2605
+ "msg": "Current fast pool market still active"
2606
+ },
2607
+ {
2608
+ "code": 6031,
2558
2609
  "name": "MarketAlreadyAggregated",
2559
2610
  "msg": "Market already aggregated"
2611
+ },
2612
+ {
2613
+ "code": 6032,
2614
+ "name": "MarketAlreadyPaidOut",
2615
+ "msg": "Market already paid out"
2560
2616
  }
2561
2617
  ],
2562
2618
  "types": [
@@ -2674,10 +2730,6 @@
2674
2730
  {
2675
2731
  "name": "timestamp",
2676
2732
  "type": "i64"
2677
- },
2678
- {
2679
- "name": "version",
2680
- "type": "u64"
2681
2733
  }
2682
2734
  ]
2683
2735
  }
@@ -2728,8 +2780,10 @@
2728
2780
  "type": "pubkey"
2729
2781
  },
2730
2782
  {
2731
- "name": "version",
2732
- "type": "u64"
2783
+ "name": "padding_1",
2784
+ "type": {
2785
+ "array": ["u8", 8]
2786
+ }
2733
2787
  },
2734
2788
  {
2735
2789
  "name": "ts",
@@ -2892,6 +2946,10 @@
2892
2946
  "array": ["u8", 80]
2893
2947
  }
2894
2948
  }
2949
+ },
2950
+ {
2951
+ "name": "is_fast",
2952
+ "type": "bool"
2895
2953
  }
2896
2954
  ]
2897
2955
  }
@@ -2956,6 +3014,22 @@
2956
3014
  ]
2957
3015
  }
2958
3016
  },
3017
+ {
3018
+ "name": "MarketAskOrderArgs",
3019
+ "type": {
3020
+ "kind": "struct",
3021
+ "fields": [
3022
+ {
3023
+ "name": "shares",
3024
+ "type": "u64"
3025
+ },
3026
+ {
3027
+ "name": "bid_order_id",
3028
+ "type": "u64"
3029
+ }
3030
+ ]
3031
+ }
3032
+ },
2959
3033
  {
2960
3034
  "name": "MarketBidOrderArgs",
2961
3035
  "type": {
@@ -3152,10 +3226,8 @@
3152
3226
  "type": "i64"
3153
3227
  },
3154
3228
  {
3155
- "name": "padding_1",
3156
- "type": {
3157
- "array": ["u8", 8]
3158
- }
3229
+ "name": "resolved_ts",
3230
+ "type": "i64"
3159
3231
  },
3160
3232
  {
3161
3233
  "name": "next_order_id",
@@ -3220,8 +3292,10 @@
3220
3292
  "type": "u16"
3221
3293
  },
3222
3294
  {
3223
- "name": "version",
3224
- "type": "u64"
3295
+ "name": "padding_2",
3296
+ "type": {
3297
+ "array": ["u8", 8]
3298
+ }
3225
3299
  },
3226
3300
  {
3227
3301
  "name": "pool_id",
@@ -3297,8 +3371,10 @@
3297
3371
  "type": "u64"
3298
3372
  },
3299
3373
  {
3300
- "name": "version",
3301
- "type": "u64"
3374
+ "name": "padding_1",
3375
+ "type": {
3376
+ "array": ["u8", 8]
3377
+ }
3302
3378
  },
3303
3379
  {
3304
3380
  "name": "total_shares",
@@ -3580,10 +3656,18 @@
3580
3656
  "name": "authority",
3581
3657
  "type": "pubkey"
3582
3658
  },
3659
+ {
3660
+ "name": "is_fast",
3661
+ "type": "bool"
3662
+ },
3663
+ {
3664
+ "name": "is_fast_market_active",
3665
+ "type": "bool"
3666
+ },
3583
3667
  {
3584
3668
  "name": "padding",
3585
3669
  "type": {
3586
- "array": ["u8", 64]
3670
+ "array": ["u8", 62]
3587
3671
  }
3588
3672
  }
3589
3673
  ]
@@ -3595,7 +3679,7 @@
3595
3679
  "kind": "struct",
3596
3680
  "fields": [
3597
3681
  {
3598
- "name": "pool_id",
3682
+ "name": "id",
3599
3683
  "type": "u64"
3600
3684
  },
3601
3685
  {
@@ -3609,10 +3693,12 @@
3609
3693
  "type": "pubkey"
3610
3694
  },
3611
3695
  {
3612
- "name": "markets",
3613
- "type": {
3614
- "array": ["u64", 60]
3615
- }
3696
+ "name": "is_fast",
3697
+ "type": "bool"
3698
+ },
3699
+ {
3700
+ "name": "is_fast_market_active",
3701
+ "type": "bool"
3616
3702
  }
3617
3703
  ]
3618
3704
  }
@@ -3910,8 +3996,10 @@
3910
3996
  "type": "u64"
3911
3997
  },
3912
3998
  {
3913
- "name": "version",
3914
- "type": "u64"
3999
+ "name": "padding_1",
4000
+ "type": {
4001
+ "array": ["u8", 8]
4002
+ }
3915
4003
  },
3916
4004
  {
3917
4005
  "name": "orders",
@@ -1,4 +1,12 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
+ export type Pool = {
3
+ address: string;
4
+ id: number;
5
+ question: string;
6
+ authority: string;
7
+ isFast: boolean;
8
+ isFastMarketActive: boolean;
9
+ };
2
10
  export type Market = {
3
11
  address: string;
4
12
  bump: number;
@@ -13,6 +21,7 @@ export type Market = {
13
21
  volume: string;
14
22
  mint: string;
15
23
  updateTs: string;
24
+ resolvedTs: string;
16
25
  nextOrderId: string;
17
26
  feeBps: number;
18
27
  isAllowedToPayout: boolean;
@@ -27,7 +36,6 @@ export type Market = {
27
36
  marketLiquidityAtStart: string;
28
37
  payoutFee: number;
29
38
  customer: string;
30
- version: number;
31
39
  poolId: number;
32
40
  };
33
41
  export type UserTrade = {
@@ -62,7 +70,6 @@ export type Chest = {
62
70
  timer: number;
63
71
  isFinished: boolean;
64
72
  lastUser: string;
65
- version: number;
66
73
  ts: number;
67
74
  };
68
75
  export declare enum WinningDirection {
@@ -149,6 +156,7 @@ export type CreateMarketArgs = {
149
156
  payoutFee: number;
150
157
  mint: PublicKey;
151
158
  poolId?: number;
159
+ currentMarketId?: number;
152
160
  };
153
161
  export type CreatePoolArgs = {
154
162
  poolId: number;
@@ -163,6 +171,7 @@ export type CreatePoolArgs = {
163
171
  marketId: number;
164
172
  question: string;
165
173
  }[];
174
+ isFast?: boolean;
166
175
  };
167
176
  export type CancelBidOrderArgs = {
168
177
  marketId: number;
@@ -1897,21 +1897,25 @@ export type TriadProtocol = {
1897
1897
  writable: true;
1898
1898
  signer: true;
1899
1899
  },
1900
+ {
1901
+ name: 'market';
1902
+ writable: true;
1903
+ },
1900
1904
  {
1901
1905
  name: 'squads';
1902
1906
  writable: true;
1903
1907
  address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
1904
1908
  },
1905
1909
  {
1906
- name: 'sellerTrade';
1910
+ name: 'buyerAuthority';
1907
1911
  writable: true;
1908
1912
  },
1909
1913
  {
1910
- name: 'buyerTrade';
1914
+ name: 'sellerTrade';
1911
1915
  writable: true;
1912
1916
  },
1913
1917
  {
1914
- name: 'market';
1918
+ name: 'buyerTrade';
1915
1919
  writable: true;
1916
1920
  },
1917
1921
  {
@@ -1975,6 +1979,63 @@ export type TriadProtocol = {
1975
1979
  };
1976
1980
  };
1977
1981
  },
1982
+ {
1983
+ name: 'buyerAta';
1984
+ writable: true;
1985
+ pda: {
1986
+ seeds: [
1987
+ {
1988
+ kind: 'account';
1989
+ path: 'buyerAuthority';
1990
+ },
1991
+ {
1992
+ kind: 'account';
1993
+ path: 'tokenProgram';
1994
+ },
1995
+ {
1996
+ kind: 'account';
1997
+ path: 'mint';
1998
+ }
1999
+ ];
2000
+ program: {
2001
+ kind: 'const';
2002
+ value: [
2003
+ 140,
2004
+ 151,
2005
+ 37,
2006
+ 143,
2007
+ 78,
2008
+ 36,
2009
+ 137,
2010
+ 241,
2011
+ 187,
2012
+ 61,
2013
+ 16,
2014
+ 41,
2015
+ 20,
2016
+ 142,
2017
+ 13,
2018
+ 131,
2019
+ 11,
2020
+ 90,
2021
+ 19,
2022
+ 153,
2023
+ 218,
2024
+ 255,
2025
+ 16,
2026
+ 132,
2027
+ 4,
2028
+ 142,
2029
+ 123,
2030
+ 216,
2031
+ 219,
2032
+ 233,
2033
+ 248,
2034
+ 89
2035
+ ];
2036
+ };
2037
+ };
2038
+ },
1978
2039
  {
1979
2040
  name: 'marketAta';
1980
2041
  writable: true;
@@ -1991,7 +2052,16 @@ export type TriadProtocol = {
1991
2052
  address: '11111111111111111111111111111111';
1992
2053
  }
1993
2054
  ];
1994
- args: [];
2055
+ args: [
2056
+ {
2057
+ name: 'args';
2058
+ type: {
2059
+ defined: {
2060
+ name: 'marketAskOrderArgs';
2061
+ };
2062
+ };
2063
+ }
2064
+ ];
1995
2065
  },
1996
2066
  {
1997
2067
  name: 'marketBidOrder';
@@ -2031,10 +2101,6 @@ export type TriadProtocol = {
2031
2101
  name: 'buyerAta';
2032
2102
  writable: true;
2033
2103
  },
2034
- {
2035
- name: 'marketAta';
2036
- writable: true;
2037
- },
2038
2104
  {
2039
2105
  name: 'sellerAta';
2040
2106
  writable: true;
@@ -2092,6 +2158,10 @@ export type TriadProtocol = {
2092
2158
  };
2093
2159
  };
2094
2160
  },
2161
+ {
2162
+ name: 'marketAta';
2163
+ writable: true;
2164
+ },
2095
2165
  {
2096
2166
  name: 'tokenProgram';
2097
2167
  },
@@ -2952,6 +3022,11 @@ export type TriadProtocol = {
2952
3022
  name: 'market';
2953
3023
  writable: true;
2954
3024
  },
3025
+ {
3026
+ name: 'pool';
3027
+ writable: true;
3028
+ optional: true;
3029
+ },
2955
3030
  {
2956
3031
  name: 'systemProgram';
2957
3032
  address: '11111111111111111111111111111111';
@@ -3595,8 +3670,18 @@ export type TriadProtocol = {
3595
3670
  },
3596
3671
  {
3597
3672
  code: 6030;
3673
+ name: 'currentFastPoolMarketStillActive';
3674
+ msg: 'Current fast pool market still active';
3675
+ },
3676
+ {
3677
+ code: 6031;
3598
3678
  name: 'marketAlreadyAggregated';
3599
3679
  msg: 'Market already aggregated';
3680
+ },
3681
+ {
3682
+ code: 6032;
3683
+ name: 'marketAlreadyPaidOut';
3684
+ msg: 'Market already paid out';
3600
3685
  }
3601
3686
  ];
3602
3687
  types: [
@@ -3714,10 +3799,6 @@ export type TriadProtocol = {
3714
3799
  {
3715
3800
  name: 'timestamp';
3716
3801
  type: 'i64';
3717
- },
3718
- {
3719
- name: 'version';
3720
- type: 'u64';
3721
3802
  }
3722
3803
  ];
3723
3804
  };
@@ -3768,8 +3849,10 @@ export type TriadProtocol = {
3768
3849
  type: 'pubkey';
3769
3850
  },
3770
3851
  {
3771
- name: 'version';
3772
- type: 'u64';
3852
+ name: 'padding1';
3853
+ type: {
3854
+ array: ['u8', 8];
3855
+ };
3773
3856
  },
3774
3857
  {
3775
3858
  name: 'ts';
@@ -3932,6 +4015,10 @@ export type TriadProtocol = {
3932
4015
  array: ['u8', 80];
3933
4016
  };
3934
4017
  };
4018
+ },
4019
+ {
4020
+ name: 'isFast';
4021
+ type: 'bool';
3935
4022
  }
3936
4023
  ];
3937
4024
  };
@@ -3996,6 +4083,22 @@ export type TriadProtocol = {
3996
4083
  ];
3997
4084
  };
3998
4085
  },
4086
+ {
4087
+ name: 'marketAskOrderArgs';
4088
+ type: {
4089
+ kind: 'struct';
4090
+ fields: [
4091
+ {
4092
+ name: 'shares';
4093
+ type: 'u64';
4094
+ },
4095
+ {
4096
+ name: 'bidOrderId';
4097
+ type: 'u64';
4098
+ }
4099
+ ];
4100
+ };
4101
+ },
3999
4102
  {
4000
4103
  name: 'marketBidOrderArgs';
4001
4104
  type: {
@@ -4192,10 +4295,8 @@ export type TriadProtocol = {
4192
4295
  type: 'i64';
4193
4296
  },
4194
4297
  {
4195
- name: 'padding1';
4196
- type: {
4197
- array: ['u8', 8];
4198
- };
4298
+ name: 'resolvedTs';
4299
+ type: 'i64';
4199
4300
  },
4200
4301
  {
4201
4302
  name: 'nextOrderId';
@@ -4260,8 +4361,10 @@ export type TriadProtocol = {
4260
4361
  type: 'u16';
4261
4362
  },
4262
4363
  {
4263
- name: 'version';
4264
- type: 'u64';
4364
+ name: 'padding2';
4365
+ type: {
4366
+ array: ['u8', 8];
4367
+ };
4265
4368
  },
4266
4369
  {
4267
4370
  name: 'poolId';
@@ -4337,8 +4440,10 @@ export type TriadProtocol = {
4337
4440
  type: 'u64';
4338
4441
  },
4339
4442
  {
4340
- name: 'version';
4341
- type: 'u64';
4443
+ name: 'padding1';
4444
+ type: {
4445
+ array: ['u8', 8];
4446
+ };
4342
4447
  },
4343
4448
  {
4344
4449
  name: 'totalShares';
@@ -4620,10 +4725,18 @@ export type TriadProtocol = {
4620
4725
  name: 'authority';
4621
4726
  type: 'pubkey';
4622
4727
  },
4728
+ {
4729
+ name: 'isFast';
4730
+ type: 'bool';
4731
+ },
4732
+ {
4733
+ name: 'isFastMarketActive';
4734
+ type: 'bool';
4735
+ },
4623
4736
  {
4624
4737
  name: 'padding';
4625
4738
  type: {
4626
- array: ['u8', 64];
4739
+ array: ['u8', 62];
4627
4740
  };
4628
4741
  }
4629
4742
  ];
@@ -4635,7 +4748,7 @@ export type TriadProtocol = {
4635
4748
  kind: 'struct';
4636
4749
  fields: [
4637
4750
  {
4638
- name: 'poolId';
4751
+ name: 'id';
4639
4752
  type: 'u64';
4640
4753
  },
4641
4754
  {
@@ -4649,10 +4762,12 @@ export type TriadProtocol = {
4649
4762
  type: 'pubkey';
4650
4763
  },
4651
4764
  {
4652
- name: 'markets';
4653
- type: {
4654
- array: ['u64', 60];
4655
- };
4765
+ name: 'isFast';
4766
+ type: 'bool';
4767
+ },
4768
+ {
4769
+ name: 'isFastMarketActive';
4770
+ type: 'bool';
4656
4771
  }
4657
4772
  ];
4658
4773
  };
@@ -4950,8 +5065,10 @@ export type TriadProtocol = {
4950
5065
  type: 'u64';
4951
5066
  },
4952
5067
  {
4953
- name: 'version';
4954
- type: 'u64';
5068
+ name: 'padding1';
5069
+ type: {
5070
+ array: ['u8', 8];
5071
+ };
4955
5072
  },
4956
5073
  {
4957
5074
  name: 'orders';
@@ -1,5 +1,5 @@
1
1
  import { Stake, StakeVault } from './../types/stake';
2
- import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Chest } from '../types/trade';
2
+ import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Chest, Pool } from '../types/trade';
3
3
  import { PublicKey } from '@solana/web3.js';
4
4
  import { IdlAccounts } from '@coral-xyz/anchor';
5
5
  import { TriadProtocol } from '../types/triad_protocol';
@@ -7,6 +7,7 @@ export declare const encodeString: (value: string, alloc?: number) => number[];
7
7
  export declare const decodeString: (bytes: number[]) => string;
8
8
  export declare const formatStakeVault: (stakeVault: IdlAccounts<TriadProtocol>['stakeVault']) => StakeVault;
9
9
  export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV2']) => Stake;
10
+ export declare const formatPool: (account: IdlAccounts<TriadProtocol>['pool'], address: PublicKey) => Pool;
10
11
  export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
11
12
  export declare const formatUserTrade: (account: IdlAccounts<TriadProtocol>['userTrade'], publicKey: PublicKey) => UserTrade;
12
13
  export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['userTrade']['orders'][number], authority?: string) => Order;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatChest = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatChest = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatPool = 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
6
  const spl_token_1 = require("@solana/spl-token");
@@ -52,6 +52,17 @@ const formatStake = (stake) => {
52
52
  };
53
53
  };
54
54
  exports.formatStake = formatStake;
55
+ const formatPool = (account, address) => {
56
+ return {
57
+ address: address.toString(),
58
+ id: account.id.toNumber(),
59
+ question: Buffer.from(account.question).toString().replace(/\0+$/, ''),
60
+ authority: account.authority.toString(),
61
+ isFast: account.isFast,
62
+ isFastMarketActive: account.isFastMarketActive
63
+ };
64
+ };
65
+ exports.formatPool = formatPool;
55
66
  const formatMarket = (account, address) => {
56
67
  return {
57
68
  bump: account.bump,
@@ -67,6 +78,7 @@ const formatMarket = (account, address) => {
67
78
  volume: account.volume.toString(),
68
79
  mint: account.mint.toString(),
69
80
  updateTs: account.updateTs.toString(),
81
+ resolvedTs: account.resolvedTs.toString(),
70
82
  nextOrderId: account.nextOrderId.toString(),
71
83
  feeBps: account.feeBps,
72
84
  isAllowedToPayout: account.isAllowedToPayout,
@@ -83,7 +95,6 @@ const formatMarket = (account, address) => {
83
95
  : '0',
84
96
  payoutFee: account.payoutFee,
85
97
  customer: account.customerId === 0 ? 'Triad' : account.customerId.toString(),
86
- version: account.version.toNumber(),
87
98
  poolId: account.poolId.toNumber()
88
99
  };
89
100
  };
@@ -129,7 +140,6 @@ const formatChest = (chest) => {
129
140
  timer: chest.timer.toNumber(),
130
141
  isFinished: chest.isFinished,
131
142
  lastUser: chest.lastUser.toString(),
132
- version: chest.version.toNumber(),
133
143
  ts: chest.ts.toNumber()
134
144
  };
135
145
  };
@@ -138,7 +148,7 @@ const calculateStakeRewards = (stake) => {
138
148
  if (stake.withdrawTs !== 0)
139
149
  return 0;
140
150
  const maxRank = 1633;
141
- const rank = 639;
151
+ const rank = 369;
142
152
  const rankWeight = (maxRank - rank + 1) / maxRank;
143
153
  const userStakedAmount = stake.mint === constants_1.TRD_MINT.toBase58()
144
154
  ? stake.amount
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.2.7-beta",
3
+ "version": "2.2.9-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -31,18 +31,16 @@
31
31
  "license": "ISC",
32
32
  "dependencies": {
33
33
  "@coral-xyz/anchor": "0.30.1",
34
- "@shadow-drive/sdk": "^6.0.0",
35
34
  "@solana/spl-token": "0.4.8",
36
- "@solana/web3.js": "^1.95.3",
37
- "axios": "^1.5.1",
38
- "base64-js": "^1.5.1",
39
- "bn.js": "^5.2.1",
40
- "bs58": "5.0.0",
41
- "uuid": "^9.0.1"
35
+ "@solana/web3.js": "1.95.3",
36
+ "axios": "1.9.0",
37
+ "bn.js": "5.2.2",
38
+ "bs58": "6.0.0"
42
39
  },
43
40
  "devDependencies": {
44
41
  "@typescript-eslint/eslint-plugin": "6.7.3",
45
42
  "@typescript-eslint/parser": "6.7.3",
43
+ "@types/bn.js": "^5.1.0",
46
44
  "eslint": "8.50.0",
47
45
  "eslint-config-prettier": "9.0.0",
48
46
  "eslint-plugin-prettier": "5.0.0",