@0dotxyz/p0-ts-sdk 1.1.0-alpha.1 → 1.1.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 CHANGED
@@ -20138,11 +20138,19 @@ var categorizePythBanks = (banks) => {
20138
20138
  const pythPushKaminosBanks = banks.filter(
20139
20139
  (bank) => bank.config.oracleSetup === "KaminoPythPush" /* KaminoPythPush */
20140
20140
  );
20141
+ const driftPythPullBanks = banks.filter(
20142
+ (bank) => bank.config.oracleSetup === "DriftPythPull" /* DriftPythPull */
20143
+ );
20144
+ const solendPythPullBanks = banks.filter(
20145
+ (bank) => bank.config.oracleSetup === "SolendPythPull" /* SolendPythPull */
20146
+ );
20141
20147
  return {
20142
20148
  pythLegacyBanks,
20143
20149
  pythPushBanks,
20144
20150
  pythStakedCollateralBanks,
20145
- pythPushKaminosBanks
20151
+ pythPushKaminosBanks,
20152
+ driftPythPullBanks,
20153
+ solendPythPullBanks
20146
20154
  };
20147
20155
  };
20148
20156
  var convertVoteAccCoeffsToBankCoeffs = (pythStakedCollateralBanks, validatorVoteAccountByBank, voteAccCoeffs) => {
@@ -20156,9 +20164,7 @@ var convertVoteAccCoeffsToBankCoeffs = (pythStakedCollateralBanks, validatorVote
20156
20164
  return priceCoeffByBank;
20157
20165
  };
20158
20166
  var extractPythOracleKeys = (pythBanks) => {
20159
- const keys = pythBanks.map(
20160
- (bank) => bank.config.oracleKeys[0].toBase58()
20161
- );
20167
+ const keys = pythBanks.map((bank) => bank.config.oracleKeys[0].toBase58());
20162
20168
  return [...keys];
20163
20169
  };
20164
20170
  var mapPythBanksToOraclePrices = (pythPushBanks, pythStakedCollateralBanks, oraclePrices, priceCoeffByBank) => {
@@ -20178,14 +20184,8 @@ var mapPythBanksToOraclePrices = (pythPushBanks, pythStakedCollateralBanks, orac
20178
20184
  if (oraclePrice) {
20179
20185
  bankOraclePriceMap.set(bank.address.toBase58(), {
20180
20186
  timestamp: oraclePrice.timestamp,
20181
- priceRealtime: adjustPriceComponent(
20182
- oraclePrice.priceRealtime,
20183
- priceCoeff
20184
- ),
20185
- priceWeighted: adjustPriceComponent(
20186
- oraclePrice.priceWeighted,
20187
- priceCoeff
20188
- )
20187
+ priceRealtime: adjustPriceComponent(oraclePrice.priceRealtime, priceCoeff),
20188
+ priceWeighted: adjustPriceComponent(oraclePrice.priceWeighted, priceCoeff)
20189
20189
  });
20190
20190
  }
20191
20191
  }
@@ -20206,9 +20206,7 @@ function parseRpcPythPriceData(rawData) {
20206
20206
  const bytesWithoutDiscriminator = rawData.slice(8);
20207
20207
  const data = parsePriceInfo(bytesWithoutDiscriminator);
20208
20208
  const exponent = new BigNumber10__default.default(10 ** data.priceMessage.exponent);
20209
- const priceRealTime = new BigNumber10__default.default(Number(data.priceMessage.price)).times(
20210
- exponent
20211
- );
20209
+ const priceRealTime = new BigNumber10__default.default(Number(data.priceMessage.price)).times(exponent);
20212
20210
  const confidenceRealTime = new BigNumber10__default.default(Number(data.priceMessage.conf)).times(exponent).times(PYTH_PRICE_CONF_INTERVALS);
20213
20211
  const cappedConfidenceRealTime = capConfidenceInterval2(
20214
20212
  priceRealTime,
@@ -20217,12 +20215,8 @@ function parseRpcPythPriceData(rawData) {
20217
20215
  );
20218
20216
  const lowestPriceRealTime = priceRealTime.minus(cappedConfidenceRealTime);
20219
20217
  const highestPriceRealTime = priceRealTime.plus(cappedConfidenceRealTime);
20220
- const priceTimeWeighted = new BigNumber10__default.default(
20221
- Number(data.priceMessage.emaPrice)
20222
- ).times(exponent);
20223
- const confidenceTimeWeighted = new BigNumber10__default.default(
20224
- Number(data.priceMessage.emaConf)
20225
- ).times(exponent).times(PYTH_PRICE_CONF_INTERVALS);
20218
+ const priceTimeWeighted = new BigNumber10__default.default(Number(data.priceMessage.emaPrice)).times(exponent);
20219
+ const confidenceTimeWeighted = new BigNumber10__default.default(Number(data.priceMessage.emaConf)).times(exponent).times(PYTH_PRICE_CONF_INTERVALS);
20226
20220
  const cappedConfidenceWeighted = capConfidenceInterval2(
20227
20221
  priceTimeWeighted,
20228
20222
  confidenceTimeWeighted,
@@ -33199,8 +33193,14 @@ function chunkArray(array4, chunkSize) {
33199
33193
 
33200
33194
  // src/services/price/services/pyth-oracle.service.ts
33201
33195
  var fetchPythOracleData = async (banks, opts) => {
33202
- const { pythPushBanks, pythStakedCollateralBanks, pythPushKaminosBanks } = categorizePythBanks(banks);
33203
- if (!pythPushBanks.length && !pythStakedCollateralBanks.length && !pythPushKaminosBanks.length) {
33196
+ const {
33197
+ pythPushBanks,
33198
+ pythStakedCollateralBanks,
33199
+ pythPushKaminosBanks,
33200
+ driftPythPullBanks,
33201
+ solendPythPullBanks
33202
+ } = categorizePythBanks(banks);
33203
+ if (!pythPushBanks.length && !pythStakedCollateralBanks.length && !pythPushKaminosBanks.length && !driftPythPullBanks.length && !solendPythPullBanks.length) {
33204
33204
  return {
33205
33205
  bankOraclePriceMap: /* @__PURE__ */ new Map()
33206
33206
  };
@@ -33210,7 +33210,12 @@ var fetchPythOracleData = async (banks, opts) => {
33210
33210
  bank.mint.toBase58()
33211
33211
  ]);
33212
33212
  const priceCoeffByBank = {};
33213
- const combinedPythBanks = [...pythPushBanks, ...pythPushKaminosBanks];
33213
+ const combinedPythBanks = [
33214
+ ...pythPushBanks,
33215
+ ...pythPushKaminosBanks,
33216
+ ...driftPythPullBanks,
33217
+ ...solendPythPullBanks
33218
+ ];
33214
33219
  const pythOracleKeys = extractPythOracleKeys(combinedPythBanks);
33215
33220
  const uniquePythOracleKeys = Array.from(new Set(pythOracleKeys));
33216
33221
  let oraclePrices;
@@ -33295,7 +33300,7 @@ var fetchPythOraclePricesFromChain = async (requestedPythOracleKeys, connection)
33295
33300
  };
33296
33301
  var fetchSwbOracleData = async (banks, opts) => {
33297
33302
  const switchboardBanks = banks.filter(
33298
- (bank) => bank.config.oracleSetup === "SwitchboardPull" /* SwitchboardPull */ || bank.config.oracleSetup === "SwitchboardV2" /* SwitchboardV2 */ || bank.config.oracleSetup === "KaminoSwitchboardPull" /* KaminoSwitchboardPull */
33303
+ (bank) => bank.config.oracleSetup === "SwitchboardPull" /* SwitchboardPull */ || bank.config.oracleSetup === "SwitchboardV2" /* SwitchboardV2 */ || bank.config.oracleSetup === "KaminoSwitchboardPull" /* KaminoSwitchboardPull */ || bank.config.oracleSetup === "DriftSwitchboardPull" /* DriftSwitchboardPull */ || bank.config.oracleSetup === "SolendSwitchboardPull" /* SolendSwitchboardPull */
33299
33304
  );
33300
33305
  if (switchboardBanks.length === 0) {
33301
33306
  return {