Skip to content

Commit a1cb3d9

Browse files
committed
reinstate pyth pull logic
1 parent 4621d1b commit a1cb3d9

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

solend-sdk/src/core/actions.ts

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,11 +1159,6 @@ export class SolendActionCore {
11591159
(oracleKey) => new PullFeed(sbod as any, oracleKey)
11601160
);
11611161

1162-
const updateFeeds = await Promise.all(
1163-
feedAccounts.map((feedAccount) => feedAccount.loadData())
1164-
);
1165-
1166-
if (updateFeeds.length) {
11671162
const crossbar = new CrossbarClient(
11681163
"https://crossbar.switchboard.xyz/"
11691164
);
@@ -1204,7 +1199,6 @@ export class SolendActionCore {
12041199
const vtx = new VersionedTransaction(message);
12051200

12061201
this.pullPriceTxns.push(vtx);
1207-
}
12081202

12091203
const pythPulledOracles = oracleAccounts.filter(
12101204
(o) =>
@@ -1214,20 +1208,27 @@ export class SolendActionCore {
12141208
const shuffledPriceIds = (
12151209
pythPulledOracles
12161210
.map((pythOracleData, index) => {
1217-
if (!pythOracleData) {
1218-
throw new Error(`Could not find oracle data at index ${index}`);
1219-
}
1220-
const priceUpdate =
1221-
pythSolanaReceiver.receiver.account.priceUpdateV2.coder.accounts.decode(
1222-
"priceUpdateV2",
1223-
pythOracleData.data
1224-
);
1225-
1226-
return {
1227-
key: Math.random(),
1228-
priceFeedId: toHexString(priceUpdate.priceMessage.feedId),
1229-
};
1230-
})
1211+
if (!pythOracleData) {
1212+
throw new Error(`Could not find oracle data at index ${index}`);
1213+
}
1214+
const priceUpdate =
1215+
pythSolanaReceiver.receiver.account.priceUpdateV2.coder.accounts.decode(
1216+
"priceUpdateV2",
1217+
pythOracleData.data
1218+
);
1219+
1220+
const needUpdate =
1221+
Date.now() / 1000 -
1222+
Number(priceUpdate.priceMessage.publishTime.toString()) >
1223+
30;
1224+
1225+
return needUpdate
1226+
? {
1227+
key: Math.random(),
1228+
priceFeedId: toHexString(priceUpdate.priceMessage.feedId),
1229+
}
1230+
: undefined;
1231+
})
12311232
.filter(Boolean) as Array<{
12321233
key: number;
12331234
priceFeedId: string;

0 commit comments

Comments
 (0)