@0dotxyz/p0-ts-sdk 2.6.0-alpha.1 → 2.6.0-alpha.2
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 +21 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -9
- package/dist/index.d.ts +30 -9
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24733,17 +24733,17 @@ var mapSwbBanksToOraclePrices = (banks, swbOracleAiDataByKey, crossbarResponse)
|
|
|
24733
24733
|
});
|
|
24734
24734
|
return bankOraclePriceMap;
|
|
24735
24735
|
};
|
|
24736
|
-
var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey,
|
|
24736
|
+
var mapBrokenFeedsToOraclePrices = (banks, swbOracleAiDataByKey, fallbackPricesByFeedId) => {
|
|
24737
24737
|
const bankOraclePriceMap = /* @__PURE__ */ new Map();
|
|
24738
24738
|
banks.forEach((bank) => {
|
|
24739
24739
|
const oracleKey = bank.config.oracleKeys[0].toBase58();
|
|
24740
24740
|
const oracleData = swbOracleAiDataByKey[oracleKey];
|
|
24741
24741
|
const oracleFeed = oracleData?.feedHash;
|
|
24742
|
-
const
|
|
24743
|
-
if (oracleFeed && oracleData &&
|
|
24742
|
+
const fallbackPrice = oracleFeed ? fallbackPricesByFeedId[oracleFeed] : void 0;
|
|
24743
|
+
if (oracleFeed && oracleData && fallbackPrice) {
|
|
24744
24744
|
const timestamp = (/* @__PURE__ */ new Date()).getTime().toString();
|
|
24745
24745
|
const oraclePrice = parseSwbOraclePriceData(
|
|
24746
|
-
[
|
|
24746
|
+
[fallbackPrice],
|
|
24747
24747
|
new BN9__default.default(oracleData.stdev),
|
|
24748
24748
|
timestamp,
|
|
24749
24749
|
oracleData
|
|
@@ -25259,8 +25259,8 @@ function partitionBanksByCrankability(banks, crankabilityResults) {
|
|
|
25259
25259
|
return { crankable, uncrankable };
|
|
25260
25260
|
}
|
|
25261
25261
|
|
|
25262
|
-
// src/services/price/utils/
|
|
25263
|
-
async function
|
|
25262
|
+
// src/services/price/utils/price-fallback.utils.ts
|
|
25263
|
+
async function getFallbackPricesForMints(mintAddresses, apiEndpoint, opts) {
|
|
25264
25264
|
const queryKey = opts?.queryKey ?? "mintList";
|
|
25265
25265
|
try {
|
|
25266
25266
|
const url = `${apiEndpoint}?${queryKey}=${mintAddresses.join(",")}`;
|
|
@@ -25279,13 +25279,14 @@ async function getBirdeyePricesForMints(mintAddresses, apiEndpoint, opts) {
|
|
|
25279
25279
|
});
|
|
25280
25280
|
return extractedPrices;
|
|
25281
25281
|
} catch (error) {
|
|
25282
|
-
console.warn("Error fetching
|
|
25282
|
+
console.warn("Error fetching fallback prices for static feeds:", error);
|
|
25283
25283
|
return {};
|
|
25284
25284
|
}
|
|
25285
25285
|
}
|
|
25286
|
-
var
|
|
25286
|
+
var getBirdeyePricesForMints = getFallbackPricesForMints;
|
|
25287
|
+
var getFallbackPricesByFeedId = async (feedMint, apiEndpoint, opts) => {
|
|
25287
25288
|
const mintAddresses = feedMint.map((feedMint2) => feedMint2.mintAddress);
|
|
25288
|
-
const prices = await
|
|
25289
|
+
const prices = await getFallbackPricesForMints(
|
|
25289
25290
|
mintAddresses,
|
|
25290
25291
|
apiEndpoint,
|
|
25291
25292
|
opts
|
|
@@ -25301,6 +25302,7 @@ var getBirdeyeFallbackPricesByFeedId = async (feedMint, apiEndpoint, opts) => {
|
|
|
25301
25302
|
});
|
|
25302
25303
|
return priceByFeedId;
|
|
25303
25304
|
};
|
|
25305
|
+
var getBirdeyeFallbackPricesByFeedId = getFallbackPricesByFeedId;
|
|
25304
25306
|
|
|
25305
25307
|
// src/services/account/types/account.types.ts
|
|
25306
25308
|
var HealthCacheFlags = /* @__PURE__ */ ((HealthCacheFlags3) => {
|
|
@@ -76919,18 +76921,19 @@ var fetchSwbOracleData = async (banks, opts) => {
|
|
|
76919
76921
|
}
|
|
76920
76922
|
});
|
|
76921
76923
|
let crossbarResponse;
|
|
76922
|
-
let
|
|
76924
|
+
let fallbackPricesByFeedId = {};
|
|
76923
76925
|
if (opts.mode === "api") {
|
|
76924
76926
|
crossbarResponse = await fetchSwbOraclePricesFromAPI(
|
|
76925
76927
|
swbFeedIds,
|
|
76926
76928
|
opts.swbCrossbarPrice.endpoint,
|
|
76927
76929
|
{ queryKey: opts.swbCrossbarPrice.queryKey }
|
|
76928
76930
|
);
|
|
76929
|
-
|
|
76930
|
-
|
|
76931
|
+
const priceFallback = opts.priceFallback ?? opts.birdeyeFallback;
|
|
76932
|
+
if (brokenSwbFeeds.length > 0 && priceFallback) {
|
|
76933
|
+
fallbackPricesByFeedId = await getFallbackPricesByFeedId(
|
|
76931
76934
|
brokenSwbFeeds,
|
|
76932
|
-
|
|
76933
|
-
{ queryKey:
|
|
76935
|
+
priceFallback.endpoint,
|
|
76936
|
+
{ queryKey: priceFallback.queryKey }
|
|
76934
76937
|
);
|
|
76935
76938
|
}
|
|
76936
76939
|
} else {
|
|
@@ -76939,7 +76942,7 @@ var fetchSwbOracleData = async (banks, opts) => {
|
|
|
76939
76942
|
opts.crossbarEndpoint || "https://crossbar.0.xyz",
|
|
76940
76943
|
"https://crossbar.switchboard.xyz"
|
|
76941
76944
|
);
|
|
76942
|
-
|
|
76945
|
+
fallbackPricesByFeedId = {};
|
|
76943
76946
|
}
|
|
76944
76947
|
const bankOraclePriceMap = mapSwbBanksToOraclePrices(
|
|
76945
76948
|
switchboardBanks,
|
|
@@ -76949,7 +76952,7 @@ var fetchSwbOracleData = async (banks, opts) => {
|
|
|
76949
76952
|
const brokenFeedOraclePriceMap = mapBrokenFeedsToOraclePrices(
|
|
76950
76953
|
switchboardBanks,
|
|
76951
76954
|
swbOracleAiDataByKey,
|
|
76952
|
-
|
|
76955
|
+
fallbackPricesByFeedId
|
|
76953
76956
|
);
|
|
76954
76957
|
const combinedOraclePriceMap = /* @__PURE__ */ new Map();
|
|
76955
76958
|
bankOraclePriceMap.forEach((oraclePrice, bankAddress) => {
|
|
@@ -81086,6 +81089,8 @@ exports.getDriftMetadata = getDriftMetadata;
|
|
|
81086
81089
|
exports.getDriftStatesDto = getDriftStatesDto;
|
|
81087
81090
|
exports.getEmodePairs = getEmodePairs;
|
|
81088
81091
|
exports.getExactOutEstimate = getExactOutEstimate;
|
|
81092
|
+
exports.getFallbackPricesByFeedId = getFallbackPricesByFeedId;
|
|
81093
|
+
exports.getFallbackPricesForMints = getFallbackPricesForMints;
|
|
81089
81094
|
exports.getHealthCacheStatusDescription = getHealthCacheStatusDescription;
|
|
81090
81095
|
exports.getHealthSimulationTransactions = getHealthSimulationTransactions;
|
|
81091
81096
|
exports.getJupLendFTokenMultiplier = getJupLendFTokenMultiplier;
|