@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.d.cts CHANGED
@@ -12945,12 +12945,17 @@ declare function partitionBanksByCrankability(banks: BankType[], crankabilityRes
12945
12945
  * - pythLegacyBanks: Banks using deprecated Pyth legacy oracles
12946
12946
  * - pythPushBanks: Banks using Pyth push oracles
12947
12947
  * - pythStakedCollateralBanks: Banks using staked collateral with Pyth push oracles
12948
+ * - pythPushKaminosBanks: Banks using Kamino with Pyth push oracles
12949
+ * - driftPythPullBanks: Banks using Drift with Pyth pull oracles
12950
+ * - solendPythPullBanks: Banks using Solend with Pyth pull oracles
12948
12951
  */
12949
12952
  declare const categorizePythBanks: (banks: BankType[]) => {
12950
12953
  pythLegacyBanks: BankType[];
12951
12954
  pythPushBanks: BankType[];
12952
12955
  pythStakedCollateralBanks: BankType[];
12953
12956
  pythPushKaminosBanks: BankType[];
12957
+ driftPythPullBanks: BankType[];
12958
+ solendPythPullBanks: BankType[];
12954
12959
  };
12955
12960
  /**
12956
12961
  * Converts vote account coefficients to bank address coefficients for staked collateral pricing
package/dist/index.d.ts CHANGED
@@ -12945,12 +12945,17 @@ declare function partitionBanksByCrankability(banks: BankType[], crankabilityRes
12945
12945
  * - pythLegacyBanks: Banks using deprecated Pyth legacy oracles
12946
12946
  * - pythPushBanks: Banks using Pyth push oracles
12947
12947
  * - pythStakedCollateralBanks: Banks using staked collateral with Pyth push oracles
12948
+ * - pythPushKaminosBanks: Banks using Kamino with Pyth push oracles
12949
+ * - driftPythPullBanks: Banks using Drift with Pyth pull oracles
12950
+ * - solendPythPullBanks: Banks using Solend with Pyth pull oracles
12948
12951
  */
12949
12952
  declare const categorizePythBanks: (banks: BankType[]) => {
12950
12953
  pythLegacyBanks: BankType[];
12951
12954
  pythPushBanks: BankType[];
12952
12955
  pythStakedCollateralBanks: BankType[];
12953
12956
  pythPushKaminosBanks: BankType[];
12957
+ driftPythPullBanks: BankType[];
12958
+ solendPythPullBanks: BankType[];
12954
12959
  };
12955
12960
  /**
12956
12961
  * Converts vote account coefficients to bank address coefficients for staked collateral pricing
package/dist/index.js CHANGED
@@ -20113,11 +20113,19 @@ var categorizePythBanks = (banks) => {
20113
20113
  const pythPushKaminosBanks = banks.filter(
20114
20114
  (bank) => bank.config.oracleSetup === "KaminoPythPush" /* KaminoPythPush */
20115
20115
  );
20116
+ const driftPythPullBanks = banks.filter(
20117
+ (bank) => bank.config.oracleSetup === "DriftPythPull" /* DriftPythPull */
20118
+ );
20119
+ const solendPythPullBanks = banks.filter(
20120
+ (bank) => bank.config.oracleSetup === "SolendPythPull" /* SolendPythPull */
20121
+ );
20116
20122
  return {
20117
20123
  pythLegacyBanks,
20118
20124
  pythPushBanks,
20119
20125
  pythStakedCollateralBanks,
20120
- pythPushKaminosBanks
20126
+ pythPushKaminosBanks,
20127
+ driftPythPullBanks,
20128
+ solendPythPullBanks
20121
20129
  };
20122
20130
  };
20123
20131
  var convertVoteAccCoeffsToBankCoeffs = (pythStakedCollateralBanks, validatorVoteAccountByBank, voteAccCoeffs) => {
@@ -20131,9 +20139,7 @@ var convertVoteAccCoeffsToBankCoeffs = (pythStakedCollateralBanks, validatorVote
20131
20139
  return priceCoeffByBank;
20132
20140
  };
20133
20141
  var extractPythOracleKeys = (pythBanks) => {
20134
- const keys = pythBanks.map(
20135
- (bank) => bank.config.oracleKeys[0].toBase58()
20136
- );
20142
+ const keys = pythBanks.map((bank) => bank.config.oracleKeys[0].toBase58());
20137
20143
  return [...keys];
20138
20144
  };
20139
20145
  var mapPythBanksToOraclePrices = (pythPushBanks, pythStakedCollateralBanks, oraclePrices, priceCoeffByBank) => {
@@ -20153,14 +20159,8 @@ var mapPythBanksToOraclePrices = (pythPushBanks, pythStakedCollateralBanks, orac
20153
20159
  if (oraclePrice) {
20154
20160
  bankOraclePriceMap.set(bank.address.toBase58(), {
20155
20161
  timestamp: oraclePrice.timestamp,
20156
- priceRealtime: adjustPriceComponent(
20157
- oraclePrice.priceRealtime,
20158
- priceCoeff
20159
- ),
20160
- priceWeighted: adjustPriceComponent(
20161
- oraclePrice.priceWeighted,
20162
- priceCoeff
20163
- )
20162
+ priceRealtime: adjustPriceComponent(oraclePrice.priceRealtime, priceCoeff),
20163
+ priceWeighted: adjustPriceComponent(oraclePrice.priceWeighted, priceCoeff)
20164
20164
  });
20165
20165
  }
20166
20166
  }
@@ -20181,9 +20181,7 @@ function parseRpcPythPriceData(rawData) {
20181
20181
  const bytesWithoutDiscriminator = rawData.slice(8);
20182
20182
  const data = parsePriceInfo(bytesWithoutDiscriminator);
20183
20183
  const exponent = new BigNumber10(10 ** data.priceMessage.exponent);
20184
- const priceRealTime = new BigNumber10(Number(data.priceMessage.price)).times(
20185
- exponent
20186
- );
20184
+ const priceRealTime = new BigNumber10(Number(data.priceMessage.price)).times(exponent);
20187
20185
  const confidenceRealTime = new BigNumber10(Number(data.priceMessage.conf)).times(exponent).times(PYTH_PRICE_CONF_INTERVALS);
20188
20186
  const cappedConfidenceRealTime = capConfidenceInterval2(
20189
20187
  priceRealTime,
@@ -20192,12 +20190,8 @@ function parseRpcPythPriceData(rawData) {
20192
20190
  );
20193
20191
  const lowestPriceRealTime = priceRealTime.minus(cappedConfidenceRealTime);
20194
20192
  const highestPriceRealTime = priceRealTime.plus(cappedConfidenceRealTime);
20195
- const priceTimeWeighted = new BigNumber10(
20196
- Number(data.priceMessage.emaPrice)
20197
- ).times(exponent);
20198
- const confidenceTimeWeighted = new BigNumber10(
20199
- Number(data.priceMessage.emaConf)
20200
- ).times(exponent).times(PYTH_PRICE_CONF_INTERVALS);
20193
+ const priceTimeWeighted = new BigNumber10(Number(data.priceMessage.emaPrice)).times(exponent);
20194
+ const confidenceTimeWeighted = new BigNumber10(Number(data.priceMessage.emaConf)).times(exponent).times(PYTH_PRICE_CONF_INTERVALS);
20201
20195
  const cappedConfidenceWeighted = capConfidenceInterval2(
20202
20196
  priceTimeWeighted,
20203
20197
  confidenceTimeWeighted,
@@ -33174,8 +33168,14 @@ function chunkArray(array4, chunkSize) {
33174
33168
 
33175
33169
  // src/services/price/services/pyth-oracle.service.ts
33176
33170
  var fetchPythOracleData = async (banks, opts) => {
33177
- const { pythPushBanks, pythStakedCollateralBanks, pythPushKaminosBanks } = categorizePythBanks(banks);
33178
- if (!pythPushBanks.length && !pythStakedCollateralBanks.length && !pythPushKaminosBanks.length) {
33171
+ const {
33172
+ pythPushBanks,
33173
+ pythStakedCollateralBanks,
33174
+ pythPushKaminosBanks,
33175
+ driftPythPullBanks,
33176
+ solendPythPullBanks
33177
+ } = categorizePythBanks(banks);
33178
+ if (!pythPushBanks.length && !pythStakedCollateralBanks.length && !pythPushKaminosBanks.length && !driftPythPullBanks.length && !solendPythPullBanks.length) {
33179
33179
  return {
33180
33180
  bankOraclePriceMap: /* @__PURE__ */ new Map()
33181
33181
  };
@@ -33185,7 +33185,12 @@ var fetchPythOracleData = async (banks, opts) => {
33185
33185
  bank.mint.toBase58()
33186
33186
  ]);
33187
33187
  const priceCoeffByBank = {};
33188
- const combinedPythBanks = [...pythPushBanks, ...pythPushKaminosBanks];
33188
+ const combinedPythBanks = [
33189
+ ...pythPushBanks,
33190
+ ...pythPushKaminosBanks,
33191
+ ...driftPythPullBanks,
33192
+ ...solendPythPullBanks
33193
+ ];
33189
33194
  const pythOracleKeys = extractPythOracleKeys(combinedPythBanks);
33190
33195
  const uniquePythOracleKeys = Array.from(new Set(pythOracleKeys));
33191
33196
  let oraclePrices;
@@ -33270,7 +33275,7 @@ var fetchPythOraclePricesFromChain = async (requestedPythOracleKeys, connection)
33270
33275
  };
33271
33276
  var fetchSwbOracleData = async (banks, opts) => {
33272
33277
  const switchboardBanks = banks.filter(
33273
- (bank) => bank.config.oracleSetup === "SwitchboardPull" /* SwitchboardPull */ || bank.config.oracleSetup === "SwitchboardV2" /* SwitchboardV2 */ || bank.config.oracleSetup === "KaminoSwitchboardPull" /* KaminoSwitchboardPull */
33278
+ (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 */
33274
33279
  );
33275
33280
  if (switchboardBanks.length === 0) {
33276
33281
  return {