@0dotxyz/p0-ts-sdk 1.2.1 → 1.2.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
@@ -44780,7 +44780,9 @@ async function computeSmartCrank({
44780
44780
  };
44781
44781
  }
44782
44782
  async function makeSmartCrankSwbFeedIx(params) {
44783
+ console.log("[makeSmartCrankSwbFeedIx] Called");
44783
44784
  const crankResult = await computeSmartCrank(params);
44785
+ console.log("[makeSmartCrankSwbFeedIx] Crank result:", crankResult);
44784
44786
  if (crankResult.uncrankableLiabilities.length > 0) {
44785
44787
  console.log(
44786
44788
  "Uncrankable liability details:",
@@ -44816,6 +44818,7 @@ async function makeSmartCrankSwbFeedIx(params) {
44816
44818
  );
44817
44819
  }
44818
44820
  const oraclesToCrank = crankResult.requiredOracles;
44821
+ console.log("[makeSmartCrankSwbFeedIx] Oracles to crank:", oraclesToCrank);
44819
44822
  const { instructions: instructions2, luts } = await makeUpdateSwbFeedIx({
44820
44823
  swbPullOracles: oraclesToCrank,
44821
44824
  feePayer: params.marginfiAccount.authority,
@@ -44852,6 +44855,9 @@ async function makeCrankSwbFeedIx(marginfiAccount, bankMap, newBanksPk, provider
44852
44855
  }
44853
44856
  }
44854
44857
  async function makeUpdateSwbFeedIx(props) {
44858
+ console.log(
44859
+ `[makeUpdateSwbFeedIx] Called with ${props.swbPullOracles.length} oracles, feePayer: ${props.feePayer.toBase58()}`
44860
+ );
44855
44861
  const seen = /* @__PURE__ */ new Set();
44856
44862
  const uniqueOracles = props.swbPullOracles.filter((oracle) => {
44857
44863
  const key = oracle.key.toBase58();
@@ -44859,6 +44865,14 @@ async function makeUpdateSwbFeedIx(props) {
44859
44865
  seen.add(key);
44860
44866
  return true;
44861
44867
  });
44868
+ console.log(
44869
+ `[makeUpdateSwbFeedIx] ${uniqueOracles.length} unique oracles after dedup (removed ${props.swbPullOracles.length - uniqueOracles.length})`
44870
+ );
44871
+ uniqueOracles.forEach(
44872
+ (o) => console.log(
44873
+ `[makeUpdateSwbFeedIx] - ${o.key.toBase58()} (hasSwitchboardData: ${!!o.price?.switchboardData})`
44874
+ )
44875
+ );
44862
44876
  const swbProgram = await onDemand.AnchorUtils.loadProgramFromConnection(props.connection);
44863
44877
  const pullFeedInstances = uniqueOracles.map((oracle) => {
44864
44878
  const pullFeed = new onDemand.PullFeed(swbProgram, oracle.key);
@@ -44874,6 +44888,7 @@ async function makeUpdateSwbFeedIx(props) {
44874
44888
  return pullFeed;
44875
44889
  });
44876
44890
  if (pullFeedInstances.length === 0) {
44891
+ console.log(`[makeUpdateSwbFeedIx] No pull feed instances, returning early`);
44877
44892
  return { instructions: [], luts: [] };
44878
44893
  }
44879
44894
  const crossbarClient = new common.CrossbarClient(
@@ -44883,11 +44898,19 @@ async function makeUpdateSwbFeedIx(props) {
44883
44898
  if (!gatewayUrls || gatewayUrls.length === 0) {
44884
44899
  throw new Error(`No gateways available for mainnet`);
44885
44900
  }
44901
+ console.log(`[makeUpdateSwbFeedIx] Fetched ${gatewayUrls.length} gateways`);
44886
44902
  const gatewayUrl = gatewayUrls[0];
44887
44903
  if (!gatewayUrl) {
44888
44904
  throw new Error(`Invalid gateway URL received formainnet`);
44889
44905
  }
44890
44906
  const gateway = new onDemand.Gateway(swbProgram, gatewayUrl);
44907
+ console.log(
44908
+ `[makeUpdateSwbFeedIx] Fetching update ix for ${pullFeedInstances.length} feeds via gateway: ${gateway.gatewayUrl}`
44909
+ );
44910
+ console.log(
44911
+ `[makeUpdateSwbFeedIx] pullFeedInstances:`,
44912
+ pullFeedInstances.map((f) => ({ key: f.pubkey.toBase58(), hasData: !!f.data }))
44913
+ );
44891
44914
  const [pullIx, luts] = await onDemand.PullFeed.fetchUpdateManyIx(swbProgram, {
44892
44915
  feeds: pullFeedInstances,
44893
44916
  gateway: gateway.gatewayUrl,
@@ -44895,6 +44918,7 @@ async function makeUpdateSwbFeedIx(props) {
44895
44918
  payer: props.feePayer,
44896
44919
  crossbarClient
44897
44920
  });
44921
+ console.log(`[makeUpdateSwbFeedIx] Got ${pullIx.length} instructions, ${luts.length} LUTs`);
44898
44922
  return { instructions: pullIx, luts };
44899
44923
  }
44900
44924