From b6adb5e5b2e93afadfeb32cec2eef7b3a37f6263 Mon Sep 17 00:00:00 2001 From: soispoke <66172107+soispoke@users.noreply.github.com> Date: Thu, 1 Sep 2022 13:58:25 +0700 Subject: [PATCH] Tornado Cash: Fix sources, lowercase and improve materialization strategy (#1460) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix sources, lowercase and improve materialization strat * ALTER TABLE, not VIEW * Revert "ALTER TABLE, not VIEW" This reverts commit f707c2e6fea17c698d951edf41ee329092a74203. * changed avalanche to avalanche_c in blockchain name for consistency across dune * Lowercase for blockchains and versiosn on schema.yml * avalanche to avalanche_c in schema and macro files * transactions_006 to transactions * Update alter_table_properties.sql * fix transactions_006 * Replace LEFT BY INNER JOINS on base transactions tables Co-authored-by: Hildebert MouliƩ --- macros/alter_table_properties.sql | 6 +- models/ens/ens_ethereum_sources.yml | 3 - .../ethereum/sudoswap_ethereum_sources.yml | 3 - models/tornado_cash/tornado_cash_deposits.sql | 70 +++++++++---------- models/tornado_cash/tornado_cash_schema.yml | 8 +-- models/tornado_cash/tornado_cash_sources.yml | 30 -------- .../tornado_cash/tornado_cash_withdrawals.sql | 70 +++++++++---------- .../ethereum/uniswap_ethereum_sources.yml | 3 - .../optimism/uniswap_optimism_sources.yml | 1 - 9 files changed, 77 insertions(+), 117 deletions(-) diff --git a/macros/alter_table_properties.sql b/macros/alter_table_properties.sql index 0a3b0fda87e..e3ae1948588 100644 --- a/macros/alter_table_properties.sql +++ b/macros/alter_table_properties.sql @@ -579,7 +579,7 @@ ALTER TABLE airdrop_optimism.addresses SET TBLPROPERTIES ('dune.public'='true', {% set tornado_cash_deposits %} ALTER TABLE tornado_cash.deposits SET TBLPROPERTIES ('dune.public'='true', - 'dune.data_explorer.blockchains'='["ethereum", "bnb", "avalanche", "gnosis", "optimism", "arbitrum"]', + 'dune.data_explorer.blockchains'='["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum"]', 'dune.data_explorer.category'='abstraction', 'dune.data_explorer.abstraction.type'='project', 'dune.data_explorer.abstraction.name'='tornado_cash', @@ -587,8 +587,8 @@ ALTER TABLE tornado_cash.deposits SET TBLPROPERTIES ('dune.public'='true', {% endset %} {% set tornado_cash_withdrawals %} -ALTER TABLE tornado_cash.withdrawals SET TBLPROPERTIES ('dune.public'='true', - 'dune.data_explorer.blockchains'='["ethereum", "bnb", "avalanche", "gnosis", "optimism", "arbitrum"]', +ALTER VIEW tornado_cash.withdrawals SET TBLPROPERTIES ('dune.public'='true', + 'dune.data_explorer.blockchains'='["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum"]', 'dune.data_explorer.category'='abstraction', 'dune.data_explorer.abstraction.type'='project', 'dune.data_explorer.abstraction.name'='tornado_cash', diff --git a/models/ens/ens_ethereum_sources.yml b/models/ens/ens_ethereum_sources.yml index c2462a204c4..fd16fcf543f 100644 --- a/models/ens/ens_ethereum_sources.yml +++ b/models/ens/ens_ethereum_sources.yml @@ -24,9 +24,6 @@ sources: error_after: { count: 24, period: hour } loaded_at_field: evt_block_time - name: ENSRegistry_evt_NewOwner - freshness: - warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } loaded_at_field: evt_block_time - name: ENSRegistryWithFallback_evt_NewOwner freshness: diff --git a/models/sudoswap/ethereum/sudoswap_ethereum_sources.yml b/models/sudoswap/ethereum/sudoswap_ethereum_sources.yml index 106a1332b2c..c0712ddc028 100644 --- a/models/sudoswap/ethereum/sudoswap_ethereum_sources.yml +++ b/models/sudoswap/ethereum/sudoswap_ethereum_sources.yml @@ -15,9 +15,6 @@ sources: error_after: { count: 24, period: hour } loaded_at_field: call_block_time - name: LSSVMPair_general_call_swapTokenForAnyNFTs - freshness: - warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } loaded_at_field: call_block_time - name: LSSVMPair_general_call_swapTokenForSpecificNFTs freshness: diff --git a/models/tornado_cash/tornado_cash_deposits.sql b/models/tornado_cash/tornado_cash_deposits.sql index 0b76ab18d1b..baa93e09ae3 100644 --- a/models/tornado_cash/tornado_cash_deposits.sql +++ b/models/tornado_cash/tornado_cash_deposits.sql @@ -15,8 +15,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract , 'ETH' AS currency_symbol - , 'Ethereum' AS blockchain - , 'Classic' AS tornado_version + , 'ethereum' AS blockchain + , 'classic' AS tornado_version , et.from AS depositor , tc.contract_address AS contract_address , CASE WHEN tc.contract_address='0x12d66f87a04a9e220743712ce6d9bb1b5616b8fc' THEN 0.1 @@ -29,19 +29,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_ethereum','eth_evt_Deposit') }} tc - LEFT JOIN {{ source('ethereum','transactions_0006') }} et + INNER JOIN {{ source('ethereum','transactions') }} et ON et.hash=tc.evt_tx_hash {% if not is_incremental() %} AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - AND et.block_time >= (select max(block_time) from {{ this }}) + AND et.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -94,8 +94,8 @@ FROM WHEN tc.contract_address='0x610b717796ad172b316836ac95a2ffad065ceab4' THEN 'WBTC' WHEN tc.contract_address='0xbb93e510bbcd0b7beb5a853875f9ec60275cf498' THEN 'WBTC' END AS currency_symbol - , 'Ethereum' AS blockchain - , 'Classic' AS tornado_version + , 'ethereum' AS blockchain + , 'classic' AS tornado_version , et.from AS depositor , tc.contract_address AS contract_address , CASE WHEN tc.contract_address='0xd4b88df4d29f5cedd6857912842cff3b20c8cfa3' THEN 100 @@ -126,19 +126,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_ethereum','erc20_evt_Deposit') }} tc - LEFT JOIN {{ source('ethereum','transactions_0006') }} et + INNER JOIN {{ source('ethereum','transactions') }} et ON et.hash=tc.evt_tx_hash {% if not is_incremental() %} AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','erc20_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - AND et.block_time >= (select max(block_time) from {{ this }}) + AND et.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','erc20_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -147,8 +147,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0xb8c77482e45f1f44de1745f52c74426c631bdd52' AS currency_contract , 'BNB' AS currency_symbol - , 'BNB' AS blockchain - , 'Classic' AS tornado_version + , 'bnb' AS blockchain + , 'classic' AS tornado_version , bt.from AS depositor , tc.contract_address AS contract_address , CASE WHEN tc.contract_address='0x84443cfd09a48af6ef360c6976c5392ac5023a1f' THEN 0.1 @@ -161,19 +161,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Deposit') }} tc - LEFT JOIN {{ source('bnb','transactions') }} bt + INNER JOIN {{ source('bnb','transactions') }} bt ON bt.hash=tc.evt_tx_hash {% if not is_incremental() %} AND bt.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - AND bt.block_time >= (select max(block_time) from {{ this }}) + AND bt.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -182,8 +182,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0x6b175474e89094c44da98b954eedeac495271d0f' AS currency_contract , 'xDAI' AS currency_symbol - , 'Gnosis' AS blockchain - , 'Classic' AS tornado_version + , 'gnosis' AS blockchain + , 'classic' AS tornado_version , gt.from AS depositor , tc.contract_address AS contract_address , CASE WHEN tc.contract_address='0x1e34a77868e19a6647b1f2f47b51ed72dede95dd' THEN 100 @@ -196,19 +196,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_gnosis','eth_evt_Deposit') }} tc - LEFT JOIN {{ source('gnosis','transactions') }} gt + INNER JOIN {{ source('gnosis','transactions') }} gt ON gt.hash=tc.evt_tx_hash {% if not is_incremental() %} AND gt.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_gnosis','eth_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - AND gt.block_time >= (select max(block_time) from {{ this }}) + AND gt.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_gnosis','eth_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -217,8 +217,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract , 'ETH' AS currency_symbol - , 'Optimism' AS blockchain - , 'Classic' AS tornado_version + , 'optimism' AS blockchain + , 'classic' AS tornado_version , ot.from AS depositor , tc.contract_address AS contract_address , CASE WHEN tc.contract_address='0x84443cfd09a48af6ef360c6976c5392ac5023a1f' THEN 0.1 @@ -231,19 +231,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_optimism','ETHTornado_evt_Deposit') }} tc - LEFT JOIN {{ source('optimism','transactions') }} ot + INNER JOIN {{ source('optimism','transactions') }} ot ON ot.hash=tc.evt_tx_hash {% if not is_incremental() %} AND ot.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_optimism','ETHTornado_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - AND ot.block_time >= (select max(block_time) from {{ this }}) + AND ot.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_optimism','ETHTornado_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -252,8 +252,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0x85f138bfEE4ef8e540890CFb48F620571d67Eda3' AS currency_contract , 'AVAX' AS currency_symbol - , 'Avalanche' AS blockchain - , 'Classic' AS tornado_version + , 'avalanche_c' AS blockchain + , 'classic' AS tornado_version , at.from AS depositor , tc.contract_address AS contract_address , CASE WHEN tc.contract_address='0x330bdfade01ee9bf63c209ee33102dd334618e0a' THEN 10 @@ -265,19 +265,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Deposit') }} tc - LEFT JOIN {{ source('avalanche_c','transactions') }} at + INNER JOIN {{ source('avalanche_c','transactions') }} at ON at.hash=tc.evt_tx_hash {% if not is_incremental() %} AND at.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - AND at.block_time >= (select max(block_time) from {{ this }}) + AND at.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -286,8 +286,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract , 'ETH' AS currency_symbol - , 'Arbitrum' AS blockchain - , 'Classic' AS tornado_version + , 'arbitrum' AS blockchain + , 'classic' AS tornado_version , at.from AS depositor , tc.contract_address AS contract_address , CASE WHEN tc.contract_address='0x84443cfd09a48af6ef360c6976c5392ac5023a1f' THEN 0.1 @@ -300,18 +300,18 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_arbitrum','ETHTornado_evt_Deposit') }} tc - LEFT JOIN {{ source('arbitrum','transactions') }} at + INNER JOIN {{ source('arbitrum','transactions') }} at ON at.hash=tc.evt_tx_hash {% if not is_incremental() %} AND at.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_arbitrum','ETHTornado_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - AND at.block_time >= (select max(block_time) from {{ this }}) + AND at.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_arbitrum','ETHTornado_evt_Deposit') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} ) \ No newline at end of file diff --git a/models/tornado_cash/tornado_cash_schema.yml b/models/tornado_cash/tornado_cash_schema.yml index 5c9cdc76de1..f58dc355634 100644 --- a/models/tornado_cash/tornado_cash_schema.yml +++ b/models/tornado_cash/tornado_cash_schema.yml @@ -5,11 +5,11 @@ version: 2 models: - name: tornado_cash_deposits meta: - blockchain: ethereum, bnb, avalanche, gnosis, optimism, arbitrum #, polygon + blockchain: ethereum, bnb, avalanche_c, gnosis, optimism, arbitrum #, polygon project: tornado_cash contibutors: [hildobby, dot2dotseurat] config: - tags: ['tornado_cash', 'deposits', 'ethereum', 'bnb', 'avalanche', 'gnosis', 'optimism', 'arbitrum'] + tags: ['tornado_cash', 'deposits', 'ethereum', 'bnb', 'avalanche_c', 'gnosis', 'optimism', 'arbitrum'] description: "Tornado Cash Deposits" columns: - &block_time @@ -25,13 +25,13 @@ models: name: blockchain tests: - accepted_values: - values: ['Ethereum', 'BNB', 'Avalanche', 'Gnosis', 'Optimism', 'Arbitrum', 'Polygon'] + values: ['ethereum', 'bnb', 'avalanche_c', 'gnosis', 'optimism', 'arbitrum', 'polygon'] description: "Blockchain" - &tornado_version name: tornado_version tests: - accepted_values: - values: ['Classic', 'Nova'] + values: ['classic', 'nova'] description: "Version of Tornado Cash used for this transaction" - &depositor name: depositor diff --git a/models/tornado_cash/tornado_cash_sources.yml b/models/tornado_cash/tornado_cash_sources.yml index 20ad5fd3b48..f6a8924c995 100644 --- a/models/tornado_cash/tornado_cash_sources.yml +++ b/models/tornado_cash/tornado_cash_sources.yml @@ -4,7 +4,6 @@ sources: - name: tornado_cash_bnb freshness: warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } tables: - name: TornadoCashBNB_evt_Deposit loaded_at_field: evt_block_time @@ -16,18 +15,6 @@ sources: - name: commitment - name: leafIndex - name: timestamp - - name: ETHTornado_evt_Withdrawal - loaded_at_field: evt_block_time - columns: - - name: contract_address - - name: evt_tx_hash - - name: evt_index - - name: evt_block_time - - name: evt_block_number - - name: fee - - name: nullifierHash - - name: relayer - - name: to - name: TornadoCashBNB_evt_Withdrawal loaded_at_field: evt_block_time columns: @@ -44,7 +31,6 @@ sources: - name: tornado_cash_arbitrum freshness: warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } tables: - name: ETHTornado_evt_Deposit loaded_at_field: evt_block_time @@ -73,7 +59,6 @@ sources: - name: tornado_cash_optimism freshness: warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } tables: - name: ETHTornado_evt_Deposit loaded_at_field: evt_block_time @@ -86,18 +71,6 @@ sources: - name: commitment - name: leafIndex - name: timestamp - - name: erc20_evt_Withdrawal - loaded_at_field: evt_block_time - columns: - - name: contract_address - - name: evt_tx_hash - - name: evt_index - - name: evt_block_time - - name: evt_block_number - - name: fee - - name: nullifierHash - - name: relayer - - name: to - name: ETHTornado_evt_Withdrawal loaded_at_field: evt_block_time columns: @@ -114,7 +87,6 @@ sources: - name: tornado_cash_avalanche_c freshness: warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } tables: - name: ETHTornado_evt_Deposit loaded_at_field: evt_block_time @@ -143,7 +115,6 @@ sources: - name: tornado_cash_ethereum freshness: warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } tables: - name: erc20_evt_Deposit loaded_at_field: evt_block_time @@ -191,7 +162,6 @@ sources: - name: tornado_cash_gnosis freshness: warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } tables: - name: eth_evt_Deposit loaded_at_field: evt_block_time diff --git a/models/tornado_cash/tornado_cash_withdrawals.sql b/models/tornado_cash/tornado_cash_withdrawals.sql index 4fbe4705085..1363ec99efa 100644 --- a/models/tornado_cash/tornado_cash_withdrawals.sql +++ b/models/tornado_cash/tornado_cash_withdrawals.sql @@ -15,8 +15,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract , 'ETH' AS currency_symbol - , 'Ethereum' AS blockchain - , 'Classic' AS tornado_version + , 'ethereum' AS blockchain + , 'classic' AS tornado_version , et.from AS tx_from , tc.nullifierHash AS nullifier , tc.fee/POWER(10, 18) AS fee @@ -32,19 +32,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_ethereum','eth_evt_Withdrawal') }} tc - LEFT JOIN {{ source('ethereum','transactions_0006') }} et + INNER JOIN {{ source('ethereum','transactions') }} et ON et.hash=tc.evt_tx_hash {% if not is_incremental() %} AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - AND et.block_time >= (select max(block_time) from {{ this }}) + AND et.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','eth_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -97,8 +97,8 @@ FROM WHEN tc.contract_address='0x610b717796ad172b316836ac95a2ffad065ceab4' THEN 'WBTC' WHEN tc.contract_address='0xbb93e510bbcd0b7beb5a853875f9ec60275cf498' THEN 'WBTC' END AS currency_symbol - , 'Ethereum' AS blockchain - , 'Classic' AS tornado_version + , 'ethereum' AS blockchain + , 'classic' AS tornado_version , et.from AS tx_from , tc.nullifierHash AS nullifier , tc.fee/POWER(10, 18) AS fee @@ -132,19 +132,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_ethereum','erc20_evt_Withdrawal') }} tc - LEFT JOIN {{ source('ethereum','transactions_0006') }} et + INNER JOIN {{ source('ethereum','transactions') }} et ON et.hash=tc.evt_tx_hash {% if not is_incremental() %} AND et.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','erc20_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - AND et.block_time >= (select max(block_time) from {{ this }}) + AND et.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_ethereum','erc20_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -153,8 +153,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0xb8c77482e45f1f44de1745f52c74426c631bdd52' AS currency_contract , 'BNB' AS currency_symbol - , 'BNB' AS blockchain - , 'Classic' AS tornado_version + , 'bnb' AS blockchain + , 'classic' AS tornado_version , bt.from AS tx_from , tc.nullifierHash AS nullifier , tc.fee/POWER(10, 18) AS fee @@ -170,19 +170,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Withdrawal') }} tc - LEFT JOIN {{ source('bnb','transactions') }} bt + INNER JOIN {{ source('bnb','transactions') }} bt ON bt.hash=tc.evt_tx_hash {% if not is_incremental() %} AND bt.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - AND bt.block_time >= (select max(block_time) from {{ this }}) + AND bt.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_bnb','TornadoCashBNB_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -191,8 +191,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0x6b175474e89094c44da98b954eedeac495271d0f' AS currency_contract , 'xDAI' AS currency_symbol - , 'Gnosis' AS blockchain - , 'Classic' AS tornado_version + , 'gnosis' AS blockchain + , 'classic' AS tornado_version , gt.from AS tx_from , nullifierHash AS nullifier , tc.fee/POWER(10, 18) AS fee @@ -208,19 +208,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_gnosis','eth_evt_Withdrawal') }} tc - LEFT JOIN {{ source('gnosis','transactions') }} gt + INNER JOIN {{ source('gnosis','transactions') }} gt ON gt.hash=tc.evt_tx_hash {% if not is_incremental() %} AND gt.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_gnosis','eth_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - AND gt.block_time >= (select max(block_time) from {{ this }}) + AND gt.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_gnosis','eth_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -229,8 +229,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract , 'ETH' AS currency_symbol - , 'Optimism' AS blockchain - , 'Classic' AS tornado_version + , 'optimism' AS blockchain + , 'classic' AS tornado_version , ot.from AS tx_from , tc.nullifierHash AS nullifier , tc.fee/POWER(10, 18) AS fee @@ -246,19 +246,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_optimism','ETHTornado_evt_Withdrawal') }} tc - LEFT JOIN {{ source('optimism','transactions') }} ot + INNER JOIN {{ source('optimism','transactions') }} ot ON ot.hash=tc.evt_tx_hash {% if not is_incremental() %} AND ot.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_optimism','ETHTornado_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - AND ot.block_time >= (select max(block_time) from {{ this }}) + AND ot.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_optimism','ETHTornado_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -267,8 +267,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0x85f138bfEE4ef8e540890CFb48F620571d67Eda3' AS currency_contract , 'AVAX' AS currency_symbol - , 'Avalanche' AS blockchain - , 'Classic' AS tornado_version + , 'avalanche_c' AS blockchain + , 'classic' AS tornado_version , at.from AS tx_from , tc.nullifierHash AS nullifier , tc.fee/POWER(10, 18) AS fee @@ -283,19 +283,19 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Withdrawal') }} tc - LEFT JOIN {{ source('avalanche_c','transactions') }} at + INNER JOIN {{ source('avalanche_c','transactions') }} at ON at.hash=tc.evt_tx_hash {% if not is_incremental() %} AND at.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - AND at.block_time >= (select max(block_time) from {{ this }}) + AND at.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_avalanche_c','ETHTornado_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} UNION @@ -304,8 +304,8 @@ FROM SELECT tc.evt_block_time AS block_time , '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' AS currency_contract , 'ETH' AS currency_symbol - , 'Arbitrum' AS blockchain - , 'Classic' AS tornado_version + , 'arbitrum' AS blockchain + , 'classic' AS tornado_version , at.from AS tx_from , tc.nullifierHash AS nullifier , tc.fee/POWER(10, 18) AS fee @@ -321,18 +321,18 @@ FROM , tc.evt_index , TRY_CAST(date_trunc('DAY', tc.evt_block_time) AS date) AS block_date FROM {{ source('tornado_cash_arbitrum','ETHTornado_evt_Withdrawal') }} tc - LEFT JOIN {{ source('arbitrum','transactions') }} at + INNER JOIN {{ source('arbitrum','transactions') }} at ON at.hash=tc.evt_tx_hash {% if not is_incremental() %} AND at.block_time >= (select min(evt_block_time) from {{ source('tornado_cash_arbitrum','ETHTornado_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - AND at.block_time >= (select max(block_time) from {{ this }}) + AND at.block_time >= date_trunc("day", now() - interval '1 week') {% endif %} {% if not is_incremental() %} WHERE tc.evt_block_time >= (select min(evt_block_time) from {{ source('tornado_cash_arbitrum','ETHTornado_evt_Withdrawal') }}) {% endif %} {% if is_incremental() %} - WHERE tc.evt_block_time >= (select max(block_time) from {{ this }}) + WHERE tc.evt_block_time >= date_trunc("day", now() - interval '1 week') {% endif %} ) \ No newline at end of file diff --git a/models/uniswap/ethereum/uniswap_ethereum_sources.yml b/models/uniswap/ethereum/uniswap_ethereum_sources.yml index 00e0d5e64e7..c63775dc205 100644 --- a/models/uniswap/ethereum/uniswap_ethereum_sources.yml +++ b/models/uniswap/ethereum/uniswap_ethereum_sources.yml @@ -54,9 +54,6 @@ sources: name: token description: "Token bought contract address" - name: Exchange_evt_EthPurchase - freshness: - warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } loaded_at_field: evt_block_time description: "" # to-do columns: diff --git a/models/uniswap/optimism/uniswap_optimism_sources.yml b/models/uniswap/optimism/uniswap_optimism_sources.yml index 8c39080f6ce..d126a6bbf02 100644 --- a/models/uniswap/optimism/uniswap_optimism_sources.yml +++ b/models/uniswap/optimism/uniswap_optimism_sources.yml @@ -4,7 +4,6 @@ sources: - name: uniswap_v3_optimism freshness: warn_after: { count: 12, period: hour } - error_after: { count: 24, period: hour } tables: - name: factory_evt_poolcreated loaded_at_field: evt_block_time