Skip to content
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

Merged
merged 21 commits into from
Mar 11, 2024
Merged

Pricing revamp #180

merged 21 commits into from
Mar 11, 2024

Conversation

franzns
Copy link
Collaborator

@franzns franzns commented Feb 29, 2024

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:

    private readonly priceHandlers: TokenPriceHandler[] = [
        new FbeetsPriceHandlerService(),
        new ClqdrPriceHandlerService(),
        new CoingeckoPriceHandlerService(),
        new BptPriceHandlerService(),
        new LinearWrappedTokenPriceHandlerService(),
        new SwapsPriceHandlerService(),
        new FallbackHandlerService(),
    ];

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.

@franzns franzns linked an issue Mar 1, 2024 that may be closed by this pull request
@@ -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;

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?

Copy link
Collaborator Author

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.

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?

Copy link
Collaborator Author

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

@franzns franzns merged commit f64a491 into v3-canary Mar 11, 2024
1 check passed
@gmbronco gmbronco deleted the feat/pricing-revamp branch March 11, 2024 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rethink token pricing
3 participants