@triadxyz/triad-protocol 2.3.3-beta → 2.3.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.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,403 @@
1
+ import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
1
2
  import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
2
- import { Connection } from '@solana/web3.js';
3
+ import BN from 'bn.js';
3
4
  import { TriadProtocol } from './types/triad_protocol';
4
- import Trade from './trade';
5
+ import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions } from './types';
5
6
  import Stake from './stake';
6
7
  import Poseidon from './poseidon';
7
8
  export default class TriadProtocolClient {
8
9
  program: Program<TriadProtocol>;
9
10
  provider: AnchorProvider;
10
- trade: Trade;
11
11
  stake: Stake;
12
12
  poseidon: Poseidon;
13
+ decimals: number;
13
14
  constructor(connection: Connection, wallet: Wallet);
15
+ /**
16
+ * Get All Pools
17
+ *
18
+ */
19
+ getAllPools(): Promise<import("./types").Pool[]>;
20
+ /**
21
+ * Get All Markets
22
+ *
23
+ */
24
+ getAllMarkets(): Promise<import("./types").Market[]>;
25
+ /**
26
+ * Get My User Trades from a user authority
27
+ * @param wallet - User wallet PublicKey
28
+ *
29
+ */
30
+ getMyUserTrades(wallet: PublicKey): Promise<UserTrade[]>;
31
+ /**
32
+ * Get User Orders
33
+ * @param wallet - User wallet PublicKey
34
+ *
35
+ */
36
+ getUserOrders(wallet: PublicKey): Promise<import("./types").Order[]>;
37
+ /**
38
+ * Get Pool By ID
39
+ * @param poolId - The ID of the pool
40
+ *
41
+ */
42
+ getPoolById(poolId: number): Promise<import("./types").Pool>;
43
+ /**
44
+ * Get Market By ID
45
+ * @param marketId - The ID of the market
46
+ *
47
+ */
48
+ getMarketById(marketId: number): Promise<import("./types").Market>;
49
+ /**
50
+ * Get Market By Address
51
+ * @param marketAddress - The address of the market
52
+ *
53
+ */
54
+ getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
55
+ /**
56
+ * Get User Trade PDA
57
+ * @param wallet - User wallet PublicKey
58
+ * @param userNonce - The nonce of the user
59
+ *
60
+ */
61
+ getUserPDA(wallet: PublicKey, userNonce?: number): PublicKey;
62
+ /**
63
+ * Get User Trade
64
+ * @param wallet - User wallet PublicKey
65
+ * @param userNonce - The nonce of the user
66
+ *
67
+ */
68
+ getUserTrade(wallet: PublicKey, userNonce?: number): Promise<{
69
+ bump: number;
70
+ authority: PublicKey;
71
+ totalDeposits: BN;
72
+ totalWithdraws: BN;
73
+ padding1: number[];
74
+ orders: {
75
+ ts: BN;
76
+ orderId: BN;
77
+ filledShares: BN;
78
+ marketId: BN;
79
+ orderStatus: ({
80
+ open?: never;
81
+ closed?: never;
82
+ claimed?: never;
83
+ liquidated?: never;
84
+ waiting?: never;
85
+ } & {
86
+ init: Record<string, never>;
87
+ }) | ({
88
+ init?: never;
89
+ closed?: never;
90
+ claimed?: never;
91
+ liquidated?: never;
92
+ waiting?: never;
93
+ } & {
94
+ open: Record<string, never>;
95
+ }) | ({
96
+ init?: never;
97
+ open?: never;
98
+ claimed?: never;
99
+ liquidated?: never;
100
+ waiting?: never;
101
+ } & {
102
+ closed: Record<string, never>;
103
+ }) | ({
104
+ init?: never;
105
+ open?: never;
106
+ closed?: never;
107
+ liquidated?: never;
108
+ waiting?: never;
109
+ } & {
110
+ claimed: Record<string, never>;
111
+ }) | ({
112
+ init?: never;
113
+ open?: never;
114
+ closed?: never;
115
+ claimed?: never;
116
+ waiting?: never;
117
+ } & {
118
+ liquidated: Record<string, never>;
119
+ }) | ({
120
+ init?: never;
121
+ open?: never;
122
+ closed?: never;
123
+ claimed?: never;
124
+ liquidated?: never;
125
+ } & {
126
+ waiting: Record<string, never>;
127
+ });
128
+ price: BN;
129
+ padding1: number[];
130
+ totalShares: BN;
131
+ orderType: ({
132
+ limit?: never;
133
+ } & {
134
+ market: Record<string, never>;
135
+ }) | ({
136
+ market?: never;
137
+ } & {
138
+ limit: Record<string, never>;
139
+ });
140
+ orderDirection: ({
141
+ flop?: never;
142
+ } & {
143
+ hype: Record<string, never>;
144
+ }) | ({
145
+ hype?: never;
146
+ } & {
147
+ flop: Record<string, never>;
148
+ });
149
+ userNonce: number;
150
+ orderSide: ({
151
+ ask?: never;
152
+ } & {
153
+ bid: Record<string, never>;
154
+ }) | ({
155
+ bid?: never;
156
+ } & {
157
+ ask: Record<string, never>;
158
+ });
159
+ padding2: number[];
160
+ createdAt: BN;
161
+ padding3: number[];
162
+ padding: number[];
163
+ }[];
164
+ nonce: number;
165
+ isSubUser: boolean;
166
+ poseidon: number;
167
+ padding: number[];
168
+ }>;
169
+ /**
170
+ * Create Market
171
+ * @param args.marketId - new markert id - length + 1
172
+ * @param args.startTime - start time
173
+ * @param args.endTime - end time
174
+ * @param args.question - question (max 80 characters)
175
+ * @param args.liquidityAtStart - liquidity at start
176
+ * @param args.payoutFee - payout fee (to add affiliate system)
177
+ * @param args.currentMarketId - if fast market, we need check the pool parameters
178
+ *
179
+ * @param options - RPC options
180
+ *
181
+ */
182
+ createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint, poolId }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
183
+ /**
184
+ * Create Pool
185
+ * @param poolId - The ID of the pool
186
+ * @param question - The question of the pool
187
+ * @param markets - The markets of the pool
188
+ *
189
+ * @param options - RPC options
190
+ */
191
+ createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
192
+ /**
193
+ * Open Order
194
+ * @param args.marketId - The ID of the Market
195
+ * @param args.amount - The amount of the Order
196
+ * @param args.direction - The direction of the Order
197
+ * @param args.mint - The mint of the Order
198
+ * @param args.token - The token to use for the Order
199
+ *
200
+ * @param options - RPC options
201
+ *
202
+ */
203
+ openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs, options?: RpcOptions): Promise<string>;
204
+ /**
205
+ * Close Order
206
+ * @param args.marketId - The ID of the Market
207
+ * @param args.orderId - The ID of the Order
208
+ * @param args.userNonce - The nonce of the user
209
+ *
210
+ * @param options - RPC options
211
+ *
212
+ */
213
+ closeOrder({ marketId, orderId, userNonce }: {
214
+ marketId: number;
215
+ orderId: number;
216
+ userNonce: number;
217
+ }, options?: RpcOptions): Promise<string>;
218
+ /**
219
+ * Resolve Market
220
+ * @param args.marketId - The ID of the Market
221
+ * @param args.winningDirection - The Winning Direction of the Market
222
+ *
223
+ * @param options - RPC options
224
+ *
225
+ */
226
+ resolveMarket({ marketId, poolId, winningDirection }: {
227
+ marketId: number;
228
+ poolId?: number;
229
+ winningDirection: {
230
+ hype: {};
231
+ } | {
232
+ flop: {};
233
+ } | {
234
+ none: {};
235
+ } | {
236
+ draw: {};
237
+ };
238
+ }, options?: RpcOptions): Promise<string>;
239
+ /**
240
+ * Collect Remaining Liquidity
241
+ * @param marketId - The ID of the market
242
+ *
243
+ * @param options - RPC options
244
+ *
245
+ */
246
+ collectRemainingLiquidity(marketId: number, options?: RpcOptions): Promise<string>;
247
+ /**
248
+ * Payout Order
249
+ * @param args.marketId - The ID of the Market
250
+ * @param args.orderId - The ID of the Order to Payout
251
+ * @param args.userNonce - The nonce of the user
252
+ *
253
+ * @param options - RPC options
254
+ *
255
+ */
256
+ payoutOrder(orders: {
257
+ marketId: number;
258
+ orderId: number;
259
+ userNonce: number;
260
+ mint: PublicKey;
261
+ }[], options?: RpcOptions): Promise<string>;
262
+ /**
263
+ * Allow Market to Payout
264
+ * @param marketId - The ID of the market
265
+ * @param poolId - The ID of the pool
266
+ *
267
+ * @param options - RPC options
268
+ *
269
+ */
270
+ allowMarketToPayout({ marketId, poolId }: {
271
+ marketId: number;
272
+ poolId?: number;
273
+ }, options?: RpcOptions): Promise<string>;
274
+ /**
275
+ * Create Sub User Trade
276
+ * @param user - User PublicKey the main user
277
+ *
278
+ * @param options - RPC options
279
+ *
280
+ */
281
+ createSubUserTrade(user: PublicKey, options?: RpcOptions): Promise<string>;
282
+ /**
283
+ * Update Market
284
+ * @param marketId - The ID of the market
285
+ * @param marketEnd - The end time of the market
286
+ *
287
+ * @param options - RPC options
288
+ *
289
+ */
290
+ updateMarket(marketId: number, marketEnd: number, options?: RpcOptions): Promise<string>;
291
+ /**
292
+ * Create Customer
293
+ * @param args.id - The ID of the customer
294
+ * @param args.name - The name of the customer
295
+ * @param args.authority - The authority of the customer
296
+ * @param args.feeRecipient - The fee recipient of the customer
297
+ *
298
+ * @param options - RPC options
299
+ *
300
+ */
301
+ createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs, options?: RpcOptions): Promise<string>;
302
+ /**
303
+ * Get User Trade Nonce With Slots
304
+ * @param userTrades - User Trades
305
+ *
306
+ */
307
+ getUserTradeNonceWithSlots(userTrades: UserTrade[]): PublicKey;
308
+ /**
309
+ * Get User Trade Ixs
310
+ *
311
+ */
312
+ getUserTradeIxs(): Promise<{
313
+ userTradePDA: PublicKey;
314
+ ixs: TransactionInstruction[];
315
+ nonce: number;
316
+ } | {
317
+ userTradePDA: PublicKey;
318
+ ixs: TransactionInstruction[];
319
+ nonce?: undefined;
320
+ }>;
321
+ /**
322
+ * Place Bid Order
323
+ * @param args.marketId - The ID of the Market
324
+ * @param args.amount - The amount of the Order
325
+ * @param args.direction - The direction of the Order
326
+ * @param args.mint - The mint of the Order
327
+ * @param args.price - The price of the Order
328
+ *
329
+ * @param options - RPC options
330
+ */
331
+ placeBidOrder({ marketId, amount, direction, mint, price }: PlaceBidOrderArgs, options?: RpcOptions): Promise<string>;
332
+ /**
333
+ * Place Ask Order
334
+ * @param args.marketId - The ID of the Market
335
+ * @param args.amount - The amount of the Order
336
+ * @param args.direction - The direction of the Order
337
+ * @param args.price - The price of the Order
338
+ * @param args.bidOrderId - The ID of the Bid Order
339
+ * @param args.bidNonce - The nonce of the Bid Order
340
+ *
341
+ * @param options - RPC options
342
+ *
343
+ */
344
+ placeAskOrder({ marketId, orders }: PlaceAskOrderArgs, options?: RpcOptions): Promise<string>;
345
+ /**
346
+ * Cancel Bid Order
347
+ * @param args.marketId - The ID of the Market
348
+ * @param args.orderId - The ID of the Order
349
+ * @param args.userNonce - The nonce of the user
350
+ * @param args.direction - The direction of the Order
351
+ *
352
+ * @param options - RPC options
353
+ */
354
+ cancelBidOrder({ marketId, orderId, userNonce, mint, direction }: CancelBidOrderArgs, options?: RpcOptions): Promise<string>;
355
+ /**
356
+ * Cancel Ask Order
357
+ * @param args.marketId - The ID of the Market
358
+ * @param args.orderId - The ID of the Order
359
+ * @param args.userNonce - The nonce of the user
360
+ * @param args.userNonceBidOrder - The nonce of the bid user
361
+ * @param args.direction - The direction of the Order
362
+ *
363
+ * @param options - RPC options
364
+ */
365
+ cancelAskOrder({ marketId, orderId, userNonce, direction }: CancelAskOrderArgs, options?: RpcOptions): Promise<string>;
366
+ /**
367
+ * Market Bid Order
368
+ * @param args.marketId - The ID of the Market
369
+ * @param args.amount - The amount of the Order
370
+ * @param args.direction - The direction of the Order
371
+ * @param args.mint - The mint of the Order
372
+ *
373
+ * @param options - RPC options
374
+ */
375
+ marketBidOrder({ marketId, amount, direction, mint, feeBps }: MarketBidOrderArgs, options?: RpcOptions): Promise<string>;
376
+ marketAskOrder({ marketId, shares, bidOrderId, direction, mint }: MarketAskOrderArgs, options?: RpcOptions): Promise<string>;
377
+ /**
378
+ * Get Orders By Market ID
379
+ * @param marketId - The ID of the market
380
+ *
381
+ */
382
+ getOrderBook(marketId: number): Promise<{
383
+ marketId: number;
384
+ rewardsAvailable: string;
385
+ rewardsClaimed: string;
386
+ spreadToReward: string;
387
+ hype: {
388
+ bid: BookOrder[];
389
+ ask: BookOrder[];
390
+ };
391
+ flop: {
392
+ bid: BookOrder[];
393
+ ask: BookOrder[];
394
+ };
395
+ }>;
396
+ /**
397
+ * Collect Market Fee
398
+ * @param marketId - The ID of the market
399
+ *
400
+ * @param options - RPC options
401
+ */
402
+ collectMarketFee(marketId: number, options?: RpcOptions): Promise<string>;
14
403
  }