threefoldtech / tfchain_graphql

Graphql for TFchain
Apache License 2.0
2 stars 3 forks source link

feat: Track historical tft prices #169

Closed sameh-farouk closed 6 months ago

sameh-farouk commented 6 months ago

What's Changed:

Decisions Made:

Related issues:

example of querying the last 3 average prices for TFT stored on tfchain.

query MyQuery {
  averagePriceStoreds(limit: 3, orderBy: block_DESC) {
    block
    id
    newAveragePrice
    timestamp
  }
}

Result:

{
  "data": {
    "averagePriceStoreds": [
      {
        "block": 11160373,
        "id": "0011160373-000003-a6bf7",
        "newAveragePrice": "0.02",
        "timestamp": "1716289794"
      },
      {
        "block": 11160363,
        "id": "0011160363-000008-81af9",
        "newAveragePrice": "0.02",
        "timestamp": "1716289734"
      },
      {
        "block": 11160353,
        "id": "0011160353-000003-91221",
        "newAveragePrice": "0.02",
        "timestamp": "1716289674"
      }
    ]
  }
}

example of querying the last 3 prices for TFT stored on tfchain.

query MyQuery {
  priceStoreds(limit: 3, orderBy: block_DESC) {
    block
    id
    newPrice
    timestamp
  }
}

Result:

{
  "data": {
    "priceStoreds": [
      {
        "block": 11160586,
        "id": "0011160586-000002-273c9",
        "newPrice": "0.02",
        "timestamp": "1716291072"
      },
      {
        "block": 11160576,
        "id": "0011160576-000017-82e41",
        "newPrice": "0.02",
        "timestamp": "1716291012"
      },
      {
        "block": 11160566,
        "id": "0011160566-000028-4cb5a",
        "newPrice": "0.02",
        "timestamp": "1716290952"
      }
    ]
  }
}