Files
DefiLlama-Adapters/projects/hydradex/getHydraV3SubgraphTvl.js
g1nt0ki f9f37f8d82 Tvl-v2 (#9466)
* use tvl function v2

* refactor addFundsInMasterChef

* replace usage of timestamp field

* more refactoring

* more refactoring
2024-03-21 13:56:53 +05:30

24 lines
703 B
JavaScript

const { graphQuery, } = require("../helper/http");
const HOURS_12 = 12 * 3600
async function getBlock(endpoint, timestamp) {
if (typeof timestamp === "object" && timestamp.timestamp) timestamp = timestamp.timestamp
const params = {
timestamp_from: timestamp - HOURS_12 * 2,
timestamp_to: timestamp + HOURS_12 * 2,
}
const query = `query ($timestamp_to: Int, $timestamp_from: Int){
blocks (orderBy: "timestamp" first:1 orderDirection: "desc" where: { timestamp_lte: $timestamp_to timestamp_gte: $timestamp_from}) {
timestamp
number
}
}`
const { blocks } = await graphQuery(endpoint, query, params)
return blocks[0].number
}
module.exports = {
getBlock,
};