interlay / interbtc-squid

Subquid GraphQL schema and indexer for the Interlay and Kintsugi networks
Apache License 2.0
4 stars 7 forks source link

Provide USD values in fixed intervals for volumes #96

Closed nud3l closed 1 year ago

nud3l commented 1 year ago

What we want

We want to show time-based data in our UI. The time-based data would be updated at fixed intervals, e.g., every 10 minutes to be the basis for graphs like this one:

image

Desired example query:

query userPortfolio($start: DateTime, $end: Datetime, $account: string) {
  userPortfolio(
    amounts
    timestamp
}

Desired example return:

[
  {
    "amounts": [
      { "amount": 21321321, "amountHuman": 0.21321321, "token": {"Token": "IBTC"}}
    ]
    "timestamp": "2023-03-08 12:43:12"
  }
]

What we have

Squid is able to easily store the amounts of tokens in a pool (or the tokens a user owns) with a timestamp on when the amounts where updated, see e.g., here: https://github.com/interlay/interbtc-squid/blob/master/src/model/generated/cumulativeDexTradingVolumePerPool.model.ts#L24

Investigation

Possible approach

Consideration

Questions