@triadxyz/triad-protocol 3.1.6-beta → 3.1.8-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/claim.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
1
2
  import { Program } from '@coral-xyz/anchor';
2
3
  import { PublicKey } from '@solana/web3.js';
3
4
  import { TriadProtocol } from './types/triad_protocol';
4
- import { RpcOptions, CreateClaimVaultArgs, ClaimTokenArgs, UpdateClaimVaultMerkleRootArgs, UpdateClaimVaultIsActiveArgs } from './types';
5
+ import { RpcOptions, CreateClaimVaultArgs, ClaimTokenArgs, UpdateClaimVaultMerkleRootArgs, UpdateClaimVaultIsActiveArgs, UpdateClaimVaultAmountArgs } from './types';
5
6
  export default class Claim {
6
7
  private program;
7
8
  private rpcOptions;
@@ -24,27 +25,35 @@ export default class Claim {
24
25
  /**
25
26
  * Claim Token
26
27
  * @param claimData - Claim data
27
- * @param vaultName - Vault name
28
+ * @param claimVaultName - Vault name
28
29
  * @param payer - Payer
29
30
  * @param mint - Mint
30
31
  * @param amount - Amount to claim
31
32
  */
32
- claimToken({ mint, vaultName, payer, claimData, amount, isFirstComeFirstServed }: ClaimTokenArgs): Promise<string>;
33
+ claimToken({ mint, claimVaultName, claimData, amount, isFirstComeFirstServed }: ClaimTokenArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
33
34
  /**
34
35
  * Create Claim Vault
35
36
  * @param args - Create Claim Vault Args
36
37
  */
37
- createClaimVault({ totalAmount, totalUsers, name, isFirstComeFirstServed, endTs, claimData, mint }: CreateClaimVaultArgs): Promise<string>;
38
+ createClaimVault({ totalAmount, totalUsers, name, isFirstComeFirstServed, endTs, claimData, mint }: CreateClaimVaultArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
38
39
  /**
39
40
  * Update Claim Vault Is Active
40
41
  * @param isActive - Is active
41
42
  * @param claimVault - Claim vault
42
43
  */
43
- updateClaimVaultIsActive({ isActive, claimVault }: UpdateClaimVaultIsActiveArgs): Promise<string>;
44
+ updateClaimVaultIsActive({ isActive, claimVaultName }: UpdateClaimVaultIsActiveArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
44
45
  /**
45
46
  * Update Claim Vault Merkle Root
46
47
  * @param merkleRoot - Merkle root
47
48
  * @param claimVault - Claim vault
48
49
  */
49
- updateClaimVaultMerkleRoot({ merkleRoot, claimVault }: UpdateClaimVaultMerkleRootArgs): Promise<string>;
50
+ updateClaimVaultMerkleRoot({ merkleRoot, claimVaultName }: UpdateClaimVaultMerkleRootArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
51
+ /**
52
+ * Update Claim Vault Amount
53
+ * @param amount - Amount to add
54
+ * @param newUsers - New users to add
55
+ * @param claimVaultName - Claim vault name
56
+ * @param mint - Mint
57
+ */
58
+ updateClaimVaultAmount({ amount, newUsers, claimVaultName, mint }: UpdateClaimVaultAmountArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
50
59
  }
package/dist/claim.js CHANGED
@@ -57,12 +57,12 @@ class Claim {
57
57
  /**
58
58
  * Claim Token
59
59
  * @param claimData - Claim data
60
- * @param vaultName - Vault name
60
+ * @param claimVaultName - Vault name
61
61
  * @param payer - Payer
62
62
  * @param mint - Mint
63
63
  * @param amount - Amount to claim
64
64
  */
65
- claimToken({ mint, vaultName, payer, claimData, amount, isFirstComeFirstServed }) {
65
+ claimToken({ mint, claimVaultName, claimData, amount, isFirstComeFirstServed }) {
66
66
  var _a;
67
67
  return __awaiter(this, void 0, void 0, function* () {
68
68
  let proof = [];
@@ -78,9 +78,9 @@ class Claim {
78
78
  })
79
79
  .accounts({
80
80
  signer: this.program.provider.publicKey,
81
- payer,
81
+ payer: this.rpcOptions.payer,
82
82
  mint,
83
- claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, vaultName),
83
+ claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, claimVaultName),
84
84
  tokenProgram: (0, helpers_1.getTokenProgram)(mint)
85
85
  })
86
86
  .instruction()
@@ -120,14 +120,14 @@ class Claim {
120
120
  * @param isActive - Is active
121
121
  * @param claimVault - Claim vault
122
122
  */
123
- updateClaimVaultIsActive({ isActive, claimVault }) {
123
+ updateClaimVaultIsActive({ isActive, claimVaultName }) {
124
124
  return __awaiter(this, void 0, void 0, function* () {
125
125
  const ixs = [
126
126
  yield this.program.methods
127
127
  .updateClaimVaultIsActive(isActive)
128
128
  .accounts({
129
129
  signer: this.program.provider.publicKey,
130
- claimVault
130
+ claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, claimVaultName)
131
131
  })
132
132
  .instruction()
133
133
  ];
@@ -139,14 +139,40 @@ class Claim {
139
139
  * @param merkleRoot - Merkle root
140
140
  * @param claimVault - Claim vault
141
141
  */
142
- updateClaimVaultMerkleRoot({ merkleRoot, claimVault }) {
142
+ updateClaimVaultMerkleRoot({ merkleRoot, claimVaultName }) {
143
143
  return __awaiter(this, void 0, void 0, function* () {
144
144
  const ixs = [
145
145
  yield this.program.methods
146
146
  .updateClaimVaultMerkleRoot(merkleRoot)
147
147
  .accounts({
148
148
  signer: this.program.provider.publicKey,
149
- claimVault
149
+ claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, claimVaultName)
150
+ })
151
+ .instruction()
152
+ ];
153
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
154
+ });
155
+ }
156
+ /**
157
+ * Update Claim Vault Amount
158
+ * @param amount - Amount to add
159
+ * @param newUsers - New users to add
160
+ * @param claimVaultName - Claim vault name
161
+ * @param mint - Mint
162
+ */
163
+ updateClaimVaultAmount({ amount, newUsers, claimVaultName, mint }) {
164
+ return __awaiter(this, void 0, void 0, function* () {
165
+ const ixs = [
166
+ yield this.program.methods
167
+ .updateClaimVaultAmount({
168
+ amount: new anchor_1.BN(amount * Math.pow(10, 6)),
169
+ newUsers: new anchor_1.BN(newUsers)
170
+ })
171
+ .accounts({
172
+ signer: this.program.provider.publicKey,
173
+ mint,
174
+ tokenProgram: (0, helpers_1.getTokenProgram)(mint),
175
+ claimVault: (0, pda_1.getClaimVaultPDA)(this.program.programId, claimVaultName)
150
176
  })
151
177
  .instruction()
152
178
  ];
package/dist/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
+ /// <reference types="@coral-xyz/anchor/node_modules/@solana/web3.js" />
1
2
  import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
2
3
  import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
3
4
  import BN from 'bn.js';
4
5
  import { TriadProtocol } from './types/triad_protocol';
5
- import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CollectMarketFeeArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, OrderDirection } from './types';
6
+ import { OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, BookOrder, MarketAskOrderArgs, RpcOptions, OrderDirection, CloseOrderArgs } from './types';
6
7
  import Stake from './stake';
7
8
  import Poseidon from './poseidon';
8
9
  import Claim from './claim';
10
+ import Market from './market';
9
11
  export * from './types';
10
12
  export * from './utils/helpers';
11
13
  export * from './utils/merkle';
@@ -18,15 +20,8 @@ export default class TriadProtocolClient {
18
20
  stake: Stake;
19
21
  poseidon: Poseidon;
20
22
  claim: Claim;
23
+ market: Market;
21
24
  constructor(connection: Connection, wallet: Wallet, rpcOptions: RpcOptions);
22
- /**
23
- * Get All Pools
24
- */
25
- getAllPools(): Promise<import("./types").Pool[]>;
26
- /**
27
- * Get All Markets
28
- */
29
- getAllMarkets(): Promise<import("./types").Market[]>;
30
25
  /**
31
26
  * Get My User Trades from a user authority
32
27
  * @param wallet - User wallet PublicKey
@@ -47,21 +42,6 @@ export default class TriadProtocolClient {
47
42
  * Get User Book Orders
48
43
  */
49
44
  getUserBookOrders(wallet: PublicKey, marketId: number): Promise<BookOrder[]>;
50
- /**
51
- * Get Pool By ID
52
- * @param poolId - The ID of the pool
53
- */
54
- getPoolById(poolId: number): Promise<import("./types").Pool>;
55
- /**
56
- * Get Market By ID
57
- * @param marketId - The ID of the market
58
- */
59
- getMarketById(marketId: number): Promise<import("./types").Market>;
60
- /**
61
- * Get Market By Address
62
- * @param marketAddress - The address of the market
63
- */
64
- getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
65
45
  /**
66
46
  * Get Costumer By Wallet Address
67
47
  * @param wallet - The wallet address of the customer
@@ -72,18 +52,6 @@ export default class TriadProtocolClient {
72
52
  * @param customerId - The ID of the customer
73
53
  */
74
54
  getCustomerById(customerId: number): Promise<import("./types").Customer>;
75
- /**
76
- * Get Current Market ID
77
- */
78
- nextMarketId(): Promise<number>;
79
- /**
80
- * Get Next Customer ID
81
- */
82
- nextCustomerId(): Promise<number>;
83
- /**
84
- * Get Next Pool ID
85
- */
86
- nextPoolId(): Promise<number>;
87
55
  /**
88
56
  * Get User Trade PDA
89
57
  * @param wallet - User wallet PublicKey
@@ -95,7 +63,7 @@ export default class TriadProtocolClient {
95
63
  * @param wallet - User wallet PublicKey
96
64
  * @param userNonce - The nonce of the user
97
65
  */
98
- getUserTrade(wallet: PublicKey, userNonce?: number): Promise<{
66
+ getUserTradeByNonce(wallet: PublicKey, userNonce?: number): Promise<{
99
67
  bump: number;
100
68
  authority: PublicKey;
101
69
  padding1: number[];
@@ -197,26 +165,6 @@ export default class TriadProtocolClient {
197
165
  poseidon: number;
198
166
  padding: number[];
199
167
  }>;
200
- /**
201
- * Create Market
202
- * @param args.markets - Array of markets to create
203
- * @param args.markets.marketId - Market ID
204
- * @param args.markets.startTime - start time
205
- * @param args.markets.endTime - end time
206
- * @param args.markets.question - question (max 80 characters)
207
- * @param args.markets.liquidityAtStart - liquidity at start
208
- * @param args.markets.payoutFee - payout fee (to add affiliate system)
209
- * @param args.customer - The customer of the market
210
- * @param args.poolId - The ID of the pool
211
- */
212
- createMarket({ markets, customer, poolId }: CreateMarketArgs): Promise<string>;
213
- /**
214
- * Create Pool
215
- * @param poolId - The ID of the pool
216
- * @param question - The question of the pool
217
- * @param markets - The markets of the pool
218
- */
219
- createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs): Promise<string>;
220
168
  /**
221
169
  * Open Order
222
170
  * @param args.marketId - The ID of the Market
@@ -225,37 +173,14 @@ export default class TriadProtocolClient {
225
173
  * @param args.mint - The mint of the Order
226
174
  * @param args.token - The token to use for the Order
227
175
  */
228
- openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs): Promise<string>;
176
+ openOrder({ marketId, amount, direction, mint, token }: OpenOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
229
177
  /**
230
178
  * Close Order
231
179
  * @param args.marketId - The ID of the Market
232
180
  * @param args.orderId - The ID of the Order
233
181
  * @param args.userNonce - The nonce of the user
234
182
  */
235
- closeOrder({ marketId, orderId, userNonce }: {
236
- marketId: number;
237
- orderId: number;
238
- userNonce: number;
239
- }): Promise<string>;
240
- /**
241
- * Resolve Market
242
- * @param args.marketId - The ID of the Market
243
- * @param args.poolId - The ID of the Pool
244
- * @param args.winningDirection - The Winning Direction of the Market
245
- */
246
- updateMarketWinningDirection({ marketId, poolId, winningDirection }: {
247
- marketId: number;
248
- poolId?: number;
249
- winningDirection: {
250
- hype: {};
251
- } | {
252
- flop: {};
253
- } | {
254
- none: {};
255
- } | {
256
- draw: {};
257
- };
258
- }): Promise<string>;
183
+ closeOrder({ marketId, orderId, userNonce }: CloseOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
259
184
  /**
260
185
  * Payout Order
261
186
  * @param args.marketId - The ID of the Market
@@ -268,41 +193,12 @@ export default class TriadProtocolClient {
268
193
  orderId: number;
269
194
  userNonce: number;
270
195
  mint: PublicKey;
271
- }[]): Promise<string>;
272
- /**
273
- * Update Market Payout
274
- * @param marketId - The ID of the market
275
- * @param poolId - The ID of the pool
276
- * @param allowPayout - Whether to allow the market to payout
277
- */
278
- updateMarketPayout({ marketId, poolId, allowPayout }: {
279
- marketId: number;
280
- poolId?: number;
281
- allowPayout: boolean;
282
- }): Promise<string>;
196
+ }[]): Promise<string | import("@solana/web3.js").VersionedTransaction>;
283
197
  /**
284
198
  * Create Sub User Trade
285
199
  * @param user - User PublicKey the main user
286
200
  */
287
- createSubUserTrade(user: PublicKey): Promise<string>;
288
- /**
289
- * Update Market End
290
- * @param marketId - The ID of the market
291
- * @param marketEnd - The end time of the market
292
- */
293
- updateMarketEnd({ marketId, marketEnd }: {
294
- marketId: number;
295
- marketEnd: number;
296
- }): Promise<string>;
297
- /**
298
- * Update Market Question
299
- * @param marketId - The ID of the market
300
- * @param question - The question of the market
301
- */
302
- updateMarketQuestion({ marketId, question }: {
303
- marketId: number;
304
- question: string;
305
- }): Promise<string>;
201
+ createSubUserTrade(user: PublicKey): Promise<string | import("@solana/web3.js").VersionedTransaction>;
306
202
  /**
307
203
  * Create Customer
308
204
  * @param args.id - The ID of the customer
@@ -310,12 +206,7 @@ export default class TriadProtocolClient {
310
206
  * @param args.authority - The authority of the customer
311
207
  * @param args.feeRecipient - The fee recipient of the customer
312
208
  */
313
- createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs): Promise<string>;
314
- /**
315
- * Get User Trade Nonce With Slots
316
- * @param userTrades - User Trades
317
- */
318
- getUserTradeNonceWithSlots(userTrades: UserTrade[]): PublicKey;
209
+ createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
319
210
  /**
320
211
  * Get User Trade Ixs
321
212
  */
@@ -347,7 +238,7 @@ export default class TriadProtocolClient {
347
238
  * @param args.mint - The mint of the Order
348
239
  * @param args.isTrdPayout - Whether to payout in TRD or not
349
240
  */
350
- placeBidOrder({ marketId, orders, isTrdPayout }: PlaceBidOrderArgs): Promise<string>;
241
+ placeBidOrder({ marketId, orders, isTrdPayout }: PlaceBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
351
242
  /**
352
243
  * Place Ask Order
353
244
  * @param args.marketId - The ID of the Market
@@ -357,7 +248,7 @@ export default class TriadProtocolClient {
357
248
  * @param args.orders.bidOrderId - The ID of the Bid Order
358
249
  * @param args.orders.bidNonce - The nonce of the Bid Order
359
250
  */
360
- placeAskOrder({ marketId, orders }: PlaceAskOrderArgs): Promise<string>;
251
+ placeAskOrder({ marketId, orders }: PlaceAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
361
252
  /**
362
253
  * Cancel Bid Order
363
254
  * @param args.marketId - The ID of the Market
@@ -365,7 +256,7 @@ export default class TriadProtocolClient {
365
256
  * @param args.orders.userNonce - The nonce of the user
366
257
  * @param args.orders.orderDirection - The direction of the Order
367
258
  */
368
- cancelBidOrder({ marketId, orders }: CancelBidOrderArgs): Promise<string>;
259
+ cancelBidOrder({ marketId, orders }: CancelBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
369
260
  /**
370
261
  * Cancel Ask Order
371
262
  * @param args.marketId - The ID of the Market
@@ -373,16 +264,15 @@ export default class TriadProtocolClient {
373
264
  * @param args.orders.userNonce - The nonce of the user
374
265
  * @param args.orders.orderDirection - The direction of the Order
375
266
  */
376
- cancelAskOrder({ marketId, orders }: CancelAskOrderArgs): Promise<string>;
267
+ cancelAskOrder({ marketId, orders }: CancelAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
377
268
  /**
378
269
  * Market Bid Order
379
270
  * @param args.marketId - The ID of the Market
380
271
  * @param args.amount - The amount of the Order
381
272
  * @param args.orderDirection - The direction of the Order
382
- * @param args.feeBps - The fee in basis points
383
273
  * @param args.isTrdPayout - Whether to payout in TRD or not
384
274
  */
385
- marketBidOrder({ marketId, amount, orderDirection, feeBps, isTrdPayout }: MarketBidOrderArgs): Promise<string>;
275
+ marketBidOrder({ marketId, amount, orderDirection, isTrdPayout }: MarketBidOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
386
276
  /**
387
277
  * Market Ask Order
388
278
  * @param args.marketId - The ID of the Market
@@ -394,7 +284,7 @@ export default class TriadProtocolClient {
394
284
  * @param args.isTrdPayout - Whether to payout in TRD or not
395
285
  * @param args.feeBps - The fee in basis points
396
286
  */
397
- marketAskOrder({ marketId, orders, orderDirection, isTrdPayout, feeBps }: MarketAskOrderArgs): Promise<string>;
287
+ marketAskOrder({ marketId, orders, orderDirection, isTrdPayout, feeBps }: MarketAskOrderArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
398
288
  /**
399
289
  * Get Orders By Market ID
400
290
  * @param marketId - Market ID
@@ -413,30 +303,6 @@ export default class TriadProtocolClient {
413
303
  ask: BookOrder[];
414
304
  };
415
305
  }>;
416
- /**
417
- * Collect Market Fee
418
- * @param args.markets - The markets to collect the fee from
419
- * @param args.markets.marketAddress - The address of the market
420
- * @param args.markets.customerId - The ID of the customer
421
- * @param args.markets.customerFeeRecipient - The address of the customer fee recipient
422
- */
423
- collectMarketFee({ markets }: CollectMarketFeeArgs): Promise<string>;
424
- /**
425
- * Collect Market Order Fee
426
- * @param marketAddress - The address of the market
427
- */
428
- collectMarketOrderFee(marketAddress: PublicKey[]): Promise<string>;
429
- /**
430
- * Close Order Book
431
- * @param marketIds - Market IDs
432
- */
433
- closeOrderBook(marketIds: number[]): Promise<string>;
434
- /**
435
- * Update Pool Question
436
- * @param poolId - Pool ID
437
- * @param question - Question
438
- */
439
- updatePoolQuestion(poolId: number, question: string): Promise<string>;
440
306
  /**
441
307
  * Update Customer Fee
442
308
  * @param customerId - Customer ID
@@ -445,5 +311,5 @@ export default class TriadProtocolClient {
445
311
  updateCustomerFee({ customerId, feeBps }: {
446
312
  customerId: number;
447
313
  feeBps: number;
448
- }): Promise<string>;
314
+ }): Promise<string | import("@solana/web3.js").VersionedTransaction>;
449
315
  }