-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pricing revamp #180
Pricing revamp #180
Conversation
…o feat/pricing-revamp
modules/common/time.ts
Outdated
@@ -142,3 +142,11 @@ export function timestampRoundedUpToNearestHour(m: moment.Moment = moment()): nu | |||
|
|||
return roundUp.unix(); | |||
} | |||
|
|||
export function timestampTopOfTheHour(): number { | |||
return moment().utc().endOf('hour').unix() + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why +1? btw. is this fn used somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's to get the top of the hour timestamp. End of hour gives you 1s before that.
And no, not used anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need some help with this one, because i think i'm missing something. What does it do apart from reading current prices and storing them back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's all it does. Basically ensuring that we always have a price
Solves this #22
We combine the coingecko and specific pricing into one stack. The updateTokenPrice method uses the following handlers in order to price tokens:
They are all multichain aware, you can pass a set of chains to the updateTokenPrice function on the tokenPriceService. It's currently done on a per-chain level. Probably we want to change that and make a "global" multichain job and price all chains in one job.
CoingeckoPriceHandler only prices using coingecko Ids, no longer via contract address. It has also the option to exclude tokens from it either via networkconfig or via content service. In the future, the content service should be used.
A new fallbackHandler is created which make sure that we have a complete data set. E.g. if a token is only priced via swap handler, it would not get an update via the swaphandler if there arent any swaps (in fact the price didnt change if there wasnt a swap). The fallback handler takes the current price of a token and upserts the hourly and daily timestamp with that price, making sure there is always a price.
Currently there is no method to "backfill" token prices. We have what we have and the history will slowly be built now. We can think about adding a backfiller and try to get token prices from coingecko or using ABA method.