diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql new file mode 100644 index 00000000000..5c8ef50fa3b --- /dev/null +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql @@ -0,0 +1,44 @@ +{% macro paraswap_all_entities() %} +{% +set date_to = "timestamp '{{date_to}}'" +%} +{% +set date_from = "timestamp '{{date_from}}'" +%} + +{% +set delta_configs = [ + ['ethereum', 'delta-v1-single', 'paraswapdelta_ethereum.ParaswapDeltav1_call_settleSwap', 'contract_address', 'call_block_time', 'call_tx_hash', null], + ['ethereum', 'delta-v1-batch', 'paraswapdelta_ethereum.ParaswapDeltav1_call_safeSettleBatchSwap', 'contract_address', 'call_block_time', 'call_tx_hash', null], + + ['ethereum', 'delta-v2', 'paraswapdelta_ethereum.ParaswapDeltav2_evt_OrderSettled', 'contract_address', 'evt_block_time', 'evt_tx_hash', null], + ['base', 'delta-v2', 'paraswapdelta_base.ParaswapDeltav2_evt_OrderSettled', 'contract_address', 'evt_block_time', 'evt_tx_hash', null], + + ['ethereum', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='ethereum'"], + + ['polygon', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='polygon'"], + ['bnb', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='bnb'"], + ['arbitrum', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='arbitrum'"], + ['avalanche_c', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='avalanche_c'"], + ['fantom', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='fantom'"], + ['optimism', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='optimism'"], + ['base', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='base'"], + + + + +] + +%} +with entities as ( + {% for blockchain, entity, table, contract_field_name, time_field_name, hash_field_name, conditional in delta_configs %} + select '{{ entity }}' as entity, '{{ blockchain }}' as blockchain, {{contract_field_name}} as contract_address, {{time_field_name}} as block_time, {{hash_field_name}} as tx_hash from {{ table }} + where + ({{time_field_name}} BETWEEN {{date_from}} AND {{date_to}}) + {% if conditional %} + AND {{ conditional }} + {% endif %} + {% if not loop.last %} union all {% endif %} + {% endfor %} +) +{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/paraswap/stats.sql b/dbt_subprojects/dex/models/_projects/paraswap/stats.sql index ae929cd4100..c32777ec838 100644 --- a/dbt_subprojects/dex/models/_projects/paraswap/stats.sql +++ b/dbt_subprojects/dex/models/_projects/paraswap/stats.sql @@ -1,48 +1,7 @@ -- NB: this is a generated query, do not edit it directly, instead edit the template and re-generate the query -- hydrate the generated ouput here: https://dune.com/queries/4403433 -{% -set date_to = "timestamp '{{date_to}}'" -%} -{% -set date_from = "timestamp '{{date_from}}'" -%} - -{% -set delta_configs = [ - ['ethereum', 'delta-v1-single', 'paraswapdelta_ethereum.ParaswapDeltav1_call_settleSwap', 'contract_address', 'call_block_time', 'call_tx_hash', null], - ['ethereum', 'delta-v1-batch', 'paraswapdelta_ethereum.ParaswapDeltav1_call_safeSettleBatchSwap', 'contract_address', 'call_block_time', 'call_tx_hash', null], - - ['ethereum', 'delta-v2', 'paraswapdelta_ethereum.ParaswapDeltav2_evt_OrderSettled', 'contract_address', 'evt_block_time', 'evt_tx_hash', null], - ['base', 'delta-v2', 'paraswapdelta_base.ParaswapDeltav2_evt_OrderSettled', 'contract_address', 'evt_block_time', 'evt_tx_hash', null], - - ['ethereum', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='ethereum'"], - - ['polygon', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='polygon'"], - ['bnb', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='bnb'"], - ['arbitrum', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='arbitrum'"], - ['avalanche_c', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='avalanche_c'"], - ['fantom', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='fantom'"], - ['optimism', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='optimism'"], - ['base', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='base'"], - - - - -] - -%} -with entities as ( - {% for blockchain, entity, table, contract_field_name, time_field_name, hash_field_name, conditional in delta_configs %} - select '{{ entity }}' as entity, '{{ blockchain }}' as blockchain, {{contract_field_name}} as contract_address, {{time_field_name}} as block_time, {{hash_field_name}} as tx_hash from {{ table }} - where - ({{time_field_name}} BETWEEN {{date_from}} AND {{date_to}}) - {% if conditional %} - AND {{ conditional }} - {% endif %} - {% if not loop.last %} union all {% endif %} - {% endfor %} -), -ordered_entities as ( +{{ paraswap_all_entities() }} +,ordered_entities as ( select entity, blockchain, contract_address, block_time, tx_hash from entities diff --git a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/stats.sql b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/stats.sql index f57fcd3e111..7a8ae59866a 100644 --- a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/stats.sql +++ b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/stats.sql @@ -3,6 +3,7 @@ + with entities as ( @@ -94,8 +95,9 @@ with entities as ( -), -ordered_entities as ( +) + +,ordered_entities as ( select entity, blockchain, contract_address, block_time, tx_hash from entities