fix centrifuge historical

This commit is contained in:
g1nt0ki
2022-06-01 19:05:23 +02:00
parent 28017ddde5
commit ab246202c6

View File

@@ -15,42 +15,39 @@ query GET_TOTAL_TOKEN_TVL($block: Int) {
}
`;
const dai = "0x6b175474e89094c44da98b954eedeac495271d0f"
let data
async function getData(ethBlock) {
if (!data)
data = request(
subgraphUrl,
graphTotalTokenTVLQuery,
{
block: ethBlock
}
return request(
subgraphUrl,
graphTotalTokenTVLQuery,
{
block: ethBlock
}
)
return data
}
async function borrowed(timestamp, ethBlock) {
let total = BigNumber(0)
const { pools } = await getData(ethBlock);
pools.forEach(pool=>{
total = total.plus(pool.assetValue)
})
let total = BigNumber(0)
const { pools } = await getData(ethBlock);
pools.forEach(pool => {
total = total.plus(pool.assetValue)
})
return {
[dai]: total.toFixed(0)
}
return {
[dai]: total.toFixed(0)
}
}
async function tvl(timestamp, ethBlock) {
let total = BigNumber(0)
const { pools } = await getData(ethBlock);
pools.forEach(pool=>{
total = total.plus(pool.reserve)
})
let total = BigNumber(0)
const { pools } = await getData(ethBlock);
pools.forEach(pool => {
total = total.plus(pool.reserve)
})
return {
[dai]: total.toFixed(0)
}
return {
[dai]: total.toFixed(0)
}
}
@@ -58,8 +55,8 @@ async function tvl(timestamp, ethBlock) {
module.exports = {
doublecounted: false,
methodology: 'TVL consist of the sum of every pool. The pool value is made up of the NAV (the value of the assets in the pool) and the Pool Reserve (undeployed capital in the pool). The Tinlake subgraph is used to pull the assetValue and reserve values of each pool.',
ethereum:{
tvl,
ethereum: {
tvl,
borrowed,
}
}