---
# System prepended metadata

title: Untitled

---

Goal: The UI needs to display trading volume in a graph that can go back multiple days/weeks to display trading activity. We can't use the already implemented `HistoricalVolume`, because it is on a per block basis and the UI would need to fetch and sum over thousands of datapoints.


Below is an example from Uniswap.

#### Daily
![](https://i.imgur.com/X84Y15Y.png)

#### Weekly
![](https://i.imgur.com/8k5Pk66.png)


Solution: The processor creates *buckets* of daily volume every 24h. For this we take the timestamp of blocks and start a new bucket for each "YYYY-MM-DD". For the latest 24h, the `createdAt` and `blockHeight` properties indicate up to which point the trading volume was processed.


```typescript
type HistoricalVolumeBucket @entity {
    "PoolId-YYYY-MM-DD-daily-volume"
    id: ID!
    assetAAmountIn: BigInt!
    assetAAmountOut: BigInt!
    assetBAmountIn: BigInt!
    assetBAmountOut: BigInt!
    pool: LBPPool!
    createdAt: DateTime! # appears as duplicate, but we need it for the "time bucket" resolver
    blockHeight: BlockHeightPairing! # latest processed block time/number in bucket
}
    
type BlockHeightPairing @entity {
    "paraChainBlockHash"
    id: ID!
    createdAt: DateTime!
    parachainBlockHeight: BigInt!
    relayChainBlockHeight: BigInt!
}
```

