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

Add poly, arb, and bnb xchange dex trades models and include xchange trades in dex.trades #3576

Merged
merged 3 commits into from
Jun 20, 2023

Conversation

mike-x7f
Copy link
Contributor

@mike-x7f mike-x7f commented Jun 19, 2023

Brief comments on the purpose of your changes:

  • Create new source, schema, model for xchange trades on arbitrum, polygon, and bnb chains
  • Create main xchange_trades model which unions xchange trades from all chains
  • Add xchange_trades to dex_trades model

For Dune Engine V2

I've checked that:

General checks:

  • I tested the query on dune.com after compiling the model with dbt compile (compiled queries are written to the target directory)
  • I used "refs" to reference other models in this repo and "sources" to reference raw or decoded tables
  • if adding a new model, I added a test
  • the filename is unique and ends with .sql
  • each sql file is a select statement and has only one view, table or function defined
  • column names are lowercase_snake_cased
  • if adding a new model, I edited the dbt project YAML file with new directory path for both models and seeds (if applicable)
  • if wanting to expose a model in the UI (Dune data explorer), I added a post-hook in the JINJA config to add metadata (blockchains, sector/project, name and contributor Dune usernames)

Pricing checks:

  • coin_id represents the ID of the coin on coinpaprika.com
  • all the coins are active on coinpaprika.com (please remove inactive ones)

Join logic:

  • if joining to base table (i.e. ethereum transactions or traces), I looked to make it an inner join if possible

Incremental logic:

  • I used is_incremental & not is_incremental jinja block filters on both base tables and decoded tables
    • where block_time >= date_trunc("day", now() - interval '1 week')
  • if joining to base table (i.e. ethereum transactions or traces), I applied join condition where block_time >= date_trunc("day", now() - interval '1 week')
  • if joining to prices view, I applied join condition where minute >= date_trunc("day", now() - interval '1 week')

@dune-eng
Copy link

Workflow run id 5315198991 approved.

@dune-eng
Copy link

Workflow run id 5315198995 approved.

@dune-eng
Copy link

Workflow run id 5315409483 approved.

@dune-eng
Copy link

Workflow run id 5315409482 approved.

@dune-eng
Copy link

Workflow run id 5315608357 approved.

@dune-eng
Copy link

Workflow run id 5315608355 approved.

@mike-x7f mike-x7f marked this pull request as ready for review June 19, 2023 20:26
@mike-x7f
Copy link
Contributor Author

Ethereum trades added to dex_trades_seed and tests have passed.

Test results for other chains (poly, arb, bnb) look good other than missing tokens, which will be added in this PR:
https://dune.com/queries/2648722

Let me know if you have any questions or comments.

@Hosuke Hosuke self-assigned this Jun 20, 2023
@Hosuke Hosuke added the dbt: dex covers the DEX dbt subproject label Jun 20, 2023
Comment on lines +383 to +388
ethereum,xchange,1,2023-06-04,0xb9cf9af8c09ee4b01f7998e4d09b5732e3d59db577453d8f649c3368a5be4723,3,0x7102dc82ef61bfb0410b1b1bf8ea74575bf0a105,16740.414870869491102082,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,349.842891200744390656
ethereum,xchange,1,2023-06-04,0xdca9e79f3d41644b579994c0e62f73e8741605b85bb9a80fcc6d173180fd891c,26,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,264.386114548212846651,0x7103ebdbf1f89be2d53eff9b3cf996c9e775c105,16740.857191421503408067
ethereum,xchange,1,2023-06-12,0xf71d8fd364e2402eb11ba7bfbd9b59336e2b075571c1523d119f74a11a1986e3,170,0x117546d1467d80c6bde13910412c724383260cf9,345579.7727468311529198,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.1
ethereum,xchange,1,2023-06-12,0x7da422240ab88976df8c9694114daf8b8cfc335e1f851a8c175bca99e5e4cdcd,200,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.134508790612232095,0x117546d1467d80c6bde13910412c724383260cf9,477750.8030874053723140
ethereum,xchange,1,2023-06-12,0x4eba2bbed2a473a3a6b2fbfc1d784940b5157afc285c35aff1200e491ea1346a,115,0xdbc7945c5403c589ec39a9aa8c5af234c706f6a2,14049529527.028758241707276441,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mike-x7f,
seems currently this file only contains seed records for the ethereum chain.
Do you want to add xchange seeds for other chains as well?
Like for [bnb, arbitrum, polygon] chains.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could add some but that test requires both the bought and sold tokens to be in the tokens.erc20 table in order to get the bought and sold amounts. Xchange is a new DEX and doesn't have a lot of volume on those chains yet, and all of the trades so far involve at least one token that isn't in tokens.erc20 yet. I am adding tokens to tokens.erc20 in this PR so I can use check_dex_seed, but I think it will fail until those tokens are added. I ran a manual test on those chains that you can find in the link in my other comment. All of the fields are populated as expected except for those that require tokens.erc20 data (symbol, pair, bought/sold amount).

Copy link
Member

@jeff-dude jeff-dude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can approve with the current state. thanks again @mike-x7f

@jeff-dude jeff-dude merged commit 7c07cb5 into duneanalytics:main Jun 20, 2023
@mike-x7f
Copy link
Contributor Author

we can approve with the current state. thanks again @mike-x7f

Thank you Jeff!

olgafetisova pushed a commit to olgafetisova/spellbook that referenced this pull request Nov 14, 2023
…trades in dex.trades (duneanalytics#3576)

* add poly, bnb, arb chains and xchange trades main

* add check_dex_seed tests

* convert to lowercase and add  tokens for test

---------

Co-authored-by: Mike X7F <@m1k3x7f>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dbt: dex covers the DEX dbt subproject
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants