@0dotxyz/p0-ts-sdk 2.8.0-alpha.5 → 2.8.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
@@ -22651,7 +22651,7 @@ function dtoToBankConfig(bankConfigDto) {
22651
22651
  interestRateConfig: dtoToInterestRateConfig(bankConfigDto.interestRateConfig),
22652
22652
  oracleMaxConfidence: bankConfigDto.oracleMaxConfidence,
22653
22653
  fixedPrice: new BigNumber3__default.default(bankConfigDto.fixedPrice),
22654
- scopeEntryIndex: bankConfigDto.scopeEntryIndex ?? 0
22654
+ scopeEntryIndex: bankConfigDto.scopeEntryIndex
22655
22655
  };
22656
22656
  }
22657
22657
  function dtoToInterestRateConfig(interestRateConfigDto) {
@@ -22765,7 +22765,7 @@ function dtoToBankConfigRaw(bankConfigDto) {
22765
22765
  interestRateConfig: bankConfigDto.interestRateConfig,
22766
22766
  oracleMaxConfidence: bankConfigDto.oracleMaxConfidence,
22767
22767
  fixedPrice: bankConfigDto.fixedPrice,
22768
- scopeEntryIndex: bankConfigDto.scopeEntryIndex ?? 0
22768
+ scopeEntryIndex: bankConfigDto.scopeEntryIndex
22769
22769
  };
22770
22770
  }
22771
22771
  function parseBankConfigRaw(bankConfigRaw) {
@@ -22805,7 +22805,7 @@ function parseBankConfigRaw(bankConfigRaw) {
22805
22805
  };
22806
22806
  const oracleMaxConfidence = bankConfigRaw.oracleMaxConfidence;
22807
22807
  const fixedPrice = wrappedI80F48toBigNumber(bankConfigRaw.fixedPrice);
22808
- const scopeEntryIndex = bankConfigRaw.scopeEntryIndex ?? 0;
22808
+ const scopeEntryIndex = bankConfigRaw.scopeEntryIndex;
22809
22809
  return {
22810
22810
  assetWeightInit,
22811
22811
  assetWeightMaint,
@@ -81380,7 +81380,8 @@ async function fetchSingleCrossbarChunk(endpoint, swbFeedIdsChunk, isPrimary) {
81380
81380
  }
81381
81381
  var scopeRequestKey = (bank) => {
81382
81382
  const oracleKey = bank.config.oracleKeys[0]?.toBase58();
81383
- return oracleKey ? `${oracleKey}:${bank.config.scopeEntryIndex ?? 0}` : void 0;
81383
+ const entryIndex = bank.config.scopeEntryIndex;
81384
+ return oracleKey && entryIndex !== void 0 ? `${oracleKey}:${entryIndex}` : void 0;
81384
81385
  };
81385
81386
  var fetchScopeOracleData = async (banks, opts) => {
81386
81387
  const scopeBanks = banks.filter((bank) => getOracleSourceFromBank(bank).key === "scope");
@@ -81400,8 +81401,12 @@ var fetchScopeOracleData = async (banks, opts) => {
81400
81401
  const uniqueRequestKeys = Array.from(
81401
81402
  new Set(scopeBanks.map(scopeRequestKey).filter((key) => key !== void 0))
81402
81403
  );
81403
- let oraclePrices;
81404
- if (opts.mode === "api") {
81404
+ let oraclePrices = {};
81405
+ if (!uniqueRequestKeys.length) {
81406
+ console.warn(
81407
+ "fetchScopeOracleData: no scope bank carries a scopeEntryIndex; all priced at zero"
81408
+ );
81409
+ } else if (opts.mode === "api") {
81405
81410
  oraclePrices = await fetchScopeOraclePricesFromAPI(
81406
81411
  uniqueRequestKeys,
81407
81412
  opts.scopeOnchainData.endpoint,
@@ -82443,7 +82448,7 @@ async function addOracleToBanksIx({
82443
82448
  groupAddress,
82444
82449
  adminAddress
82445
82450
  }) {
82446
- if (setup === "Scope" /* Scope */ || setup === "PTPyth" /* PTPyth */ || setup === "PTFixed" /* PTFixed */) {
82451
+ if (setup === "Scope" /* Scope */ || setup === "PTPyth" /* PTPyth */ || setup === "PTFixed" /* PTFixed */ || setup === "Fixed" /* Fixed */ || setup === "FixedKamino" /* FixedKamino */ || setup === "FixedDrift" /* FixedDrift */ || setup === "FixedJuplend" /* FixedJuplend */) {
82447
82452
  throw new Error(
82448
82453
  `${setup} must be configured with ${setup === "Scope" /* Scope */ ? "configureScopeOracleIx" : "setOraclePriceIx"}`
82449
82454
  );
@@ -82453,6 +82458,11 @@ async function addOracleToBanksIx({
82453
82458
  if (expectedAccountCount !== void 0 && resolvedOracleAccounts.length !== expectedAccountCount) {
82454
82459
  throw new Error(`${setup} requires ${expectedAccountCount} ordered oracle accounts`);
82455
82460
  }
82461
+ if (expectedAccountCount !== void 0 && !resolvedOracleAccounts[0].equals(feedId)) {
82462
+ throw new Error(
82463
+ `${setup} requires oracleAccounts[0] to be the primary feed ${feedId.toBase58()}`
82464
+ );
82465
+ }
82456
82466
  const ix = await instructions_default.makeLendingPoolConfigureBankOracleIx(
82457
82467
  program,
82458
82468
  {