-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
DUX-823 Prices v2 rework #7391
base: main
Are you sure you want to change the base?
DUX-823 Prices v2 rework #7391
Conversation
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.
Had a few comments but lgtm.
dbt_subprojects/tokens/models/prices_v2/minute/prices_v2_dex_minute_raw.sql
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,23 @@ | |||
{{ config( | |||
schema='prices_v2', | |||
alias = 'latest', |
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 is this model needed?
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 not needed for the sqlmesh side, just thought it would be cheaper do do it directly on the sparse dataset then later on the filled one.
SELECT | ||
* | ||
FROM {{ ref('prices_v2_dex_minute_raw') }} | ||
INNER JOIN {{ ref('prices_v2_dex_filter') }} using (blockchain, contract_address) |
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.
Can't we do this filtering below in prices_v2_dex_minute_raw
directly instead?
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.
opted to keep prices_v2_dex_minute_raw
a clean union model
is the intention of this PR to remove the need for
if that is the case, where is the logic here for obtaining median price per token per block? did we decide to do away with that logic (that could change results a lot and require more testing)? we would need to perform this calculation prior to the vwap calculation. |
That's indeed the end goal. Do you know why we needed the median block price before doing the vwap? Is it outliers in dex.trades, where we don't want them to influence the vwap price? |
yeah, we use the median price per block to remove outliers from DEX activity such as MEV/sandwiches/other approaches i'm no expert in 😅 we had hit a lot of outliers across various tokens and this helped get around most. we still have some outlier prices that get through, which will require more in-depth filtering/logic if fixing. it's documented a bit here: i think we should stick to block for now, and can revisit minute level later to see how it compares. i think the decision of block vs. minute was due to grouping of tx's that could produce those outlier numbers (mev/sandwich/etc) |
Thank you for contributing to Spellbook 🪄
Please open the PR in draft and mark as ready when you want to request a review.
Description:
Goal is to:
This should resolve any duplicates we're currently having and will allow us to switch tokens from different sources without having temporary gaps or duplicates.
Also resolves DUX-702 while we're at it.
quick links for more information: