diff --git a/projects/maiar/index.js b/projects/maiar/index.js index 3d6e7da189..212eef8df2 100644 --- a/projects/maiar/index.js +++ b/projects/maiar/index.js @@ -1,13 +1,14 @@ const { request } = require("graphql-request"); -const { toUSDTBalances } = require('../helper/balances') const LiquidityQuery = ` { - factory { - pairCount - totalValueLockedUSD - } + pairs(limit: 1000 minLockedValueUSD: 100) { + address + lockedValueUSD + liquidityPoolTokenPriceUSD } +} + ` const StakingQuery2 = `{ @@ -16,15 +17,21 @@ const StakingQuery2 = `{ totalLockedMexStakedUSD }` -async function tvl() { - const results = await request("http://graph.xexchange.com/graphql", LiquidityQuery) - - return toUSDTBalances(results.factory.totalValueLockedUSD) +async function tvl(api) { + const { pairs } = await request("http://graph.xexchange.com/graphql", LiquidityQuery) + console.log(pairs.length) + pairs.forEach(i => { + if (i.lockedValueUSD > 1e8) { + api.log(`Pair ${i.address} has ${i.lockedValueUSD} USD locked, ignoring it`) + return; + } + api.addUSDValue(Math.round(+i.lockedValueUSD)) + }); } -async function stakingAndLockedMEX() { +async function stakingAndLockedMEX(api) { const results = await request("http://graph.xexchange.com/graphql", StakingQuery2) - return toUSDTBalances(results.totalValueStakedUSD) + api.addUSDValue(+results.totalValueStakedUSD) } module.exports = { diff --git a/test.js b/test.js index 686d68c1fd..dc8017ba75 100644 --- a/test.js +++ b/test.js @@ -170,6 +170,8 @@ function validateHallmarks(hallmark) { storedKey = chain; tvlFunctionIsFetch = true; } + try { + await getTvl( unixTimestamp, ethBlock, @@ -181,6 +183,10 @@ function validateHallmarks(hallmark) { tvlFunctionIsFetch, storedKey, ); + } catch (e) { + console.error(`Error in ${storedKey}:`, e) + process.exit(1) + } let keyToAddChainBalances = tvlType; if (tvlType === "tvl" || tvlType === "fetch") { keyToAddChainBalances = "tvl";