Skip to content

Commit

Permalink
use average ts for solana
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnd committed Jul 27, 2024
1 parent 23c1f97 commit 27a2c95
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utils/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { BridgeNetwork } from "../data/types";
import { groupBy } from "lodash";
import { getProvider } from "./provider";
import { sendDiscordText } from "./discord";
import { getConnection } from "../helpers/solana";
const axios = require("axios");
const retry = require("async-retry");

Expand Down Expand Up @@ -491,8 +492,14 @@ export const runAdapterHistorical = async (
let block = {} as { timestamp: number; number: number };

let latestSolanaBlock = null;
let averageBlockTimestamp = null;

if (chain === "solana") {
latestSolanaBlock = await getLatestBlock("solana");
const averageBlock = Math.floor((minBlock + maxBlock) / 2);
const connection = getConnection();

averageBlockTimestamp = await connection.getBlockTime(averageBlock);
}

for (let i = 0; i < 10; i++) {
Expand All @@ -507,7 +514,7 @@ export const runAdapterHistorical = async (
break;
}
} else if (chain === "solana") {
blockTimestamps[i] = await getTimestampBySolanaSlot(blockNumber, latestSolanaBlock);
blockTimestamps[i] = averageBlockTimestamp as any;
break;
} else {
blockTimestamps[i] = currentTimestamp;
Expand Down

0 comments on commit 27a2c95

Please sign in to comment.