Skip to content

Commit

Permalink
fix sb pull oracles
Browse files Browse the repository at this point in the history
  • Loading branch information
0xodia committed Jul 19, 2024
1 parent 64bb9c4 commit 23bf8f2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion solend-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solendprotocol/solend-sdk",
"version": "0.11.10",
"version": "0.11.13",
"private": true,
"main": "src/index.ts",
"module": "src/index.ts",
Expand Down
29 changes: 19 additions & 10 deletions solend-sdk/src/core/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -935,29 +935,38 @@ export class SolendActionCore {
(_o, index) =>
oracleAccounts[index]?.owner.toBase58() === sbod.programId.toBase58()
);
if (sbPulledOracles.length) {
const feedAccounts = sbPulledOracles.map(
(oracleKey) => new PullFeed(sbod as any, oracleKey)
);
const feedAccounts = sbPulledOracles.map(
(oracleKey) => new PullFeed(sbod as any, oracleKey)
);

const feedData = await Promise.all(
feedAccounts.map((feedAccount) => feedAccount.loadData())
);

const feedsThatNeedUpdate = feedData.map(
(feed) =>
Date.now() / 1000 - Number(feed.lastUpdateTimestamp.toString()) > 70
);
const updateFeeds = feedAccounts.filter(
(_, index) => feedsThatNeedUpdate[index]
);

if (updateFeeds.length) {
const crossbar = new CrossbarClient(
"https://crossbar-fvumormova-uc.a.run.app"
);

// Responses is Array<[pullIx, responses, success]>
const responses = await Promise.all(
feedAccounts.map((feedAccount) =>
updateFeeds.map((feedAccount) =>
feedAccount.fetchUpdateIx({
numSignatures: 1,
crossbarClient: crossbar,
gateway: "https://xoracle-1-mn.switchboard.xyz",
})
)
);
const oracles = responses.flatMap((x) => x[1].map((y) => y.oracle));
const lookupTables = await loadLookupTables([
...oracles,
...feedAccounts,
]);
const lookupTables = await loadLookupTables([...oracles, ...updateFeeds]);

const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
microLamports: 100_000,
Expand Down

0 comments on commit 23bf8f2

Please sign in to comment.