Closed bvotteler closed 1 year ago
7-day, 24-hour volumes can be calculated using the cumulative volumes. See this comment for example queries.
This is what a 7-day volume query could look like: Query:
fragment AmountFields on PooledAmount {
amount
amountHuman
token {
... on NativeToken {
__typename
token
}
... on ForeignAsset {
__typename
asset
}
... on StableLpToken {
__typename
poolId
}
}
}
fragment PoolVolumeFields on CumulativeDexTradingVolumePerPool {
poolId
poolType
tillTimestamp
amounts {
...AmountFields
}
}
query poolVolumes($start: DateTime, $end: DateTime, $poolIdSubstr1: String, $poolIdSubstr2: String) {
startVolumes: cumulativeDexTradingVolumePerPools(limit: 1, orderBy: tillTimestamp_DESC, where: {poolId_contains: $poolIdSubstr1, tillTimestamp_lte: $start, AND: {poolId_contains: $poolIdSubstr2}}) {
...PoolVolumeFields
}
endVolumes: cumulativeDexTradingVolumePerPools(limit: 1, orderBy: tillTimestamp_DESC, where: {poolId_contains: $poolIdSubstr1, tillTimestamp_lte: $end, AND: {poolId_contains: $poolIdSubstr2}}) {
...PoolVolumeFields
}
}
eg. using these parameter values
{
"poolIdSubstr1": "KBTC",
"poolIdSubstr2": "KSM",
"start": "2023-02-01T00:00:00.000000Z",
"end": "2023-02-08T00:00:00.000000Z"
}
@bvotteler This looks good to me, approving now. This comment does not need to be handled as we are sure other types of currencies won't be used, right? https://github.com/interlay/interbtc-squid/pull/81/files#r1106863865
Yes, I am assuming this holds true until our types are updated to include those. When that happens, the interbtc-types definition here will need to be updated, too, at which point we know squid needs to follow suit.
Split off from #35
Added cumulative volumes per pool, containing volume per token of the swap.
Resolves #80