@0dotxyz/p0-ts-sdk 2.5.1 → 2.5.2-alpha.0

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.cjs CHANGED
@@ -24720,17 +24720,17 @@ var mapSwbBanksToOraclePrices = (banks, swbOracleAiDataByKey, crossbarResponse)
24720
24720
  });
24721
24721
  return bankOraclePriceMap;
24722
24722
  };
24723
- var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey, birdeyeResponse) => {
24723
+ var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey, fallbackPricesByFeedId) => {
24724
24724
  const bankOraclePriceMap = /* @__PURE__ */ new Map();
24725
24725
  banks.forEach((bank) => {
24726
24726
  const oracleKey = bank.config.oracleKeys[0].toBase58();
24727
24727
  const oracleData = swbOracleAiDataByKey[oracleKey];
24728
24728
  const oracleFeed = oracleData?.feedHash;
24729
- const birdeyeData = oracleFeed ? birdeyeResponse[oracleFeed] : void 0;
24730
- if (oracleFeed && oracleData && birdeyeData) {
24729
+ const fallbackPrice = oracleFeed ? fallbackPricesByFeedId[oracleFeed] : void 0;
24730
+ if (oracleFeed && oracleData && fallbackPrice) {
24731
24731
  const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
24732
24732
  const oraclePrice = parseSwbOraclePriceData(
24733
- [birdeyeData],
24733
+ [fallbackPrice],
24734
24734
  new BN9__default.default(oracleData.stdev),
24735
24735
  timestamp,
24736
24736
  oracleData
@@ -25246,8 +25246,8 @@ function partitionBanksByCrankability(banks, crankabilityResults) {
25246
25246
  return { crankable, uncrankable };
25247
25247
  }
25248
25248
 
25249
- // src/services/price/utils/birdeye.utils.ts
25250
- async function getBirdeyePricesForMints(mintAddresses, apiEndpoint, opts) {
25249
+ // src/services/price/utils/price-fallback.utils.ts
25250
+ async function getFallbackPricesForMints(mintAddresses, apiEndpoint, opts) {
25251
25251
  const queryKey = opts?.queryKey ?? "mintList";
25252
25252
  try {
25253
25253
  const url = `${apiEndpoint}?${queryKey}=${mintAddresses.join(",")}`;
@@ -25266,13 +25266,14 @@ async function getBirdeyePricesForMints(mintAddresses, apiEndpoint, opts) {
25266
25266
  });
25267
25267
  return extractedPrices;
25268
25268
  } catch (error) {
25269
- console.warn("Error fetching Birdeye prices for static feeds:", error);
25269
+ console.warn("Error fetching fallback prices for static feeds:", error);
25270
25270
  return {};
25271
25271
  }
25272
25272
  }
25273
- var getBirdeyeFallbackPricesByFeedId = async (feedMint, apiEndpoint, opts) => {
25273
+ var getBirdeyePricesForMints = getFallbackPricesForMints;
25274
+ var getFallbackPricesByFeedId = async (feedMint, apiEndpoint, opts) => {
25274
25275
  const mintAddresses = feedMint.map((feedMint2) => feedMint2.mintAddress);
25275
- const prices = await getBirdeyePricesForMints(
25276
+ const prices = await getFallbackPricesForMints(
25276
25277
  mintAddresses,
25277
25278
  apiEndpoint,
25278
25279
  opts
@@ -25288,6 +25289,7 @@ var getBirdeyeFallbackPricesByFeedId = async (feedMint, apiEndpoint, opts) => {
25288
25289
  });
25289
25290
  return priceByFeedId;
25290
25291
  };
25292
+ var getBirdeyeFallbackPricesByFeedId = getFallbackPricesByFeedId;
25291
25293
 
25292
25294
  // src/services/account/types/account.types.ts
25293
25295
  var HealthCacheFlags = /* @__PURE__ */ ((HealthCacheFlags3) => {
@@ -71526,18 +71528,19 @@ var fetchSwbOracleData = async (banks, opts) => {
71526
71528
  }
71527
71529
  });
71528
71530
  let crossbarResponse;
71529
- let birdeyeResponse = {};
71531
+ let fallbackPricesByFeedId = {};
71530
71532
  if (opts.mode === "api") {
71531
71533
  crossbarResponse = await fetchSwbOraclePricesFromAPI(
71532
71534
  swbFeedIds,
71533
71535
  opts.swbCrossbarPrice.endpoint,
71534
71536
  { queryKey: opts.swbCrossbarPrice.queryKey }
71535
71537
  );
71536
- if (brokenSwbFeeds.length > 0 && opts.birdeyeFallback) {
71537
- birdeyeResponse = await getBirdeyeFallbackPricesByFeedId(
71538
+ const priceFallback = opts.priceFallback ?? opts.birdeyeFallback;
71539
+ if (brokenSwbFeeds.length > 0 && priceFallback) {
71540
+ fallbackPricesByFeedId = await getFallbackPricesByFeedId(
71538
71541
  brokenSwbFeeds,
71539
- opts.birdeyeFallback.endpoint,
71540
- { queryKey: opts.birdeyeFallback.queryKey }
71542
+ priceFallback.endpoint,
71543
+ { queryKey: priceFallback.queryKey }
71541
71544
  );
71542
71545
  }
71543
71546
  } else {
@@ -71546,7 +71549,7 @@ var fetchSwbOracleData = async (banks, opts) => {
71546
71549
  opts.crossbarEndpoint || "https://crossbar.0.xyz",
71547
71550
  "https://crossbar.switchboard.xyz"
71548
71551
  );
71549
- birdeyeResponse = {};
71552
+ fallbackPricesByFeedId = {};
71550
71553
  }
71551
71554
  const bankOraclePriceMap = mapSwbBanksToOraclePrices(
71552
71555
  switchboardBanks,
@@ -71556,7 +71559,7 @@ var fetchSwbOracleData = async (banks, opts) => {
71556
71559
  const brokenFeedOraclePriceMap = mapBrokenFeedsToOraclePrices(
71557
71560
  switchboardBanks,
71558
71561
  swbOracleAiDataByKey,
71559
- birdeyeResponse
71562
+ fallbackPricesByFeedId
71560
71563
  );
71561
71564
  const combinedOraclePriceMap = /* @__PURE__ */ new Map();
71562
71565
  bankOraclePriceMap.forEach((oraclePrice, bankAddress) => {
@@ -75419,6 +75422,8 @@ exports.getDriftMetadata = getDriftMetadata;
75419
75422
  exports.getDriftStatesDto = getDriftStatesDto;
75420
75423
  exports.getEmodePairs = getEmodePairs;
75421
75424
  exports.getExactOutEstimate = getExactOutEstimate;
75425
+ exports.getFallbackPricesByFeedId = getFallbackPricesByFeedId;
75426
+ exports.getFallbackPricesForMints = getFallbackPricesForMints;
75422
75427
  exports.getHealthCacheStatusDescription = getHealthCacheStatusDescription;
75423
75428
  exports.getHealthSimulationTransactions = getHealthSimulationTransactions;
75424
75429
  exports.getJupLendFTokenMultiplier = getJupLendFTokenMultiplier;