@triadxyz/triad-protocol 2.4.1-beta → 2.4.3-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
@@ -188,7 +188,7 @@ export default class TriadProtocolClient {
188
188
  *
189
189
  * @param options - RPC options
190
190
  */
191
- createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
191
+ createOrEditPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
192
192
  /**
193
193
  * Open Order
194
194
  * @param args.marketId - The ID of the Market
@@ -410,4 +410,11 @@ export default class TriadProtocolClient {
410
410
  * @param options - RPC options
411
411
  */
412
412
  collectMarketFee({ marketId, feeRecipient }: CollectMarketFeeArgs, options?: RpcOptions): Promise<string>;
413
+ /**
414
+ * Close Order Book
415
+ * @param marketId - The ID of the market
416
+ *
417
+ * @param options - RPC options
418
+ */
419
+ closeOrderBook(marketId: number, options?: RpcOptions): Promise<string>;
413
420
  }
package/dist/index.js CHANGED
@@ -209,29 +209,34 @@ class TriadProtocolClient {
209
209
  *
210
210
  * @param options - RPC options
211
211
  */
212
- createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }, options) {
212
+ createOrEditPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }, options) {
213
213
  return __awaiter(this, void 0, void 0, function* () {
214
214
  if (question.length > 80) {
215
215
  throw new Error('Pool question must be less than 80 characters');
216
216
  }
217
217
  const ixs = [];
218
218
  const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
219
- ixs.push(yield this.program.methods
220
- .createPool({
221
- poolId: new bn_js_1.default(poolId),
222
- question: (0, helpers_1.encodeString)(question, 80),
223
- isFast
224
- })
225
- .accounts({
226
- signer: this.program.provider.publicKey
227
- })
228
- .instruction());
219
+ try {
220
+ yield this.getPoolById(poolId);
221
+ }
222
+ catch (_a) {
223
+ ixs.push(yield this.program.methods
224
+ .createPool({
225
+ poolId: new bn_js_1.default(poolId),
226
+ question: (0, helpers_1.encodeString)(question, 80),
227
+ isFast
228
+ })
229
+ .accounts({
230
+ signer: this.program.provider.publicKey
231
+ })
232
+ .instruction());
233
+ }
229
234
  let userTrade = null;
230
235
  try {
231
236
  yield this.getUserTrade(this.program.provider.publicKey);
232
237
  userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
233
238
  }
234
- catch (_a) { }
239
+ catch (_b) { }
235
240
  for (const market of markets) {
236
241
  if (market.question.length > 80) {
237
242
  throw new Error('Market question must be less than 80 characters');
@@ -907,5 +912,25 @@ class TriadProtocolClient {
907
912
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
908
913
  });
909
914
  }
915
+ /**
916
+ * Close Order Book
917
+ * @param marketId - The ID of the market
918
+ *
919
+ * @param options - RPC options
920
+ */
921
+ closeOrderBook(marketId, options) {
922
+ return __awaiter(this, void 0, void 0, function* () {
923
+ const ixs = [];
924
+ ixs.push(yield this.program.methods
925
+ .closeOrderBook()
926
+ .accounts({
927
+ signer: this.program.provider.publicKey,
928
+ market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
929
+ orderBook: (0, pda_1.getOrderBookPDA)(this.program.programId, marketId)
930
+ })
931
+ .instruction());
932
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
933
+ });
934
+ }
910
935
  }
911
936
  exports.default = TriadProtocolClient;
@@ -394,6 +394,35 @@
394
394
  }
395
395
  ]
396
396
  },
397
+ {
398
+ "name": "close_order_book",
399
+ "discriminator": [219, 134, 73, 219, 180, 7, 94, 206],
400
+ "accounts": [
401
+ {
402
+ "name": "signer",
403
+ "writable": true,
404
+ "signer": true
405
+ },
406
+ {
407
+ "name": "squads",
408
+ "writable": true,
409
+ "address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
410
+ },
411
+ {
412
+ "name": "market",
413
+ "writable": true
414
+ },
415
+ {
416
+ "name": "order_book",
417
+ "writable": true
418
+ },
419
+ {
420
+ "name": "system_program",
421
+ "address": "11111111111111111111111111111111"
422
+ }
423
+ ],
424
+ "args": []
425
+ },
397
426
  {
398
427
  "name": "collect_market_fee",
399
428
  "discriminator": [139, 4, 96, 182, 216, 250, 122, 79],
@@ -586,6 +586,35 @@ export type TriadProtocol = {
586
586
  }
587
587
  ];
588
588
  },
589
+ {
590
+ name: 'closeOrderBook';
591
+ discriminator: [219, 134, 73, 219, 180, 7, 94, 206];
592
+ accounts: [
593
+ {
594
+ name: 'signer';
595
+ writable: true;
596
+ signer: true;
597
+ },
598
+ {
599
+ name: 'squads';
600
+ writable: true;
601
+ address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
602
+ },
603
+ {
604
+ name: 'market';
605
+ writable: true;
606
+ },
607
+ {
608
+ name: 'orderBook';
609
+ writable: true;
610
+ },
611
+ {
612
+ name: 'systemProgram';
613
+ address: '11111111111111111111111111111111';
614
+ }
615
+ ];
616
+ args: [];
617
+ },
589
618
  {
590
619
  name: 'collectMarketFee';
591
620
  discriminator: [139, 4, 96, 182, 216, 250, 122, 79];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.4.1-beta",
3
+ "version": "2.4.3-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",