@d8x/perpetuals-sdk 2.1.3-alpha2 → 2.1.5-alpha2

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/src/marketData.ts CHANGED
@@ -2505,4 +2505,34 @@ export default class MarketData extends PerpetualDataHandler {
2505
2505
  public async fetchPricesForPerpetual(symbol: string): Promise<IdxPriceInfo> {
2506
2506
  return this.priceFeedGetter.fetchPricesForPerpetual(symbol);
2507
2507
  }
2508
+
2509
+ /**
2510
+ * fetch prediction markets question
2511
+ * @param symbol symbol of the form "TRUMP24-USD"
2512
+ * @returns question for given symbol
2513
+ */
2514
+ public async fetchPrdMktQuestion(symbol: string): Promise<string> {
2515
+ const c = this.priceFeedGetter.getConfig().ids;
2516
+ let j = -1;
2517
+ for (let k = 0; k < c.length; k++) {
2518
+ if (c[k].symbol == symbol) {
2519
+ j = k;
2520
+ break;
2521
+ }
2522
+ }
2523
+ if (j == -1) {
2524
+ throw Error("${symbol} not found");
2525
+ }
2526
+ let origin = c[j].origin;
2527
+ const query = "https://clob.polymarket.com/markets/" + origin;
2528
+ let response = await fetch(query);
2529
+ if (response.status !== 200) {
2530
+ throw new Error(`unexpected status code: ${response.status}`);
2531
+ }
2532
+ if (!response.ok) {
2533
+ throw new Error(`failed to fetch posts (${response.status}): ${response.statusText} ${query}`);
2534
+ }
2535
+ const data = await response.json();
2536
+ return data.question;
2537
+ }
2508
2538
  }
package/src/priceFeeds.ts CHANGED
@@ -73,6 +73,9 @@ export default class PriceFeeds {
73
73
  this.triangulations = new Map<string, [string[], boolean[]]>();
74
74
  }
75
75
 
76
+ public getConfig(): PriceFeedConfig {
77
+ return this.config;
78
+ }
76
79
  // overridePriceEndpointsOfSameType overrides endpoints of config with same
77
80
  // type endpoints provided by user and returns the updated price feed
78
81
  // endpoints list.
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const D8X_SDK_VERSION = "2.1.3-alpha2";
1
+ export const D8X_SDK_VERSION = "2.1.5-alpha2";