@triadxyz/triad-protocol 4.4.0 → 4.4.2

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
@@ -32,6 +32,10 @@ export default class TriadProtocol {
32
32
  constructor(connection: Connection, wallet: Wallet, rpcOptions: RpcOptions);
33
33
  getPriorityFee(): Promise<void>;
34
34
  getCentral(): Promise<import("./types").Central>;
35
+ /**
36
+ * Collect Central Fee (transfers accumulated fees to the protocol treasury)
37
+ */
38
+ collectCentralFee(): Promise<string | import("@solana/web3.js").VersionedTransaction>;
35
39
  /**
36
40
  * Burn Triad
37
41
  * @param amount - Amount to burn
package/dist/index.js CHANGED
@@ -83,6 +83,22 @@ class TriadProtocol {
83
83
  return (0, helpers_1.formatCentral)(central, centralPDA);
84
84
  });
85
85
  }
86
+ /**
87
+ * Collect Central Fee (transfers accumulated fees to the protocol treasury)
88
+ */
89
+ collectCentralFee() {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const ixs = [
92
+ yield this.program.methods
93
+ .collectCentralFee()
94
+ .accounts({
95
+ signer: this.program.provider.publicKey
96
+ })
97
+ .instruction()
98
+ ];
99
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
100
+ });
101
+ }
86
102
  /**
87
103
  * Burn Triad
88
104
  * @param amount - Amount to burn
package/dist/market.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
2
  import { Program } from '@coral-xyz/anchor';
3
3
  import { TriadProtocol } from './types/triad_protocol';
4
- import { RpcOptions, CreateMarketArgs, CreatePoolArgs, UpdateMarketWinningDirectionArgs, UpdateMarketPayoutArgs, UpdateMarketQuestionArgs, UpdateMarketEndArgs, CreateMarketPythArgs } from './types';
4
+ import { RpcOptions, CreateMarketArgs, CreatePoolArgs, UpdateMarketWinningDirectionArgs, UpdateMarketPayoutArgs, UpdateMarketQuestionArgs, UpdateMarketEndArgs, CreateMarketPythArgs, UpdateCentralArgs } from './types';
5
5
  export default class Market {
6
6
  private program;
7
7
  private rpcOptions;
@@ -35,7 +35,7 @@ export default class Market {
35
35
  */
36
36
  getMarketByAddress(marketAddress: PublicKey): Promise<import("./types").Market>;
37
37
  /**
38
- * Get Current Market ID
38
+ * Get Next Market ID (from central account)
39
39
  */
40
40
  nextMarketId(): Promise<number>;
41
41
  /**
@@ -45,11 +45,9 @@ export default class Market {
45
45
  /**
46
46
  * Create Market
47
47
  * @param args.markets - Array of markets to create
48
- * @param args.markets.marketId - Market ID
49
48
  * @param args.markets.startTime - start time
50
49
  * @param args.markets.endTime - end time
51
50
  * @param args.markets.question - question (max 80 characters)
52
- * @param args.markets.liquidityAtStart - liquidity at start
53
51
  * @param args.markets.payoutFee - payout fee (to add affiliate system)
54
52
  * @param args.customer - The customer of the market
55
53
  * @param args.poolId - The ID of the pool
@@ -125,10 +123,9 @@ export default class Market {
125
123
  /**
126
124
  * Create Market Pyth
127
125
  * @param args.markets - Array of markets to create
128
- * @param args.markets.marketId - Market ID
129
126
  * @param args.markets.resolveIn - Time to add for resolver the market in seconds
130
- * @param args.customer - The customer of the market
131
- * @param args.poolId - The ID of the pool
127
+ * @param args.markets.customer - The customer of the market
128
+ * @param args.markets.poolId - The ID of the pool
132
129
  */
133
130
  createMarketPyth({ markets }: CreateMarketPythArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
134
131
  /**
@@ -139,7 +136,6 @@ export default class Market {
139
136
  * @param toResolve.poolId - Pool ID
140
137
  * @param toResolve.withPayout - Whether to update market payout
141
138
  * @param market - Market to create
142
- * @param market.marketId - Market ID
143
139
  * @param market.resolveIn - Time to add for resolver the market in seconds
144
140
  * @param market.direction - Direction of the market
145
141
  * @param market.customer - The customer of the market
@@ -153,11 +149,15 @@ export default class Market {
153
149
  * @param toResolve.winningDirection - Winning direction
154
150
  * @param toResolve.withPayout - Whether to update market payout
155
151
  * @param market - Market to create
156
- * @param market.marketId - Market ID
157
152
  * @param market.resolveIn - Time to add for resolver the market in seconds
158
- * @param market.direction - Direction of the market
159
153
  * @param market.customer - The customer of the market
160
154
  * @param market.poolId - The ID of the pool
161
155
  */
162
156
  createAndResolveMarket(toResolve: UpdateMarketWinningDirectionArgs['markets'][0], market: CreateMarketArgs['markets'][0], customer: PublicKey): Promise<string | import("@solana/web3.js").VersionedTransaction>;
157
+ /**
158
+ * Update Central
159
+ * @param args.nextMarketId - Override the next market ID
160
+ * @param args.isLocked - Lock or unlock the protocol
161
+ */
162
+ updateCentral({ nextMarketId, isLocked }: UpdateCentralArgs): Promise<string | import("@solana/web3.js").VersionedTransaction>;
163
163
  }
package/dist/market.js CHANGED
@@ -93,21 +93,13 @@ class Market {
93
93
  });
94
94
  }
95
95
  /**
96
- * Get Current Market ID
96
+ * Get Next Market ID (from central account)
97
97
  */
98
98
  nextMarketId() {
99
99
  return __awaiter(this, void 0, void 0, function* () {
100
- let validId = null;
101
- while (!validId) {
102
- const marketId = Math.floor(Math.random() * 1000000000000000);
103
- try {
104
- yield this.program.account.marketV2.fetch((0, pda_1.getMarketPDA)(this.program.programId, marketId));
105
- }
106
- catch (_a) {
107
- validId = marketId;
108
- }
109
- }
110
- return validId;
100
+ const centralPDA = (0, pda_1.getCentralPDA)(this.program.programId);
101
+ const central = yield this.program.account.central.fetch(centralPDA);
102
+ return central.nextMarketId.toNumber() + 1;
111
103
  });
112
104
  }
113
105
  /**
@@ -122,11 +114,9 @@ class Market {
122
114
  /**
123
115
  * Create Market
124
116
  * @param args.markets - Array of markets to create
125
- * @param args.markets.marketId - Market ID
126
117
  * @param args.markets.startTime - start time
127
118
  * @param args.markets.endTime - end time
128
119
  * @param args.markets.question - question (max 80 characters)
129
- * @param args.markets.liquidityAtStart - liquidity at start
130
120
  * @param args.markets.payoutFee - payout fee (to add affiliate system)
131
121
  * @param args.customer - The customer of the market
132
122
  * @param args.poolId - The ID of the pool
@@ -134,17 +124,22 @@ class Market {
134
124
  createMarket({ markets, customer, poolId }) {
135
125
  return __awaiter(this, void 0, void 0, function* () {
136
126
  const ixs = [];
127
+ const centralPDA = (0, pda_1.getCentralPDA)(this.program.programId);
128
+ const central = yield this.program.account.central.fetch(centralPDA);
129
+ const baseMarketId = central.nextMarketId.toNumber();
137
130
  let poolPDA = null;
138
131
  if (poolId) {
139
132
  poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
140
133
  }
141
- for (const market of markets) {
134
+ for (let i = 0; i < markets.length; i++) {
135
+ const market = markets[i];
136
+ const nextMarketId = baseMarketId + 1 + i;
142
137
  if (market.question.length > 80) {
143
138
  throw new Error('Question must be less than 80 characters');
144
139
  }
140
+ const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, nextMarketId);
145
141
  ixs.push(yield this.program.methods
146
142
  .createMarket({
147
- marketId: new bn_js_1.default(market.marketId),
148
143
  question: (0, helpers_1.encodeString)(market.question, 80),
149
144
  marketStart: new bn_js_1.default(market.startTime),
150
145
  marketEnd: new bn_js_1.default(market.endTime),
@@ -156,14 +151,15 @@ class Market {
156
151
  .accounts({
157
152
  signer: this.program.provider.publicKey,
158
153
  pool: poolPDA,
159
- customer
154
+ customer,
155
+ market: marketPDA
160
156
  })
161
157
  .instruction());
162
158
  ixs.push(yield this.program.methods
163
- .createOrderBook(new bn_js_1.default(market.marketId))
159
+ .createOrderBook()
164
160
  .accounts({
165
161
  signer: this.program.provider.publicKey,
166
- market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
162
+ market: marketPDA
167
163
  })
168
164
  .instruction());
169
165
  }
@@ -209,13 +205,17 @@ class Market {
209
205
  feed: (0, helpers_1.getFeedIdFromHex)(feedId)
210
206
  })
211
207
  .instruction());
212
- for (const market of markets) {
208
+ const centralPDA = (0, pda_1.getCentralPDA)(this.program.programId);
209
+ const central = yield this.program.account.central.fetch(centralPDA);
210
+ const baseMarketId = central.nextMarketId.toNumber();
211
+ for (let i = 0; i < markets.length; i++) {
212
+ const market = markets[i];
213
+ const nextMarketId = baseMarketId + 1 + i;
213
214
  if (market.question.length > 80) {
214
215
  throw new Error('Market question must be less than 80 characters');
215
216
  }
216
217
  ixs.push(yield this.program.methods
217
218
  .createMarket({
218
- marketId: new bn_js_1.default(market.marketId),
219
219
  question: (0, helpers_1.encodeString)(market.question, 80),
220
220
  marketStart: new bn_js_1.default(startTime),
221
221
  marketEnd: new bn_js_1.default(endTime),
@@ -231,10 +231,10 @@ class Market {
231
231
  })
232
232
  .instruction());
233
233
  ixs.push(yield this.program.methods
234
- .createOrderBook(new bn_js_1.default(market.marketId))
234
+ .createOrderBook()
235
235
  .accounts({
236
236
  signer: this.program.provider.publicKey,
237
- market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
237
+ market: (0, pda_1.getMarketPDA)(this.program.programId, nextMarketId)
238
238
  })
239
239
  .instruction());
240
240
  }
@@ -395,20 +395,23 @@ class Market {
395
395
  /**
396
396
  * Create Market Pyth
397
397
  * @param args.markets - Array of markets to create
398
- * @param args.markets.marketId - Market ID
399
398
  * @param args.markets.resolveIn - Time to add for resolver the market in seconds
400
- * @param args.customer - The customer of the market
401
- * @param args.poolId - The ID of the pool
399
+ * @param args.markets.customer - The customer of the market
400
+ * @param args.markets.poolId - The ID of the pool
402
401
  */
403
402
  createMarketPyth({ markets }) {
404
403
  return __awaiter(this, void 0, void 0, function* () {
405
404
  const ixs = [];
406
- for (const market of markets) {
407
- let poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, market.poolId);
405
+ const centralPDA = (0, pda_1.getCentralPDA)(this.program.programId);
406
+ const central = yield this.program.account.central.fetch(centralPDA);
407
+ const baseMarketId = central.nextMarketId.toNumber();
408
+ for (let i = 0; i < markets.length; i++) {
409
+ const market = markets[i];
410
+ const nextMarketId = baseMarketId + 1 + i;
411
+ const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, market.poolId);
408
412
  const feedPDA = (0, helpers_2.getPriceFeedAccountForProgram)(market.feedId);
409
413
  ixs.push(yield this.program.methods
410
414
  .createMarketPyth({
411
- marketId: new bn_js_1.default(market.marketId),
412
415
  resolveIn: new bn_js_1.default(market.resolveIn),
413
416
  direction: market.direction
414
417
  })
@@ -420,10 +423,10 @@ class Market {
420
423
  })
421
424
  .instruction());
422
425
  ixs.push(yield this.program.methods
423
- .createOrderBook(new bn_js_1.default(market.marketId))
426
+ .createOrderBook()
424
427
  .accounts({
425
428
  signer: this.program.provider.publicKey,
426
- market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
429
+ market: (0, pda_1.getMarketPDA)(this.program.programId, nextMarketId)
427
430
  })
428
431
  .instruction());
429
432
  }
@@ -438,7 +441,6 @@ class Market {
438
441
  * @param toResolve.poolId - Pool ID
439
442
  * @param toResolve.withPayout - Whether to update market payout
440
443
  * @param market - Market to create
441
- * @param market.marketId - Market ID
442
444
  * @param market.resolveIn - Time to add for resolver the market in seconds
443
445
  * @param market.direction - Direction of the market
444
446
  * @param market.customer - The customer of the market
@@ -447,7 +449,11 @@ class Market {
447
449
  createAndResolvePythMarket(toResolve, market) {
448
450
  return __awaiter(this, void 0, void 0, function* () {
449
451
  const ixs = [];
450
- const marketInfo = yield this.getMarketById(toResolve.marketId);
452
+ const [marketInfo, central] = yield Promise.all([
453
+ this.getMarketById(toResolve.marketId),
454
+ this.program.account.central.fetch((0, pda_1.getCentralPDA)(this.program.programId))
455
+ ]);
456
+ const nextMarketId = central.nextMarketId.toNumber() + 1;
451
457
  if (marketInfo.winningDirection === types_1.WinningDirection.NONE) {
452
458
  ixs.push(yield this.program.methods
453
459
  .updateMarketWinningDirection(toResolve.winningDirection)
@@ -472,7 +478,6 @@ class Market {
472
478
  const feedPDA = (0, helpers_2.getPriceFeedAccountForProgram)(market.feedId);
473
479
  ixs.push(yield this.program.methods
474
480
  .createMarketPyth({
475
- marketId: new bn_js_1.default(market.marketId),
476
481
  resolveIn: new bn_js_1.default(market.resolveIn),
477
482
  direction: market.direction
478
483
  })
@@ -486,10 +491,10 @@ class Market {
486
491
  })
487
492
  .instruction());
488
493
  ixs.push(yield this.program.methods
489
- .createOrderBook(new bn_js_1.default(market.marketId))
494
+ .createOrderBook()
490
495
  .accounts({
491
496
  signer: this.program.provider.publicKey,
492
- market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
497
+ market: (0, pda_1.getMarketPDA)(this.program.programId, nextMarketId)
493
498
  })
494
499
  .instruction());
495
500
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
@@ -502,16 +507,18 @@ class Market {
502
507
  * @param toResolve.winningDirection - Winning direction
503
508
  * @param toResolve.withPayout - Whether to update market payout
504
509
  * @param market - Market to create
505
- * @param market.marketId - Market ID
506
510
  * @param market.resolveIn - Time to add for resolver the market in seconds
507
- * @param market.direction - Direction of the market
508
511
  * @param market.customer - The customer of the market
509
512
  * @param market.poolId - The ID of the pool
510
513
  */
511
514
  createAndResolveMarket(toResolve, market, customer) {
512
515
  return __awaiter(this, void 0, void 0, function* () {
513
516
  const ixs = [];
514
- const marketInfo = yield this.getMarketById(toResolve.marketId);
517
+ const [marketInfo, central] = yield Promise.all([
518
+ this.getMarketById(toResolve.marketId),
519
+ this.program.account.central.fetch((0, pda_1.getCentralPDA)(this.program.programId))
520
+ ]);
521
+ const nextMarketId = central.nextMarketId.toNumber() + 1;
515
522
  if (marketInfo.winningDirection === types_1.WinningDirection.NONE) {
516
523
  ixs.push(yield this.program.methods
517
524
  .updateMarketWinningDirection(toResolve.winningDirection)
@@ -535,7 +542,6 @@ class Market {
535
542
  }
536
543
  ixs.push(yield this.program.methods
537
544
  .createMarket({
538
- marketId: new bn_js_1.default(market.marketId),
539
545
  question: (0, helpers_1.encodeString)(market.question, 80),
540
546
  marketStart: new bn_js_1.default(market.startTime),
541
547
  marketEnd: new bn_js_1.default(market.endTime),
@@ -553,14 +559,35 @@ class Market {
553
559
  })
554
560
  .instruction());
555
561
  ixs.push(yield this.program.methods
556
- .createOrderBook(new bn_js_1.default(market.marketId))
562
+ .createOrderBook()
557
563
  .accounts({
558
564
  signer: this.program.provider.publicKey,
559
- market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
565
+ market: (0, pda_1.getMarketPDA)(this.program.programId, nextMarketId)
560
566
  })
561
567
  .instruction());
562
568
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
563
569
  });
564
570
  }
571
+ /**
572
+ * Update Central
573
+ * @param args.nextMarketId - Override the next market ID
574
+ * @param args.isLocked - Lock or unlock the protocol
575
+ */
576
+ updateCentral({ nextMarketId, isLocked }) {
577
+ return __awaiter(this, void 0, void 0, function* () {
578
+ const ixs = [
579
+ yield this.program.methods
580
+ .updateCentral({
581
+ nextMarketId: nextMarketId != null ? new bn_js_1.default(nextMarketId) : null,
582
+ isLocked: isLocked !== null && isLocked !== void 0 ? isLocked : null
583
+ })
584
+ .accounts({
585
+ signer: this.program.provider.publicKey
586
+ })
587
+ .instruction()
588
+ ];
589
+ return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
590
+ });
591
+ }
565
592
  }
566
593
  exports.default = Market;
@@ -310,11 +310,6 @@
310
310
  "writable": true,
311
311
  "signer": true
312
312
  },
313
- {
314
- "name": "squads",
315
- "writable": true,
316
- "address": "Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4"
317
- },
318
313
  {
319
314
  "name": "market",
320
315
  "writable": true,
@@ -381,6 +376,114 @@
381
376
  ],
382
377
  "args": []
383
378
  },
379
+ {
380
+ "name": "collect_central_fee",
381
+ "discriminator": [6, 142, 3, 94, 210, 59, 147, 136],
382
+ "accounts": [
383
+ {
384
+ "name": "signer",
385
+ "writable": true,
386
+ "signer": true
387
+ },
388
+ {
389
+ "name": "central",
390
+ "writable": true,
391
+ "pda": {
392
+ "seeds": [
393
+ {
394
+ "kind": "const",
395
+ "value": [99, 101, 110, 116, 114, 97, 108]
396
+ },
397
+ {
398
+ "kind": "const",
399
+ "value": [
400
+ 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
401
+ ]
402
+ }
403
+ ]
404
+ }
405
+ },
406
+ {
407
+ "name": "fee_recipient",
408
+ "writable": true,
409
+ "address": "Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4"
410
+ },
411
+ {
412
+ "name": "mint",
413
+ "writable": true,
414
+ "address": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
415
+ },
416
+ {
417
+ "name": "central_ata",
418
+ "writable": true,
419
+ "pda": {
420
+ "seeds": [
421
+ {
422
+ "kind": "account",
423
+ "path": "central"
424
+ },
425
+ {
426
+ "kind": "account",
427
+ "path": "token_program"
428
+ },
429
+ {
430
+ "kind": "account",
431
+ "path": "mint"
432
+ }
433
+ ],
434
+ "program": {
435
+ "kind": "const",
436
+ "value": [
437
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
438
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
439
+ 219, 233, 248, 89
440
+ ]
441
+ }
442
+ }
443
+ },
444
+ {
445
+ "name": "fee_recipient_ata",
446
+ "writable": true,
447
+ "pda": {
448
+ "seeds": [
449
+ {
450
+ "kind": "account",
451
+ "path": "fee_recipient"
452
+ },
453
+ {
454
+ "kind": "account",
455
+ "path": "token_program"
456
+ },
457
+ {
458
+ "kind": "account",
459
+ "path": "mint"
460
+ }
461
+ ],
462
+ "program": {
463
+ "kind": "const",
464
+ "value": [
465
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
466
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
467
+ 219, 233, 248, 89
468
+ ]
469
+ }
470
+ }
471
+ },
472
+ {
473
+ "name": "token_program",
474
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
475
+ },
476
+ {
477
+ "name": "associated_token_program",
478
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
479
+ },
480
+ {
481
+ "name": "system_program",
482
+ "address": "11111111111111111111111111111111"
483
+ }
484
+ ],
485
+ "args": []
486
+ },
384
487
  {
385
488
  "name": "collect_customer_fee",
386
489
  "discriminator": [187, 253, 215, 126, 168, 246, 253, 21],
@@ -680,30 +783,36 @@
680
783
  "signer": true
681
784
  },
682
785
  {
683
- "name": "customer",
684
- "writable": true
685
- },
686
- {
687
- "name": "pool",
688
- "writable": true,
689
- "optional": true
690
- },
691
- {
692
- "name": "market",
786
+ "name": "central",
693
787
  "writable": true,
694
788
  "pda": {
695
789
  "seeds": [
696
790
  {
697
791
  "kind": "const",
698
- "value": [109, 97, 114, 107, 101, 116]
792
+ "value": [99, 101, 110, 116, 114, 97, 108]
699
793
  },
700
794
  {
701
- "kind": "arg",
702
- "path": "args.market_id"
795
+ "kind": "const",
796
+ "value": [
797
+ 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
798
+ ]
703
799
  }
704
800
  ]
705
801
  }
706
802
  },
803
+ {
804
+ "name": "customer",
805
+ "writable": true
806
+ },
807
+ {
808
+ "name": "pool",
809
+ "writable": true,
810
+ "optional": true
811
+ },
812
+ {
813
+ "name": "market",
814
+ "writable": true
815
+ },
707
816
  {
708
817
  "name": "system_program",
709
818
  "address": "11111111111111111111111111111111"
@@ -730,29 +839,35 @@
730
839
  "signer": true
731
840
  },
732
841
  {
733
- "name": "customer",
734
- "writable": true
735
- },
736
- {
737
- "name": "pool",
738
- "writable": true
739
- },
740
- {
741
- "name": "market",
842
+ "name": "central",
742
843
  "writable": true,
743
844
  "pda": {
744
845
  "seeds": [
745
846
  {
746
847
  "kind": "const",
747
- "value": [109, 97, 114, 107, 101, 116]
848
+ "value": [99, 101, 110, 116, 114, 97, 108]
748
849
  },
749
850
  {
750
- "kind": "arg",
751
- "path": "args.market_id"
851
+ "kind": "const",
852
+ "value": [
853
+ 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
854
+ ]
752
855
  }
753
856
  ]
754
857
  }
755
858
  },
859
+ {
860
+ "name": "customer",
861
+ "writable": true
862
+ },
863
+ {
864
+ "name": "pool",
865
+ "writable": true
866
+ },
867
+ {
868
+ "name": "market",
869
+ "writable": true
870
+ },
756
871
  {
757
872
  "name": "price_update",
758
873
  "writable": true
@@ -796,8 +911,9 @@
796
911
  "value": [111, 114, 100, 101, 114, 95, 98, 111, 111, 107]
797
912
  },
798
913
  {
799
- "kind": "arg",
800
- "path": "market_id"
914
+ "kind": "account",
915
+ "path": "market.market_id",
916
+ "account": "MarketV2"
801
917
  }
802
918
  ]
803
919
  }
@@ -807,12 +923,7 @@
807
923
  "address": "11111111111111111111111111111111"
808
924
  }
809
925
  ],
810
- "args": [
811
- {
812
- "name": "market_id",
813
- "type": "u64"
814
- }
815
- ]
926
+ "args": []
816
927
  },
817
928
  {
818
929
  "name": "create_pool",
@@ -1610,6 +1721,49 @@
1610
1721
  ],
1611
1722
  "args": []
1612
1723
  },
1724
+ {
1725
+ "name": "update_central",
1726
+ "discriminator": [251, 46, 123, 120, 218, 7, 245, 140],
1727
+ "accounts": [
1728
+ {
1729
+ "name": "signer",
1730
+ "writable": true,
1731
+ "signer": true
1732
+ },
1733
+ {
1734
+ "name": "central",
1735
+ "writable": true,
1736
+ "pda": {
1737
+ "seeds": [
1738
+ {
1739
+ "kind": "const",
1740
+ "value": [99, 101, 110, 116, 114, 97, 108]
1741
+ },
1742
+ {
1743
+ "kind": "const",
1744
+ "value": [
1745
+ 116, 114, 105, 97, 100, 109, 97, 114, 107, 101, 116, 115
1746
+ ]
1747
+ }
1748
+ ]
1749
+ }
1750
+ },
1751
+ {
1752
+ "name": "system_program",
1753
+ "address": "11111111111111111111111111111111"
1754
+ }
1755
+ ],
1756
+ "args": [
1757
+ {
1758
+ "name": "args",
1759
+ "type": {
1760
+ "defined": {
1761
+ "name": "UpdateCentralArgs"
1762
+ }
1763
+ }
1764
+ }
1765
+ ]
1766
+ },
1613
1767
  {
1614
1768
  "name": "update_customer",
1615
1769
  "discriminator": [158, 118, 103, 177, 241, 229, 169, 124],
@@ -2557,10 +2711,14 @@
2557
2711
  "name": "rewards_paid",
2558
2712
  "type": "u64"
2559
2713
  },
2714
+ {
2715
+ "name": "next_market_id",
2716
+ "type": "u64"
2717
+ },
2560
2718
  {
2561
2719
  "name": "padding",
2562
2720
  "type": {
2563
- "array": ["u8", 295]
2721
+ "array": ["u8", 287]
2564
2722
  }
2565
2723
  }
2566
2724
  ]
@@ -2689,10 +2847,6 @@
2689
2847
  "type": {
2690
2848
  "kind": "struct",
2691
2849
  "fields": [
2692
- {
2693
- "name": "market_id",
2694
- "type": "u64"
2695
- },
2696
2850
  {
2697
2851
  "name": "question",
2698
2852
  "type": {
@@ -2731,10 +2885,6 @@
2731
2885
  "type": {
2732
2886
  "kind": "struct",
2733
2887
  "fields": [
2734
- {
2735
- "name": "market_id",
2736
- "type": "u64"
2737
- },
2738
2888
  {
2739
2889
  "name": "resolve_in",
2740
2890
  "type": "i64"
@@ -4014,6 +4164,26 @@
4014
4164
  ]
4015
4165
  }
4016
4166
  },
4167
+ {
4168
+ "name": "UpdateCentralArgs",
4169
+ "type": {
4170
+ "kind": "struct",
4171
+ "fields": [
4172
+ {
4173
+ "name": "next_market_id",
4174
+ "type": {
4175
+ "option": "u64"
4176
+ }
4177
+ },
4178
+ {
4179
+ "name": "is_locked",
4180
+ "type": {
4181
+ "option": "bool"
4182
+ }
4183
+ }
4184
+ ]
4185
+ }
4186
+ },
4017
4187
  {
4018
4188
  "name": "UpdateCustomerArgs",
4019
4189
  "type": {
@@ -61,6 +61,7 @@ export type Central = {
61
61
  feeAvailable: number;
62
62
  feeClaimed: number;
63
63
  rewardsPaid: number;
64
+ nextMarketId: number;
64
65
  };
65
66
  export type BookOrder = {
66
67
  id: string;
@@ -147,7 +148,6 @@ export type InitializeMarketArgs = {
147
148
  };
148
149
  export type CreateMarketArgs = {
149
150
  markets: {
150
- marketId: number;
151
151
  startTime: number;
152
152
  endTime: number;
153
153
  question: string;
@@ -159,7 +159,6 @@ export type CreateMarketArgs = {
159
159
  };
160
160
  export type CreateMarketPythArgs = {
161
161
  markets: {
162
- marketId: number;
163
162
  resolveIn: number;
164
163
  customer: PublicKey;
165
164
  poolId: number;
@@ -167,6 +166,10 @@ export type CreateMarketPythArgs = {
167
166
  direction: 'Above' | 'Below';
168
167
  }[];
169
168
  };
169
+ export type UpdateCentralArgs = {
170
+ nextMarketId?: number;
171
+ isLocked?: boolean;
172
+ };
170
173
  export type CreatePoolArgs = {
171
174
  poolId: number;
172
175
  question?: string;
@@ -415,11 +415,6 @@ export type TriadProtocol = {
415
415
  writable: true;
416
416
  signer: true;
417
417
  },
418
- {
419
- name: 'squads';
420
- writable: true;
421
- address: 'Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4';
422
- },
423
418
  {
424
419
  name: 'market';
425
420
  writable: true;
@@ -486,6 +481,183 @@ export type TriadProtocol = {
486
481
  ];
487
482
  args: [];
488
483
  },
484
+ {
485
+ name: 'collectCentralFee';
486
+ discriminator: [6, 142, 3, 94, 210, 59, 147, 136];
487
+ accounts: [
488
+ {
489
+ name: 'signer';
490
+ writable: true;
491
+ signer: true;
492
+ },
493
+ {
494
+ name: 'central';
495
+ writable: true;
496
+ pda: {
497
+ seeds: [
498
+ {
499
+ kind: 'const';
500
+ value: [99, 101, 110, 116, 114, 97, 108];
501
+ },
502
+ {
503
+ kind: 'const';
504
+ value: [
505
+ 116,
506
+ 114,
507
+ 105,
508
+ 97,
509
+ 100,
510
+ 109,
511
+ 97,
512
+ 114,
513
+ 107,
514
+ 101,
515
+ 116,
516
+ 115
517
+ ];
518
+ }
519
+ ];
520
+ };
521
+ },
522
+ {
523
+ name: 'feeRecipient';
524
+ writable: true;
525
+ address: 'Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4';
526
+ },
527
+ {
528
+ name: 'mint';
529
+ writable: true;
530
+ address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
531
+ },
532
+ {
533
+ name: 'centralAta';
534
+ writable: true;
535
+ pda: {
536
+ seeds: [
537
+ {
538
+ kind: 'account';
539
+ path: 'central';
540
+ },
541
+ {
542
+ kind: 'account';
543
+ path: 'tokenProgram';
544
+ },
545
+ {
546
+ kind: 'account';
547
+ path: 'mint';
548
+ }
549
+ ];
550
+ program: {
551
+ kind: 'const';
552
+ value: [
553
+ 140,
554
+ 151,
555
+ 37,
556
+ 143,
557
+ 78,
558
+ 36,
559
+ 137,
560
+ 241,
561
+ 187,
562
+ 61,
563
+ 16,
564
+ 41,
565
+ 20,
566
+ 142,
567
+ 13,
568
+ 131,
569
+ 11,
570
+ 90,
571
+ 19,
572
+ 153,
573
+ 218,
574
+ 255,
575
+ 16,
576
+ 132,
577
+ 4,
578
+ 142,
579
+ 123,
580
+ 216,
581
+ 219,
582
+ 233,
583
+ 248,
584
+ 89
585
+ ];
586
+ };
587
+ };
588
+ },
589
+ {
590
+ name: 'feeRecipientAta';
591
+ writable: true;
592
+ pda: {
593
+ seeds: [
594
+ {
595
+ kind: 'account';
596
+ path: 'feeRecipient';
597
+ },
598
+ {
599
+ kind: 'account';
600
+ path: 'tokenProgram';
601
+ },
602
+ {
603
+ kind: 'account';
604
+ path: 'mint';
605
+ }
606
+ ];
607
+ program: {
608
+ kind: 'const';
609
+ value: [
610
+ 140,
611
+ 151,
612
+ 37,
613
+ 143,
614
+ 78,
615
+ 36,
616
+ 137,
617
+ 241,
618
+ 187,
619
+ 61,
620
+ 16,
621
+ 41,
622
+ 20,
623
+ 142,
624
+ 13,
625
+ 131,
626
+ 11,
627
+ 90,
628
+ 19,
629
+ 153,
630
+ 218,
631
+ 255,
632
+ 16,
633
+ 132,
634
+ 4,
635
+ 142,
636
+ 123,
637
+ 216,
638
+ 219,
639
+ 233,
640
+ 248,
641
+ 89
642
+ ];
643
+ };
644
+ };
645
+ },
646
+ {
647
+ name: 'tokenProgram';
648
+ address: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA';
649
+ },
650
+ {
651
+ name: 'associatedTokenProgram';
652
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
653
+ },
654
+ {
655
+ name: 'systemProgram';
656
+ address: '11111111111111111111111111111111';
657
+ }
658
+ ];
659
+ args: [];
660
+ },
489
661
  {
490
662
  name: 'collectCustomerFee';
491
663
  discriminator: [187, 253, 215, 126, 168, 246, 253, 21];
@@ -922,6 +1094,35 @@ export type TriadProtocol = {
922
1094
  writable: true;
923
1095
  signer: true;
924
1096
  },
1097
+ {
1098
+ name: 'central';
1099
+ writable: true;
1100
+ pda: {
1101
+ seeds: [
1102
+ {
1103
+ kind: 'const';
1104
+ value: [99, 101, 110, 116, 114, 97, 108];
1105
+ },
1106
+ {
1107
+ kind: 'const';
1108
+ value: [
1109
+ 116,
1110
+ 114,
1111
+ 105,
1112
+ 97,
1113
+ 100,
1114
+ 109,
1115
+ 97,
1116
+ 114,
1117
+ 107,
1118
+ 101,
1119
+ 116,
1120
+ 115
1121
+ ];
1122
+ }
1123
+ ];
1124
+ };
1125
+ },
925
1126
  {
926
1127
  name: 'customer';
927
1128
  writable: true;
@@ -934,18 +1135,6 @@ export type TriadProtocol = {
934
1135
  {
935
1136
  name: 'market';
936
1137
  writable: true;
937
- pda: {
938
- seeds: [
939
- {
940
- kind: 'const';
941
- value: [109, 97, 114, 107, 101, 116];
942
- },
943
- {
944
- kind: 'arg';
945
- path: 'args.market_id';
946
- }
947
- ];
948
- };
949
1138
  },
950
1139
  {
951
1140
  name: 'systemProgram';
@@ -973,29 +1162,46 @@ export type TriadProtocol = {
973
1162
  signer: true;
974
1163
  },
975
1164
  {
976
- name: 'customer';
977
- writable: true;
978
- },
979
- {
980
- name: 'pool';
981
- writable: true;
982
- },
983
- {
984
- name: 'market';
1165
+ name: 'central';
985
1166
  writable: true;
986
1167
  pda: {
987
1168
  seeds: [
988
1169
  {
989
1170
  kind: 'const';
990
- value: [109, 97, 114, 107, 101, 116];
1171
+ value: [99, 101, 110, 116, 114, 97, 108];
991
1172
  },
992
1173
  {
993
- kind: 'arg';
994
- path: 'args.market_id';
1174
+ kind: 'const';
1175
+ value: [
1176
+ 116,
1177
+ 114,
1178
+ 105,
1179
+ 97,
1180
+ 100,
1181
+ 109,
1182
+ 97,
1183
+ 114,
1184
+ 107,
1185
+ 101,
1186
+ 116,
1187
+ 115
1188
+ ];
995
1189
  }
996
1190
  ];
997
1191
  };
998
1192
  },
1193
+ {
1194
+ name: 'customer';
1195
+ writable: true;
1196
+ },
1197
+ {
1198
+ name: 'pool';
1199
+ writable: true;
1200
+ },
1201
+ {
1202
+ name: 'market';
1203
+ writable: true;
1204
+ },
999
1205
  {
1000
1206
  name: 'priceUpdate';
1001
1207
  writable: true;
@@ -1039,8 +1245,9 @@ export type TriadProtocol = {
1039
1245
  value: [111, 114, 100, 101, 114, 95, 98, 111, 111, 107];
1040
1246
  },
1041
1247
  {
1042
- kind: 'arg';
1043
- path: 'marketId';
1248
+ kind: 'account';
1249
+ path: 'market.market_id';
1250
+ account: 'marketV2';
1044
1251
  }
1045
1252
  ];
1046
1253
  };
@@ -1050,12 +1257,7 @@ export type TriadProtocol = {
1050
1257
  address: '11111111111111111111111111111111';
1051
1258
  }
1052
1259
  ];
1053
- args: [
1054
- {
1055
- name: 'marketId';
1056
- type: 'u64';
1057
- }
1058
- ];
1260
+ args: [];
1059
1261
  },
1060
1262
  {
1061
1263
  name: 'createPool';
@@ -2078,6 +2280,60 @@ export type TriadProtocol = {
2078
2280
  ];
2079
2281
  args: [];
2080
2282
  },
2283
+ {
2284
+ name: 'updateCentral';
2285
+ discriminator: [251, 46, 123, 120, 218, 7, 245, 140];
2286
+ accounts: [
2287
+ {
2288
+ name: 'signer';
2289
+ writable: true;
2290
+ signer: true;
2291
+ },
2292
+ {
2293
+ name: 'central';
2294
+ writable: true;
2295
+ pda: {
2296
+ seeds: [
2297
+ {
2298
+ kind: 'const';
2299
+ value: [99, 101, 110, 116, 114, 97, 108];
2300
+ },
2301
+ {
2302
+ kind: 'const';
2303
+ value: [
2304
+ 116,
2305
+ 114,
2306
+ 105,
2307
+ 97,
2308
+ 100,
2309
+ 109,
2310
+ 97,
2311
+ 114,
2312
+ 107,
2313
+ 101,
2314
+ 116,
2315
+ 115
2316
+ ];
2317
+ }
2318
+ ];
2319
+ };
2320
+ },
2321
+ {
2322
+ name: 'systemProgram';
2323
+ address: '11111111111111111111111111111111';
2324
+ }
2325
+ ];
2326
+ args: [
2327
+ {
2328
+ name: 'args';
2329
+ type: {
2330
+ defined: {
2331
+ name: 'updateCentralArgs';
2332
+ };
2333
+ };
2334
+ }
2335
+ ];
2336
+ },
2081
2337
  {
2082
2338
  name: 'updateCustomer';
2083
2339
  discriminator: [158, 118, 103, 177, 241, 229, 169, 124];
@@ -3094,10 +3350,14 @@ export type TriadProtocol = {
3094
3350
  name: 'rewardsPaid';
3095
3351
  type: 'u64';
3096
3352
  },
3353
+ {
3354
+ name: 'nextMarketId';
3355
+ type: 'u64';
3356
+ },
3097
3357
  {
3098
3358
  name: 'padding';
3099
3359
  type: {
3100
- array: ['u8', 295];
3360
+ array: ['u8', 287];
3101
3361
  };
3102
3362
  }
3103
3363
  ];
@@ -3226,10 +3486,6 @@ export type TriadProtocol = {
3226
3486
  type: {
3227
3487
  kind: 'struct';
3228
3488
  fields: [
3229
- {
3230
- name: 'marketId';
3231
- type: 'u64';
3232
- },
3233
3489
  {
3234
3490
  name: 'question';
3235
3491
  type: {
@@ -3268,10 +3524,6 @@ export type TriadProtocol = {
3268
3524
  type: {
3269
3525
  kind: 'struct';
3270
3526
  fields: [
3271
- {
3272
- name: 'marketId';
3273
- type: 'u64';
3274
- },
3275
3527
  {
3276
3528
  name: 'resolveIn';
3277
3529
  type: 'i64';
@@ -4551,6 +4803,26 @@ export type TriadProtocol = {
4551
4803
  ];
4552
4804
  };
4553
4805
  },
4806
+ {
4807
+ name: 'updateCentralArgs';
4808
+ type: {
4809
+ kind: 'struct';
4810
+ fields: [
4811
+ {
4812
+ name: 'nextMarketId';
4813
+ type: {
4814
+ option: 'u64';
4815
+ };
4816
+ },
4817
+ {
4818
+ name: 'isLocked';
4819
+ type: {
4820
+ option: 'bool';
4821
+ };
4822
+ }
4823
+ ];
4824
+ };
4825
+ },
4554
4826
  {
4555
4827
  name: 'updateCustomerArgs';
4556
4828
  type: {
@@ -278,7 +278,8 @@ const formatCentral = (account, publicKey) => {
278
278
  isLocked: account.isLocked,
279
279
  feeAvailable: account.feeAvailable.toNumber() / 1e6,
280
280
  feeClaimed: account.feeClaimed.toNumber() / 1e6,
281
- rewardsPaid: account.rewardsPaid.toNumber() / 1e6
281
+ rewardsPaid: account.rewardsPaid.toNumber() / 1e6,
282
+ nextMarketId: account.nextMarketId.toNumber()
282
283
  };
283
284
  };
284
285
  exports.formatCentral = formatCentral;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "4.4.0",
3
+ "version": "4.4.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",