@0dotxyz/p0-ts-sdk 1.2.5 → 1.2.7-alpha.1
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 +70 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { deserialize } from 'borsh';
|
|
|
11
11
|
import * as borsh from '@coral-xyz/borsh';
|
|
12
12
|
import { struct as struct$1, bool, publicKey as publicKey$1, array as array$1, u64 as u64$1, u8 as u8$1, u32 as u32$1, u128 } from '@coral-xyz/borsh';
|
|
13
13
|
import { SwapApi, Configuration, createJupiterApiClient } from '@jup-ag/api';
|
|
14
|
-
import { AnchorUtils, PullFeed } from '@switchboard-xyz/on-demand';
|
|
14
|
+
import { AnchorUtils, PullFeed, Gateway } from '@switchboard-xyz/on-demand';
|
|
15
15
|
import { CrossbarClient } from '@switchboard-xyz/common';
|
|
16
16
|
|
|
17
17
|
// src/config.ts
|
|
@@ -44848,16 +44848,22 @@ async function makeUpdateSwbFeedIx(props) {
|
|
|
44848
44848
|
`[makeUpdateSwbFeedIx] - ${o.key.toBase58()} (hasSwitchboardData: ${!!o.price?.switchboardData})`
|
|
44849
44849
|
)
|
|
44850
44850
|
);
|
|
44851
|
-
|
|
44852
|
-
|
|
44853
|
-
|
|
44854
|
-
|
|
44855
|
-
|
|
44856
|
-
const swbProgram = await AnchorUtils.loadProgramFromConnection(props.connection, dummyWallet);
|
|
44851
|
+
console.log(`[makeUpdateSwbFeedIx] Loading SWB program from connection...`);
|
|
44852
|
+
const swbProgram = await AnchorUtils.loadProgramFromConnection(props.connection);
|
|
44853
|
+
console.log(
|
|
44854
|
+
`[makeUpdateSwbFeedIx] SWB program loaded - programId: ${swbProgram.programId.toBase58()}`
|
|
44855
|
+
);
|
|
44857
44856
|
const pullFeedInstances = uniqueOracles.map((oracle) => {
|
|
44858
44857
|
const pullFeed = new PullFeed(swbProgram, oracle.key);
|
|
44858
|
+
console.log(
|
|
44859
|
+
`[makeUpdateSwbFeedIx] Created PullFeed for ${oracle.key.toBase58()} - no switchboardData set (commented out)`
|
|
44860
|
+
);
|
|
44859
44861
|
return pullFeed;
|
|
44860
44862
|
});
|
|
44863
|
+
console.log(
|
|
44864
|
+
`[makeUpdateSwbFeedIx] pullFeedInstances:`,
|
|
44865
|
+
pullFeedInstances.map((f) => ({ key: f.pubkey.toBase58(), hasConfigs: !!f.configs }))
|
|
44866
|
+
);
|
|
44861
44867
|
if (pullFeedInstances.length === 0) {
|
|
44862
44868
|
console.log(`[makeUpdateSwbFeedIx] No pull feed instances, returning early`);
|
|
44863
44869
|
return { instructions: [], luts: [] };
|
|
@@ -44865,19 +44871,66 @@ async function makeUpdateSwbFeedIx(props) {
|
|
|
44865
44871
|
const crossbarClient = new CrossbarClient(
|
|
44866
44872
|
process.env.NEXT_PUBLIC_SWITCHBOARD_CROSSSBAR_API || "https://integrator-crossbar.prod.mrgn.app"
|
|
44867
44873
|
);
|
|
44868
|
-
console.log(`[makeUpdateSwbFeedIx] Fetching update ix for ${pullFeedInstances.length} feeds`);
|
|
44869
44874
|
console.log(
|
|
44870
|
-
`[makeUpdateSwbFeedIx]
|
|
44871
|
-
pullFeedInstances.map((f) => ({ key: f.pubkey.toBase58(), hasConfigs: !!f.configs }))
|
|
44875
|
+
`[makeUpdateSwbFeedIx] crossbarClient URL: ${process.env.NEXT_PUBLIC_SWITCHBOARD_CROSSSBAR_API || "https://integrator-crossbar.prod.mrgn.app"}`
|
|
44872
44876
|
);
|
|
44873
|
-
|
|
44874
|
-
|
|
44875
|
-
|
|
44876
|
-
|
|
44877
|
-
|
|
44878
|
-
|
|
44879
|
-
|
|
44880
|
-
|
|
44877
|
+
console.log(
|
|
44878
|
+
`[makeUpdateSwbFeedIx] SWB on-demand version: 2.14.4, common version: 4.1.0 (alpha.1)`
|
|
44879
|
+
);
|
|
44880
|
+
console.log(`[makeUpdateSwbFeedIx] Fetching gateways for mainnet...`);
|
|
44881
|
+
const gatewayUrls = await crossbarClient.fetchGateways("mainnet");
|
|
44882
|
+
console.log(`[makeUpdateSwbFeedIx] Gateway URLs received:`, gatewayUrls);
|
|
44883
|
+
if (!gatewayUrls || gatewayUrls.length === 0) {
|
|
44884
|
+
throw new Error(`No gateways available for mainnet`);
|
|
44885
|
+
}
|
|
44886
|
+
const gatewayUrl = gatewayUrls[0];
|
|
44887
|
+
if (!gatewayUrl) {
|
|
44888
|
+
throw new Error(`Invalid gateway URL received for mainnet`);
|
|
44889
|
+
}
|
|
44890
|
+
console.log(`[makeUpdateSwbFeedIx] Using gateway: ${gatewayUrl}`);
|
|
44891
|
+
const gateway = new Gateway(swbProgram, gatewayUrl);
|
|
44892
|
+
console.log(`[makeUpdateSwbFeedIx] Gateway gatewayUrl: ${gateway.gatewayUrl}`);
|
|
44893
|
+
try {
|
|
44894
|
+
for (const feed of pullFeedInstances) {
|
|
44895
|
+
try {
|
|
44896
|
+
const accountInfo = await props.connection.getAccountInfo(feed.pubkey);
|
|
44897
|
+
console.log(
|
|
44898
|
+
`[makeUpdateSwbFeedIx] Feed account ${feed.pubkey.toBase58()}: exists=${!!accountInfo}, owner=${accountInfo?.owner?.toBase58() ?? "N/A"}, dataLen=${accountInfo?.data?.length ?? 0}`
|
|
44899
|
+
);
|
|
44900
|
+
if (accountInfo?.data) {
|
|
44901
|
+
const discriminator = accountInfo.data.slice(0, 8);
|
|
44902
|
+
console.log(
|
|
44903
|
+
`[makeUpdateSwbFeedIx] Feed account ${feed.pubkey.toBase58()} discriminator: [${Array.from(discriminator).join(", ")}]`
|
|
44904
|
+
);
|
|
44905
|
+
}
|
|
44906
|
+
} catch (accErr) {
|
|
44907
|
+
console.error(
|
|
44908
|
+
`[makeUpdateSwbFeedIx] Failed to fetch account info for ${feed.pubkey.toBase58()}:`,
|
|
44909
|
+
accErr
|
|
44910
|
+
);
|
|
44911
|
+
}
|
|
44912
|
+
}
|
|
44913
|
+
console.log(`[makeUpdateSwbFeedIx] Calling PullFeed.fetchUpdateManyIx...`);
|
|
44914
|
+
const [pullIx, luts] = await PullFeed.fetchUpdateManyIx(swbProgram, {
|
|
44915
|
+
feeds: pullFeedInstances,
|
|
44916
|
+
gateway: gateway.gatewayUrl,
|
|
44917
|
+
numSignatures: 1,
|
|
44918
|
+
payer: props.feePayer,
|
|
44919
|
+
crossbarClient
|
|
44920
|
+
});
|
|
44921
|
+
console.log(`[makeUpdateSwbFeedIx] Got ${pullIx.length} instructions, ${luts.length} LUTs`);
|
|
44922
|
+
return { instructions: pullIx, luts };
|
|
44923
|
+
} catch (err) {
|
|
44924
|
+
console.error(`[makeUpdateSwbFeedIx] fetchUpdateManyIx FAILED:`, err?.message || err);
|
|
44925
|
+
console.error(`[makeUpdateSwbFeedIx] Error name: ${err?.name}, code: ${err?.code}`);
|
|
44926
|
+
if (err?.logs) {
|
|
44927
|
+
console.error(`[makeUpdateSwbFeedIx] Error logs:`, err.logs);
|
|
44928
|
+
}
|
|
44929
|
+
if (err?.stack) {
|
|
44930
|
+
console.error(`[makeUpdateSwbFeedIx] Stack:`, err.stack);
|
|
44931
|
+
}
|
|
44932
|
+
throw err;
|
|
44933
|
+
}
|
|
44881
44934
|
}
|
|
44882
44935
|
|
|
44883
44936
|
// src/services/price/actions/klend-reserve-refresh.ts
|