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