@triadxyz/triad-protocol 3.1.5-beta → 3.1.7-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.js CHANGED
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const web3_js_1 = require("@solana/web3.js");
30
30
  const anchor_1 = require("@coral-xyz/anchor");
31
+ const spl_token_1 = require("@solana/spl-token");
31
32
  const bn_js_1 = __importDefault(require("bn.js"));
32
33
  const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
33
34
  const types_1 = require("./types");
@@ -38,38 +39,27 @@ const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersione
38
39
  const swap_1 = require("./utils/swap");
39
40
  const stake_1 = __importDefault(require("./stake"));
40
41
  const poseidon_1 = __importDefault(require("./poseidon"));
41
- const spl_token_1 = require("@solana/spl-token");
42
+ const claim_1 = __importDefault(require("./claim"));
43
+ const market_1 = __importDefault(require("./market"));
42
44
  __exportStar(require("./types"), exports);
43
45
  __exportStar(require("./utils/helpers"), exports);
46
+ __exportStar(require("./utils/merkle"), exports);
44
47
  class TriadProtocolClient {
45
48
  constructor(connection, wallet, rpcOptions) {
46
49
  this.connection = connection;
47
50
  this.wallet = wallet;
48
51
  this.rpcOptions = rpcOptions;
52
+ if (!this.rpcOptions.payer) {
53
+ this.rpcOptions.payer = this.wallet.publicKey;
54
+ }
49
55
  this.provider = new anchor_1.AnchorProvider(this.connection, this.wallet, {
50
56
  commitment: this.rpcOptions.commitment || 'confirmed'
51
57
  });
52
58
  this.program = new anchor_1.Program(idl_triad_protocol_json_1.default, this.provider);
53
59
  this.stake = new stake_1.default(this.program, this.rpcOptions);
54
60
  this.poseidon = new poseidon_1.default(this.program, this.rpcOptions);
55
- }
56
- /**
57
- * Get All Pools
58
- */
59
- getAllPools() {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const pool = yield this.program.account.pool.all();
62
- return pool.map(({ account, publicKey }) => (0, helpers_1.formatPool)(account, publicKey));
63
- });
64
- }
65
- /**
66
- * Get All Markets
67
- */
68
- getAllMarkets() {
69
- return __awaiter(this, void 0, void 0, function* () {
70
- const marketV2 = yield this.program.account.marketV2.all();
71
- return marketV2.map(({ account, publicKey }) => (0, helpers_1.formatMarket)(account, publicKey));
72
- });
61
+ this.claim = new claim_1.default(this.program, this.rpcOptions);
62
+ this.market = new market_1.default(this.program, this.rpcOptions);
73
63
  }
74
64
  /**
75
65
  * Get My User Trades from a user authority
@@ -122,38 +112,6 @@ class TriadProtocolClient {
122
112
  order.linkedBookOrderId === constants_1.BOOK_ORDER_NULL.toString());
123
113
  });
124
114
  }
125
- /**
126
- * Get Pool By ID
127
- * @param poolId - The ID of the pool
128
- */
129
- getPoolById(poolId) {
130
- return __awaiter(this, void 0, void 0, function* () {
131
- const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
132
- const response = yield this.program.account.pool.fetch(poolPDA);
133
- return (0, helpers_1.formatPool)(response, poolPDA);
134
- });
135
- }
136
- /**
137
- * Get Market By ID
138
- * @param marketId - The ID of the market
139
- */
140
- getMarketById(marketId) {
141
- return __awaiter(this, void 0, void 0, function* () {
142
- const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
143
- const response = yield this.program.account.marketV2.fetch(marketPDA);
144
- return (0, helpers_1.formatMarket)(response, marketPDA);
145
- });
146
- }
147
- /**
148
- * Get Market By Address
149
- * @param marketAddress - The address of the market
150
- */
151
- getMarketByAddress(marketAddress) {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- const account = yield this.program.account.marketV2.fetch(marketAddress);
154
- return (0, helpers_1.formatMarket)(account, marketAddress);
155
- });
156
- }
157
115
  /**
158
116
  * Get Costumer By Wallet Address
159
117
  * @param wallet - The wallet address of the customer
@@ -182,33 +140,6 @@ class TriadProtocolClient {
182
140
  return (0, helpers_1.formatCustomer)(customer, customerPDA);
183
141
  });
184
142
  }
185
- /**
186
- * Get Current Market ID
187
- */
188
- nextMarketId() {
189
- return __awaiter(this, void 0, void 0, function* () {
190
- const markets = yield this.program.account.marketV2.all();
191
- return markets.length + 10;
192
- });
193
- }
194
- /**
195
- * Get Next Customer ID
196
- */
197
- nextCustomerId() {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- const customers = yield this.program.account.customer.all();
200
- return customers.length + 1;
201
- });
202
- }
203
- /**
204
- * Get Next Pool ID
205
- */
206
- nextPoolId() {
207
- return __awaiter(this, void 0, void 0, function* () {
208
- const pools = yield this.program.account.pool.all();
209
- return pools.length + 1;
210
- });
211
- }
212
143
  /**
213
144
  * Get User Trade PDA
214
145
  * @param wallet - User wallet PublicKey
@@ -227,117 +158,12 @@ class TriadProtocolClient {
227
158
  * @param wallet - User wallet PublicKey
228
159
  * @param userNonce - The nonce of the user
229
160
  */
230
- getUserTrade(wallet, userNonce = 0) {
161
+ getUserTradeByNonce(wallet, userNonce = 0) {
231
162
  return __awaiter(this, void 0, void 0, function* () {
232
163
  const userTradePDA = this.getUserPDA(wallet, userNonce);
233
164
  return this.program.account.userTrade.fetch(userTradePDA);
234
165
  });
235
166
  }
236
- /**
237
- * Create Market
238
- * @param args.markets - Array of markets to create
239
- * @param args.markets.marketId - Market ID
240
- * @param args.markets.startTime - start time
241
- * @param args.markets.endTime - end time
242
- * @param args.markets.question - question (max 80 characters)
243
- * @param args.markets.liquidityAtStart - liquidity at start
244
- * @param args.markets.payoutFee - payout fee (to add affiliate system)
245
- * @param args.customer - The customer of the market
246
- * @param args.poolId - The ID of the pool
247
- */
248
- createMarket({ markets, customer, poolId }) {
249
- return __awaiter(this, void 0, void 0, function* () {
250
- const ixs = [];
251
- let poolPDA = null;
252
- if (poolId) {
253
- poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
254
- }
255
- for (const market of markets) {
256
- if (market.question.length > 80) {
257
- throw new Error('Question must be less than 80 characters');
258
- }
259
- ixs.push(yield this.program.methods
260
- .createMarket({
261
- marketId: new bn_js_1.default(market.marketId),
262
- question: (0, helpers_1.encodeString)(market.question, 80),
263
- marketStart: new bn_js_1.default(market.startTime),
264
- marketEnd: new bn_js_1.default(market.endTime),
265
- feeBps: market.feeBps,
266
- payoutFee: market.payoutFee
267
- })
268
- .accounts({
269
- signer: this.program.provider.publicKey,
270
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
271
- pool: poolPDA,
272
- customer
273
- })
274
- .instruction());
275
- ixs.push(yield this.program.methods
276
- .createOrderBook(new bn_js_1.default(market.marketId))
277
- .accounts({
278
- signer: this.program.provider.publicKey,
279
- market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
280
- })
281
- .instruction());
282
- }
283
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
284
- });
285
- }
286
- /**
287
- * Create Pool
288
- * @param poolId - The ID of the pool
289
- * @param question - The question of the pool
290
- * @param markets - The markets of the pool
291
- */
292
- createPool({ poolId, question, markets, customer, startTime, endTime, feeBps, payoutFee, isFast }) {
293
- return __awaiter(this, void 0, void 0, function* () {
294
- if (question.length > 80) {
295
- throw new Error('Pool question must be less than 80 characters');
296
- }
297
- const ixs = [];
298
- const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
299
- ixs.push(yield this.program.methods
300
- .createPool({
301
- poolId: new bn_js_1.default(poolId),
302
- question: (0, helpers_1.encodeString)(question, 80),
303
- isFast
304
- })
305
- .accounts({
306
- signer: this.program.provider.publicKey,
307
- customer
308
- })
309
- .instruction());
310
- for (const market of markets) {
311
- if (market.question.length > 80) {
312
- throw new Error('Market question must be less than 80 characters');
313
- }
314
- ixs.push(yield this.program.methods
315
- .createMarket({
316
- marketId: new bn_js_1.default(market.marketId),
317
- question: (0, helpers_1.encodeString)(market.question, 80),
318
- marketStart: new bn_js_1.default(startTime),
319
- marketEnd: new bn_js_1.default(endTime),
320
- feeBps,
321
- payoutFee
322
- })
323
- .accounts({
324
- signer: this.program.provider.publicKey,
325
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
326
- pool: poolPDA,
327
- customer
328
- })
329
- .instruction());
330
- ixs.push(yield this.program.methods
331
- .createOrderBook(new bn_js_1.default(market.marketId))
332
- .accounts({
333
- signer: this.program.provider.publicKey,
334
- market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
335
- })
336
- .instruction());
337
- }
338
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
339
- });
340
- }
341
167
  /**
342
168
  * Open Order
343
169
  * @param args.marketId - The ID of the Market
@@ -378,6 +204,7 @@ class TriadProtocolClient {
378
204
  })
379
205
  .accounts({
380
206
  signer: this.program.provider.publicKey,
207
+ payer: this.rpcOptions.payer,
381
208
  market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
382
209
  userTrade: userTradePDA,
383
210
  mint
@@ -394,41 +221,19 @@ class TriadProtocolClient {
394
221
  */
395
222
  closeOrder({ marketId, orderId, userNonce }) {
396
223
  return __awaiter(this, void 0, void 0, function* () {
397
- const ixs = [];
398
224
  const userTrade = this.getUserPDA(this.program.provider.publicKey, userNonce);
399
- ixs.push(yield this.program.methods
400
- .closeOrder(new bn_js_1.default(orderId))
401
- .accounts({
402
- signer: this.program.provider.publicKey,
403
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
404
- mint: constants_1.TRD_MINT,
405
- userTrade
406
- })
407
- .instruction());
408
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
409
- });
410
- }
411
- /**
412
- * Resolve Market
413
- * @param args.marketId - The ID of the Market
414
- * @param args.poolId - The ID of the Pool
415
- * @param args.winningDirection - The Winning Direction of the Market
416
- */
417
- updateMarketWinningDirection({ marketId, poolId, winningDirection }) {
418
- return __awaiter(this, void 0, void 0, function* () {
419
- const ixs = [];
420
- let poolPDA = null;
421
- if (poolId) {
422
- poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
423
- }
424
- ixs.push(yield this.program.methods
425
- .updateMarketWinningDirection(winningDirection)
426
- .accounts({
427
- signer: this.program.provider.publicKey,
428
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
429
- pool: poolPDA
430
- })
431
- .instruction());
225
+ const ixs = [
226
+ yield this.program.methods
227
+ .closeOrder(new bn_js_1.default(orderId))
228
+ .accounts({
229
+ signer: this.program.provider.publicKey,
230
+ payer: this.rpcOptions.payer,
231
+ market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
232
+ mint: constants_1.TRD_MINT,
233
+ userTrade
234
+ })
235
+ .instruction()
236
+ ];
432
237
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
433
238
  });
434
239
  }
@@ -450,6 +255,7 @@ class TriadProtocolClient {
450
255
  .payoutOrder(new bn_js_1.default(order.orderId))
451
256
  .accounts({
452
257
  signer: this.program.provider.publicKey,
258
+ payer: this.rpcOptions.payer,
453
259
  userTrade: this.getUserPDA(this.program.provider.publicKey, order.userNonce),
454
260
  market: (0, pda_1.getMarketPDA)(this.program.programId, order.marketId),
455
261
  mint: order.mint,
@@ -460,29 +266,6 @@ class TriadProtocolClient {
460
266
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
461
267
  });
462
268
  }
463
- /**
464
- * Update Market Payout
465
- * @param marketId - The ID of the market
466
- * @param poolId - The ID of the pool
467
- * @param allowPayout - Whether to allow the market to payout
468
- */
469
- updateMarketPayout({ marketId, poolId, allowPayout }) {
470
- return __awaiter(this, void 0, void 0, function* () {
471
- const ixs = [];
472
- let poolPDA = null;
473
- if (poolId) {
474
- poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
475
- }
476
- ixs.push(yield this.program.methods
477
- .updateMarketPayout(allowPayout)
478
- .accounts({
479
- signer: this.program.provider.publicKey,
480
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
481
- })
482
- .instruction());
483
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
484
- });
485
- }
486
269
  /**
487
270
  * Create Sub User Trade
488
271
  * @param user - User PublicKey the main user
@@ -490,7 +273,7 @@ class TriadProtocolClient {
490
273
  createSubUserTrade(user) {
491
274
  return __awaiter(this, void 0, void 0, function* () {
492
275
  const ixs = [];
493
- const userTrade = yield this.getUserTrade(user);
276
+ const userTrade = yield this.getUserTradeByNonce(user);
494
277
  const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, user, userTrade.nonce + 1);
495
278
  ixs.push(yield this.program.methods
496
279
  .createSubUserTrade(subUserTradePDA)
@@ -501,42 +284,6 @@ class TriadProtocolClient {
501
284
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
502
285
  });
503
286
  }
504
- /**
505
- * Update Market End
506
- * @param marketId - The ID of the market
507
- * @param marketEnd - The end time of the market
508
- */
509
- updateMarketEnd({ marketId, marketEnd }) {
510
- return __awaiter(this, void 0, void 0, function* () {
511
- const ixs = [];
512
- ixs.push(yield this.program.methods
513
- .updateMarketEnd(new bn_js_1.default(marketEnd))
514
- .accounts({
515
- signer: this.program.provider.publicKey,
516
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
517
- })
518
- .instruction());
519
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
520
- });
521
- }
522
- /**
523
- * Update Market Question
524
- * @param marketId - The ID of the market
525
- * @param question - The question of the market
526
- */
527
- updateMarketQuestion({ marketId, question }) {
528
- return __awaiter(this, void 0, void 0, function* () {
529
- const ixs = [];
530
- ixs.push(yield this.program.methods
531
- .updateMarketQuestion((0, helpers_1.encodeString)(question, 80))
532
- .accounts({
533
- signer: this.program.provider.publicKey,
534
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
535
- })
536
- .instruction());
537
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
538
- });
539
- }
540
287
  /**
541
288
  * Create Customer
542
289
  * @param args.id - The ID of the customer
@@ -557,28 +304,6 @@ class TriadProtocolClient {
557
304
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
558
305
  });
559
306
  }
560
- /**
561
- * Get User Trade Nonce With Slots
562
- * @param userTrades - User Trades
563
- */
564
- getUserTradeNonceWithSlots(userTrades) {
565
- let nonce = null;
566
- for (const userTrade of userTrades) {
567
- if (nonce !== null) {
568
- break;
569
- }
570
- userTrade.orders.forEach((order) => {
571
- if (order.orderStatus === types_1.OrderStatus.INIT ||
572
- order.orderStatus === types_1.OrderStatus.CLOSED) {
573
- nonce = userTrade.isSubUser ? Number(userTrade.nonce) : 0;
574
- }
575
- });
576
- }
577
- if (nonce === null) {
578
- throw new Error('No open orders found');
579
- }
580
- return this.getUserPDA(this.program.provider.publicKey, nonce);
581
- }
582
307
  /**
583
308
  * Get User Trade Ixs
584
309
  */
@@ -601,10 +326,32 @@ class TriadProtocolClient {
601
326
  };
602
327
  }
603
328
  try {
604
- const userTradePDA = this.getUserTradeNonceWithSlots(myUserTrades);
605
- return { userTradePDA, ixs };
329
+ let nonce = null;
330
+ for (const userTrade of myUserTrades) {
331
+ if (userTrade.nonce === '9') {
332
+ continue;
333
+ }
334
+ if (nonce !== null) {
335
+ break;
336
+ }
337
+ userTrade.orders.forEach((order) => {
338
+ if (order.orderStatus === types_1.OrderStatus.INIT ||
339
+ order.orderStatus === types_1.OrderStatus.CLOSED) {
340
+ nonce = userTrade.isSubUser ? Number(userTrade.nonce) : 0;
341
+ }
342
+ });
343
+ }
344
+ console.log('nonce', nonce);
345
+ if (nonce === null) {
346
+ throw new Error('No open orders found');
347
+ }
348
+ return {
349
+ userTradePDA: this.getUserPDA(this.program.provider.publicKey, nonce),
350
+ ixs
351
+ };
606
352
  }
607
353
  catch (_a) {
354
+ console.log('No open orders found');
608
355
  const mainUserTrade = myUserTrades.find((trade) => !trade.isSubUser);
609
356
  const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, Number(mainUserTrade.nonce) + 1);
610
357
  ixs.push(yield this.program.methods
@@ -630,7 +377,8 @@ class TriadProtocolClient {
630
377
  return __awaiter(this, void 0, void 0, function* () {
631
378
  const userOrders = yield this.getUserOrdersByMarketId(this.program.provider.publicKey, marketId);
632
379
  const userNonce = (_a = userOrders.find((order) => order.orderDirection === orderDirection &&
633
- order.orderStatus === types_1.OrderStatus.OPEN)) === null || _a === void 0 ? void 0 : _a.userNonce;
380
+ order.orderStatus === types_1.OrderStatus.OPEN &&
381
+ Number(order.marketId) === marketId)) === null || _a === void 0 ? void 0 : _a.userNonce;
634
382
  let userTradePDA = null;
635
383
  let userTradeIxs = [];
636
384
  if (userNonce) {
@@ -763,6 +511,7 @@ class TriadProtocolClient {
763
511
  })
764
512
  .accounts({
765
513
  signer: this.program.provider.publicKey,
514
+ payer: this.rpcOptions.payer,
766
515
  market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
767
516
  orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
768
517
  userTrade: this.getUserPDA(this.program.provider.publicKey, order.userNonce)
@@ -807,10 +556,9 @@ class TriadProtocolClient {
807
556
  * @param args.marketId - The ID of the Market
808
557
  * @param args.amount - The amount of the Order
809
558
  * @param args.orderDirection - The direction of the Order
810
- * @param args.feeBps - The fee in basis points
811
559
  * @param args.isTrdPayout - Whether to payout in TRD or not
812
560
  */
813
- marketBidOrder({ marketId, amount, orderDirection, feeBps = 0, isTrdPayout }) {
561
+ marketBidOrder({ marketId, amount, orderDirection, isTrdPayout }) {
814
562
  return __awaiter(this, void 0, void 0, function* () {
815
563
  const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
816
564
  const ixs = [];
@@ -839,15 +587,13 @@ class TriadProtocolClient {
839
587
  const orderPrice = new bn_js_1.default(order.price);
840
588
  const availableShares = new bn_js_1.default(order.totalShares).sub(new bn_js_1.default(order.filledShares));
841
589
  let adjustedPrice = orderPrice;
842
- if (feeBps > 0) {
843
- const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
844
- const fee = priceSpread
845
- .mul(orderPrice)
846
- .mul(new bn_js_1.default(feeBps))
847
- .div(new bn_js_1.default(10000))
848
- .div(new bn_js_1.default(1000000));
849
- adjustedPrice = orderPrice.add(fee);
850
- }
590
+ const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
591
+ const fee = priceSpread
592
+ .mul(orderPrice)
593
+ .mul(new bn_js_1.default(700))
594
+ .div(new bn_js_1.default(10000))
595
+ .div(new bn_js_1.default(1000000));
596
+ adjustedPrice = orderPrice.add(fee);
851
597
  const maxSharesForPrice = tempRemainingUSDC
852
598
  .mul(new bn_js_1.default(Math.pow(10, constants_1.BASE_DECIMALS)))
853
599
  .div(adjustedPrice);
@@ -888,15 +634,13 @@ class TriadProtocolClient {
888
634
  const orderPrice = new bn_js_1.default(order.price);
889
635
  const availableShares = new bn_js_1.default(order.totalShares).sub(new bn_js_1.default(order.filledShares));
890
636
  let adjustedPrice = orderPrice;
891
- if (feeBps > 0) {
892
- const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
893
- const fee = priceSpread
894
- .mul(orderPrice)
895
- .mul(new bn_js_1.default(feeBps))
896
- .div(new bn_js_1.default(10000))
897
- .div(new bn_js_1.default(1000000));
898
- adjustedPrice = orderPrice.add(fee);
899
- }
637
+ const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
638
+ const fee = priceSpread
639
+ .mul(orderPrice)
640
+ .mul(new bn_js_1.default(700))
641
+ .div(new bn_js_1.default(10000))
642
+ .div(new bn_js_1.default(1000000));
643
+ adjustedPrice = orderPrice.add(fee);
900
644
  const maxSharesForPrice = remainingUSDC
901
645
  .mul(new bn_js_1.default(Math.pow(10, constants_1.BASE_DECIMALS)))
902
646
  .div(adjustedPrice);
@@ -917,15 +661,14 @@ class TriadProtocolClient {
917
661
  })
918
662
  .accounts({
919
663
  signer: this.program.provider.publicKey,
664
+ payer: this.rpcOptions.payer,
920
665
  market: marketPDA,
921
666
  buyerTrade: userTradePDA,
922
667
  orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId),
923
668
  sellerAuthority: new web3_js_1.PublicKey(order.authority),
924
669
  sellerTrade: this.getUserPDA(new web3_js_1.PublicKey(order.authority), Number(order.userNonce)),
925
670
  marketAta: (0, pda_1.getTokenATA)(marketPDA, constants_1.USDC_MINT, spl_token_1.TOKEN_PROGRAM_ID),
926
- buyerAta: (0, pda_1.getTokenATA)(this.program.provider.publicKey, constants_1.USDC_MINT, spl_token_1.TOKEN_PROGRAM_ID),
927
- mint: constants_1.USDC_MINT,
928
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
671
+ buyerAta: (0, pda_1.getTokenATA)(this.program.provider.publicKey, constants_1.USDC_MINT, spl_token_1.TOKEN_PROGRAM_ID)
929
672
  })
930
673
  .instruction());
931
674
  remainingUSDC = remainingUSDC.sub(usdcAmount);
@@ -996,6 +739,7 @@ class TriadProtocolClient {
996
739
  })
997
740
  .accounts({
998
741
  signer: this.program.provider.publicKey,
742
+ payer: this.rpcOptions.payer,
999
743
  market: marketPDA,
1000
744
  buyerAuthority: new web3_js_1.PublicKey(order.authority),
1001
745
  buyerTrade: this.getUserPDA(new web3_js_1.PublicKey(order.authority), Number(order.userNonce)),
@@ -1064,87 +808,6 @@ class TriadProtocolClient {
1064
808
  return data;
1065
809
  });
1066
810
  }
1067
- /**
1068
- * Collect Market Fee
1069
- * @param args.markets - The markets to collect the fee from
1070
- * @param args.markets.marketAddress - The address of the market
1071
- * @param args.markets.customerId - The ID of the customer
1072
- * @param args.markets.customerFeeRecipient - The address of the customer fee recipient
1073
- */
1074
- collectMarketFee({ markets }) {
1075
- return __awaiter(this, void 0, void 0, function* () {
1076
- const ixs = [];
1077
- for (const market of markets) {
1078
- ixs.push(yield this.program.methods
1079
- .collectMarketFee()
1080
- .accounts({
1081
- signer: this.program.provider.publicKey,
1082
- market: market.marketAddress,
1083
- customer: (0, pda_1.getCustomerPDA)(this.program.programId, market.customerId),
1084
- customerFeeRecipient: market.customerFeeRecipient
1085
- })
1086
- .instruction());
1087
- }
1088
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
1089
- });
1090
- }
1091
- /**
1092
- * Collect Market Order Fee
1093
- * @param marketAddress - The address of the market
1094
- */
1095
- collectMarketOrderFee(marketAddress) {
1096
- return __awaiter(this, void 0, void 0, function* () {
1097
- const ixs = [];
1098
- for (const market of marketAddress) {
1099
- ixs.push(yield this.program.methods
1100
- .collectMarketOrderFee()
1101
- .accounts({
1102
- signer: this.program.provider.publicKey,
1103
- market: market
1104
- })
1105
- .instruction());
1106
- }
1107
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
1108
- });
1109
- }
1110
- /**
1111
- * Close Order Book
1112
- * @param marketIds - Market IDs
1113
- */
1114
- closeOrderBook(marketIds) {
1115
- return __awaiter(this, void 0, void 0, function* () {
1116
- const ixs = [];
1117
- for (const marketId of marketIds) {
1118
- ixs.push(yield this.program.methods
1119
- .closeOrderBook()
1120
- .accounts({
1121
- signer: this.program.provider.publicKey,
1122
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
1123
- orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId)
1124
- })
1125
- .instruction());
1126
- }
1127
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
1128
- });
1129
- }
1130
- /**
1131
- * Update Pool Question
1132
- * @param poolId - Pool ID
1133
- * @param question - Question
1134
- */
1135
- updatePoolQuestion(poolId, question) {
1136
- return __awaiter(this, void 0, void 0, function* () {
1137
- const ixs = [];
1138
- ixs.push(yield this.program.methods
1139
- .updatePoolQuestion((0, helpers_1.encodeString)(question, 80))
1140
- .accounts({
1141
- signer: this.program.provider.publicKey,
1142
- pool: (0, pda_1.getPoolPDA)(this.program.programId, poolId)
1143
- })
1144
- .instruction());
1145
- return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
1146
- });
1147
- }
1148
811
  /**
1149
812
  * Update Customer Fee
1150
813
  * @param customerId - Customer ID
@@ -1152,13 +815,14 @@ class TriadProtocolClient {
1152
815
  */
1153
816
  updateCustomerFee({ customerId, feeBps }) {
1154
817
  return __awaiter(this, void 0, void 0, function* () {
1155
- const ixs = [];
1156
- ixs.push(yield this.program.methods
1157
- .updateCustomerFee({ id: customerId, feeBps })
1158
- .accounts({
1159
- signer: this.program.provider.publicKey
1160
- })
1161
- .instruction());
818
+ const ixs = [
819
+ yield this.program.methods
820
+ .updateCustomerFee({ id: customerId, feeBps })
821
+ .accounts({
822
+ signer: this.program.provider.publicKey
823
+ })
824
+ .instruction()
825
+ ];
1162
826
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
1163
827
  });
1164
828
  }