Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
g1nt0ki committed Sep 10, 2024
1 parent 3c767bd commit 0ee9cf9
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions projects/predict-fun/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { graphQuery } = require('../helper/http')
const ADDRESSES = require('../helper/coreAssets.json')

const config = {
blast: 'https://graphql.predict.fun/graphql'
}


const query = (after) => `query {
categories (pagination: {
first: 100
${after ? `after: "${after}"` : ''}
}) {
totalCount
pageInfo {
hasNextPage
startCursor
endCursor
}
edges {
node {
id
slug
title
statistics {
liquidityValueUsd
volume24hUsd
volumeTotalUsd
}
}
}
}
}
`

Object.keys(config).forEach(chain => {
const endpoint = config[chain]
module.exports[chain] = {
tvl: async (api) => {
const categories = []
let after = null
do {
const data = await graphQuery(endpoint, query(after))
categories.push(...data.categories.edges)
if (data.categories.pageInfo.hasNextPage) {
after = data.pageInfo.endCursor
}
} while (after)
const usd = categories.reduce((tvl, category) => tvl + category.node.statistics.liquidityValueUsd, 0)
api.add(ADDRESSES.blast.USDB, usd * 1e18)
}
}
})

module.exports.timetravel = false

0 comments on commit 0ee9cf9

Please sign in to comment.