From 8aae45f0f7dc476e302efbdb7ad32e127f7f53a3 Mon Sep 17 00:00:00 2001 From: Ilia Kovalev Date: Sun, 23 Mar 2025 13:36:38 +0100 Subject: [PATCH 1/2] update queries to get deltav2 and partially filled --- .../models/_project/paraswap/all-entities.sql | 3 ++- .../paraswap/all-entities-aggregated.sql | 16 ++++++++++++++++ .../_projects/paraswap/all-entities-details.sql | 16 ++++++++++++++++ .../paraswap_delta_v1_ethereum_trades.sql | 10 +++++----- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql index 02f1fd3c4bc..8aaafa92291 100644 --- a/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql @@ -12,10 +12,11 @@ set delta_configs = [ ['ethereum', 'delta-v1-batch', 'paraswapdelta_ethereum.ParaswapDeltav1_call_safeSettleBatchSwap', 'contract_address', 'call_block_time', 'call_tx_hash', null, '0'], ['ethereum', 'delta-v2', 'paraswapdelta_ethereum.ParaswapDeltav2_evt_OrderSettled', 'contract_address', 'evt_block_time', 'evt_tx_hash', null, '0'], + ['ethereum', 'delta-v2', 'paraswapdelta_base.ParaswapDeltav2_evt_OrderPartiallyFilled', 'contract_address', 'evt_block_time', 'evt_tx_hash', 'evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53', '0'], ['base', 'delta-v2', 'paraswapdelta_base.ParaswapDeltav2_evt_OrderSettled', 'contract_address', 'evt_block_time', 'evt_tx_hash', 'evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53', '0'], + ['base', 'delta-v2', 'paraswapdelta_base.ParaswapDeltav2_evt_OrderPartiallyFilled', 'contract_address', 'evt_block_time', 'evt_tx_hash', 'evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53', '0'], ['ethereum', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='ethereum'", 'amount_usd'], - ['polygon', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='polygon'", 'amount_usd'], ['bnb', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='bnb'", 'amount_usd'], ['arbitrum', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='arbitrum'", 'amount_usd'], diff --git a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-aggregated.sql b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-aggregated.sql index 1f1ea5dfa18..af7b88d1026 100644 --- a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-aggregated.sql +++ b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-aggregated.sql @@ -25,6 +25,14 @@ with entities as ( union all + select 'delta-v2' as entity, 'ethereum' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_base.ParaswapDeltav2_evt_OrderPartiallyFilled + where + (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') + + AND evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53 + + union all + select 'delta-v2' as entity, 'base' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_base.ParaswapDeltav2_evt_OrderSettled where (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') @@ -33,6 +41,14 @@ with entities as ( union all + select 'delta-v2' as entity, 'base' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_base.ParaswapDeltav2_evt_OrderPartiallyFilled + where + (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') + + AND evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53 + + union all + select 'augustus' as entity, 'ethereum' as blockchain, project_contract_address as contract_address, block_time as block_time, tx_hash as tx_hash, amount_usd as usd_value from dex_aggregator.trades where (block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') diff --git a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-details.sql b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-details.sql index b701b9fa2f5..f2daac23795 100644 --- a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-details.sql +++ b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-details.sql @@ -27,6 +27,14 @@ with entities as ( union all + select 'delta-v2' as entity, 'ethereum' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_base.ParaswapDeltav2_evt_OrderPartiallyFilled + where + (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') + + AND evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53 + + union all + select 'delta-v2' as entity, 'base' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_base.ParaswapDeltav2_evt_OrderSettled where (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') @@ -35,6 +43,14 @@ with entities as ( union all + select 'delta-v2' as entity, 'base' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_base.ParaswapDeltav2_evt_OrderPartiallyFilled + where + (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') + + AND evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53 + + union all + select 'augustus' as entity, 'ethereum' as blockchain, project_contract_address as contract_address, block_time as block_time, tx_hash as tx_hash, amount_usd as usd_value from dex_aggregator.trades where (block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') diff --git a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql index 2cde3dfccc7..93a56f79174 100644 --- a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql +++ b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/ethereum/paraswap_delta_v1_ethereum_trades.sql @@ -297,24 +297,24 @@ from delta_v1_safe_settle_batch_swap_model -- d.trace_address, -- d.evt_index -- FROM dexs d --- INNER JOIN delta_prod.ethereum.transactions tx ON d.tx_hash = tx.hash +-- INNER JOIN "delta_prod"."ethereum"."transactions" tx ON d.tx_hash = tx.hash -- AND d.block_number = tx.block_number -- -- AND tx.block_time >= TIMESTAMP '2024-05-01' -- -- --- LEFT JOIN delta_prod.tokens.erc20 e1 ON e1.contract_address = d.token_bought_address +-- LEFT JOIN "delta_prod"."tokens"."erc20" e1 ON e1.contract_address = d.token_bought_address -- AND e1.blockchain = 'ethereum' --- LEFT JOIN delta_prod.tokens.erc20 e2 ON e2.contract_address = d.token_sold_address +-- LEFT JOIN "delta_prod"."tokens"."erc20" e2 ON e2.contract_address = d.token_sold_address -- AND e2.blockchain = 'ethereum' --- LEFT JOIN delta_prod.prices.usd p1 ON p1.minute = date_trunc('minute', d.block_time) +-- LEFT JOIN "delta_prod"."prices"."usd" p1 ON p1.minute = date_trunc('minute', d.block_time) -- AND p1.contract_address = d.token_bought_address -- AND p1.blockchain = 'ethereum' -- -- AND p1.minute >= TIMESTAMP '2024-05-01' -- -- --- LEFT JOIN delta_prod.prices.usd p2 ON p2.minute = date_trunc('minute', d.block_time) +-- LEFT JOIN "delta_prod"."prices"."usd" p2 ON p2.minute = date_trunc('minute', d.block_time) -- AND p2.contract_address = d.token_sold_address -- AND p2.blockchain = 'ethereum' -- From f604e74aea3d328902908a985ec6dfa6125741fd Mon Sep 17 00:00:00 2001 From: Ilia Kovalev Date: Mon, 19 May 2025 14:12:40 +0200 Subject: [PATCH 2/2] add optimism deltav2 --- .../models/_project/paraswap/all-entities.sql | 4 +++- .../paraswap/all-entities-aggregated.sql | 16 ++++++++++++++++ .../_projects/paraswap/all-entities-details.sql | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql b/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql index 8aaafa92291..a6a0b1627f7 100644 --- a/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql +++ b/dbt_subprojects/dex/macros/models/_project/paraswap/all-entities.sql @@ -15,6 +15,8 @@ set delta_configs = [ ['ethereum', 'delta-v2', 'paraswapdelta_base.ParaswapDeltav2_evt_OrderPartiallyFilled', 'contract_address', 'evt_block_time', 'evt_tx_hash', 'evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53', '0'], ['base', 'delta-v2', 'paraswapdelta_base.ParaswapDeltav2_evt_OrderSettled', 'contract_address', 'evt_block_time', 'evt_tx_hash', 'evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53', '0'], ['base', 'delta-v2', 'paraswapdelta_base.ParaswapDeltav2_evt_OrderPartiallyFilled', 'contract_address', 'evt_block_time', 'evt_tx_hash', 'evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53', '0'], + ['optimism', 'delta-v2', 'paraswapdelta_optimism.ParaswapDeltav2_evt_OrderSettled', 'contract_address', 'evt_block_time', 'evt_tx_hash', 'evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53', '0'], + ['optimism', 'delta-v2', 'paraswapdelta_optimism.ParaswapDeltav2_evt_OrderPartiallyFilled', 'contract_address', 'evt_block_time', 'evt_tx_hash', 'evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53', '0'], ['ethereum', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='ethereum'", 'amount_usd'], ['polygon', 'augustus', 'dex_aggregator.trades', 'project_contract_address', 'block_time', 'tx_hash', "project='paraswap' and blockchain='polygon'", 'amount_usd'], @@ -42,4 +44,4 @@ with entities as ( {% if not loop.last %} union all {% endif %} {% endfor %} ) -{% endmacro %} \ No newline at end of file +{% endmacro %} diff --git a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-aggregated.sql b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-aggregated.sql index af7b88d1026..f610f8f114e 100644 --- a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-aggregated.sql +++ b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-aggregated.sql @@ -49,6 +49,22 @@ with entities as ( union all + select 'delta-v2' as entity, 'optimism' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_optimism.ParaswapDeltav2_evt_OrderSettled + where + (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') + + AND evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53 + + union all + + select 'delta-v2' as entity, 'optimism' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_optimism.ParaswapDeltav2_evt_OrderPartiallyFilled + where + (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') + + AND evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53 + + union all + select 'augustus' as entity, 'ethereum' as blockchain, project_contract_address as contract_address, block_time as block_time, tx_hash as tx_hash, amount_usd as usd_value from dex_aggregator.trades where (block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') diff --git a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-details.sql b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-details.sql index f2daac23795..97954431da6 100644 --- a/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-details.sql +++ b/dbt_subprojects/dex/target/compiled/dex/models/_projects/paraswap/all-entities-details.sql @@ -51,6 +51,22 @@ with entities as ( union all + select 'delta-v2' as entity, 'optimism' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_optimism.ParaswapDeltav2_evt_OrderSettled + where + (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') + + AND evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53 + + union all + + select 'delta-v2' as entity, 'optimism' as blockchain, contract_address as contract_address, evt_block_time as block_time, evt_tx_hash as tx_hash, 0 as usd_value from paraswapdelta_optimism.ParaswapDeltav2_evt_OrderPartiallyFilled + where + (evt_block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}') + + AND evt_tx_from <> 0xace5ae3de4baffc4a45028659c5ee330764e4f53 + + union all + select 'augustus' as entity, 'ethereum' as blockchain, project_contract_address as contract_address, block_time as block_time, tx_hash as tx_hash, amount_usd as usd_value from dex_aggregator.trades where (block_time BETWEEN timestamp '{{date_from}}' AND timestamp '{{date_to}}')