Indexing TFT price and average TFT price, by processing two tfchain events TFTPriceModule.AveragePriceStored and TFTPriceModule.PriceStored. data included is a timestamp, block height, and 1 TFT price in USD.
Decisions Made:
Since our squid indexed the price from tfchain emitted events there are different versions of price data with different scales (the number of digits to the right of the decimal point in a number). Some have too few like 2 and some have too many. I chose not to attempt to unify these and leave the values as they are. clients could round these as needed.
Prices are stored in Postgresql as decimal/numeric type
What's Changed:
TFTPriceModule.AveragePriceStored
andTFTPriceModule.PriceStored
. data included is a timestamp, block height, and 1 TFT price in USD.Decisions Made:
Related issues:
example of querying the last 3 average prices for TFT stored on tfchain.
Result:
example of querying the last 3 prices for TFT stored on tfchain.
Result: