balancer-subgraph
balancer-subgraph copied to clipboard
Feature request - daily aggregated data
I am making a request for a feature in this subgraph - daily aggregated data, such as is present on the Uniswap subgraph under the name uniswapDayData
. This is an extremely useful feature for other subgraphs, and reduces the need for heavily querying a graph to find day aggregated data. Specifically, I am posting this because I am trying to query the daily transaction count, but it seems that this value returns as 0 in many cases because there were no transactions in that particular block.
@watersnake1 We don't store day by day data but we have another way to gather such data for the volume, liquidity and swap fees that may help you.
The way it work for the volume for example is that we store on the Pool
entity the swap volume since inception in the field Pool.totalSwapVolume
and we also stored this same amount on the Swap
entity at the time when a swap occur in the field Swap.poolTotalSwapVolume
. Then when we query for pools we also query for one swap, the last swap that occured before 24h ago. Then on the UI we do this calculation:
Pool.totalSwapVolume (total swap volume of the pool since inception)
- (minus)
Swap.poolTotalSwapVolume (total swap volume of the pool 24h ago)
= 24h swap volume
Here is an example on thegraph console: https://thegraph.com/explorer/subgraph/bonustrack/balancer?query=Get%2024h%20swap%20volume%20per%20pool
Currently when we do a change on the subgraph it take few days to sync, we will probably not add more data to it to avoid it take longer for sync but we may create a new subgraph for day by day data to make it easier to process for 3p apps.
Thanks so much for the helpful information! I'll try out that approach. If a daily data subgraph was created I would certainly be a user!