Open Hosuke opened 10 months ago
thanks for the intiative @Hosuke 🙌
should we repurpose this issue to be dex.trades
lineage specific? so rather than just general macro usage, this issue will track all new dex's that get added to the new _beta
dex lineage
we could have separate issues for separate sectors
edit: based on the title and label on issue, maybe you intended dex only? reading the description made me doubt that a bit, just want to clarify
thanks for the intiative @Hosuke 🙌
should we repurpose this issue to be
dex.trades
lineage specific? so rather than just general macro usage, this issue will track all new dex's that get added to the new_beta
dex lineagewe could have separate issues for separate sectors
edit: based on the title and label on issue, maybe you intended dex only? reading the description made me doubt that a bit, just want to clarify
Sorry my phrase may not clear enough. I intended in the dex
sector only.
dex.trades
redesign workstreamfollowing the format for uniswap in liked PR from issue description above, add all dex models in dex.trades
lineage to the new beta design.
notes from the original redesign gh issue:
base_
prefix for table aliases to indicate it's a stepping stone to a final trades table dex.trades
for project-specific spells, which would ultimately use the same naming standard as old pipeline, therefore replacing the old schema/alias name, and leaving base_
for the pipelines only (i.e. no app usage)@Hosuke are you comfortable leading this? we can also reach out to users in the community to help migrate to new design in this issue, and coordinate who is helping migrate which dex.
it is recommended to open one PR per dex to keep review cycle clean & quick as possible. it's okay to do all blockchains of a dex in one PR, but at minimum keep the PR to one dex.
@Hosuke are you comfortable leading this? we can also reach out to users in the community to help migrate to new design in this issue, and coordinate who is helping migrate which dex.
I am very enthusiastic about leading this initiative. However, there may be times when my language or technical descriptions might not be as precise as needed. Any additional directions or specific content that you can provide to ensure the success of this project are welcomed.
I am very enthusiastic about leading this initiative. However, there may be times when my language or technical descriptions might not be as precise as needed. Any additional directions or specific content that you can provide to ensure the success of this project are welcomed.
no problem -- i'll be closely engaged all along 🤝 thanks for leading this!
specific next steps:
block_number
is pulled through all base_trades
spells in first PR (uniswap, defiswap) — new PR, if needed, to add. if they already exist, move on but ensure future ones include tooblock_number
is part of join condition checks. use the generic check seed test, follow format in nft projects.once we reach step 3, we can look to see if anyone in the community is interested in helping migrate any dex projects to the new structure 🙏
Once you reach step 3 and finalized instructions created, i would like to help to migrate spells to the new structure
Thank you @nyssarex , as I think we are at step 3, you can take any project to migrate and list them here if you want.
@Hosuke can we monitor the beta spell over time, as more are added, in terms of matching existing dex.trades
?
this comment had a query to compare during the initial build and results matched. sadly i didn't save the query & it's a screenshot, but should be quick to rewrite (and enhance as needed). if results differ at all as more dexes are added, we can group by project / blockchain / version and find specific spells which may be the issue.
we could explore adding as a test in the repo too, so it runs in CI automatically, if that's easier.
Hi guys, quick updated, i did base trade for quickswap (only in polygon ). Localy compiled with no error , in CI failed (https://github.com/duneanalytics/spellbook/pull/4895). May be to scale process fast and seemles. @Hosuke can make simple guide or me after i get everything clearly how we migrate to base trades in different cases. uniswap compitable, notation with v1,v2,v3 , etc.
@Hosuke can we monitor the beta spell over time, as more are added, in terms of matching existing
dex.trades
?this comment had a query to compare during the initial build and results matched. sadly i didn't save the query & it's a screenshot, but should be quick to rewrite (and enhance as needed). if results differ at all as more dexes are added, we can group by project / blockchain / version and find specific spells which may be the issue.
we could explore adding as a test in the repo too, so it runs in CI automatically, if that's easier.
I write a draft query to track migration counts: https://dune.com/queries/3239455/5419355
Will try to enhance more, but currently it serves as an MVP tracker.
@Hosuke can we monitor the beta spell over time, as more are added, in terms of matching existing
dex.trades
? this comment had a query to compare during the initial build and results matched. sadly i didn't save the query & it's a screenshot, but should be quick to rewrite (and enhance as needed). if results differ at all as more dexes are added, we can group by project / blockchain / version and find specific spells which may be the issue. we could explore adding as a test in the repo too, so it runs in CI automatically, if that's easier.I write a draft query to track migration counts: https://dune.com/queries/3239455/5419355
Will try to enhance more, but currently it serves as an MVP tracker.
love it!
we should likely dig into the ones that aren't 100% match sooner rather than later, before it become too long of a list, to see why
I write a draft query to track migration counts: https://dune.com/queries/3239455/5419355
Will try to enhance more, but currently it serves as an MVP tracker.
I looked at the results of your query and was concerned about the ones not 100% matching, so I checked them. I forked your query and in addition to project
I also added breakdown by blockchain
and version
- I think that (query) gives clearer picture, for example:
Hi guys, quick updated, i did base trade for quickswap (only in polygon ). Localy compiled with no error , in CI failed (#4895). May be to scale process fast and seemles. @Hosuke can make simple guide or me after i get everything clearly how we migrate to base trades in different cases. uniswap compitable, notation with v1,v2,v3 , etc.
thanks again for helping!
i'm not sure how we can determine ahead of time what is uniswap compatible and what isn't (is there a resource out there?). we may just need to look at the code each time and determine, it's pretty obvious to know when seeing the code. as for standards on versions and such, let's mostly stick to what was in there previously. i believe dex lineage prefers 1
rather than v1
, for example. there are some projects which use letters/words instead of numbers.
I write a draft query to track migration counts: https://dune.com/queries/3239455/5419355 Will try to enhance more, but currently it serves as an MVP tracker.
I looked at the results of your query and was concerned about the ones not 100% matching, so I checked them. I forked your query and in addition to
project
I also added breakdown byblockchain
andversion
- I think that (query) gives clearer picture, for example:
- curve is actually matching 100% as it's only Celo trades that are migrated atm
- ubeswap - prod version has an incorrect project start date set (my fault!), and beta trades are actually accurate
- sushiswap - few reasons for discrepancy: 1) I added sushi v2 to beta trades so that adds more records to total counts, 2) with break down by version - v1 counts in prod are matching v2 counts in beta as per this note (tl;dr beta is correct)
- there are still these left to check:
way ahead of me, two minutes after i commented to dig deeper 😆 thanks for helping here
agreed on adding blockchain
and version
, that gives us a clear picture of where to look. that also helps us only compare beta against what existed in old dex lineage, rather than net new projects in beta only.
way ahead of me, two minutes after i commented to dig deeper 😆 thanks for helping here
agreed on adding
blockchain
andversion
, that gives us a clear picture of where to look. that also helps us only compare beta against what existed in old dex lineage, rather than net new projects in beta only.
I added now amounts comparison to the query too, but it might be an overkill 😂
I'm looking at amount_usd
column and I see a trend of blank records starting around block_time Feb 2021 and then decreasing over time (possibly something similar I noticed in my other PR
https://dune.com/queries/3263618/5462973
Polygon case seems to be quite clear:
I'm looking at
amount_usd
column and I see a trend of blank records starting around block_time Feb 2021 and then decreasing over time (possibly something similar I noticed in my other PRhttps://dune.com/queries/3263618/5462973
Polygon case seems to be quite clear:
this came up in the 1inch PR to rebuild lineage into dex_aggregator.trades
. we merged this change, which should help cover some gaps in prices. it appears the pricing providor doesn't have as much history for wrapped tokens and such, so we flipped the id value to the native id for coverage.
this may take some time to propogate through prices.usd
, then may require a refresh of sector-level spells to account for it.
@Hosuke can you add a readme md file in models/_sector/dex/
that contains info on:
we should already have most of this info across gh issues/PRs/comments. it'd be good to summarize in a readme at the root level of the sector.
i'll be happy to review it with ya when ready
once that is merged, we can explore building a more generic sector readme up one directory in models/_sector/
@Hosuke can you add a readme md file in
models/_sector/dex/
that contains info on:
- how to contribute
- example PRs
- details on the design & why we've chosen that path
- ...and so on
we should already have most of this info across gh issues/PRs/comments. it'd be good to summarize in a readme at the root level of the sector.
i'll be happy to review it with ya when ready
once that is merged, we can explore building a more generic sector readme up one directory in
models/_sector/
I init a readme in this PR: #5027
From all I can find Warden (wardenswap) is only a dex aggregator and doesn't have it's own liquidity (so not a direct DEX). If that's correct, shouldn't it only appear in the aggregator table (or as an aggregator if the two tables plan on being merged like they were on postgres 🤞)? Or am I missing something? I'm just confused about it showing up in dex.trades cc @chain-l @tomfutago
From all I can find Warden (wardenswap) is only a dex aggregator and doesn't have it's own liquidity (so not a direct DEX). If that's correct, shouldn't it only appear in the aggregator table (or as an aggregator if the two tables plan on being merged like they were on postgres 🤞)? Or am I missing something? I'm just confused about it showing up in dex.trades cc @chain-l @tomfutago
Looks like BSC is an exception - wardenswap got deployed as uniswap v2 fork. source: https://defillama.com/protocol/wardenswap
@Hosuke @tomfutago
another enhancement i don't want us to forget about is how we assign amount_usd
in the final stages. as of now, we've continued the pattern from early days of dex.trades
and default to token bought, then fallback to token sold if bought isn't available in prices.usd
we should look for a better if this/then that scenario to assign a value. can you guys brainstorm some ideas? random thoughts on my side:
whichever approach we take, should it also be a universal macro that can be used in other sector spells?
edit: reference in discord here
@Hosuke @tomfutago another enhancement i don't want us to forget about is how we assign
amount_usd
in the final stages. as of now, we've continued the pattern from early days ofdex.trades
and default to token bought, then fallback to token sold if bought isn't available inprices.usd
we should look for a better if this/then that scenario to assign a value. can you guys brainstorm some ideas? random thoughts on my side:
- have a static list of "trust tokens" -- think USDC/WETH/etc -- then always use those when present. else, do the bought/sold coalesce
I have done some experiments to rank token stability in this query: https://dune.com/queries/3327086
If this rank is useful to solve this problem, I can extend the query into a spell.
edit: which is better? static or dynamic stable coin rank?
@Hosuke where do we stand on the status? what steps are left to finalize the migration?
some thoughts:
_beta
to final table@Hosuke where do we stand on the status? what steps are left to finalize the migration?
some thoughts:
- coverage of dexes included
- test query showing data matches (or v close, as some calculations can differ slightly / had some bug fixes in new lineage)
- steps to migrate
_beta
to final table- communication plan (i can help here)
The current dex.trades_beta covers all existing dex.trades:
https://dune.com/queries/3446010
and sushiswap_base.trades
discrepancy is tested in #5376
@Hosuke where do we stand on the status? what steps are left to finalize the migration? some thoughts:
- coverage of dexes included
- test query showing data matches (or v close, as some calculations can differ slightly / had some bug fixes in new lineage)
- steps to migrate
_beta
to final table- communication plan (i can help here)
The current dex.trades_beta covers all existing dex.trades: https://dune.com/queries/3446010 and
sushiswap_base.trades
discrepancy is tested in #5376
fantastic!
want to open a PR which renames the _beta
lineage to normal naming standards (i.e. remove beta
)? should just be that final spell?
then we can also delete the entire legacy dex.trades
lineage within the same PR
i will work on how to finalize communication on this
@Hosuke where do we stand on the status? what steps are left to finalize the migration? some thoughts:
- coverage of dexes included
- test query showing data matches (or v close, as some calculations can differ slightly / had some bug fixes in new lineage)
- steps to migrate
_beta
to final table- communication plan (i can help here)
The current dex.trades_beta covers all existing dex.trades: https://dune.com/queries/3446010 and
sushiswap_base.trades
discrepancy is tested in #5376fantastic!
want to open a PR which renames the
_beta
lineage to normal naming standards (i.e. removebeta
)? should just be that final spell? then we can also delete the entire legacydex.trades
lineage within the same PR
We may keep the original dex.trades maybe as dex.trades_legacy
, and we can try to test/compare the some more detailed trades:
https://dune.com/queries/3467096
Here is a simple test we may use for testing data consistency.
We may keep the original dex.trades maybe as
dex.trades_legacy
, and we can try to test/compare the some more detailed trades: https://dune.com/queries/3454010Here is a simple test we may use for testing data consistency.
okay, we can keep it live under _legacy
for a bit, but after a little time, we'll remove completely
the linked query here will need to evolve a bit as analysis continues, to account for some intentional changes we made of switching bought/sold during migration (as tom found bugs, for example). so we could add case statements for certain projets/versions/blockchains to ignore in results, if we know we flipped intentionally.
We may keep the original dex.trades maybe as
dex.trades_legacy
, and we can try to test/compare the some more detailed trades: https://dune.com/queries/3454010 Here is a simple test we may use for testing data consistency.okay, we can keep it live under
_legacy
for a bit, but after a little time, we'll remove completelythe linked query here will need to evolve a bit as analysis continues, to account for some intentional changes we made of switching bought/sold during migration (as tom found bugs, for example). so we could add case statements for certain projets/versions/blockchains to ignore in results, if we know we flipped intentionally.
Since we have fixed flipped tokens in both dex.trades and dex.trades_beta, the diff is caused by token_bought_address = token_sold_address
in dex.trades:
https://dune.com/queries/3467096
- steps to migrate
_beta
to final table
- steps to migrate
_beta
to final table
- Rename the dex.trades and dex.trades_beta Rename dex.trades #5501
- Remove legacy code gradually
i wonder if we quickly add one final test / validation, we fork this dashboard: https://dune.com/hagaetc/dex-metrics
and update a few queries to read from dex.trades_beta
and see how the dashboard looks relative to original, since post-merge on attached PR will flip the main dashboard to this new dex spell.
we don't need to do all the queries and visuals, but maybe 2-3, such as: 1 - DEX 24 hours volume 2 - DEX 7 days value 3 - Ranked DEX by volume
if you think you can do this in ~an hour or two, let's see how that looks 🙏
edit: i think we may end up with quite different numbers, as we have more projects and fixed some bugs, but could be nice to see anyway. or at least on the 3rd item above, where it's project specific, so easier to compare i know the query covers most of this already, so this isn't a must, just a nice quick visual
Updated at Apr 23, 2024: Since all dexes have been migrated to the new dex.trades lineage. We continue to remove/modify the legacy code project by project.
Hello Team,
I'm opening this issue to keep track of all the Pull Requests (PRs) that implement the new macro approach in dex.trades, as introduced in PR #4533.
Purpose
_beta
dex lineage.Call for Contributions
Looking forward to seeing the innovative ways this new approach is being utilized and enhanced!
Migration tracking table
Updated records in dex.trades_beta compared to dex.trades
Related PR
Enhancement PR