polkamarkets-js 3.1.8 → 3.1.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkamarkets-js",
3
- "version": "3.1.8",
3
+ "version": "3.1.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -198,11 +198,21 @@ class PredictionMarketV3Contract extends PredictionMarketV2Contract {
198
198
  const decimals = marketDecimals[marketId];
199
199
 
200
200
  const outcomeShares = Object.fromEntries(marketData.outcomeShares.map((item, index) => {
201
+ const shares = Numbers.fromDecimalsNumber(item, decimals);
202
+ const price = this.getAverageOutcomeBuyPrice({events, marketId, outcomeId: index});
203
+ const voidedWinningsToClaim = marketData.voidedSharesToClaim && shares > 0;
204
+ const voidedWinningsClaimed = voidedWinningsToClaim && events.some((event) => {
205
+ return event.action === 'Claim Voided' &&
206
+ event.marketId === marketId &&
207
+ event.outcomeId === index
208
+ });
201
209
  return [
202
210
  index,
203
211
  {
204
- shares: Numbers.fromDecimalsNumber(item, decimals),
205
- price: this.getAverageOutcomeBuyPrice({events, marketId, outcomeId: index})
212
+ shares,
213
+ price,
214
+ voidedWinningsToClaim,
215
+ voidedWinningsClaimed
206
216
  }
207
217
  ];
208
218
  }));
@@ -278,13 +288,11 @@ class PredictionMarketV3Contract extends PredictionMarketV2Contract {
278
288
  marketsPrices = await this.querier.getMarketsPrices({ marketIds });
279
289
  }
280
290
 
281
- // fetching all markets decimals asynchrounously
282
- const marketDecimals = await this.getMarketsERC20Decimals({ marketIds });
283
-
284
291
  return marketIds.reduce((obj, marketId) => {
285
292
  const index = marketIds.indexOf(marketId);
286
293
  const marketData = marketsPrices[index];
287
- const decimals = marketDecimals[marketId];
294
+ // market prices decimals are always 18, don't depend on the erc20 decimals
295
+ const decimals = 18;
288
296
 
289
297
  return {
290
298
  ...obj,