@triadxyz/triad-protocol 1.7.1-beta → 1.7.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.
@@ -50,7 +50,6 @@ const getStakeByWallet = () => __awaiter(void 0, void 0, void 0, function* () {
50
50
  }
51
51
  console.log(sum);
52
52
  });
53
- getStakeByWallet();
54
53
  const getAllStakes = () => __awaiter(void 0, void 0, void 0, function* () {
55
54
  const stakes = yield triadProtocol.stake.getStakes();
56
55
  console.log(stakes.length);
@@ -120,7 +119,8 @@ const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
120
119
  }
121
120
  let liquidity = (Number(market.hypeLiquidity) + Number(market.flopLiquidity)) /
122
121
  Math.pow(10, 6);
123
- liquidity = liquidity - Number(market.marketLiquidityAtStart) / Math.pow(10, 6);
122
+ liquidity =
123
+ liquidity - Number(market.marketLiquidityAtStart) / Math.pow(10, 6);
124
124
  console.log('Market ID:', market.question);
125
125
  console.log('Liquidity:', liquidity);
126
126
  console.log('Hype Shares:', Number(market.hypeShares) / Math.pow(10, 6));
@@ -367,12 +367,13 @@ const collectRoyalties = () => __awaiter(void 0, void 0, void 0, function* () {
367
367
  console.log(response);
368
368
  });
369
369
  const collectRemainingLiquidity = () => __awaiter(void 0, void 0, void 0, function* () {
370
- const markets = [34];
370
+ const markets = [160, 162, 164];
371
371
  for (const market of markets) {
372
372
  const response = yield triadProtocol.trade.collectRemainingLiquidity(market);
373
373
  console.log(response);
374
374
  }
375
375
  });
376
+ collectRemainingLiquidity();
376
377
  const allowMarketToPayout = () => __awaiter(void 0, void 0, void 0, function* () {
377
378
  const markets = [163, 164, 165];
378
379
  for (const market of markets) {
@@ -29,7 +29,7 @@ class InitMarket {
29
29
  endTime: market.endTime,
30
30
  feeBps: 0,
31
31
  customer: null,
32
- liquidityAtStart: 12000
32
+ mint: new web3_js_1.PublicKey('2222222222222222222222222222222222222222')
33
33
  });
34
34
  if (market.image) {
35
35
  yield this.deployImage(market.image);
package/dist/trade.d.ts CHANGED
@@ -130,7 +130,7 @@ export default class Trade {
130
130
  * @param options - RPC options
131
131
  *
132
132
  */
133
- createMarket({ marketId, startTime, endTime, question, feeBps, customer, liquidityAtStart }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
133
+ createMarket({ marketId, startTime, endTime, question, feeBps, customer, mint }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
134
134
  /**
135
135
  * Get User Trade Nonce With Slots
136
136
  * @param userTrades - User Trades
@@ -199,10 +199,11 @@ export default class Trade {
199
199
  * @param options - RPC options
200
200
  *
201
201
  */
202
- payoutOrder({ marketId, orderId, userNonce }: {
202
+ payoutOrder({ marketId, orderId, userNonce, mint }: {
203
203
  marketId: number;
204
204
  orderId: number;
205
205
  userNonce: number;
206
+ mint: PublicKey;
206
207
  }, options?: RpcOptions): Promise<string>;
207
208
  /**
208
209
  * Allow Market to Payout
package/dist/trade.js CHANGED
@@ -114,7 +114,7 @@ class Trade {
114
114
  * @param options - RPC options
115
115
  *
116
116
  */
117
- createMarket({ marketId, startTime, endTime, question, feeBps, customer, liquidityAtStart }, options) {
117
+ createMarket({ marketId, startTime, endTime, question, feeBps, customer, mint }, options) {
118
118
  return __awaiter(this, void 0, void 0, function* () {
119
119
  if (question.length > 80) {
120
120
  throw new Error('Question must be less than 80 characters');
@@ -125,13 +125,12 @@ class Trade {
125
125
  question: (0, helpers_1.encodeString)(question, 80),
126
126
  marketStart: new bn_js_1.default(startTime),
127
127
  marketEnd: new bn_js_1.default(endTime),
128
- liquidityAtStart: new bn_js_1.default(liquidityAtStart * Math.pow(10, constants_1.TRD_DECIMALS)),
129
128
  feeBps
130
129
  })
131
130
  .accounts({
132
131
  signer: this.provider.publicKey,
133
- mint: this.mint,
134
- tokenProgram: (0, helpers_1.getTokenProgram)(this.mint),
132
+ mint,
133
+ tokenProgram: (0, helpers_1.getTokenProgram)(mint),
135
134
  customer
136
135
  }), options);
137
136
  });
@@ -297,10 +296,14 @@ class Trade {
297
296
  collectRemainingLiquidity(marketId, options) {
298
297
  return __awaiter(this, void 0, void 0, function* () {
299
298
  const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
299
+ const market = yield this.getMarketByAddress(marketPDA);
300
+ if (market.isAllowedToPayout) {
301
+ return;
302
+ }
300
303
  return (0, sendTransactionWithOptions_1.default)(this.program.methods.collectRemainingLiquidity().accounts({
301
304
  signer: this.provider.publicKey,
302
305
  market: marketPDA,
303
- mint: this.mint
306
+ mint: market.mint
304
307
  }), options);
305
308
  });
306
309
  }
@@ -313,7 +316,7 @@ class Trade {
313
316
  * @param options - RPC options
314
317
  *
315
318
  */
316
- payoutOrder({ marketId, orderId, userNonce }, options) {
319
+ payoutOrder({ marketId, orderId, userNonce, mint }, options) {
317
320
  return __awaiter(this, void 0, void 0, function* () {
318
321
  const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
319
322
  let userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, this.provider.publicKey);
@@ -325,7 +328,7 @@ class Trade {
325
328
  signer: this.provider.publicKey,
326
329
  userTrade: userTradePDA,
327
330
  market: marketPDA,
328
- mint: this.mint
331
+ mint
329
332
  }), options);
330
333
  });
331
334
  }
@@ -1706,10 +1706,6 @@
1706
1706
  {
1707
1707
  "name": "fee_bps",
1708
1708
  "type": "u8"
1709
- },
1710
- {
1711
- "name": "liquidity_at_start",
1712
- "type": "u64"
1713
1709
  }
1714
1710
  ]
1715
1711
  }
@@ -86,7 +86,7 @@ export type CreateMarketArgs = {
86
86
  question: string;
87
87
  feeBps: number;
88
88
  customer: PublicKey;
89
- liquidityAtStart: number;
89
+ mint: PublicKey;
90
90
  };
91
91
  export type CreateCustomerArgs = {
92
92
  id: number;
@@ -2205,10 +2205,6 @@ export type TriadProtocol = {
2205
2205
  {
2206
2206
  name: 'feeBps';
2207
2207
  type: 'u8';
2208
- },
2209
- {
2210
- name: 'liquidityAtStart';
2211
- type: 'u64';
2212
2208
  }
2213
2209
  ];
2214
2210
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.7.1-beta",
3
+ "version": "1.7.3-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",