Skip to content

Commit

Permalink
[WIP] feat: add honeyswap folders (duneanalytics#4139)
Browse files Browse the repository at this point in the history
* feat: add honeyswap folders

* feat: honeyswap polygon trades and schema

* chore: consistent naming

* feat: honeyswap_v2_gnosis_trades.sql

* chore:add legacy dummy tables

* chore: update legacy schemas

* chore: more legacy schema changes

* rebase to main

* Dex trades beta dunesql (duneanalytics#4107)

* Add dex_trades_migration_beta to models

* Create dex_trades_migration_beta

* Drop trace_address from select

* temporarily remove some models

* Comment out hashflow

* Disable more models

* Fix glacier types

* Fix day

* Add back models that now exist

* Partition by block_month instead

* Add to model

* Actually add block_month

* Add fixed models

* Fix babyswap

* Add block_month to zipswap

* Fix maker type for zipswap

* Don't include zeroex for now

* Trigger CI

* exclude zeroex and kyberswap for now

* Disable zipswap

* Fix model

* Add back models

* exclude failing model (duneanalytics#4144)

* Dex Aggregator Migration - #2 - Yield yak (duneanalytics#4063)

* Dex Aggregator Migration - #2 - Yield yak

* fixes and clean up

* Dex Aggregator Feat: Lifi Optimism - Ready for review (duneanalytics#4082)

* Dex Aggregator Migration - #1 - Lifi

* push dex aggregator seed

* revert changes to legacy file

* test fix

* test

* test

* smol fix

* Dex Aggregator Feat: Lifi Optimism

* CLEAN

* adjust seed

* NFT transfers refactor (duneanalytics#4072)

* Use merge strategy and stop using unique_transfer_id

* Use different unique key

* Drop unique_transfer_id

* Drop anti_table and let trino do join instead during merge into

* Fix typo

* Fix formatting

* Revert "Drop unique_transfer_id"

This reverts commit 09e374d.

* Update unique_transfer_id to be smaller

Keep it for backward compatibility

* Use correct column

* Fix tests and drop duplicate line

* Add back unique_transfer_id

* Add incremental filter for erc1155_batch as well

* Feature/oracle addresses (duneanalytics#4053)

* Add Chainlink OCR to arbitrum, avalanche_c, bnb, ethereum, fantom, gnosis, optimism, and polygon
Generate OCR Operator Meta
Add incremental tables to Chainlink OCR and add a README
Alphabetize OCR Operator Meta
General OCR Cleanup
Polish Chainlink OCR Model

* Add incremental table tests

* add new networks to chainlink feeds, add all current feeds per network

* Trigger CI

* Trigger CI

* add dummy models for new networks

---------

Co-authored-by: ryanostrom <rpostrom@gmail.com>

* DuneSQL Migration: `balancer_trades` (duneanalytics#4097)

* Update balancer_arbitrum_schema.yml

* Update balancer_v2_arbitrum_transfers_bpt.sql

* Update balancer_v2_arbitrum_transfers_bpt_legacy.sql

* Create balancer_v2_avalanche_c_transfers_bpt.sql

* Create balancer_v2_avalanche_c_transfers_bpt_legacy.sql

* Update balancer_avalanche_c_schema.yml

* Update balancer_schema.yml

* Create balancer_transfers_bpt.sql

* Create balancer_transfers_bpt_legacy.sql

* Create balancer_base_schema.yml

* Create balancer_base_sources.yml

* Create balancer_v2_base_transfers_bpt.sql

* Create balancer_v2_base_transfers_bpt_legacy.sql

* Update balancer_ethereum_schema.yml

* Update balancer_v2_ethereum_transfers_bpt_legacy.sql

* Update balancer_v2_ethereum_transfers_bpt.sql

* Update balancer_gnosis_schema.yml

* Create balancer_v2_gnosis_transfers_bpt.sql

* Create balancer_v2_gnosis_transfers_bpt_legacy.sql

* Update balancer_v2_gnosis_transfers_bpt_legacy.sql

* Update balancer_optimism_schema.yml

* Update balancer_v2_optimism_transfers_bpt.sql

* Update balancer_v2_optimism_transfers_bpt_legacy.sql

* Update balancer_polygon_schema.yml

* Update balancer_v2_polygon_transfers_bpt.sql

* Update balancer_v2_polygon_transfers_bpt_legacy.sql

* Migrate `pools_fees` to DuneSQL

* Add migrated `pools_fees` model to Avalanche, Base, and create an aggregate spell.

* Migrate `balancer_v2_trades` to DuneSQL

* Update balancer_v2_arbitrum_trades.sql

* Update balancer_v2_arbitrum_trades.sql

* Update balancer_ethereum_trades.sql

* Update balancer_v2_optimism_trades.sql

* Update balancer_ethereum_trades.sql

* Update balancer_v2_ethereum_trades.sql

* Revert "Update balancer_v2_ethereum_trades.sql"

This reverts commit c03026c.

* Revert "Update balancer_ethereum_trades.sql"

This reverts commit d037954.

* Revert "Update balancer_v2_optimism_trades.sql"

This reverts commit aae6872.

* Revert "Update balancer_ethereum_trades.sql"

This reverts commit f41a607.

* Revert "Update balancer_v2_arbitrum_trades.sql"

This reverts commit d6ff85a.

* Revert "Update balancer_v2_arbitrum_trades.sql"

This reverts commit b1e3362.

* Revert "Migrate `balancer_v2_trades` to DuneSQL"

This reverts commit 83ca534.

* Update balancer_v2_ethereum_bpt_prices.sql

* Update balancer_v2_ethereum_bpt_prices.sql

* Update balancer_v2_ethereum_trades.sql

* Update balancer_v2_ethereum_trades.sql

* Update balancer_v2_ethereum_trades.sql

* Update balancer_v2_ethereum_trades.sql

* Update balancer_v2_ethereum_trades.sql

* Requested changes.

* Update balancer_v2_ethereum_trades.sql

* Update balancer_v2_ethereum_trades.sql

* Update balancer_ethereum_schema.yml

* Update balancer_v2_ethereum_trades_legacy.sql

* Update balancer_v2_ethereum_trades_legacy.sql

* Removing the _legacy part

As it returns this error: TrinoUserError(type=USER_ERROR, name=SYNTAX_ERROR, message="line 112:40: backquoted identifiers are not supported; use double quotes to quote identifiers", query_id=20230815_211318_32606_9uda9)

* Revert "Removing the _legacy part"

This reverts commit 40b2402.

* Update balancer_ethereum_schema.yml

* Add migrated bpt_prices to arb, gno, poly, opt

* Migrate `bpt_prices` on Avalanche and deploy on Base.

* Update balancer_base_schema.yml

* Update balancer_base_sources.yml

* Migrate balancer_v2_trades and deploy on avalanche_c and base.

* Add in casting to keep the same data types as old lang.

* Revert "Add in casting to keep the same data types as old lang."

This reverts commit 00ca48a.

* Migrate Balancer Trades v1 to DuneSQL

* Update balancer_v1_ethereum_trades.sql

* Update balancer_v1_ethereum_trades.sql

* Add DuneSQL tag to balancer_ethereum_trades aggregation spell.

* Migrate balancer trades agg spells to DuneSQL and deploy on base and avalanche_c.

* Update balancer_avalanche_c_schema.yml

* Update balancer_base_schema.yml

* Update balancer_base_schema.yml

* Update balancer_avalanche_c_trades.sql

* Update balancer_avalanche_c_trades_legacy.sql

* Add in `schema = 'balancer_base',`

* Remove `_legacy` in schemas for each chains agg trades spell.

* Update balancer_base_schema.yml

* Add in `pool_id` and swap_fee` to balancer trades agg spell and schemas.

* Update balancer_schema.yml

* Update balancer_arbitrum_schema.yml

* Update balancer_avalanche_c_schema.yml

* Update balancer_ethereum_schema.yml

* Update schemas

* Update balancer_base_schema.yml

* Cast NULL values to appropriate data types.

* Fix name.

* Update balancer_ethereum_schema.yml

* Hot fix

* Spark fixes

* Update balancer_v1_ethereum_trades.sql

* Update balancer_v1_ethereum_trades_legacy.sql

* Update balancer_v1_ethereum_trades.sql

* Update balancer_v2_ethereum_trades.sql

* Update balancer_v2_ethereum_trades_legacy.sql

* FIx type issues.

* Remove duplicate partition by.

* Update balancer_ethereum_schema.yml

* Revert "Update balancer_ethereum_schema.yml"

This reverts commit 1cd76cc.

* Check the combination of unique columns.

* Fix casting issue.

* Change casting.

* Update balancer_v1_ethereum_trades_legacy.sql

* Update balancer_v1_ethereum_trades_legacy.sql

* Update balancer_v1_ethereum_trades_legacy.sql

* Fix mistake.

* Requested changes.

* Update balancer_v1_ethereum_trades.sql

* Migrate NFT opensea models (duneanalytics#4083)

* non-seaport models

* dunesql tags

* don;t partition

* fix seeds and tests

* seed tags

* seed schema

* fix polygon subtring

* fix token_id in seeds

* fix token_id in seeds

* fix opensea polygon

* migrate seaport v4 models

* migrate seaport v4 models

* remove partitioning

* migrate v3

* migrate matching logic

* bugfix

* bugfix

* bugfix

* sources

* more sources

* fix zone type

* fix token_id type

* temp ignore OP

* temp ignore OP

* seed test rerun

* change start date ETH

* unnest with ordinality is 1-indexed

* start dates

* another idx fix

* try and fix om id logic

* deduplicate order match hash re-use

* fix

* re-enable optimism v3

* temp fix

* fixes

* fixes

* fix missing column

* Fix check_seeds macro (duneanalytics#4146)

* Fix check_seeds macro

* Use is distinct from

* Add Tigris Options Trade & Enrich Models - Ready for review  (duneanalytics#4099)

* blank push

* rewrite

* fix typo

* fix version

* test polygon options models

* fix typo

* add arbitrum options

* consolidate versions in blockchain perps

* smol fix

* add protocol version to positions leverage

* add protocol version on polygon

* missing limit cancelled

* add fees distributed events

* fix synthax

* create options & perpetual trades table on arbit

* fix fees

* add seeds

* fix version

* fix trade

* add polygon models

* final updates

* fix... so proud of myself for completing this

* typo fix

* blank on tokenserc20 and add tigris to perp table

* add columns

* add column to main models

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* New Tigris Perpetual Contracts - Easy - Ready for review (duneanalytics#4148)

* test

* test riun

* remove inner join

* add new sources

* Add Balancer and Hashflow to dex.trades_migration_beta (duneanalytics#4149)

* Add block month to balancer models

* Add balancer and hasflow to dex_migration_beta

* Add block_month to hashflow

* Fix schemas

* Add month to balancer_v1

* Drop trace_address

* Change maker type for hashflow

* Fix typoes (duneanalytics#4154)

* Add correct tokens (duneanalytics#4159)

* [labels] Add more arbitrum cex address (duneanalytics#4132)

* Add more arbitrum cex address

* SQL formatting

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* Add crvUSD price  (duneanalytics#4140)

* Update prices_ethereum_tokens.sql

* Update prices_ethereum_tokens.sql

* Add base safes (duneanalytics#3827)

* Add Safe celo spells, schema and sources

Spells implemented are:
safe_celo_safes.sql
safe_celo_singletons.sql
safe_celo_transactions.sql
safe_celo_celo_transafers.sql

Source implemented is safe_celo_sources.yml

Schema implemented is safe_celo_schema.yml

* Add Safes on Celo

* Implement celo_base_sources

* Rename transactions file

* Add schema property to all spells

schema property follows format project_version_blockchain, e.g. safe_celo

* Remove Celo dependency for safe_safes_all schema

* Declare sql files for spells

* Implement singletons sql file

* Implement base safes

* Implement transfers file

* Implement transactions file

* Implement schema file

* Implement sources file

* Add base sources

* Update starting date of project

* Fix typo

* Migrate safe_base_eth_transfers

* Add dummy legacy models for safe_base_* spells

* Migrate safe_base spells

* Add schema

* Fix source typo

* Fix source

* Fix from

* Add safe_base_safes to meta-table

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* Migrate Seaport forks to DuneSQL (duneanalytics#4155)

* seaport forks

* add sources

* fix schema

* fix

* fix seed tests

* fix seeds

* trigger seed

* adapt macro for forks

* [READY TO REVIEW] Add kyberswap aggregator (duneanalytics#4070)

* Add kyberswap aggregator on arbitrum

* Fix varbinary vs varchar(42)

* Fix trace_address

* * Remove comma in dex_aggregator_trades

* Fix lower case

* Fix table 'hive.oneinch_ethereum.trades' does not exist

* Fix tags in oneinch ethereum

* Revert "Fix table 'hive.oneinch_ethereum.trades' does not exist"

This reverts commit d39292e.

* Revert "Fix tags in oneinch ethereum"

This reverts commit 303feab.

* Temporary omit dex_aggregator_trades

* Fix schema 'kyberswap_arbitrum' does not exist

* Try check_dex_seed_legacy

* Indent

* Add check_dex_aggregator_seed

* Fix test check_dex_aggregator_seed_kyberswap_aggregator_arbitrum_trades_arbitrum__kyberswap__2

* Add optimism, avalanche_c, ethereum

* Add bnb

* Add polygon

* Fix conflict

* Fix redundant commas

* No touch trade

* Migrate dex_aggregator.trades

* Fix dex_aggregator.trades

* Recover dex_aggregator.trades

* Add other versions of kyberswap aggregator, total 5 versions

* Revert "Add other versions of kyberswap aggregator, total 5 versions"

This reverts commit d60d564.

* Naming standards

* Update version

* Fix legacy

* Bad file name

* Fix feedback

* Fix feedback

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* Labels dao migration (duneanalytics#4157)

* Migrate labels_dao_multisig_ethereum

* Migrate labels_dao_framework

* Migrate labels_dao

* Fix labels_dao_framework

* [ETH staking] Add More ETH staking entities (duneanalytics#4141)

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* Update token_checker.py (duneanalytics#4150)

I'm not sure why this was commented out (maybe wasn't supported at the time the script was drafted?) but arbitrum is supported now. 

https://api.coinpaprika.com/v1/coins/wbtc-wrapped-bitcoin

* Add clipper.exchange Arbitrum v2 (duneanalytics#4125)

* Add clipper.exchange Arbitrum v2

* Add clipper.exchange dex.trades seed data

* Fix schema

* Fix schema

* Remove trace_address

* Add tags=['dunesql']

* Fix schema

* Fix schema

* Create OP Worldcoin Safes (duneanalytics#3762)

* add worldcoin

* add to project

* rm incremental in deployer identification

* sources

* unique

* add

* error

* commi

* label

* lbl

* update logic

* fix

* relayer slot

* dummy legacy

* test alias

* alias test

* finalize code

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>
Co-authored-by: jeff-dude <jeff@dune.xyz>
Co-authored-by: jeff <102681548+jeff-dude@users.noreply.github.com>

* [dunesql] OP NFT: Add Sound and Generated NFT insert (duneanalytics#3613)

* add sound & init nft generated

* commit

* undo

* typo

* add zora

* gen

* add col

* dunesql and add zora 1155

* alias

* test

* test

* dune

* adds

* dbt project

* unique key

* fixes

* source

* schema

* cast

* cast

* comma

* syntax

* pct

* group

* dece

* alias

* dummy legacy

* legacy z

* rm config

* rm

* test legacy

* mod

* add unique tests

---------

Co-authored-by: jeff-dude <jeff@dune.xyz>
Co-authored-by: jeff <102681548+jeff-dude@users.noreply.github.com>

* (feat) Add PNDC for eth price tracking (duneanalytics#4152)

* (feat) Add PNDC for eth price tracking

* trigger CLA recheck

---------

Co-authored-by: jeff <102681548+jeff-dude@users.noreply.github.com>

* Add more chains to `evms.info` (& legacy file) (duneanalytics#4126)

* add chains and legacy file

* fix

* adds celo to transfers (duneanalytics#4060)

* adds celo to transfers

* added missing dunesql tag

* amended transfers_celo_erc20, added test

* tweaked varchar size

* replaced legacy transfers with placeholder

* added block_month, left amount_raw as double

* too many commas..

* Remove file format

* Revert "Remove file format"

This reverts commit d511239.

* updated unique_key

* amended schema

* column name tweak

* more tweaks to test file

* added amount_raw to unique_key

* test with limited data sample

* back to full dataset (except for WCELO)

* join tweak and 1mln limit test

* limit 100k test..

* and 1k limit test..

* cast block_month as date

* tidying up

* applying suggested changes

* updated schema

* updated test total

* Add uniqueness test

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* arbitrum date: legacy (duneanalytics#3916)

Co-authored-by: jeff <102681548+jeff-dude@users.noreply.github.com>

* OP Predeploy Updates (duneanalytics#3889)

* allo

* static updates

* push

* push

* adds

* add

* legacy equivalence

* debank

* Refresh addresses_optimism_grants_funding

* Refresh deps

* Refresh deps

* wld

* handle for eas predeploys

* comma

* fix addrs

* chainx

* push

* Revert "push"

This reverts commit 89fdf35.

* Revert "chainx"

This reverts commit 7c2dbf0.

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* timeswap: adds Stafi(rETH)/WETH Arbitrum pool (duneanalytics#3844)

* update: adds new pool

* fix : runtime err

* update : consistent symbols

* update: new arbitrum pools added

* fix

* fixx

* Migrate timeswap_*_pools.sql

* Revert "Migrate timeswap_*_pools.sql"

This reverts commit fb8141e.

* Revert "update: new arbitrum pools added"

This reverts commit 07be96e.

* adds new pool -- legacy

* update: Stafi(rETH)/WETH arbitrum pool added

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* [READY TO REVIEW][MINOR] Fix price native token of avax and polygon (duneanalytics#4162)

* Fix price native token of avax and polygon

* Fix price native token of avax and polygon

* Try ETH to check pipeline

* Revert "Try ETH to check pipeline"

This reverts commit 064ce50.

* Refresh seed

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>

* Migrate dodo (duneanalytics#4043)

* Migrate dodo to dunesql

* migrate address to dunesql

* fix

* remove semicolon

* fix

* fix

* update test seed

* update test

* revert test

* fix

* fix

* fix unique_key

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* Add proxy column

* Select proxy

* Remove trace_address in the unique_key

* Fix uniqueness test

* fix

* add trace_address back to unique keys

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>
Co-authored-by: jeff-dude <jeff@dune.xyz>

* Migrate Optimism Bridge Flows - Ready for review  (duneanalytics#4130)

* draft: Migrate Optimism Bridge Flows

* migrate ovm & chain ids

* SMOL FIX

* fix cast

* smol fix

* another smol fix

* switch bridge token address to bytearray sub

* make changes

* FIX TYPE TO integer

* change to uint256

* Optimism Wallet Summary - WIP (duneanalytics#4127)

* wallet summary wip

* create addresses summary model

* add age, frequency and gas spent

* add unique dapps

* fix usage frequency

* Test fix

* fix join

* fix seed

* rewrite first activity

* smol test

* smol test

* make naming changes and schema fixes

* add first function and other columns

* smol fix

* add recency age label & functions name

* rename to signatures to test

* fix group by

* test fix

* fix dupes

* make first changes

* remove error

* Another synthax fix

* make changes

* models without tag for untranslated list (duneanalytics#4166)

---------

Co-authored-by: Alan Ghobadi <aalan3@gmail.com>
Co-authored-by: jeff <102681548+jeff-dude@users.noreply.github.com>
Co-authored-by: henrystats <65398020+henrystats@users.noreply.github.com>
Co-authored-by: AnonJon <43953219+AnonJon@users.noreply.github.com>
Co-authored-by: ryanostrom <rpostrom@gmail.com>
Co-authored-by: thetroyharris <127905654+thetroyharris@users.noreply.github.com>
Co-authored-by: 0xRob <83790096+0xRobin@users.noreply.github.com>
Co-authored-by: Huang Geyang <Sukebeta@outlook.com>
Co-authored-by: sankinyue <126844369+sankinyue@users.noreply.github.com>
Co-authored-by: chef-seaweed <121569855+chef-seaweed@users.noreply.github.com>
Co-authored-by: Daniel <32246390+danielpartida@users.noreply.github.com>
Co-authored-by: nhd98z <34548156+nhd98z@users.noreply.github.com>
Co-authored-by: Meghan Heintz <meghan@dune.com>
Co-authored-by: Alexey Malashkevich <m.alexey@gmail.com>
Co-authored-by: Michael Silberling <4006780+MSilb7@users.noreply.github.com>
Co-authored-by: jeff-dude <jeff@dune.xyz>
Co-authored-by: skiinginjeans <97915403+skiinginjeans@users.noreply.github.com>
Co-authored-by: hildobby <h.moulie@gmail.com>
Co-authored-by: tomfutago <35136350+tomfutago@users.noreply.github.com>
Co-authored-by: denver <denverbaumgartner@gmail.com>
Co-authored-by: yashvik <39464729+waverune@users.noreply.github.com>
Co-authored-by: owen05 <owen05@users.noreply.github.com>
Co-authored-by: Alex Courouble <56831527+couralex6@users.noreply.github.com>

* fix: move change onto dex trades migration beta

* feat: fix honeyswap dbt run

* feat: honeyswap adding seeds

* Fix check_dex_seed

* chore: rename honeyswap_v2 occurences to honeyswap

* fix: undo some tbl name changes

* fix: undo some tbl name changes

* fix: undo further name changes

* fix: undo further name changes

* final naming standards

---------

Co-authored-by: Alan Ghobadi <aalan3@gmail.com>
Co-authored-by: jeff <102681548+jeff-dude@users.noreply.github.com>
Co-authored-by: henrystats <65398020+henrystats@users.noreply.github.com>
Co-authored-by: AnonJon <43953219+AnonJon@users.noreply.github.com>
Co-authored-by: ryanostrom <rpostrom@gmail.com>
Co-authored-by: thetroyharris <127905654+thetroyharris@users.noreply.github.com>
Co-authored-by: 0xRob <83790096+0xRobin@users.noreply.github.com>
Co-authored-by: Huang Geyang <Sukebeta@outlook.com>
Co-authored-by: sankinyue <126844369+sankinyue@users.noreply.github.com>
Co-authored-by: chef-seaweed <121569855+chef-seaweed@users.noreply.github.com>
Co-authored-by: Daniel <32246390+danielpartida@users.noreply.github.com>
Co-authored-by: nhd98z <34548156+nhd98z@users.noreply.github.com>
Co-authored-by: Meghan Heintz <meghan@dune.com>
Co-authored-by: Alexey Malashkevich <m.alexey@gmail.com>
Co-authored-by: Michael Silberling <4006780+MSilb7@users.noreply.github.com>
Co-authored-by: jeff-dude <jeff@dune.xyz>
Co-authored-by: skiinginjeans <97915403+skiinginjeans@users.noreply.github.com>
Co-authored-by: hildobby <h.moulie@gmail.com>
Co-authored-by: tomfutago <35136350+tomfutago@users.noreply.github.com>
Co-authored-by: denver <denverbaumgartner@gmail.com>
Co-authored-by: yashvik <39464729+waverune@users.noreply.github.com>
Co-authored-by: owen05 <owen05@users.noreply.github.com>
Co-authored-by: Alex Courouble <56831527+couralex6@users.noreply.github.com>
  • Loading branch information
1 parent 7f1d6d4 commit 70a5916
Show file tree
Hide file tree
Showing 9 changed files with 395 additions and 2 deletions.
3 changes: 2 additions & 1 deletion models/dex/dex_trades_migration_beta.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
post_hook='{{ expose_spells(\'["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum", "fantom", "polygon"]\',
"sector",
"dex",
\'["jeff-dude", "hosuke", "0xRob", "pandajackson42", "Henrystats", "scoffie", "zhongyiio", "justabi", "umer_h_adil", "mtitus6", "dbustos20", "tian7", "bh2smith", "rantum", "mike-x7f"]\') }}'
\'["jeff-dude", "hosuke", "0xRob", "pandajackson42", "Henrystats", "scoffie", "zhongyiio", "justabi", "umer_h_adil", "mtitus6", "dbustos20", "tian7", "bh2smith", "rantum", "mike-x7f", "0xr3x"]\') }}'
)
}}

Expand Down Expand Up @@ -68,6 +68,7 @@
,ref('zipswap_trades')
,ref('balancer_trades')
,ref('hashflow_trades')
,ref('honeyswap_trades')
,ref('synthetix_spot_trades')
,ref('dodo_trades')
] %}
Expand Down
73 changes: 73 additions & 0 deletions models/honeyswap/gnosis/honeyswap_gnosis_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
version: 2

models:
- name: honeyswap_v2_gnosis_trades
meta:
blockchain: gnosis
sector: dex
project: honeyswap
contributors: 0xr3x, jeff-dude, masquot, soispoke
config:
tags: ['gnosis','honeyswap','trades', 'dex']
description: >
Honeyswap V2 contract trades on Gnosis
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- block_date
- blockchain
- project
- version
- tx_hash
- evt_index
- check_dex_seed:
blockchain: gnosis
project: honeyswap
version: 2
columns:
- &blockchain
name: blockchain
- &project
name: project
- &version
name: version
- &block_month
name: block_month
- &block_date
name: block_date
- &block_time
name: block_time
- &token_bought_symbol
name: token_bought_symbol
- &token_sold_symbol
name: token_sold_symbol
- &token_pair
name: token_pair
- &token_bought_amount
name: token_bought_amount
- &token_sold_amount
name: token_sold_amount
- &token_bought_amount_raw
name: token_bought_amount_raw
- &token_sold_amount_raw
name: token_sold_amount_raw
- &amount_usd
name: amount_usd
- &token_bought_address
name: token_bought_address
- &token_sold_address
name: token_sold_address
- &taker
name: taker
- &maker
name: maker
- &project_contract_address
name: project_contract_address
- &tx_hash
name: tx_hash
- &tx_from
name: tx_from
- &tx_to
name: tx_to
- &evt_index
name: evt_index
52 changes: 52 additions & 0 deletions models/honeyswap/gnosis/honeyswap_gnosis_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
version: 2

sources:
- name: honeyswap_v2_gnosis
description: "Gnosis decoded tables related to Honeyswap contracts"
freshness:
warn_after: { count: 12, period: hour }
tables:
- name: UniswapV2Pair_evt_Swap
loaded_at_field: evt_block_time
description: "" # to-do
columns:
- &amount0In
name: amount0In
- &amount0Out
name: amount0Out
- &amount1In
name: amount1In
- &amount1Out
name: amount1Out
- &contract_address
name: contract_address
- &evt_block_number
name: evt_block_number
- &evt_block_time
name: evt_block_time
- &evt_index
name: evt_index
- &evt_tx_hash
name: evt_tx_hash
- &sender
name: sender
- &to
name: to

- name: UniswapV2Factory_evt_PairCreated
loaded_at_field: evt_block_time
description: "" # to-do
columns:
- &_0
name: _0
- *contract_address
- *evt_block_number
- *evt_block_time
- *evt_index
- *evt_tx_hash
- &pair
name: pair
- &token0
name: token0
- &token1
name: token1
108 changes: 108 additions & 0 deletions models/honeyswap/gnosis/honeyswap_v2_gnosis_trades.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{{ config(tags=['dunesql'],
schema = 'honeyswap_v2_gnosis',
alias = alias('trades'),
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index'],
post_hook='{{ expose_spells(\'["gnosis"]\',
"project",
"honeyswap",
\'["0xr3x", "jeff-dude", "markusbkoch", "masquot", "milkyklim", "0xBoxer", "mewwts", "hagaetc"]\') }}'
)
}}

{% set project_start_date = '2020-05-05' %}

WITH dexs AS
(
-- Honeyswap v2
SELECT
t.evt_block_time AS block_time
,t.to AS taker
,CAST(NULL as VARBINARY) as maker
,CASE WHEN amount0Out = UINT256 '0' THEN amount1Out ELSE amount0Out END AS token_bought_amount_raw
,CASE WHEN amount0In = UINT256 '0' OR amount1Out = UINT256 '0' THEN amount1In ELSE amount0In END AS token_sold_amount_raw
,NULL AS amount_usd
,CASE WHEN amount0Out = UINT256 '0' THEN f.token1 ELSE f.token0 END AS token_bought_address
,CASE WHEN amount0In = UINT256 '0' OR amount1Out = UINT256 '0' THEN f.token1 ELSE f.token0 END AS token_sold_address
,t.contract_address as project_contract_address
,t.evt_tx_hash AS tx_hash

,t.evt_index
FROM
{{ source('honeyswap_v2_gnosis', 'UniswapV2Pair_evt_Swap') }} t
INNER JOIN {{ source('honeyswap_v2_gnosis', 'UniswapV2Factory_evt_PairCreated') }} f
ON f.pair = t.contract_address
{% if is_incremental() %}
WHERE t.evt_block_time >= date_trunc('day', now() - interval '7' day)
{% endif %}
)
SELECT
'gnosis' AS blockchain
,'honeyswap' AS project
,'2' AS version
,CAST(date_trunc('month', dexs.block_time) AS date) AS block_month
,CAST(date_trunc('DAY', dexs.block_time) AS date) AS block_date
,dexs.block_time
,erc20a.symbol AS token_bought_symbol
,erc20b.symbol AS token_sold_symbol
,case
when lower(erc20a.symbol) > lower(erc20b.symbol) then concat(erc20b.symbol, '-', erc20a.symbol)
else concat(erc20a.symbol, '-', erc20b.symbol)
end as token_pair
,dexs.token_bought_amount_raw / power(10, erc20a.decimals) AS token_bought_amount
,dexs.token_sold_amount_raw / power(10, erc20b.decimals) AS token_sold_amount
,dexs.token_bought_amount_raw AS token_bought_amount_raw
,dexs.token_sold_amount_raw AS token_sold_amount_raw
,coalesce(
dexs.amount_usd
,(dexs.token_bought_amount_raw / power(10, p_bought.decimals)) * p_bought.price
,(dexs.token_sold_amount_raw / power(10, p_sold.decimals)) * p_sold.price
) AS amount_usd
,dexs.token_bought_address
,dexs.token_sold_address
,coalesce(dexs.taker, tx."from") AS taker -- subqueries rely on this COALESCE to avoid redundant joins with the transactions table
,dexs.maker
,dexs.project_contract_address
,dexs.tx_hash
,tx."from" AS tx_from
,tx.to AS tx_to

,dexs.evt_index
FROM dexs
INNER JOIN {{ source('gnosis', 'transactions') }} tx
ON tx.hash = dexs.tx_hash
{% if not is_incremental() %}
AND tx.block_time >= TIMESTAMP '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
AND tx.block_time >= date_trunc('day', now() - interval '7' day)
{% endif %}
LEFT JOIN {{ ref('tokens_erc20') }} erc20a
ON erc20a.contract_address = dexs.token_bought_address
AND erc20a.blockchain = 'gnosis'
LEFT JOIN {{ ref('tokens_erc20') }} erc20b
ON erc20b.contract_address = dexs.token_sold_address
AND erc20b.blockchain = 'gnosis'
LEFT JOIN {{ source('prices', 'usd') }} p_bought
ON p_bought.minute = date_trunc('minute', dexs.block_time)
AND p_bought.contract_address = dexs.token_bought_address
AND p_bought.blockchain = 'gnosis'
{% if not is_incremental() %}
AND p_bought.minute >= TIMESTAMP '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
AND p_bought.minute >= date_trunc('day', now() - interval '7' day)
{% endif %}
LEFT JOIN {{ source('prices', 'usd') }} p_sold
ON p_sold.minute = date_trunc('minute', dexs.block_time)
AND p_sold.contract_address = dexs.token_sold_address
AND p_sold.blockchain = 'gnosis'
{% if not is_incremental() %}
AND p_sold.minute >= TIMESTAMP '{{project_start_date}}'
{% endif %}
{% if is_incremental() %}
AND p_sold.minute >= date_trunc('day', now() - interval '7' day)
{% endif %}
11 changes: 11 additions & 0 deletions models/honeyswap/gnosis/honeyswap_v2_gnosis_trades_legacy.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ config(
schema = 'honeyswap_v2_gnosis',
alias = alias('trades', legacy_model=True),
tags = ['legacy']
)
}}


-- DUMMY TABLE, WILL BE REMOVED SOON
select
666
83 changes: 83 additions & 0 deletions models/honeyswap/honeyswap_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
version: 2

models:
- name: honeyswap_trades
meta:
blockchain: gnosis, polygon
sector: dex
project: honeyswap
contributors: 0xr3x
config:
tags: ['gnosis', 'polygon', 'honeyswap','trades', 'dex', '0xr3x','cross-chain']
description: >
Honeyswap trades on all chains across all contracts and versions. This table will load dex trades downstream.
columns:
- &blockchain
name: blockchain
description: "Blockchain which the DEX is deployed"
- &project
name: project
description: "Project name of the DEX"
- &version
name: version
description: "Version of the contract built and deployed by the DEX project"
- &block_month
name: block_month
description: "UTC event block month of each DEX trade"
- &block_date
name: block_date
description: "UTC event block date of each DEX trade"
- &block_time
name: block_time
description: "UTC event block time of each DEX trade"
- &token_bought_symbol
name: token_bought_symbol
description: "Token symbol for token bought in the transaction"
- &token_sold_symbol
name: token_sold_symbol
description: "Token symbol for token sold in the transaction"
- &token_pair
name: token_pair
description: "Token symbol pair for each token involved in the transaction"
- &token_bought_amount
name: token_bought_amount
description: "Value of the token bought at time of execution in the original currency"
- &token_sold_amount
name: token_sold_amount
description: "Value of the token sold at time of execution in the original currency"
- &token_bought_amount_raw
name: token_bought_amount_raw
description: "Raw value of the token bought at time of execution in the original currency"
- &token_sold_amount_raw
name: token_sold_amount_raw
description: "Raw value of the token sold at time of execution in the original currency"
- &amount_usd
name: amount_usd
description: "USD value of the trade at time of execution"
- &token_bought_address
name: token_bought_address
description: "Contract address of the token bought"
- &token_sold_address
name: token_sold_address
description: "Contract address of the token sold"
- &taker
name: taker
description: "Address of trader who purchased a token"
- &maker
name: maker
description: "Address of trader who sold a token"
- &project_contract_address
name: project_contract_address
description: "Project contract address which executed the trade on the blockchain"
- &tx_hash
name: tx_hash
description: "Unique transaction hash value tied to each transaction on the DEX"
- &tx_from
name: tx_from
description: "Address which initiated the transaction"
- &tx_to
name: tx_to
description: "Address which received the transaction"
- &evt_index
name: evt_index
description: "the position of this event log within this transaction"
48 changes: 48 additions & 0 deletions models/honeyswap/honeyswap_trades.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{ config(tags=['dunesql'],
schema = 'honeyswap',
alias = alias('trades'),
post_hook='{{ expose_spells(\'["gnosis", "polygon"]\',
"project",
"honeyswap",
\'["0xr3x"]\') }}'
)
}}

{% set honeyswap_models = [
ref('honeyswap_v2_gnosis_trades')
] %}
-- , ref('honeyswap_polygon_trades')

SELECT *
FROM (
{% for dex_model in honeyswap_models %}
SELECT
blockchain,
project,
version,
block_month,
block_date,
block_time,
token_bought_symbol,
token_sold_symbol,
token_pair,
token_bought_amount,
token_sold_amount,
token_bought_amount_raw,
token_sold_amount_raw,
amount_usd,
token_bought_address,
token_sold_address,
taker,
maker,
project_contract_address,
tx_hash,
tx_from,
tx_to,
evt_index
FROM {{ dex_model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)

0 comments on commit 70a5916

Please sign in to comment.