@triadxyz/triad-protocol 2.4.5-beta → 2.4.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.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
2
2
  import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
3
3
  import BN from 'bn.js';
4
4
  import { TriadProtocol } from './types/triad_protocol';
5
- import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreateOrUpdatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, CollectMarketFeeArgs } from './types';
5
+ import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs, BookOrder, MarketAskOrderArgs, RpcOptions, CollectMarketFeeArgs } from './types';
6
6
  import Stake from './stake';
7
7
  import Poseidon from './poseidon';
8
8
  export default class TriadProtocolClient {
@@ -174,12 +174,11 @@ export default class TriadProtocolClient {
174
174
  * @param args.question - question (max 80 characters)
175
175
  * @param args.liquidityAtStart - liquidity at start
176
176
  * @param args.payoutFee - payout fee (to add affiliate system)
177
- * @param args.currentMarketId - if fast market, we need check the pool parameters
178
177
  *
179
178
  * @param options - RPC options
180
179
  *
181
180
  */
182
- createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint, poolId }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
181
+ createMarket({ markets, customer, mint, poolId }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
183
182
  /**
184
183
  * Create Pool
185
184
  * @param poolId - The ID of the pool
@@ -188,7 +187,7 @@ export default class TriadProtocolClient {
188
187
  *
189
188
  * @param options - RPC options
190
189
  */
191
- createOrUpdatePool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreateOrUpdatePoolArgs, options?: RpcOptions): Promise<string>;
190
+ createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
192
191
  /**
193
192
  * Open Order
194
193
  * @param args.marketId - The ID of the Market
package/dist/index.js CHANGED
@@ -152,52 +152,53 @@ class TriadProtocolClient {
152
152
  * @param args.question - question (max 80 characters)
153
153
  * @param args.liquidityAtStart - liquidity at start
154
154
  * @param args.payoutFee - payout fee (to add affiliate system)
155
- * @param args.currentMarketId - if fast market, we need check the pool parameters
156
155
  *
157
156
  * @param options - RPC options
158
157
  *
159
158
  */
160
- createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint, poolId }, options) {
159
+ createMarket({ markets, customer, mint, poolId }, options) {
161
160
  return __awaiter(this, void 0, void 0, function* () {
162
- if (question.length > 80) {
163
- throw new Error('Question must be less than 80 characters');
164
- }
165
161
  const ixs = [];
166
- let poolPDA = null;
167
- if (poolId) {
168
- poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
169
- }
170
162
  let userTrade = null;
171
163
  try {
172
164
  yield this.getUserTrade(this.program.provider.publicKey);
173
165
  userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
174
166
  }
175
167
  catch (_a) { }
176
- ixs.push(yield this.program.methods
177
- .createMarket({
178
- marketId: new bn_js_1.default(marketId),
179
- question: (0, helpers_1.encodeString)(question, 80),
180
- marketStart: new bn_js_1.default(startTime),
181
- marketEnd: new bn_js_1.default(endTime),
182
- feeBps,
183
- payoutFee
184
- })
185
- .accounts({
186
- signer: this.program.provider.publicKey,
187
- mint,
188
- tokenProgram: (0, helpers_1.getTokenProgram)(mint),
189
- customer,
190
- pool: poolPDA,
191
- userTrade
192
- })
193
- .instruction());
194
- ixs.push(yield this.program.methods
195
- .createOrderBook(new bn_js_1.default(marketId))
196
- .accounts({
197
- signer: this.program.provider.publicKey,
198
- market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
199
- })
200
- .instruction());
168
+ let poolPDA = null;
169
+ if (poolId) {
170
+ poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
171
+ }
172
+ for (const market of markets) {
173
+ if (market.question.length > 80) {
174
+ throw new Error('Question must be less than 80 characters');
175
+ }
176
+ ixs.push(yield this.program.methods
177
+ .createMarket({
178
+ marketId: new bn_js_1.default(market.marketId),
179
+ question: (0, helpers_1.encodeString)(market.question, 80),
180
+ marketStart: new bn_js_1.default(market.startTime),
181
+ marketEnd: new bn_js_1.default(market.endTime),
182
+ feeBps: market.feeBps,
183
+ payoutFee: market.payoutFee
184
+ })
185
+ .accounts({
186
+ signer: this.program.provider.publicKey,
187
+ mint,
188
+ tokenProgram: (0, helpers_1.getTokenProgram)(mint),
189
+ customer,
190
+ pool: poolPDA,
191
+ userTrade
192
+ })
193
+ .instruction());
194
+ ixs.push(yield this.program.methods
195
+ .createOrderBook(new bn_js_1.default(market.marketId))
196
+ .accounts({
197
+ signer: this.program.provider.publicKey,
198
+ market: (0, pda_1.getMarketPDA)(this.program.programId, market.marketId)
199
+ })
200
+ .instruction());
201
+ }
201
202
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
202
203
  });
203
204
  }
@@ -209,34 +210,29 @@ class TriadProtocolClient {
209
210
  *
210
211
  * @param options - RPC options
211
212
  */
212
- createOrUpdatePool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }, options) {
213
+ createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }, options) {
213
214
  return __awaiter(this, void 0, void 0, function* () {
214
215
  if (question.length > 80) {
215
216
  throw new Error('Pool question must be less than 80 characters');
216
217
  }
217
218
  const ixs = [];
218
219
  const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
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
- }
220
+ ixs.push(yield this.program.methods
221
+ .createPool({
222
+ poolId: new bn_js_1.default(poolId),
223
+ question: (0, helpers_1.encodeString)(question, 80),
224
+ isFast
225
+ })
226
+ .accounts({
227
+ signer: this.program.provider.publicKey
228
+ })
229
+ .instruction());
234
230
  let userTrade = null;
235
231
  try {
236
232
  yield this.getUserTrade(this.program.provider.publicKey);
237
233
  userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
238
234
  }
239
- catch (_b) { }
235
+ catch (_a) { }
240
236
  for (const market of markets) {
241
237
  if (market.question.length > 80) {
242
238
  throw new Error('Market question must be less than 80 characters');
@@ -156,18 +156,19 @@ export type OpenOrderArgs = {
156
156
  mint: PublicKey;
157
157
  };
158
158
  export type CreateMarketArgs = {
159
- marketId: number;
160
- startTime: number;
161
- endTime: number;
162
- question: string;
163
- feeBps: number;
159
+ markets: {
160
+ marketId: number;
161
+ startTime: number;
162
+ endTime: number;
163
+ question: string;
164
+ feeBps: number;
165
+ payoutFee: number;
166
+ }[];
164
167
  customer: PublicKey | null;
165
- payoutFee: number;
166
168
  mint: PublicKey;
167
169
  poolId?: number;
168
- currentMarketId?: number;
169
170
  };
170
- export type CreateOrUpdatePoolArgs = {
171
+ export type CreatePoolArgs = {
171
172
  poolId: number;
172
173
  question?: string;
173
174
  startTime: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "2.4.5-beta",
3
+ "version": "2.4.7-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",