@triadxyz/triad-protocol 3.1.1-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,112 +1,96 @@
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
72
  /**
84
73
  * Get Current Market ID
85
- *
86
74
  */
87
75
  nextMarketId(): Promise<number>;
88
76
  /**
89
77
  * Get Next Customer ID
90
- *
91
78
  */
92
79
  nextCustomerId(): Promise<number>;
93
80
  /**
94
81
  * Get Next Pool ID
95
- *
96
82
  */
97
83
  nextPoolId(): Promise<number>;
98
84
  /**
99
85
  * Get User Trade PDA
100
86
  * @param wallet - User wallet PublicKey
101
87
  * @param userNonce - The nonce of the user
102
- *
103
88
  */
104
89
  getUserPDA(wallet: PublicKey, userNonce?: number): PublicKey;
105
90
  /**
106
91
  * Get User Trade
107
92
  * @param wallet - User wallet PublicKey
108
93
  * @param userNonce - The nonce of the user
109
- *
110
94
  */
111
95
  getUserTrade(wallet: PublicKey, userNonce?: number): Promise<{
112
96
  bump: number;
@@ -212,26 +196,24 @@ export default class TriadProtocolClient {
212
196
  }>;
213
197
  /**
214
198
  * Create Market
215
- * @param args.marketId - new markert id - length + 1
216
- * @param args.startTime - start time
217
- * @param args.endTime - end time
218
- * @param args.question - question (max 80 characters)
219
- * @param args.liquidityAtStart - liquidity at start
220
- * @param args.payoutFee - payout fee (to add affiliate system)
221
- *
222
- * @param options - RPC options
223
- *
224
- */
225
- 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>;
226
210
  /**
227
211
  * Create Pool
228
212
  * @param poolId - The ID of the pool
229
213
  * @param question - The question of the pool
230
214
  * @param markets - The markets of the pool
231
- *
232
- * @param options - RPC options
233
215
  */
234
- 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>;
235
217
  /**
236
218
  * Open Order
237
219
  * @param args.marketId - The ID of the Market
@@ -239,34 +221,26 @@ export default class TriadProtocolClient {
239
221
  * @param args.direction - The direction of the Order
240
222
  * @param args.mint - The mint of the Order
241
223
  * @param args.token - The token to use for the Order
242
- *
243
- * @param options - RPC options
244
- *
245
224
  */
246
- openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs, options?: RpcOptions): Promise<string>;
225
+ openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs): Promise<string>;
247
226
  /**
248
227
  * Close Order
249
228
  * @param args.marketId - The ID of the Market
250
229
  * @param args.orderId - The ID of the Order
251
230
  * @param args.userNonce - The nonce of the user
252
- *
253
- * @param options - RPC options
254
- *
255
231
  */
256
232
  closeOrder({ marketId, orderId, userNonce }: {
257
233
  marketId: number;
258
234
  orderId: number;
259
235
  userNonce: number;
260
- }, options?: RpcOptions): Promise<string>;
236
+ }): Promise<string>;
261
237
  /**
262
238
  * Resolve Market
263
239
  * @param args.marketId - The ID of the Market
240
+ * @param args.poolId - The ID of the Pool
264
241
  * @param args.winningDirection - The Winning Direction of the Market
265
- *
266
- * @param options - RPC options
267
- *
268
242
  */
269
- resolveMarket({ marketId, poolId, winningDirection }: {
243
+ updateMarketWinningDirection({ marketId, poolId, winningDirection }: {
270
244
  marketId: number;
271
245
  poolId?: number;
272
246
  winningDirection: {
@@ -278,86 +252,74 @@ export default class TriadProtocolClient {
278
252
  } | {
279
253
  draw: {};
280
254
  };
281
- }, options?: RpcOptions): Promise<string>;
255
+ }): Promise<string>;
282
256
  /**
283
257
  * Collect Remaining Liquidity
284
258
  * @param marketId - The ID of the market
285
- *
286
- * @param options - RPC options
287
- *
288
259
  */
289
- collectRemainingLiquidity(marketId: number, options?: RpcOptions): Promise<string>;
260
+ collectRemainingLiquidity(marketId: number): Promise<string>;
290
261
  /**
291
262
  * Payout Order
292
263
  * @param args.marketId - The ID of the Market
293
264
  * @param args.orderId - The ID of the Order to Payout
294
265
  * @param args.userNonce - The nonce of the user
295
266
  * @param args.mint - The mint of the market
296
- * @param args.shares - The shares of the order
297
- *
298
- * @param options - RPC options
299
- *
300
267
  */
301
268
  payoutOrder(orders: {
302
269
  marketId: number;
303
270
  orderId: number;
304
271
  userNonce: number;
305
272
  mint: PublicKey;
306
- shares: number;
307
- }[], options?: RpcOptions): Promise<string>;
273
+ }[]): Promise<string>;
308
274
  /**
309
- * Allow Market to Payout
275
+ * Update Market Payout
310
276
  * @param marketId - The ID of the market
311
277
  * @param poolId - The ID of the pool
312
- *
313
- * @param options - RPC options
314
- *
278
+ * @param allowPayout - Whether to allow the market to payout
315
279
  */
316
- allowMarketToPayout({ marketId, poolId }: {
280
+ updateMarketPayout({ marketId, poolId, allowPayout }: {
317
281
  marketId: number;
318
282
  poolId?: number;
319
- }, options?: RpcOptions): Promise<string>;
283
+ allowPayout: boolean;
284
+ }): Promise<string>;
320
285
  /**
321
286
  * Create Sub User Trade
322
287
  * @param user - User PublicKey the main user
323
- *
324
- * @param options - RPC options
325
- *
326
288
  */
327
- createSubUserTrade(user: PublicKey, options?: RpcOptions): Promise<string>;
289
+ createSubUserTrade(user: PublicKey): Promise<string>;
328
290
  /**
329
- * Update Market
291
+ * Update Market End
330
292
  * @param marketId - The ID of the market
331
293
  * @param marketEnd - The end time of the market
332
- *
333
- * @param options - RPC options
334
- *
335
294
  */
336
- updateMarket({ marketId, marketEnd, poolId }: {
295
+ updateMarketEnd({ marketId, marketEnd }: {
337
296
  marketId: number;
338
297
  marketEnd: number;
339
- poolId?: number;
340
- }, 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>;
341
308
  /**
342
309
  * Create Customer
343
310
  * @param args.id - The ID of the customer
344
311
  * @param args.name - The name of the customer
345
312
  * @param args.authority - The authority of the customer
346
313
  * @param args.feeRecipient - The fee recipient of the customer
347
- *
348
- * @param options - RPC options
349
- *
350
314
  */
351
- createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs, options?: RpcOptions): Promise<string>;
315
+ createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs): Promise<string>;
352
316
  /**
353
317
  * Get User Trade Nonce With Slots
354
318
  * @param userTrades - User Trades
355
- *
356
319
  */
357
320
  getUserTradeNonceWithSlots(userTrades: UserTrade[]): PublicKey;
358
321
  /**
359
322
  * Get User Trade Ixs
360
- *
361
323
  */
362
324
  getUserTradeIxs(): Promise<{
363
325
  userTradePDA: PublicKey;
@@ -371,85 +333,73 @@ export default class TriadProtocolClient {
371
333
  /**
372
334
  * Get User Trade Nonce
373
335
  * @param marketId - The ID of the Market
374
- * @param direction - The direction of the Order
375
- *
336
+ * @param orderDirection - The direction of the Order
376
337
  */
377
- getUserTradeNonce(marketId: number, direction: OrderDirection): Promise<{
338
+ getUserTradeNonce(marketId: number, orderDirection: OrderDirection): Promise<{
378
339
  userTradePDA: PublicKey;
379
340
  userTradeIxs: TransactionInstruction[];
380
341
  }>;
381
342
  /**
382
343
  * Place Bid Order
383
344
  * @param args.marketId - The ID of the Market
384
- * @param args.amount - The amount of the Order
385
- * @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
386
349
  * @param args.mint - The mint of the Order
387
- * @param args.price - The price of the Order
388
350
  * @param args.isTrdPayout - Whether to payout in TRD or not
389
- *
390
- * @param options - RPC options
391
351
  */
392
- placeBidOrder({ marketId, orders, mint, isTrdPayout }: PlaceBidOrderArgs, options?: RpcOptions): Promise<string>;
352
+ placeBidOrder({ marketId, orders, isTrdPayout }: PlaceBidOrderArgs): Promise<string>;
393
353
  /**
394
354
  * Place Ask Order
395
355
  * @param args.marketId - The ID of the Market
396
- * @param args.amount - The amount of the Order
397
- * @param args.direction - The direction of the Order
398
- * @param args.price - The price of the Order
399
- * @param args.bidOrderId - The ID of the Bid Order
400
- * @param args.bidNonce - The nonce of the Bid Order
401
- *
402
- * @param options - RPC options
403
- *
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
404
361
  */
405
- placeAskOrder({ marketId, orders }: PlaceAskOrderArgs, options?: RpcOptions): Promise<string>;
362
+ placeAskOrder({ marketId, orders }: PlaceAskOrderArgs): Promise<string>;
406
363
  /**
407
364
  * Cancel Bid Order
408
365
  * @param args.marketId - The ID of the Market
409
- * @param args.orderId - The ID of the Order
410
- * @param args.userNonce - The nonce of the user
411
- * @param args.direction - The direction of the Order
412
- *
413
- * @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
414
369
  */
415
- cancelBidOrder({ marketId, orders, mint }: CancelBidOrderArgs, options?: RpcOptions): Promise<string>;
370
+ cancelBidOrder({ marketId, orders }: CancelBidOrderArgs): Promise<string>;
416
371
  /**
417
372
  * Cancel Ask Order
418
373
  * @param args.marketId - The ID of the Market
419
- * @param args.orderId - The ID of the Order
420
- * @param args.userNonce - The nonce of the user
421
- * @param args.userNonceBidOrder - The nonce of the bid user
422
- * @param args.direction - The direction of the Order
423
- *
424
- * @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
425
377
  */
426
- cancelAskOrder({ marketId, orders }: CancelAskOrderArgs, options?: RpcOptions): Promise<string>;
378
+ cancelAskOrder({ marketId, orders }: CancelAskOrderArgs): Promise<string>;
427
379
  /**
428
380
  * Market Bid Order
429
381
  * @param args.marketId - The ID of the Market
430
382
  * @param args.amount - The amount of the Order
431
- * @param args.direction - The direction of the Order
432
- * @param args.mint - The mint of the Order
383
+ * @param args.orderDirection - The direction of the Order
433
384
  * @param args.feeBps - The fee in basis points
434
385
  * @param args.isTrdPayout - Whether to payout in TRD or not
435
- *
436
- * @param options - RPC options
437
386
  */
438
- marketBidOrder({ marketId, amount, direction, mint, feeBps, isTrdPayout }: MarketBidOrderArgs, options?: RpcOptions): Promise<string>;
387
+ marketBidOrder({ marketId, amount, orderDirection, feeBps, isTrdPayout }: MarketBidOrderArgs): Promise<string>;
439
388
  /**
440
389
  * Market Ask Order
441
390
  * @param args.marketId - The ID of the Market
442
391
  * @param args.orders - Array of orders to execute
443
- * @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
444
396
  * @param args.isTrdPayout - Whether to payout in TRD or not
445
- *
446
- * @param options - RPC options
397
+ * @param args.feeBps - The fee in basis points
447
398
  */
448
- marketAskOrder({ marketId, orders, direction, isTrdPayout, feeBps }: MarketAskOrderArgs, options?: RpcOptions): Promise<string>;
399
+ marketAskOrder({ marketId, orders, orderDirection, isTrdPayout, feeBps }: MarketAskOrderArgs): Promise<string>;
449
400
  /**
450
401
  * Get Orders By Market ID
451
- * @param marketId - The ID of the market
452
- *
402
+ * @param marketId - Market ID
453
403
  */
454
404
  getOrderBook(marketId: number): Promise<{
455
405
  marketId: number;
@@ -468,32 +418,14 @@ export default class TriadProtocolClient {
468
418
  /**
469
419
  * Collect Market Fee
470
420
  * @param args.markets - The markets to collect the fee from
471
- * @param args.markets.mint - The mint of the market
472
421
  * @param args.markets.marketAddress - The address of the market
473
422
  * @param args.markets.customerId - The ID of the customer
474
423
  * @param args.markets.customerFeeRecipient - The address of the customer fee recipient
475
- *
476
- * @param options - RPC options
477
424
  */
478
- collectMarketFee(markets: {
479
- mint: PublicKey;
480
- marketAddress: PublicKey;
481
- customerId: number;
482
- customerFeeRecipient: PublicKey;
483
- }[], options?: RpcOptions): Promise<string>;
425
+ collectMarketFee({ markets }: CollectMarketFeeArgs): Promise<string>;
484
426
  /**
485
427
  * Close Order Book
486
- * @param marketId - The ID of the market
487
- *
488
- * @param options - RPC options
489
- */
490
- closeOrderBook(marketIds: number[], options?: RpcOptions): Promise<string>;
491
- /**
492
- * Update Customer Fee
493
- * @param feeBps - The fee in basis points
494
- * @param wallet - The wallet of the customer to update the fee for
495
- *
496
- * @param options - RPC options
428
+ * @param marketIds - Market IDs
497
429
  */
498
- updateCustomerFee({ feeBps, wallet }: UpdateCustomerFeeArgs, options?: RpcOptions): Promise<string>;
430
+ closeOrderBook(marketIds: number[]): Promise<string>;
499
431
  }