@triadxyz/triad-protocol 1.6.8-beta → 1.7.0-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
@@ -39,13 +39,6 @@ export default class TriadProtocolClient {
39
39
  * @param options - RPC options
40
40
  */
41
41
  collectRoyalty(collection: string, options?: RpcOptions): Promise<string>;
42
- /**
43
- * Add Default Poseidon
44
- * @param users - Users
45
- *
46
- * @param options - RPC options
47
- */
48
- addDefaultPoseidon(users: PublicKey[], options?: RpcOptions): Promise<string>;
49
42
  /**
50
43
  * Add Trader Poseidon
51
44
  * @param user - User
package/dist/index.js CHANGED
@@ -100,28 +100,6 @@ class TriadProtocolClient {
100
100
  }), options);
101
101
  });
102
102
  }
103
- /**
104
- * Add Default Poseidon
105
- * @param users - Users
106
- *
107
- * @param options - RPC options
108
- */
109
- addDefaultPoseidon(users, options) {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- const ixs = [];
112
- for (const user of users) {
113
- const UserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, user);
114
- ixs.push(yield this.program.methods
115
- .addDefaultPoseidon()
116
- .accounts({
117
- signer: this.provider.wallet.publicKey,
118
- userTrade: UserTradePDA
119
- })
120
- .instruction());
121
- }
122
- return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
123
- });
124
- }
125
103
  /**
126
104
  * Add Trader Poseidon
127
105
  * @param user - User
package/dist/trade.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { AnchorProvider, Program } from '@coral-xyz/anchor';
2
2
  import { TriadProtocol } from './types/triad_protocol';
3
3
  import { PublicKey } from '@solana/web3.js';
4
- import { InitializeMarketArgs, OpenOrderArgs, UserTrade } from './types/trade';
4
+ import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs } from './types/trade';
5
5
  import { RpcOptions } from './types';
6
6
  import BN from 'bn.js';
7
7
  export default class Trade {
8
8
  private program;
9
9
  private provider;
10
+ mint: PublicKey;
10
11
  constructor(program: Program<TriadProtocol>, provider: AnchorProvider);
11
12
  /**
12
13
  * Get All Markets
@@ -129,7 +130,7 @@ export default class Trade {
129
130
  * @param options - RPC options
130
131
  *
131
132
  */
132
- initializeMarket({ marketId, startTime, endTime, question }: InitializeMarketArgs, options?: RpcOptions): Promise<string>;
133
+ createMarket({ marketId, startTime, endTime, question, feeBps, customer }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
133
134
  /**
134
135
  * Get User Trade Nonce With Slots
135
136
  * @param userTrades - User Trades
@@ -141,7 +142,7 @@ export default class Trade {
141
142
  * @param args.marketId - The ID of the Market
142
143
  * @param args.amount - The amount of the Order
143
144
  * @param args.direction - The direction of the Order
144
- * @param args.token - The token to use for the Order
145
+ * @param args.token - The token of the Order
145
146
  *
146
147
  * @param options - RPC options
147
148
  *
@@ -229,19 +230,13 @@ export default class Trade {
229
230
  */
230
231
  updateMarket(marketId: number, marketEnd: number, options?: RpcOptions): Promise<string>;
231
232
  /**
232
- * Force Cancel Order
233
- * @param args.marketId - The ID of the Market
234
- * @param args.user - The user to force cancel the order for
235
- * @param args.orderId - The ID of the Order
236
- * @param args.userNonce - The nonce of the user
233
+ * Create Customer
234
+ * @param args.id - The ID of the customer
235
+ * @param args.name - The name of the customer
236
+ * @param args.authority - The authority of the customer
237
237
  *
238
238
  * @param options - RPC options
239
239
  *
240
240
  */
241
- forceCancelOrder({ marketId, user, orderId, userNonce }: {
242
- marketId: number;
243
- user: PublicKey;
244
- orderId: number;
245
- userNonce: number;
246
- }, options?: RpcOptions): Promise<string>;
241
+ createCustomer({ id, name, authority }: CreateCustomerArgs, options?: RpcOptions): Promise<string>;
247
242
  }
package/dist/trade.js CHANGED
@@ -23,6 +23,7 @@ class Trade {
23
23
  constructor(program, provider) {
24
24
  this.program = program;
25
25
  this.provider = provider;
26
+ this.mint = constants_1.TRD_MINT;
26
27
  }
27
28
  /**
28
29
  * Get All Markets
@@ -113,21 +114,24 @@ class Trade {
113
114
  * @param options - RPC options
114
115
  *
115
116
  */
116
- initializeMarket({ marketId, startTime, endTime, question }, options) {
117
+ createMarket({ marketId, startTime, endTime, question, feeBps, customer }, options) {
117
118
  return __awaiter(this, void 0, void 0, function* () {
118
119
  if (question.length > 80) {
119
120
  throw new Error('Question must be less than 80 characters');
120
121
  }
121
122
  return (0, sendTransactionWithOptions_1.default)(this.program.methods
122
- .initializeMarket({
123
+ .createMarket({
123
124
  marketId: new bn_js_1.default(marketId),
124
125
  question: (0, helpers_1.encodeString)(question, 80),
125
126
  marketStart: new bn_js_1.default(startTime),
126
- marketEnd: new bn_js_1.default(endTime)
127
+ marketEnd: new bn_js_1.default(endTime),
128
+ feeBps
127
129
  })
128
130
  .accounts({
129
131
  signer: this.provider.publicKey,
130
- mint: constants_1.TRD_MINT
132
+ mint: this.mint,
133
+ tokenProgram: (0, helpers_1.getTokenProgram)(this.mint),
134
+ customer
131
135
  }), options);
132
136
  });
133
137
  }
@@ -169,7 +173,7 @@ class Trade {
169
173
  * @param args.marketId - The ID of the Market
170
174
  * @param args.amount - The amount of the Order
171
175
  * @param args.direction - The direction of the Order
172
- * @param args.token - The token to use for the Order
176
+ * @param args.token - The token of the Order
173
177
  *
174
178
  * @param options - RPC options
175
179
  *
@@ -231,7 +235,7 @@ class Trade {
231
235
  signer: this.provider.publicKey,
232
236
  market: marketPDA,
233
237
  userTrade: userTradePDA,
234
- mint: constants_1.TRD_MINT
238
+ mint: this.mint
235
239
  })
236
240
  .instruction());
237
241
  return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, undefined, addressLookupTableAccounts);
@@ -257,7 +261,7 @@ class Trade {
257
261
  return (0, sendTransactionWithOptions_1.default)(this.program.methods.closeOrder(new bn_js_1.default(orderId)).accounts({
258
262
  signer: this.provider.publicKey,
259
263
  market: marketPDA,
260
- mint: constants_1.TRD_MINT,
264
+ mint: this.mint,
261
265
  userTrade: userTradePDA
262
266
  }), options);
263
267
  });
@@ -295,7 +299,7 @@ class Trade {
295
299
  return (0, sendTransactionWithOptions_1.default)(this.program.methods.collectRemainingLiquidity().accounts({
296
300
  signer: this.provider.publicKey,
297
301
  market: marketPDA,
298
- mint: constants_1.TRD_MINT
302
+ mint: this.mint
299
303
  }), options);
300
304
  });
301
305
  }
@@ -320,7 +324,7 @@ class Trade {
320
324
  signer: this.provider.publicKey,
321
325
  userTrade: userTradePDA,
322
326
  market: marketPDA,
323
- mint: constants_1.TRD_MINT
327
+ mint: this.mint
324
328
  }), options);
325
329
  });
326
330
  }
@@ -374,29 +378,18 @@ class Trade {
374
378
  });
375
379
  }
376
380
  /**
377
- * Force Cancel Order
378
- * @param args.marketId - The ID of the Market
379
- * @param args.user - The user to force cancel the order for
380
- * @param args.orderId - The ID of the Order
381
- * @param args.userNonce - The nonce of the user
381
+ * Create Customer
382
+ * @param args.id - The ID of the customer
383
+ * @param args.name - The name of the customer
384
+ * @param args.authority - The authority of the customer
382
385
  *
383
386
  * @param options - RPC options
384
387
  *
385
388
  */
386
- forceCancelOrder({ marketId, user, orderId, userNonce }, options) {
389
+ createCustomer({ id, name, authority }, options) {
387
390
  return __awaiter(this, void 0, void 0, function* () {
388
- const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
389
- let userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, user);
390
- if (userNonce !== 0) {
391
- const subUserTradePDA = (0, trade_1.getSubUserTradePDA)(this.program.programId, user, userNonce);
392
- userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
393
- }
394
- return (0, sendTransactionWithOptions_1.default)(this.program.methods.forceCancelOrder(new bn_js_1.default(orderId)).accounts({
395
- signer: this.provider.publicKey,
396
- user,
397
- market: marketPDA,
398
- mint: constants_1.TRD_MINT,
399
- userTrade: userTradePDA
391
+ return (0, sendTransactionWithOptions_1.default)(this.program.methods.createCustomer({ id, name, authority }).accounts({
392
+ signer: this.provider.publicKey
400
393
  }), options);
401
394
  });
402
395
  }