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 support for additional chains in dex.automated_trades (part 1) #7049

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
version: 2

models:
- name: dex_avalanche_c_automated_base_trades
description: "all dex trades on avalanche_c, mass decoded"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index

- name: uniswap_v2_avalanche_c_decoded_factory_evt
description: >
mass decoding of all forks of uniswap v2 factory contract on avalanche_c
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- index

- name: uniswap_v2_avalanche_c_decoded_pool_evt_swap
description: >
mass decoding of all forks of uniswap v2 pool contracts on avalanche_c
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- index

- name: uniswap_v2_avalanche_c_automated_base_trades
meta:
blockchain: avalanche_c
sector: dex
project: uniswap
contributors: 0xboxer
config:
tags: [ 'avalanche_c', 'dex', 'trades', 'uniswap', 'v2', 'forks' ]
description: "base trades for all forks of uniswap v2 on avalanche_c"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index

- name: uniswap_v3_avalanche_c_decoded_factory_evt
description: >
mass decoding of all forks of uniswap v3 factory contract on avalanche_c
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- index

- name: uniswap_v3_avalanche_c_decoded_pool_evt_swap
description: >
mass decoding of all forks of uniswap v3 pool contracts on avalanche_c
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- index

- name: uniswap_v3_avalanche_c_automated_base_trades
meta:
blockchain: avalanche_c
sector: dex
project: uniswap
contributors: 0xboxer
config:
tags: [ 'avalanche_c', 'dex', 'trades', 'uniswap', 'v3', 'forks' ]
description: "base trades for all forks of uniswap v3 on avalanche_c"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{ config(
schema = 'dex_avalanche_c'
, alias = 'automated_base_trades'
, materialized = 'view'
)
}}

{% set base_models = [
ref('uniswap_v2_avalanche_c_automated_base_trades')
, ref('uniswap_v3_avalanche_c_automated_base_trades')
] %}

WITH base_union AS (
SELECT *
FROM (
{% for base_model in base_models %}
SELECT
blockchain
, project
, version
, dex_type
, factory_address
, block_month
, block_date
, block_time
, block_number
, token_bought_amount_raw
, token_sold_amount_raw
, token_bought_address
, token_sold_address
, taker
, maker
, project_contract_address
, tx_hash
, evt_index
FROM
{{ base_model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
)

{{
add_tx_columns(
model_cte = 'base_union'
, blockchain = 'avalanche_c'
, columns = ['from', 'to', 'index']
)
}}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ config(
schema = 'uniswap_v2_avalanche_c',
alias = 'automated_base_trades',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'evt_index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{
uniswap_v2_forks_trades(
blockchain = 'avalanche_c'
, version = '2'
, project = 'null'
, Pair_evt_Swap = ref('uniswap_v2_avalanche_c_decoded_pool_evt_swap')
, Factory_evt_PairCreated = ref('uniswap_v2_avalanche_c_decoded_factory_evt')
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ config(
schema = 'uniswap_v2_avalanche_c',
alias = 'decoded_factory_evt',
partition_by = ['block_date'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{uniswap_v2_factory_event_decoding(
logs = source('avalanche_c', 'logs')
)}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ config(
schema = 'uniswap_v2_avalanche_c',
alias = 'decoded_pool_evt_swap',
partition_by = ['block_date'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{uniswap_v2_pool_event_decoding(
logs = source('avalanche_c', 'logs')
)}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ config(
schema = 'uniswap_v3_avalanche_c',
alias = 'automated_base_trades',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'evt_index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{
uniswap_v3_forks_trades(
blockchain = 'avalanche_c'
, version = '3'
, project = 'null'
, Pair_evt_Swap = ref('uniswap_v3_avalanche_c_decoded_pool_evt_swap')
, Factory_evt_PoolCreated = ref('uniswap_v3_avalanche_c_decoded_factory_evt')
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{ config(
schema = 'uniswap_v3_avalanche_c',
alias = 'decoded_factory_evt',
partition_by = ['block_date'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{uniswap_v3_factory_event_decoding(
logs = source('avalanche_c', 'logs')
)}}

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{ config(
schema = 'uniswap_v3_avalanche_c',
alias = 'decoded_pool_evt_swap',
partition_by = ['block_date'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{uniswap_v3_pool_event_decoding(
logs = source('avalanche_c', 'logs')
)}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
version: 2

models:
- name: dex_base_automated_base_trades
description: "all dex trades on base, mass decoded"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index

- name: uniswap_v2_base_decoded_factory_evt
description: >
mass decoding of all forks of uniswap v2 factory contract on base
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- index

- name: uniswap_v2_base_decoded_pool_evt_swap
description: >
mass decoding of all forks of uniswap v2 pool contracts on base
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- index

- name: uniswap_v2_base_automated_base_trades
meta:
blockchain: base
sector: dex
project: uniswap
contributors: 0xboxer
config:
tags: [ 'base', 'dex', 'trades', 'uniswap', 'v2', 'forks' ]
description: "base trades for all forks of uniswap v2 on base"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index

- name: uniswap_v3_base_decoded_factory_evt
description: >
mass decoding of all forks of uniswap v3 factory contract on base
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- index

- name: uniswap_v3_base_decoded_pool_evt_swap
description: >
mass decoding of all forks of uniswap v3 pool contracts on base
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- index

- name: uniswap_v3_base_automated_base_trades
meta:
blockchain: base
sector: dex
project: uniswap
contributors: 0xboxer
config:
tags: [ 'base', 'dex', 'trades', 'uniswap', 'v3', 'forks' ]
description: "base trades for all forks of uniswap v3 on base"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{ config(
schema = 'dex_base'
, alias = 'automated_base_trades'
, materialized = 'view'
)
}}

{% set base_models = [
ref('uniswap_v2_base_automated_base_trades')
, ref('uniswap_v3_base_automated_base_trades')
] %}

WITH base_union AS (
SELECT *
FROM (
{% for base_model in base_models %}
SELECT
blockchain
, project
, version
, dex_type
, factory_address
, block_month
, block_date
, block_time
, block_number
, token_bought_amount_raw
, token_sold_amount_raw
, token_bought_address
, token_sold_address
, taker
, maker
, project_contract_address
, tx_hash
, evt_index
FROM
{{ base_model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
)

{{
add_tx_columns(
model_cte = 'base_union'
, blockchain = 'base'
, columns = ['from', 'to', 'index']
)
}}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ config(
schema = 'uniswap_v2_base',
alias = 'automated_base_trades',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['tx_hash', 'evt_index'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
)
}}

{{
uniswap_v2_forks_trades(
blockchain = 'base'
, version = '2'
, project = 'null'
, Pair_evt_Swap = ref('uniswap_v2_base_decoded_pool_evt_swap')
, Factory_evt_PairCreated = ref('uniswap_v2_base_decoded_factory_evt')
)
}}
Loading
Loading