@triadxyz/triad-protocol 3.1.0-beta → 3.1.2-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/index.d.ts CHANGED
@@ -1,125 +1,103 @@
1
- import { Connection, PublicKey, TransactionInstruction, Commitment } from '@solana/web3.js';
1
+ import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
2
2
  import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
3
3
  import BN from 'bn.js';
4
4
  import { TriadProtocol } from './types/triad_protocol';
5
- import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, UpdateCustomerFeeArgs, OrderDirection } from './types';
5
+ import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CollectMarketFeeArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, OrderDirection } from './types';
6
6
  import Stake from './stake';
7
7
  import Poseidon from './poseidon';
8
8
  export * from './types';
9
- export * from './types/stake';
10
- export * from './types/poseidon';
11
9
  export * from './utils/helpers';
12
10
  export default class TriadProtocolClient {
11
+ private connection;
12
+ private wallet;
13
+ private rpcOptions;
13
14
  program: Program<TriadProtocol>;
14
15
  provider: AnchorProvider;
15
16
  stake: Stake;
16
17
  poseidon: Poseidon;
17
- decimals: number;
18
- constructor(connection: Connection, wallet: Wallet, commitment?: Commitment);
18
+ constructor(connection: Connection, wallet: Wallet, rpcOptions: RpcOptions);
19
19
  /**
20
20
  * Get All Pools
21
- *
22
21
  */
23
22
  getAllPools(): Promise<import("./types").Pool[]>;
24
23
  /**
25
24
  * Get All Markets
26
- *
27
25
  */
28
26
  getAllMarkets(): Promise<import("./types").Market[]>;
29
27
  /**
30
28
  * Get My User Trades from a user authority
31
29
  * @param wallet - User wallet PublicKey
32
- *
33
30
  */
34
31
  getMyUserTrades(wallet: PublicKey): Promise<UserTrade[]>;
35
32
  /**
36
33
  * Get User Orders
37
34
  * @param wallet - User wallet PublicKey
38
- *
39
35
  */
40
36
  getUserOrders(wallet: PublicKey): Promise<import("./types").Order[]>;
41
37
  /**
42
38
  * Get User Orders By Market ID
43
39
  * @param wallet - User wallet PublicKey
44
40
  * @param marketId - The ID of the market
45
- *
46
41
  */
47
42
  getUserOrdersByMarketId(wallet: PublicKey, marketId: number): Promise<import("./types").Order[]>;
48
43
  /**
49
44
  * Get User Book Orders
50
- *
51
45
  */
52
46
  getUserBookOrders(wallet: PublicKey, marketId: number): Promise<BookOrder[]>;
53
47
  /**
54
48
  * Get Pool By ID
55
49
  * @param poolId - The ID of the pool
56
- *
57
50
  */
58
51
  getPoolById(poolId: number): Promise<import("./types").Pool>;
59
52
  /**
60
53
  * Get Market By ID
61
54
  * @param marketId - The ID of the market
62
- *
63
55
  */
64
56
  getMarketById(marketId: number): Promise<import("./types").Market>;
65
57
  /**
66
58
  * Get Market By Address
67
59
  * @param marketAddress - The address of the market
68
- *
69
60
  */
70
61
  getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
71
62
  /**
72
63
  * Get Costumer By Wallet Address
73
64
  * @param wallet - The wallet address of the customer
74
- *
75
65
  */
76
66
  getCustomerByWallet(wallet: PublicKey): Promise<import("./types").Customer>;
77
67
  /**
78
68
  * Get Customer By ID
79
69
  * @param customerId - The ID of the customer
80
- *
81
70
  */
82
71
  getCustomerById(customerId: number): Promise<import("./types").Customer>;
83
- /**
84
- * Get Refer By Wallet Address
85
- * @param wallet - The wallet address of the refer
86
- *
87
- */
88
- getReferByWallet(wallet: PublicKey): Promise<import("./types").Refer>;
89
72
  /**
90
73
  * Get Current Market ID
91
- *
92
74
  */
93
75
  nextMarketId(): Promise<number>;
94
76
  /**
95
77
  * Get Next Customer ID
96
- *
97
78
  */
98
79
  nextCustomerId(): Promise<number>;
99
80
  /**
100
81
  * Get Next Pool ID
101
- *
102
82
  */
103
83
  nextPoolId(): Promise<number>;
104
84
  /**
105
85
  * Get User Trade PDA
106
86
  * @param wallet - User wallet PublicKey
107
87
  * @param userNonce - The nonce of the user
108
- *
109
88
  */
110
89
  getUserPDA(wallet: PublicKey, userNonce?: number): PublicKey;
111
90
  /**
112
91
  * Get User Trade
113
92
  * @param wallet - User wallet PublicKey
114
93
  * @param userNonce - The nonce of the user
115
- *
116
94
  */
117
95
  getUserTrade(wallet: PublicKey, userNonce?: number): Promise<{
118
96
  bump: number;
119
97
  authority: PublicKey;
120
98
  totalDeposits: BN;
121
99
  totalWithdraws: BN;
122
- referId: BN;
100
+ padding1: number[];
123
101
  orders: {
124
102
  ts: BN;
125
103
  orderId: BN;
@@ -218,26 +196,24 @@ export default class TriadProtocolClient {
218
196
  }>;
219
197
  /**
220
198
  * Create Market
221
- * @param args.marketId - new markert id - length + 1
222
- * @param args.startTime - start time
223
- * @param args.endTime - end time
224
- * @param args.question - question (max 80 characters)
225
- * @param args.liquidityAtStart - liquidity at start
226
- * @param args.payoutFee - payout fee (to add affiliate system)
227
- *
228
- * @param options - RPC options
229
- *
230
- */
231
- createMarket({ markets, customer, mint, poolId }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
199
+ * @param args.markets - Array of markets to create
200
+ * @param args.markets.marketId - Market ID
201
+ * @param args.markets.startTime - start time
202
+ * @param args.markets.endTime - end time
203
+ * @param args.markets.question - question (max 80 characters)
204
+ * @param args.markets.liquidityAtStart - liquidity at start
205
+ * @param args.markets.payoutFee - payout fee (to add affiliate system)
206
+ * @param args.customer - The customer of the market
207
+ * @param args.poolId - The ID of the pool
208
+ */
209
+ createMarket({ markets, customer, poolId }: CreateMarketArgs): Promise<string>;
232
210
  /**
233
211
  * Create Pool
234
212
  * @param poolId - The ID of the pool
235
213
  * @param question - The question of the pool
236
214
  * @param markets - The markets of the pool
237
- *
238
- * @param options - RPC options
239
215
  */
240
- createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
216
+ createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs): Promise<string>;
241
217
  /**
242
218
  * Open Order
243
219
  * @param args.marketId - The ID of the Market
@@ -245,34 +221,26 @@ export default class TriadProtocolClient {
245
221
  * @param args.direction - The direction of the Order
246
222
  * @param args.mint - The mint of the Order
247
223
  * @param args.token - The token to use for the Order
248
- *
249
- * @param options - RPC options
250
- *
251
224
  */
252
- openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs, options?: RpcOptions): Promise<string>;
225
+ openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs): Promise<string>;
253
226
  /**
254
227
  * Close Order
255
228
  * @param args.marketId - The ID of the Market
256
229
  * @param args.orderId - The ID of the Order
257
230
  * @param args.userNonce - The nonce of the user
258
- *
259
- * @param options - RPC options
260
- *
261
231
  */
262
232
  closeOrder({ marketId, orderId, userNonce }: {
263
233
  marketId: number;
264
234
  orderId: number;
265
235
  userNonce: number;
266
- }, options?: RpcOptions): Promise<string>;
236
+ }): Promise<string>;
267
237
  /**
268
238
  * Resolve Market
269
239
  * @param args.marketId - The ID of the Market
240
+ * @param args.poolId - The ID of the Pool
270
241
  * @param args.winningDirection - The Winning Direction of the Market
271
- *
272
- * @param options - RPC options
273
- *
274
242
  */
275
- resolveMarket({ marketId, poolId, winningDirection }: {
243
+ updateMarketWinningDirection({ marketId, poolId, winningDirection }: {
276
244
  marketId: number;
277
245
  poolId?: number;
278
246
  winningDirection: {
@@ -284,88 +252,74 @@ export default class TriadProtocolClient {
284
252
  } | {
285
253
  draw: {};
286
254
  };
287
- }, options?: RpcOptions): Promise<string>;
255
+ }): Promise<string>;
288
256
  /**
289
257
  * Collect Remaining Liquidity
290
258
  * @param marketId - The ID of the market
291
- *
292
- * @param options - RPC options
293
- *
294
259
  */
295
- collectRemainingLiquidity(marketId: number, options?: RpcOptions): Promise<string>;
260
+ collectRemainingLiquidity(marketId: number): Promise<string>;
296
261
  /**
297
262
  * Payout Order
298
263
  * @param args.marketId - The ID of the Market
299
264
  * @param args.orderId - The ID of the Order to Payout
300
265
  * @param args.userNonce - The nonce of the user
301
- * @param args.isTrdPayout - Whether to payout in TRD or not
302
- *
303
- * @param options - RPC options
304
- *
266
+ * @param args.mint - The mint of the market
305
267
  */
306
268
  payoutOrder(orders: {
307
269
  marketId: number;
308
270
  orderId: number;
309
271
  userNonce: number;
310
272
  mint: PublicKey;
311
- shares: number;
312
- isTrdPayout: boolean;
313
- isWinner: boolean;
314
- }[], options?: RpcOptions): Promise<string>;
273
+ }[]): Promise<string>;
315
274
  /**
316
- * Allow Market to Payout
275
+ * Update Market Payout
317
276
  * @param marketId - The ID of the market
318
277
  * @param poolId - The ID of the pool
319
- *
320
- * @param options - RPC options
321
- *
278
+ * @param allowPayout - Whether to allow the market to payout
322
279
  */
323
- allowMarketToPayout({ marketId, poolId }: {
280
+ updateMarketPayout({ marketId, poolId, allowPayout }: {
324
281
  marketId: number;
325
282
  poolId?: number;
326
- }, options?: RpcOptions): Promise<string>;
283
+ allowPayout: boolean;
284
+ }): Promise<string>;
327
285
  /**
328
286
  * Create Sub User Trade
329
287
  * @param user - User PublicKey the main user
330
- *
331
- * @param options - RPC options
332
- *
333
288
  */
334
- createSubUserTrade(user: PublicKey, options?: RpcOptions): Promise<string>;
289
+ createSubUserTrade(user: PublicKey): Promise<string>;
335
290
  /**
336
- * Update Market
291
+ * Update Market End
337
292
  * @param marketId - The ID of the market
338
293
  * @param marketEnd - The end time of the market
339
- *
340
- * @param options - RPC options
341
- *
342
294
  */
343
- updateMarket({ marketId, marketEnd, poolId }: {
295
+ updateMarketEnd({ marketId, marketEnd }: {
344
296
  marketId: number;
345
297
  marketEnd: number;
346
- poolId?: number;
347
- }, options?: RpcOptions): Promise<string>;
298
+ }): Promise<string>;
299
+ /**
300
+ * Update Market Question
301
+ * @param marketId - The ID of the market
302
+ * @param question - The question of the market
303
+ */
304
+ updateMarketQuestion({ marketId, question }: {
305
+ marketId: number;
306
+ question: string;
307
+ }): Promise<string>;
348
308
  /**
349
309
  * Create Customer
350
310
  * @param args.id - The ID of the customer
351
311
  * @param args.name - The name of the customer
352
312
  * @param args.authority - The authority of the customer
353
313
  * @param args.feeRecipient - The fee recipient of the customer
354
- *
355
- * @param options - RPC options
356
- *
357
314
  */
358
- createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs, options?: RpcOptions): Promise<string>;
315
+ createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs): Promise<string>;
359
316
  /**
360
317
  * Get User Trade Nonce With Slots
361
318
  * @param userTrades - User Trades
362
- *
363
319
  */
364
320
  getUserTradeNonceWithSlots(userTrades: UserTrade[]): PublicKey;
365
321
  /**
366
322
  * Get User Trade Ixs
367
- * @param refer - The refer public key
368
- *
369
323
  */
370
324
  getUserTradeIxs(): Promise<{
371
325
  userTradePDA: PublicKey;
@@ -379,85 +333,73 @@ export default class TriadProtocolClient {
379
333
  /**
380
334
  * Get User Trade Nonce
381
335
  * @param marketId - The ID of the Market
382
- * @param direction - The direction of the Order
383
- *
336
+ * @param orderDirection - The direction of the Order
384
337
  */
385
- getUserTradeNonce(marketId: number, direction: OrderDirection): Promise<{
338
+ getUserTradeNonce(marketId: number, orderDirection: OrderDirection): Promise<{
386
339
  userTradePDA: PublicKey;
387
340
  userTradeIxs: TransactionInstruction[];
388
341
  }>;
389
342
  /**
390
343
  * Place Bid Order
391
344
  * @param args.marketId - The ID of the Market
392
- * @param args.amount - The amount of the Order
393
- * @param args.direction - The direction of the Order
345
+ * @param args.orders - Array of orders to execute
346
+ * @param args.orders.amount - The amount of the Order
347
+ * @param args.orders.price - The price of the Order
348
+ * @param args.orders.orderDirection - The direction of the Order
394
349
  * @param args.mint - The mint of the Order
395
- * @param args.price - The price of the Order
396
350
  * @param args.isTrdPayout - Whether to payout in TRD or not
397
- *
398
- * @param options - RPC options
399
351
  */
400
- placeBidOrder({ marketId, orders, mint, isTrdPayout }: PlaceBidOrderArgs, options?: RpcOptions): Promise<string>;
352
+ placeBidOrder({ marketId, orders, isTrdPayout }: PlaceBidOrderArgs): Promise<string>;
401
353
  /**
402
354
  * Place Ask Order
403
355
  * @param args.marketId - The ID of the Market
404
- * @param args.amount - The amount of the Order
405
- * @param args.direction - The direction of the Order
406
- * @param args.price - The price of the Order
407
- * @param args.bidOrderId - The ID of the Bid Order
408
- * @param args.bidNonce - The nonce of the Bid Order
409
- *
410
- * @param options - RPC options
411
- *
356
+ * @param args.orders - Array of orders to execute
357
+ * @param args.orders.amount - The amount of the Order
358
+ * @param args.orders.price - The price of the Order
359
+ * @param args.orders.bidOrderId - The ID of the Bid Order
360
+ * @param args.orders.bidNonce - The nonce of the Bid Order
412
361
  */
413
- placeAskOrder({ marketId, orders }: PlaceAskOrderArgs, options?: RpcOptions): Promise<string>;
362
+ placeAskOrder({ marketId, orders }: PlaceAskOrderArgs): Promise<string>;
414
363
  /**
415
364
  * Cancel Bid Order
416
365
  * @param args.marketId - The ID of the Market
417
- * @param args.orderId - The ID of the Order
418
- * @param args.userNonce - The nonce of the user
419
- * @param args.direction - The direction of the Order
420
- *
421
- * @param options - RPC options
366
+ * @param args.orders.orderId - The ID of the Order
367
+ * @param args.orders.userNonce - The nonce of the user
368
+ * @param args.orders.orderDirection - The direction of the Order
422
369
  */
423
- cancelBidOrder({ marketId, orders, mint }: CancelBidOrderArgs, options?: RpcOptions): Promise<string>;
370
+ cancelBidOrder({ marketId, orders }: CancelBidOrderArgs): Promise<string>;
424
371
  /**
425
372
  * Cancel Ask Order
426
373
  * @param args.marketId - The ID of the Market
427
- * @param args.orderId - The ID of the Order
428
- * @param args.userNonce - The nonce of the user
429
- * @param args.userNonceBidOrder - The nonce of the bid user
430
- * @param args.direction - The direction of the Order
431
- *
432
- * @param options - RPC options
374
+ * @param args.orders.orderId - The ID of the Order
375
+ * @param args.orders.userNonce - The nonce of the user
376
+ * @param args.orders.orderDirection - The direction of the Order
433
377
  */
434
- cancelAskOrder({ marketId, orders }: CancelAskOrderArgs, options?: RpcOptions): Promise<string>;
378
+ cancelAskOrder({ marketId, orders }: CancelAskOrderArgs): Promise<string>;
435
379
  /**
436
380
  * Market Bid Order
437
381
  * @param args.marketId - The ID of the Market
438
382
  * @param args.amount - The amount of the Order
439
- * @param args.direction - The direction of the Order
440
- * @param args.mint - The mint of the Order
383
+ * @param args.orderDirection - The direction of the Order
441
384
  * @param args.feeBps - The fee in basis points
442
385
  * @param args.isTrdPayout - Whether to payout in TRD or not
443
- *
444
- * @param options - RPC options
445
386
  */
446
- marketBidOrder({ marketId, amount, direction, mint, feeBps, isTrdPayout }: MarketBidOrderArgs, options?: RpcOptions): Promise<string>;
387
+ marketBidOrder({ marketId, amount, orderDirection, feeBps, isTrdPayout }: MarketBidOrderArgs): Promise<string>;
447
388
  /**
448
389
  * Market Ask Order
449
390
  * @param args.marketId - The ID of the Market
450
391
  * @param args.orders - Array of orders to execute
451
- * @param args.direction - The direction of the Order
392
+ * @param args.orders.shares - The amount of shares to sell
393
+ * @param args.orders.bidOrderId - The ID of the Bid Order
394
+ * @param args.orders.userNonce - The nonce of the user
395
+ * @param args.orderDirection - The direction of the Order
452
396
  * @param args.isTrdPayout - Whether to payout in TRD or not
453
- *
454
- * @param options - RPC options
397
+ * @param args.feeBps - The fee in basis points
455
398
  */
456
- marketAskOrder({ marketId, orders, direction, isTrdPayout, feeBps }: MarketAskOrderArgs, options?: RpcOptions): Promise<string>;
399
+ marketAskOrder({ marketId, orders, orderDirection, isTrdPayout, feeBps }: MarketAskOrderArgs): Promise<string>;
457
400
  /**
458
401
  * Get Orders By Market ID
459
- * @param marketId - The ID of the market
460
- *
402
+ * @param marketId - Market ID
461
403
  */
462
404
  getOrderBook(marketId: number): Promise<{
463
405
  marketId: number;
@@ -476,39 +418,14 @@ export default class TriadProtocolClient {
476
418
  /**
477
419
  * Collect Market Fee
478
420
  * @param args.markets - The markets to collect the fee from
479
- * @param args.markets.mint - The mint of the market
480
421
  * @param args.markets.marketAddress - The address of the market
481
422
  * @param args.markets.customerId - The ID of the customer
482
423
  * @param args.markets.customerFeeRecipient - The address of the customer fee recipient
483
- *
484
- * @param options - RPC options
485
424
  */
486
- collectMarketFee(markets: {
487
- mint: PublicKey;
488
- marketAddress: PublicKey;
489
- customerId: number;
490
- customerFeeRecipient: PublicKey;
491
- }[], options?: RpcOptions): Promise<string>;
425
+ collectMarketFee({ markets }: CollectMarketFeeArgs): Promise<string>;
492
426
  /**
493
427
  * Close Order Book
494
- * @param marketId - The ID of the market
495
- *
496
- * @param options - RPC options
497
- */
498
- closeOrderBook(marketIds: number[], options?: RpcOptions): Promise<string>;
499
- /**
500
- * Create Refer
501
- * @param id - The ID of the refer
502
- *
503
- * @param options - RPC options
504
- */
505
- createRefer(options?: RpcOptions): Promise<string>;
506
- /**
507
- * Update Customer Fee
508
- * @param feeBps - The fee in basis points
509
- * @param wallet - The wallet of the customer to update the fee for
510
- *
511
- * @param options - RPC options
428
+ * @param marketIds - Market IDs
512
429
  */
513
- updateCustomerFee({ feeBps, wallet }: UpdateCustomerFeeArgs, options?: RpcOptions): Promise<string>;
430
+ closeOrderBook(marketIds: number[]): Promise<string>;
514
431
  }