Closed bvotteler closed 1 year ago
We can achieve both by having cumulative volumes that can be queried filtering for block timestamps.
To add more details, here is in example of how we can get volumes for the past 7 days with cumulative volume queries.
Take this query as example for getting 7 day volume for Issued amounts.
query AggregateQuery($beforeDateTime: DateTime, $fromDateTime: DateTime) {
issuedUntilEnd: cumulativeVolumes(limit: 1, orderBy: tillTimestamp_DESC, where: {type_eq: Issued, tillTimestamp_lt: $beforeDateTime}) {
amount
tillTimestamp
type
}
issuedUntilBefore: cumulativeVolumes(limit: 1, orderBy: tillTimestamp_DESC, where: {type_eq: Issued, tillTimestamp_lte: $fromDateTime}) {
amount
tillTimestamp
type
}
}
with parameters
{
"beforeDateTime": "2023-01-17T00:00:00.000000Z",
"fromDateTime": "2023-01-10T00:00:00.000000Z"
}
The above gives us the cumulative volume (in this example of Issued tokens) before and after the time period of Jan 10th until 7 days later. The delta between the two amounts is the volume. We can use any start and end date to get as granular a delta as we want to.
Split off from #35 :
We can achieve both by having cumulative volumes that can be queried filtering for block timestamps.
So we want to provide cumulative volumes per pool with trading volumes for each token that can be swapped in that pool.