Files
DefiLlama-Adapters/projects/defiplaza.js
2022-03-18 19:29:34 +01:00

27 lines
662 B
JavaScript

const { request, gql } = require('graphql-request');
const { toUSDTBalances } = require('./helper/balances');
const graphUrl = 'https://api.thegraph.com/subgraphs/name/omegasyndicate/defiplaza';
const graphQuery = gql`
query get_tvl($timestamp: Int) {
hourlies(first: 1, orderBy: date, orderDirection: desc, where:{date_lte: $timestamp}) {
totalValueLockedUSD
}
}
`;
async function tvl(timestamp, block) {
const { hourlies } = await request(graphUrl, graphQuery, {
timestamp,
});
const usdTvl = Number(hourlies[0].totalValueLockedUSD);
return toUSDTBalances(usdTvl);
}
module.exports = {
ethereum: {
tvl,
},
};