From 0836ea404a5892976cd6404595aa52bf1d61233f Mon Sep 17 00:00:00 2001 From: Austin <93135983+austinFlipside@users.noreply.github.com> Date: Wed, 12 Feb 2025 07:57:53 -0500 Subject: [PATCH] An 5338/avax dexalot standardization (#302) * compile * dexalot * curated models * updates * refs * seaport * seaport * nft * mega * logs * timestamps * predicate * warehouse * add * predicate * updates --------- Co-authored-by: sam --- .github/workflows/dbt_run_adhoc.yml | 1 + macros/dbt/incremental_predicates.sql | 22 + macros/tests/missing_decoding.sql | 14 +- models/dexalot/gold/dexalot__fact_blocks.sql | 26 +- models/dexalot/gold/dexalot__fact_blocks.yml | 58 +- .../dexalot/gold/dexalot__fact_event_logs.sql | 22 +- .../dexalot/gold/dexalot__fact_event_logs.yml | 44 +- .../gold/dexalot__fact_transactions.sql | 19 +- .../gold/dexalot__fact_transactions.yml | 4 +- models/doc_descriptions/fsc_evm/blocks.md | 143 +++++ .../fsc_evm/complete_general.md | 65 ++ models/doc_descriptions/fsc_evm/event_logs.md | 83 +++ .../fsc_evm/evm_deprecations.md | 203 ++++++ models/doc_descriptions/fsc_evm/nft.md | 587 ++++++++++++++++++ models/doc_descriptions/fsc_evm/traces.md | 125 ++++ .../doc_descriptions/fsc_evm/transactions.md | 188 ++++++ models/doc_descriptions/fsc_evm/transfers.md | 144 +++++ .../transfers/evm_transfers_table_doc.md | 17 - .../gold/core/core__ez_decoded_event_logs.sql | 63 +- .../gold/core/core__ez_decoded_event_logs.yml | 10 +- .../gold/core/core__ez_native_transfers.sql | 27 +- .../gold/core/core__ez_native_transfers.yml | 2 +- models/gold/core/core__ez_token_transfers.sql | 18 +- models/gold/core/core__ez_token_transfers.yml | 16 +- models/gold/core/core__fact_blocks.sql | 77 +-- models/gold/core/core__fact_blocks.yml | 58 +- .../core/core__fact_decoded_event_logs.yml | 36 +- models/gold/core/core__fact_event_logs.sql | 27 +- models/gold/core/core__fact_event_logs.yml | 44 +- .../gold/core/core__fact_token_transfers.yml | 2 +- models/gold/core/core__fact_traces.yml | 104 ++-- models/gold/core/core__fact_transactions.sql | 24 +- models/gold/core/core__fact_transactions.yml | 62 +- models/gold/defi/defi__ez_dex_swaps.sql | 4 +- models/gold/defi/defi__ez_dex_swaps.yml | 8 +- models/gold/nft/nft__ez_nft_sales.sql | 25 +- models/gold/nft/nft__ez_nft_sales.yml | 34 +- models/gold/nft/nft__ez_nft_transfers.sql | 39 +- models/gold/nft/nft__ez_nft_transfers.yml | 30 +- models/silver/abis/silver__proxies.sql | 4 +- .../abis/silver__user_verified_abis.sql | 2 +- .../silver/core/silver__created_contracts.sql | 4 +- models/silver/core/silver__logs.sql | 6 + .../silver/core/silver__native_transfers.sql | 51 +- .../core/silver__relevant_contracts.sql | 4 +- models/silver/core/silver__transfers.sql | 12 +- models/silver/core/silver__tx_count.sql | 12 +- .../silver_bridge__allbridge_sent.sql | 35 +- .../silver_bridge__allbridge_tokens_sent.sql | 12 +- ...r_bridge__axelar_contractcallwithtoken.sql | 75 ++- .../silver_bridge__celer_cbridge_send.sql | 37 +- ...lver_bridge__dln_debridge_createdorder.sql | 63 +- .../eywa/silver_bridge__eywa_requestsent.sql | 41 +- .../meson/silver_bridge__meson_transfers.sql | 46 +- ...er_bridge__multichain_v7_loganyswapout.sql | 33 +- .../silver_bridge__stargate_createpool.sql | 4 +- .../stargate/silver_bridge__stargate_swap.sql | 37 +- ...er_bridge__symbiosis_synthesizerequest.sql | 35 +- .../silver_bridge__synapse_token_bridge.sql | 29 +- ...ver_bridge__synapse_tokenbridgeandswap.sql | 37 +- .../silver_bridge__wormhole_transfers.sql | 33 +- .../balancer/silver_dex__balancer_pools.sql | 23 +- .../balancer/silver_dex__balancer_swaps.sql | 13 +- .../dex/curve/silver_dex__curve_pools.sql | 5 +- .../dex/curve/silver_dex__curve_swaps.sql | 16 +- .../fraxswap/silver_dex__fraxswap_pools.sql | 13 +- .../fraxswap/silver_dex__fraxswap_swaps.sql | 13 +- .../defi/dex/gmx/silver_dex__gmx_swaps.sql | 13 +- .../hashflow/silver_dex__hashflow_pools.sql | 5 +- .../hashflow/silver_dex__hashflow_swaps.sql | 30 +- .../silver_dex__hashflow_v3_pools.sql | 13 +- .../silver_dex__hashflow_v3_swaps.sql | 13 +- ...silver_dex__kyberswap_v1_dynamic_pools.sql | 13 +- ...silver_dex__kyberswap_v1_dynamic_swaps.sql | 13 +- .../silver_dex__kyberswap_v1_static_pools.sql | 13 +- .../silver_dex__kyberswap_v1_static_swaps.sql | 13 +- ...silver_dex__kyberswap_v2_elastic_pools.sql | 13 +- ...silver_dex__kyberswap_v2_elastic_swaps.sql | 13 +- .../pangolin/silver_dex__pangolin_pools.sql | 13 +- .../pangolin/silver_dex__pangolin_swaps.sql | 13 +- .../pharaoh/silver_dex__pharaoh_v1_pools.sql | 13 +- .../pharaoh/silver_dex__pharaoh_v1_swaps.sql | 13 +- .../pharaoh/silver_dex__pharaoh_v2_pools.sql | 18 +- .../pharaoh/silver_dex__pharaoh_v2_swaps.sql | 5 +- .../platypus/silver_dex__platypus_pools.sql | 5 +- .../platypus/silver_dex__platypus_swaps.sql | 13 +- .../dex/sushi/silver_dex__sushi_pools.sql | 13 +- .../dex/sushi/silver_dex__sushi_swaps.sql | 13 +- .../silver_dex__trader_joe_v1_pools.sql | 13 +- .../silver_dex__trader_joe_v1_swaps.sql | 13 +- .../silver_dex__trader_joe_v2_1_swaps.sql | 13 +- .../silver_dex__trader_joe_v2_pools.sql | 13 +- .../silver_dex__trader_joe_v2_swaps.sql | 13 +- .../dex/uniswap/silver_dex__univ2_pools.sql | 13 +- .../dex/uniswap/silver_dex__univ2_swaps.sql | 13 +- .../dex/uniswap/silver_dex__univ3_pools.sql | 18 +- .../dex/uniswap/silver_dex__univ3_swaps.sql | 13 +- .../dex/woofi/silver_dex__woofi_swaps.sql | 26 +- .../lending/aave/silver__aave_borrows.sql | 13 +- .../lending/aave/silver__aave_deposits.sql | 13 +- .../lending/aave/silver__aave_flashloans.sql | 13 +- .../aave/silver__aave_liquidations.sql | 13 +- .../lending/aave/silver__aave_repayments.sql | 13 +- .../defi/lending/aave/silver__aave_tokens.sql | 4 +- .../lending/aave/silver__aave_withdraws.sql | 13 +- .../benqi/silver__benqi_asset_details.sql | 13 +- .../lending/benqi/silver__benqi_borrows.sql | 13 +- .../lending/benqi/silver__benqi_deposits.sql | 13 +- .../benqi/silver__benqi_liquidations.sql | 13 +- .../benqi/silver__benqi_repayments.sql | 13 +- .../lending/benqi/silver__benqi_withdraws.sql | 13 +- .../silver__trader_joe_asset_details.sql | 10 +- .../trader_joe/silver__trader_joe_borrows.sql | 13 +- .../silver__trader_joe_deposits.sql | 13 +- .../silver__trader_joe_liquidations.sql | 13 +- .../silver__trader_joe_repayments.sql | 13 +- .../silver__trader_joe_withdraws.sql | 13 +- .../nft/sales/silver__element_sales.sql | 60 +- .../nft/sales/silver__joepegs_sales.sql | 66 +- .../silver/nft/sales/silver__salvor_sales.sql | 20 +- .../nft/sales/silver__seaport_1_1_sales.sql | 60 +- .../nft/sales/silver__seaport_1_4_sales.sql | 172 ++--- .../nft/sales/silver__seaport_1_5_sales.sql | 114 ++-- .../nft/sales/silver__seaport_1_6_sales.sql | 114 ++-- models/silver/nft/silver__nft_transfers.sql | 12 +- .../streamline__decoded_logs_realtime.sql | 2 +- 126 files changed, 3304 insertions(+), 1140 deletions(-) create mode 100644 macros/dbt/incremental_predicates.sql create mode 100644 models/doc_descriptions/fsc_evm/blocks.md create mode 100644 models/doc_descriptions/fsc_evm/complete_general.md create mode 100644 models/doc_descriptions/fsc_evm/event_logs.md create mode 100644 models/doc_descriptions/fsc_evm/evm_deprecations.md create mode 100644 models/doc_descriptions/fsc_evm/nft.md create mode 100644 models/doc_descriptions/fsc_evm/traces.md create mode 100644 models/doc_descriptions/fsc_evm/transactions.md create mode 100644 models/doc_descriptions/fsc_evm/transfers.md delete mode 100644 models/doc_descriptions/transfers/evm_transfers_table_doc.md diff --git a/.github/workflows/dbt_run_adhoc.yml b/.github/workflows/dbt_run_adhoc.yml index 92873f2..3b2d63f 100644 --- a/.github/workflows/dbt_run_adhoc.yml +++ b/.github/workflows/dbt_run_adhoc.yml @@ -22,6 +22,7 @@ on: - DBT - DBT_CLOUD - DBT_EMERGENCY + - DBT_MEGA default: DBT dbt_command: type: string diff --git a/macros/dbt/incremental_predicates.sql b/macros/dbt/incremental_predicates.sql new file mode 100644 index 0000000..47d3c72 --- /dev/null +++ b/macros/dbt/incremental_predicates.sql @@ -0,0 +1,22 @@ +{% macro standard_predicate( + input_column = 'block_number' + ) -%} + {%- set database_name = target.database -%} + {%- set schema_name = generate_schema_name( + node = model + ) -%} + {%- set table_name = generate_alias_name( + node = model + ) -%} + {%- set tmp_table_name = table_name ~ '__dbt_tmp' -%} + {%- set full_table_name = database_name ~ '.' ~ schema_name ~ '.' ~ table_name -%} + {%- set full_tmp_table_name = database_name ~ '.' ~ schema_name ~ '.' ~ tmp_table_name -%} + {{ full_table_name }}.{{ input_column }} >= ( + SELECT + MIN( + {{ input_column }} + ) + FROM + {{ full_tmp_table_name }} + ) +{%- endmacro %} \ No newline at end of file diff --git a/macros/tests/missing_decoding.sql b/macros/tests/missing_decoding.sql index 54558a3..f1e2beb 100644 --- a/macros/tests/missing_decoding.sql +++ b/macros/tests/missing_decoding.sql @@ -1,14 +1,22 @@ {% test missing_decoded_logs(model) %} SELECT l.block_number, - l._log_id + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l LEFT JOIN {{ model }} d ON l.block_number = d.block_number - AND l._log_id = d._log_id + AND CONCAT( + l.tx_hash, + '-', + l.event_index + ) = d._log_id WHERE l.contract_address = LOWER('0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7') -- WAVAX AND l.topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' -- Transfer diff --git a/models/dexalot/gold/dexalot__fact_blocks.sql b/models/dexalot/gold/dexalot__fact_blocks.sql index afe2cc0..62c8270 100644 --- a/models/dexalot/gold/dexalot__fact_blocks.sql +++ b/models/dexalot/gold/dexalot__fact_blocks.sql @@ -10,21 +10,27 @@ SELECT A.block_number AS block_number, + hash AS block_hash, block_timestamp, 'mainnet' AS network, - 'dexalot' AS blockchain, tx_count, + size, + miner, + extra_data, + parent_hash, + gas_used, + gas_limit, + base_fee_per_gas, difficulty, total_difficulty, - extra_data, - gas_limit, - gas_used, - HASH, - parent_hash, - receipts_root, + uncles as uncle_blocks, + nonce, + number, sha3_uncles, - SIZE, - uncles AS uncle_blocks, + receipts_root, + state_root, + transactions_root, + logs_bloom, OBJECT_CONSTRUCT( 'baseFeePerGas', base_fee_per_gas, @@ -68,6 +74,8 @@ SELECT blocks_id AS fact_blocks_id, inserted_timestamp, modified_timestamp, + 'dexalot' AS blockchain, + hash FROM {{ ref('silver_dexalot__blocks') }} A diff --git a/models/dexalot/gold/dexalot__fact_blocks.yml b/models/dexalot/gold/dexalot__fact_blocks.yml index 466a963..93fcfe1 100644 --- a/models/dexalot/gold/dexalot__fact_blocks.yml +++ b/models/dexalot/gold/dexalot__fact_blocks.yml @@ -1,46 +1,62 @@ version: 2 models: - name: dexalot__fact_blocks - description: '{{ doc("dexalot_blocks_table_doc") }}' + description: '{{ doc("evm_blocks_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("dexalot_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("dexalot_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: NETWORK - description: '{{ doc("dexalot_network") }}' + description: '{{ doc("evm_network") }}' - name: BLOCKCHAIN - description: '{{ doc("dexalot_blockchain") }}' + description: '{{ doc("evm_column_deprecation_notice_blockchain") }}' + - name: MINER + description: '{{ doc("evm_miner") }}' + - name: NONCE + description: '{{ doc("evm_blocks_nonce") }}' - name: TX_COUNT - description: '{{ doc("dexalot_tx_count") }}' + description: '{{ doc("evm_tx_count") }}' - name: DIFFICULTY - description: '{{ doc("dexalot_difficulty") }}' + description: '{{ doc("evm_difficulty") }}' - name: TOTAL_DIFFICULTY - description: '{{ doc("dexalot_total_difficulty") }}' + description: '{{ doc("evm_total_difficulty") }}' - name: EXTRA_DATA - description: '{{ doc("dexalot_extra_data") }}' + description: '{{ doc("evm_extra_data") }}' - name: GAS_LIMIT - description: '{{ doc("dexalot_gas_limit") }}' + description: '{{ doc("evm_gas_limit") }}' - name: GAS_USED - description: '{{ doc("dexalot_gas_used") }}' + description: '{{ doc("evm_gas_used") }}' + - name: BASE_FEE_PER_GAS + description: '{{ doc("evm_base_fee_per_gas") }}' + - name: BLOCK_HASH + description: '{{ doc("evm_blocks_hash") }}' - name: HASH - description: '{{ doc("dexalot_blocks_hash") }}' + description: '{{ doc("evm_column_deprecation_notice_hash") }}' - name: PARENT_HASH - description: '{{ doc("dexalot_parent_hash") }}' + description: '{{ doc("evm_parent_hash") }}' - name: RECEIPTS_ROOT - description: '{{ doc("dexalot_receipts_root") }}' + description: '{{ doc("evm_receipts_root") }}' - name: SHA3_UNCLES - description: '{{ doc("dexalot_sha3_uncles") }}' + description: '{{ doc("evm_sha3_uncles") }}' - name: SIZE - description: '{{ doc("dexalot_size") }}' + description: '{{ doc("evm_size") }}' - name: UNCLE_BLOCKS - description: '{{ doc("dexalot_uncle_blocks") }}' + description: '{{ doc("evm_uncle_blocks") }}' + - name: STATE_ROOT + description: '{{ doc("evm_state_root") }}' + - name: TRANSACTIONS_ROOT + description: '{{ doc("evm_transactions_root") }}' + - name: LOGS_BLOOM + description: '{{ doc("evm_logs_bloom") }}' - name: BLOCK_HEADER_JSON - description: '{{ doc("dexalot_block_header_json") }}' + description: '{{ doc("evm_column_deprecation_notice_block_header_json") }}' + - name: BASE_FEE_PER_GAS + description: '{{ doc("evm_base_fee_per_gas") }}' - name: FACT_BLOCKS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/dexalot/gold/dexalot__fact_event_logs.sql b/models/dexalot/gold/dexalot__fact_event_logs.sql index acaee2a..6224e6c 100644 --- a/models/dexalot/gold/dexalot__fact_event_logs.sql +++ b/models/dexalot/gold/dexalot__fact_event_logs.sql @@ -11,19 +11,29 @@ SELECT block_number, block_timestamp, tx_hash, - origin_function_signature, - origin_from_address, - origin_to_address, + {# tx_position, -- new column #} event_index, contract_address, topics, + topics[0] AS topic_0, + topics[1] AS topic_1, + topics[2] AS topic_2, + topics[3] AS topic_3, DATA, event_removed, - tx_status AS tx_succeeded, - _log_id, + origin_from_address, + origin_to_address, + origin_function_signature, + CASE + WHEN tx_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS tx_succeeded, logs_id AS fact_event_logs_id, inserted_timestamp, - modified_timestamp + modified_timestamp, + tx_status, + -- deprecate + _log_id -- deprecate FROM {{ ref('silver_dexalot__logs') }} diff --git a/models/dexalot/gold/dexalot__fact_event_logs.yml b/models/dexalot/gold/dexalot__fact_event_logs.yml index 60d862b..3393583 100644 --- a/models/dexalot/gold/dexalot__fact_event_logs.yml +++ b/models/dexalot/gold/dexalot__fact_event_logs.yml @@ -1,38 +1,48 @@ version: 2 models: - name: dexalot__fact_event_logs - description: '{{ doc("dexalot_logs_table_doc") }}' + description: '{{ doc("evm_logs_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("dexalot_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("dexalot_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: TX_HASH - description: '{{ doc("dexalot_logs_tx_hash") }}' + description: '{{ doc("evm_logs_tx_hash") }}' - name: EVENT_INDEX - description: '{{ doc("dexalot_event_index") }}' + description: '{{ doc("evm_event_index") }}' - name: CONTRACT_ADDRESS - description: '{{ doc("dexalot_logs_contract_address") }}' + description: '{{ doc("evm_logs_contract_address") }}' - name: TOPICS - description: '{{ doc("dexalot_topics") }}' + description: '{{ doc("evm_topics") }}' + - name: TOPIC_0 + description: '{{ doc("evm_topic_0") }}' + - name: TOPIC_1 + description: '{{ doc("evm_topic_1") }}' + - name: TOPIC_2 + description: '{{ doc("evm_topic_2") }}' + - name: TOPIC_3 + description: '{{ doc("evm_topic_3") }}' - name: DATA - description: '{{ doc("dexalot_logs_data") }}' + description: '{{ doc("evm_logs_data") }}' - name: EVENT_REMOVED - description: '{{ doc("dexalot_event_removed") }}' + description: '{{ doc("evm_event_removed") }}' - name: _LOG_ID - description: '{{ doc("internal_column") }}' + description: '{{ doc("evm_column_deprecation_notice_log_id") }}' + - name: TX_STATUS + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' - name: TX_SUCCEEDED - description: '{{ doc("dexalot_tx_status") }}' + description: '{{ doc("evm_tx_succeeded") }}' - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("dexalot_origin_sig") }}' + description: '{{ doc("evm_origin_sig") }}' - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("dexalot_origin_from") }}' + description: '{{ doc("evm_origin_from") }}' - name: ORIGIN_TO_ADDRESS - description: '{{ doc("dexalot_origin_to") }}' + description: '{{ doc("evm_origin_to") }}' - name: FACT_EVENT_LOGS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/dexalot/gold/dexalot__fact_transactions.sql b/models/dexalot/gold/dexalot__fact_transactions.sql index 9146611..58b063d 100644 --- a/models/dexalot/gold/dexalot__fact_transactions.sql +++ b/models/dexalot/gold/dexalot__fact_transactions.sql @@ -10,18 +10,20 @@ SELECT block_number, block_timestamp, - block_hash, tx_hash, - nonce, - POSITION, - origin_function_signature, from_address, to_address, - VALUE, + origin_function_signature, + value, value_precise_raw, value_precise, tx_fee, tx_fee_precise, + tx_status AS tx_succeeded, + tx_type, + nonce, + position as tx_position, + input_data, gas_price, effective_gas_price, gas AS gas_limit, @@ -29,14 +31,15 @@ SELECT cumulative_gas_used, max_fee_per_gas, max_priority_fee_per_gas, - input_data, - tx_status AS tx_succeeded, r, s, v, transactions_id AS fact_transactions_id, inserted_timestamp, - modified_timestamp + modified_timestamp, + block_hash, + -- deprecate + position -- deprecate FROM {{ ref('silver_dexalot__transactions') }} diff --git a/models/dexalot/gold/dexalot__fact_transactions.yml b/models/dexalot/gold/dexalot__fact_transactions.yml index de822d5..0f4e749 100644 --- a/models/dexalot/gold/dexalot__fact_transactions.yml +++ b/models/dexalot/gold/dexalot__fact_transactions.yml @@ -9,12 +9,14 @@ models: - name: BLOCK_TIMESTAMP description: '{{ doc("dexalot_block_timestamp") }}' - name: BLOCK_HASH - description: '{{ doc("dexalot_tx_block_hash") }}' + description: '{{ doc("evm_column_deprecation_notice_block_hash") }}' - name: TX_HASH description: '{{ doc("dexalot_tx_hash") }}' - name: NONCE description: '{{ doc("dexalot_tx_nonce") }}' - name: POSITION + description: '{{ doc("evm_column_deprecation_notice_position") }}' + - name: TX_POSITION description: '{{ doc("dexalot_tx_position") }}' - name: FROM_ADDRESS description: '{{ doc("dexalot_from_address") }}' diff --git a/models/doc_descriptions/fsc_evm/blocks.md b/models/doc_descriptions/fsc_evm/blocks.md new file mode 100644 index 0000000..2f2f846 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/blocks.md @@ -0,0 +1,143 @@ +{% docs evm_blocks_table_doc %} + +This table contains block level data for this EVM blockchain. This table can be used to analyze trends at a block level, for example gas fees vs. total transactions over time. For more information, please see [Etherscan Resources](https://etherscan.io/directory/Learning_Resources/Ethereum) or [The Ethereum Organization](https://ethereum.org/en/developers/docs/blocks/) + +{% enddocs %} + +{% docs evm_block_header_json %} + +This JSON column contains the block header details. + +{% enddocs %} + +{% docs evm_blockchain %} + +The blockchain on which transactions are being confirmed. + +{% enddocs %} + +{% docs evm_blocks_hash %} + +The hash of the block header for a given block. + +{% enddocs %} + +{% docs evm_blocks_nonce %} + +Block nonce is a value used during mining to demonstrate proof of work for a given block. + +{% enddocs %} + +{% docs evm_difficulty %} + +The effort required to mine the block. + +{% enddocs %} + +{% docs evm_extra_data %} + +Any data included by the miner for a given block. + +{% enddocs %} + +{% docs evm_gas_limit %} + +Total gas limit provided by all transactions in the block. + +{% enddocs %} + +{% docs evm_gas_used %} + +Total gas used in the block. + +{% enddocs %} + +{% docs evm_network %} + +The network on the blockchain used by a transaction. + +{% enddocs %} + +{% docs evm_parent_hash %} + +The hash of the block from which a given block is generated. Also known as the parent block. + +{% enddocs %} + +{% docs evm_receipts_root %} + +The root of the state trie. + +{% enddocs %} + +{% docs evm_sha3_uncles %} + +The mechanism which Ethereum Javascript RLP encodes an empty string. + +{% enddocs %} + +{% docs evm_size %} + +Block size, which is determined by a given block's gas limit. + +{% enddocs %} + +{% docs evm_total_difficulty %} + +Total difficulty of the chain at a given block. + +{% enddocs %} + +{% docs evm_tx_count %} + +Total number of transactions within a block. + +{% enddocs %} + +{% docs evm_uncle_blocks %} + +Uncle blocks occur when two blocks are mined and broadcasted at the same time, with the same block number. The block validated across the most nodes will be added to the primary chain, and the other one becomes an uncle block. Miners do receive rewards for uncle blocks. + +{% enddocs %} + +{% docs evm_miner %} + +The address of the beneficiary to whom the mining rewards were given + +{% enddocs %} + +{% docs evm_state_root %} + +The root of the final state trie of the block + +{% enddocs %} + +{% docs evm_transactions_root %} + +The root of the transaction trie of the block + +{% enddocs %} + +{% docs evm_logs_bloom %} + +The bloom filter for the logs of the block. + +{% enddocs %} + +{% docs evm_mix_hash %} + +A string of a 256-bit hash encoded as a hexadecimal + +{% enddocs %} + +{% docs evm_base_fee_per_gas %} + +A string of the base fee encoded in hexadecimal format. Please note that this response field will not be included in a block requested before the EIP-1559 upgrade + +{% enddocs %} + +{% docs evm_withdrawals_root %} + +The root of the withdrawals trie. + +{% enddocs %} diff --git a/models/doc_descriptions/fsc_evm/complete_general.md b/models/doc_descriptions/fsc_evm/complete_general.md new file mode 100644 index 0000000..77e2b35 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/complete_general.md @@ -0,0 +1,65 @@ +{% docs evm_block_number %} + +Also known as block height. The block number, which indicates the length of the blockchain, increases after the addition of each new block. + +{% enddocs %} + +{% docs evm_block_timestamp %} + +The date and time at which the block was produced. + +{% enddocs %} + +{% docs evm_from_address %} + +The sending address of this transaction. + +{% enddocs %} + +{% docs evm_ingested_at %} + +Internal column. + +{% enddocs %} + +{% docs evm_to_address %} + +The receiving address of this transaction. This can be a contract address. + +{% enddocs %} + +{% docs evm_pk %} + +The unique identifier for each row in the table. + +{% enddocs %} + +{% docs evm_inserted_timestamp %} + +The UTC timestamp at which the row was inserted into the table. + +{% enddocs %} + +{% docs evm_modified_timestamp %} + +The UTC timestamp at which the row was last modified. + +{% enddocs %} + +{% docs evm_precise_amount_unadjusted %} + +The precise, unadjusted amount of the transaction. This is returned as a string to avoid precision loss. + +{% enddocs %} + +{% docs evm_precise_amount_adjusted %} + +The precise, adjusted amount of the transaction. This is returned as a string to avoid precision loss. + +{% enddocs %} + +{% docs evm_value_hex %} + +The value of the transaction in hexadecimal format. + +{% enddocs %} diff --git a/models/doc_descriptions/fsc_evm/event_logs.md b/models/doc_descriptions/fsc_evm/event_logs.md new file mode 100644 index 0000000..8880f5c --- /dev/null +++ b/models/doc_descriptions/fsc_evm/event_logs.md @@ -0,0 +1,83 @@ +{% docs evm_logs_table_doc %} + +This table contains flattened event logs from transactions on this EVM blockchain. Transactions may have multiple events, which are denoted by the event index for a transaction hash. Therefore, this table is unique on the combination of transaction hash and event index. Please see `fact_decoded_event_logs` or `ez_decoded_event_logs` for the decoded event logs. + +{% enddocs %} + +{% docs evm_event_index %} + +Event number within a transaction. + +{% enddocs %} + +{% docs evm_event_inputs %} + +The decoded event inputs for a given event. + +{% enddocs %} + +{% docs evm_event_removed %} + +Whether the event has been removed from the transaction. + +{% enddocs %} + +{% docs evm_log_id_events %} + +This is the primary key for this table. This is a concatenation of the transaction hash and the event index at which the event occurred. This field can be used within other event based tables such as `fact_transfers` & `ez_token_transfers`. + +{% enddocs %} + +{% docs evm_logs_contract_address %} + +The address interacted with for a given event. + +{% enddocs %} + +{% docs evm_logs_contract_name %} + +The name of the contract or token, where possible. + +{% enddocs %} + +{% docs evm_logs_data %} + +The un-decoded event data. + +{% enddocs %} + +{% docs evm_logs_tx_hash %} + +Transaction hash is a unique 66-character identifier that is generated when a transaction is executed. This field will not be unique in this table, as a given transaction can include multiple events. + +{% enddocs %} + +{% docs evm_topics %} + +The un-decoded event input topics. + +{% enddocs %} + +{% docs evm_topic_0 %} + +The first topic of the event, which is a unique identifier for the event. + +{% enddocs %} + +{% docs evm_topic_1 %} + +The second topic of the event, if applicable. + +{% enddocs %} + +{% docs evm_topic_2 %} + +The third topic of the event, if applicable. + +{% enddocs %} + +{% docs evm_topic_3 %} + +The fourth topic of the event, if applicable. + +{% enddocs %} diff --git a/models/doc_descriptions/fsc_evm/evm_deprecations.md b/models/doc_descriptions/fsc_evm/evm_deprecations.md new file mode 100644 index 0000000..331f1c2 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/evm_deprecations.md @@ -0,0 +1,203 @@ +{% docs evm_column_deprecation_notice %} + +This column is being deprecated for standardization purposes. Please update your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_hash %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `block_hash` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_block_hash %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_position %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `tx_position` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_tx_status %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `tx_succeeded` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_chain_id %} + +This column is being removed for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_identifier %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `trace_address` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_trace_status %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `trace_succeeded` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_log_id %} + +This column is being removed for standardization purposes. Please remove or update your queries with `CONCAT(tx_hash, '_', event_index)` to reconstruct `_log_id` by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_inserted_timestamp %} + +This column is being removed for standardization purposes. Please update your queries to use the `modified_timestamp` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_blockchain %} + +This column is being removed for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_block_header_json %} + +This column is being removed for standardization purposes and will be replaced with new columns associated with the keys extracted from this json. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_table_deprecation_notice %} + +This table is being deprecated for standardization purposes. Please update your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_table_deprecation_notice_fact_decoded_event_logs %} + +This table is being deprecated for standardization purposes. Please update your queries to use `ez_decoded_event_logs` instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_table_deprecation_notice_fact_decoded_traces %} + +This table is being deprecated for standardization purposes. Please update your queries to use `ez_decoded_traces` instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_table_deprecation_notice_fact_token_transfers %} + +This table is being deprecated for standardization purposes. Please update your queries to use `ez_token_transfers` instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_l1_state_root_tx_hash %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_l1_state_root_batch_index %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_l1_submission_tx_hash %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_l1_submission_batch_index %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_l1_submission_details %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_data %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_deposit_nonce %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_deposit_receipt_version %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_token_price %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_has_decimal %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_has_price %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{%docs evm_column_deprecation_notice_tokenid %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `token_id` column instead by March 10, 2025. + +{% enddocs %} + +{%docs evm_column_deprecation_notice_erc1155_value %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{%docs evm_column_deprecation_notice_nft_address %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `contract_address` column instead by March 10, 2025. + +{% enddocs %} + +{%docs evm_column_deprecation_notice_project_name %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `name` column instead by March 10, 2025. + +{% enddocs %} + +{%docs evm_column_deprecation_notice_event_type %} + +This column is being deprecated for standardization purposes. Please remove from your queries by March 10, 2025. + +{% enddocs %} + +{%docs evm_column_deprecation_notice_nft_from_address %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `from_address` column instead by March 10, 2025. + +{% enddocs %} + +{%docs evm_column_deprecation_notice_nft_to_address %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `to_address` column instead by March 10, 2025. + +{% enddocs %} diff --git a/models/doc_descriptions/fsc_evm/nft.md b/models/doc_descriptions/fsc_evm/nft.md new file mode 100644 index 0000000..dba8714 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/nft.md @@ -0,0 +1,587 @@ +{% docs evm_nft_events_table_doc %} + +This table contains NFT sales on this EVM blockchain. More NFT marketplaces will be added over time. + +{% enddocs %} + +{% docs evm_ez_nft_sales_table_doc %} + +This table contains NFT sale events from various marketplaces. + +{% enddocs %} + +{% docs evm_ez_nft_mint_table_doc %} + +This table contains NFT mint events, defined as NFT transfers from a burn address to an address, on this EVM blockchain. + +{% enddocs %} + +{% docs evm_ez_nft_transfer_table_doc %} + +This table contains NFT transfer events on this EVM blockchain. + +{% enddocs %} + +{% docs evm_lending_repayments_table_doc %} + +This table contains repayment events for loans backed by collateralized NFTs on this EVM blockchain. Events in this table can be a full repayment either by the borrower to get their collateral back or by a new lender to repay the borrower's previous loan. The latter is labeled as refinance where the same borrower takes on a new loan from a new lender and repays the past loan. The NFT collateral is still locked in this scenario. + +{% enddocs %} + +{% docs evm_nft_aggregator_name %} + +The name of the aggregator platform where the sale took place. If the sale did not take place via an aggregator platform, then the value will be null. + +{% enddocs %} + +{% docs evm_nft_amount %} + +The total amount, specified by the mint token address, used as payment to mint the specified number of NFTs corresponding to this token id. + +{% enddocs %} + +{% docs evm_nft_amount_usd %} + +The USD value of amount. + +{% enddocs %} + +{% docs evm_nft_block_no %} + +The block number at which the NFT event occurred. + +{% enddocs %} + +{% docs evm_nft_blocktime %} + +The block timestamp at which the NFT event occurred. + +{% enddocs %} + +{% docs evm_nft_buyer_address %} + +The address of the buyer of the NFT in the transaction. + +{% enddocs %} + +{% docs evm_nft_creator_fee %} + +The decimal adjusted amount of fees paid to the NFT collection as royalty payments for this NFT event in the transaction's currency. + +{% enddocs %} + +{% docs evm_nft_creator_fee_usd %} + +The amount of fees paid to the NFT collection as royalty payments for this NFT event in US dollars. + +{% enddocs %} + +{% docs evm_nft_currency_address %} + +The token contract address for this NFT event. This will be the native asset for native transactions. + +{% enddocs %} + +{% docs evm_nft_currency_symbol %} + +The token symbol for this NFT event. + +{% enddocs %} + +{% docs evm_nft_erc1155_value %} + +If the NFT is an ERC-1155 contract, this field may be one or greater, representing the number of tokens. If it is not an ERC-1155 token, this value will be null. + +{% enddocs %} + +{% docs evm_nft_event_index %} + +The event number within a transaction. + +{% enddocs %} + +{% docs evm_nft_event_type %} + +The type of NFT event in this transaction, either sale, bid_won, redeem, or mint. + +{% enddocs %} + +{% docs evm_nft_from_address %} + +The sending address of the NFT in the transaction. + +{% enddocs %} + +{% docs evm_nft_intra_event_index %} + +The order of events within a single event index. This is primarily used for ERC1155 NFT batch transfer events. + +{% enddocs %} + +{% docs evm_nft_metadata %} + +The token metadata for this NFT. This may be blank for many NFTs. We are working to expand this field. + +{% enddocs %} + +{% docs evm_nft_mint_count %} + +The number of NFTs minted in this event. + +{% enddocs %} + +{% docs evm_nft_mint_price %} + +The price paid in the native asset to mint the NFT(s). + +{% enddocs %} + +{% docs evm_nft_mint_price_usd %} + +The price paid in US dollars to mint the NFT(s). + +{% enddocs %} + +{% docs evm_nft_mints_symbol %} + +The symbol of the token supplied to mint the NFT, if applicable. This field may not handle all edge cases. + +{% enddocs %} + +{% docs evm_nft_mints_token_address %} + +The contract address of the token supplied to mint the NFT, if applicable. This field may not handle all edge cases. + +{% enddocs %} + +{% docs evm_nft_mints_token_price %} + +The decimal adjusted amount of tokens supplied within the same transaction to mint the NFT. This field may not handle all edge cases. + +{% enddocs %} + +{% docs evm_nft_mints_token_price_usd %} + +The amount of tokens supplied in US dollars within the same transaction to mint the NFT. This field may not handle all edge cases. + +{% enddocs %} + +{% docs evm_nft_nft_address %} + +The contract address of the NFT. + +{% enddocs %} + +{% docs evm_nft_origin_from %} + +The from address of this transaction. In most cases, this is the NFT buyer. However, for some more complex transactions, it may not be the NFT buyer. + +{% enddocs %} + +{% docs evm_nft_origin_sig %} + +The function signature of this transaction. + +{% enddocs %} + +{% docs evm_nft_origin_to %} + +The to address of this transaction. In most cases, this is the exchange contract. However, for some more complex NFT events, such as aggregate buys with tools, this may not be the exchange address. + +{% enddocs %} + +{% docs evm_nft_platform_address %} + +The address of the exchange used for the transaction. + +{% enddocs %} + +{% docs evm_nft_platform_exchange_version %} + +The version of the exchange contract used for the transaction. + +{% enddocs %} + +{% docs evm_nft_platform_fee %} + +The decimal adjusted amount of fees paid to the platform for this NFT event in the transaction's currency. There are cases where there are fees paid to multiple marketplaces. In those cases, the fee in the platform_fee column will only reflect the platform fee related to the platform exchange contract. + +{% enddocs %} + +{% docs evm_nft_platform_fee_usd %} + +The amount of fees paid to the platform for this NFT event in US dollars. There are cases where there are fees paid to multiple marketplaces. In those cases, the fee in the platform_fee column will only reflect the platform fee related to the platform exchange contract. + +{% enddocs %} + +{% docs evm_nft_platform_name %} + +The name of the exchange used for the trade. + +{% enddocs %} + +{% docs evm_nft_price %} + +The total price of the NFT, in the currency in which the transaction occurred and decimal adjusted where possible. Please note that the price of the NFT, after subtracting total fees, may not represent the net amount paid to the seller in all cases. You may refer to the platform fee description for more info. + +{% enddocs %} + +{% docs evm_nft_price_usd %} + +The total price of the NFT in US dollars. This will be 0 for tokens without a decimal adjustment or hourly price. Please note that the price of the NFT, after subtracting total fees, may not represent the net amount paid to the seller in all cases. You may refer to the platform fee description for more info. + +{% enddocs %} + +{% docs evm_nft_project_name %} + +The name of the NFT project. This field, along with metadata, will be filled in over time. + +{% enddocs %} + +{% docs evm_nft_seller_address %} + +The address of the seller of the NFT in the transaction. + +{% enddocs %} + +{% docs evm_nft_to_address %} + +The receiving address of the NFT in the transaction. + +{% enddocs %} + +{% docs evm_nft_tokenid %} + +The token ID for this NFT contract. + +{% enddocs %} + +{% docs evm_nft_total_fees %} + +The total amount of fees paid relating to the NFT purchase in the transaction currency. This includes royalty payments to creators and platform fees. Please note, this does not include the gas fee. + +{% enddocs %} + +{% docs evm_nft_total_fees_usd %} + +The total amount of fees paid relating to the NFT purchase in US dollars. This includes royalty payments to creators and platform fees. Please note, this does not include the gas fee. + +{% enddocs %} + +{% docs evm_nft_tx_fee %} + +The gas fee for this transaction in the native asset. + +{% enddocs %} + +{% docs evm_nft_tx_fee_usd %} + +The gas fee for this transaction in US dollars. + +{% enddocs %} + +{% docs evm_nft_tx_hash %} + +The transaction hash for the NFT event. This is not necessarily unique in this table as a transaction may contain multiple NFT events. + +{% enddocs %} + +{% docs evm_nft_lending_liquidations_table_doc %} + +This table contains liquidation events for loans backed by collateralized NFTs on this EVM blockchain. This typically means the lender of the loan closes the loan and receives the NFT collateral. + +{% enddocs %} + +{% docs evm_platform_address %} + +The contract address of the platform's lending contract. + +{% enddocs %} + +{% docs evm_platform_name %} + +The name of the platform. + +{% enddocs %} + +{% docs evm_platform_exchange_version %} + +The version of the platform's lending contract. + +{% enddocs %} + +{% docs evm_loanid %} + +The ID associated with the loan, often times tied to the borrower's address and collateral. This ID can be used as a unique identifier when tracking active loans. However, note that refinances can happen while still maintaining the same loanId. For some platforms, loanids of previously paid loans are reused hence they can't be reliably used as a unique identifier without appropriate timestamp filters. Instead, use the unique_loan_id column. + +{% enddocs %} + +{% docs evm_unique_loan_id %} + +The unique ID that can be used to represent a loan within the same platform. For the same loan, the value of this ID will remain the same across the loans taken, liquidations and repayment tables. For some platforms where the lender is issued a promissory note, the lender can send this note to any address, making the receiver the new lender. However, the unique_loan_id still remains the same although the final lender is different. The unique_loan_id changes only if the loanId and lender changes which would also indicate the previous loan has been fully paid off. + +{% enddocs %} + +{% docs evm_lender_address %} + +The address that gives out a loan to the borrower. When a loan is issued, a promissory note (an ERC721) is issued to the lender. The lender can transfer this note to any address which makes any receiving address the new lender. + +{% enddocs %} + +{% docs evm_borrower_address %} + +The address that receives the loan and has an NFT locked as collateral. + +{% enddocs %} + +{% docs evm_nft_address %} + +The address of the NFT used as collateral. + +{% enddocs %} + +{% docs evm_tokenid %} + +The tokenId of the NFT used as collateral. + +{% enddocs %} + +{% docs evm_loan_token_address %} + +The contract address of what the loan is denominated in. This could be either the native asset or other tokens. + +{% enddocs %} + +{% docs evm_loan_token_symbol %} + +The symbol of the loan token address. + +{% enddocs %} + +{% docs evm_principal_unadj %} + +The principal amount of the loan taken with unadjusted decimal places. + +{% enddocs %} + +{% docs evm_principal %} + +The principal amount of the loan taken with adjusted decimal places. + +{% enddocs %} + +{% docs evm_principal_usd %} + +The principal amount of the loan taken in USD terms. + +{% enddocs %} + +{% docs evm_interest_rate %} + +The non-annualized rate charged by the lender on the principal amount of the loan denominated in percentage (%). For fixed term loans, it is calculated by taking the difference between total debt and principal amount divided by principal amount. For perpetual term loans, interest rate is usually on an annual basis and total debt is calculated prorated. + +{% enddocs %} + +{% docs evm_apr %} + +The annualized interest rate denominated in percentage (%). + +{% enddocs %} + +{% docs evm_loan_term_type %} + +The type of loan terms, could be either a fixed loan or a perpetual loan. A fixed term loan has a fixed repayment date while a perpetual loan does not. + +{% enddocs %} + +{% docs evm_loan_start_timestamp %} + +The timestamp of when the loan offer is accepted. + +{% enddocs %} + +{% docs evm_loan_due_timestamp %} + +The timestamp of when the loan is due. For perpetual term loan, the value will be null. + +{% enddocs %} + +{% docs evm_loan_tenure %} + +The tenure of the loan denominated in seconds. For perpetual term loan, the value will be null. + +{% enddocs %} + +{% docs evm_lending_loans %} + +This table contains NFT lending events for loans backed by collateralized NFTs on this EVM blockchain. This could be depositing an NFT and taking out a loan or using the Buy Now Pay Later (BNPL) feature to take a loan out of the newly bought NFT. This NFT will remain locked until the loan is cleared. + +{% enddocs %} + +{% docs evm_nft_lending_event_type %} + +There are 2 types of loan creation events. It can either be a new loan or a refinance of an existing loan. Note that renegotiation events are categorized as refinance events in this table. Old loans are repaid and new loan ids are reissued so these would be new loan entries in this table. + +{% enddocs %} + +{% docs evm_debt_unadj %} + +The total debt of the loan (principal amount plus interests) with unadjusted decimal places. + +{% enddocs %} + +{% docs evm_debt %} + +The total debt of the loan (principal amount plus interests) with adjusted decimal places. + +{% enddocs %} + +{% docs evm_debt_usd %} + +The total debt of the loan (principal amount plus interests) in USD terms. + +{% enddocs %} + +{% docs evm_platform_fee_unadj %} + +The fee charged by the lending platform with unadjusted decimal places. + +{% enddocs %} + +{% docs evm_platform_fee %} + +The fee charged by the lending platform with adjusted decimal places. + +{% enddocs %} + +{% docs evm_platform_fee_usd %} + +The fee charged by the lending platform in USD terms. + +{% enddocs %} + +{% docs evm_mev_arbitrage %} + +This table contains the financial metrics from NFT arbitrage transactions including cost, revenue and profits. + +{% enddocs %} + +{% docs evm_mev_searcher %} + +The address of the MEV finder, taken from the origin address that initiated the transaction. + +{% enddocs %} + +{% docs evm_mev_contract %} + +The contract address that the MEV searcher uses to execute mev transactions, taken from the origin to address of the transaction. + +{% enddocs %} + +{% docs evm_cost_usd %} + +The total cost in USD to purchase the NFT(s) in the transaction. + +{% enddocs %} + +{% docs evm_revenue_usd %} + +The total revenue in USD from selling the NFT(s) and other related tokens in the transaction. + +{% enddocs %} + +{% docs evm_miner_tip_usd %} + +The total amount in USD sent to the block miner/builder as a tip to include the transaction in the block. + +{% enddocs %} + +{% docs evm_profit_usd %} + +The remainder in USD after subtracting cost, miner tip and transaction fee from revenue. + +{% enddocs %} + +{% docs evm_funding_source %} + +The source of the funds used to perform the arbitrage. Currently there are three sources. Existing funds indicate that the user uses funds that are already in their balance while flash loan and flash swaps indicate that the user took a flash loan in the transaction. + +{% enddocs %} + +{% docs evm_arbitrage_direction %} + +The direction in which the arbitrage is performed. There are two possibilities of origin and destination: pool and marketplace. Pool represents marketplaces where users swap from a pool whereas marketplace represents regular marketplaces that are not pool-based. + +{% enddocs %} + +{% docs evm_fact_mev_arbitrage_events %} + +This table contains information about the NFTs involved in arbitrage transactions, documenting events from both the buy and sell sides. + +{% enddocs %} + +{% docs evm_trade_side %} + +The side of the trade that this event represents. This can be either buy or sell. Buy would represent the events where NFTs are bought while sell would present the events where the bought NFTs are sold. Note that the number of events for buy and sell may not be the same for a given transaction. + +{% enddocs %} + +{% docs evm_dim_nft_collection_metadata %} + +This table contains the metadata for popular NFT collections on this EVM blockchain. + +{% enddocs %} + +{% docs evm_nft_blockchain %} + +Blockchain where the NFT metadata is retrieved from. + +{% enddocs %} + +{% docs evm_collection_name %} + +The name for this NFT collection. + +{% enddocs %} + +{% docs evm_tokenid_name %} + +The name for this specific tokenId. This may be the same for all tokenIds within the same collection. + +{% enddocs %} + +{% docs evm_traits %} + +The traits for this tokenId in a key-value pair format. + +{% enddocs %} + +{% docs evm_tokenid_description %} + +The description for this specific tokenId. This may be the same for all tokenIds within the same collection. + +{% enddocs %} + +{% docs evm_tokenid_image_url %} + +The url of the image for this tokenId. + +{% enddocs %} + +{% docs evm_nft_address_tokenid %} + +The concatenation of NFT address and tokenId. + +{% enddocs %} + +{% docs evm_nft_quantity %} + +The number of NFTs transferred in this transaction. If it is an ERC1155, there can be multiple NFTs transferred in a single transaction. If it is an ERC721, this will be 1. + +{% enddocs %} + +{% docs evm_nft_token_standard %} + +The token standard of the NFT. + +{% enddocs %} diff --git a/models/doc_descriptions/fsc_evm/traces.md b/models/doc_descriptions/fsc_evm/traces.md new file mode 100644 index 0000000..cebd31a --- /dev/null +++ b/models/doc_descriptions/fsc_evm/traces.md @@ -0,0 +1,125 @@ +{% docs evm_traces_table_doc %} + +This table contains flattened trace data for internal contract calls. User-defined functions (UDFs) are available to decode hex encoded fields, including `utils.udf_hex_to_int()`. + +{% enddocs %} + +{% docs evm_traces_block_no %} + +The block number of this transaction. + +{% enddocs %} + +{% docs evm_traces_blocktime %} + +The block timestamp of this transaction. + +{% enddocs %} + +{% docs evm_traces_call_data %} + +The raw JSON data for this trace. + +{% enddocs %} + +{% docs evm_traces_value %} + +The amount of the native asset transferred in this trace. + +{% enddocs %} + +{% docs evm_traces_from %} + +The sending address of this trace. This is not necessarily the from address of the transaction. + +{% enddocs %} + +{% docs evm_traces_gas %} + +The gas supplied for this trace. + +{% enddocs %} + +{% docs evm_traces_gas_used %} + +The gas used for this trace. + +{% enddocs %} + +{% docs evm_traces_identifier %} + +This field represents the position and type of the trace within the transaction. + +{% enddocs %} + +{% docs evm_trace_index %} + +The index of the trace within the transaction. + +{% enddocs %} + +{% docs evm_traces_input %} + +The input data for this trace. + +{% enddocs %} + +{% docs evm_traces_output %} + +The output data for this trace. + +{% enddocs %} + +{% docs evm_sub_traces %} + +The amount of nested sub traces for this trace. + +{% enddocs %} + +{% docs evm_traces_to %} + +The receiving address of this trace. This is not necessarily the to address of the transaction. + +{% enddocs %} + +{% docs evm_traces_tx_hash %} + +The transaction hash for the trace. Please note, this is not necessarily unique in this table as transactions frequently have multiple traces. + +{% enddocs %} + +{% docs evm_traces_type %} + +The type of internal transaction. Common trace types are `CALL`, `DELEGATECALL`, and `STATICCALL`. + +{% enddocs %} + +{% docs evm_trace_succeeded %} + +The boolean value representing if the trace succeeded. + +{% enddocs %} + +{% docs evm_trace_error_reason %} + +The reason for the trace failure, if any. + +{% enddocs %} + +{% docs evm_revert_reason %} + +The reason for the revert, if available. + +{% enddocs %} + +{% docs evm_trace_address %} + +The trace address for this trace. + +{% enddocs %} + +{% docs evm_trace_type %} + +The type of internal transaction. Common trace types are `CALL`, `DELEGATECALL`, and `STATICCALL`. + +{% enddocs %} diff --git a/models/doc_descriptions/fsc_evm/transactions.md b/models/doc_descriptions/fsc_evm/transactions.md new file mode 100644 index 0000000..a5b74ea --- /dev/null +++ b/models/doc_descriptions/fsc_evm/transactions.md @@ -0,0 +1,188 @@ +{% docs evm_tx_table_doc %} + +This table contains transaction level data for this EVM blockchain. Each transaction will have a unique transaction hash, along with transaction fees and a value transferred in the native asset when applicable. Transactions may be native asset transfers or interactions with contract addresses. For more information, please see [The Ethereum Organization - Transactions](https://ethereum.org/en/developers/docs/transactions/) + +Below are the specific native tokens that correspond to each EVM chain: + +| Status | Description | +| --------- | ----------- | +| ETHEREUM | ETH | +| BINANCE | BNB | +| POLYGON | POL | +| AVALANCHE | AVAX | +| ARBITRUM | ETH | +| OPTIMISM | ETH | +| GNOSIS | xDAI | +| KAIA | KLAY | +| SEI | SEI | +| CORE | CORE | + +{% enddocs %} + +{% docs evm_cumulative_gas_used %} + +The total amount of gas used when this transaction was executed in the block. + +{% enddocs %} + +{% docs evm_tx_block_hash %} + +Block hash is a unique 66-character identifier that is generated when a block is produced. + +{% enddocs %} + +{% docs evm_tx_fee %} + +Amount paid to validate the transaction in the native asset. + +{% enddocs %} + +{% docs evm_tx_gas_limit %} + +Maximum amount of gas allocated for the transaction. + +{% enddocs %} + +{% docs evm_tx_gas_price %} + +Cost per unit of gas in Gwei. + +{% enddocs %} + +{% docs evm_tx_gas_used %} + +Gas used by the transaction. + +{% enddocs %} + +{% docs evm_tx_hash %} + +Transaction hash is a unique 66-character identifier that is generated when a transaction is executed. + +{% enddocs %} + +{% docs evm_tx_input_data %} + +This column contains additional data for this transaction, and is commonly used as part of a contract interaction or as a message to the recipient. + +{% enddocs %} + +{% docs evm_tx_json %} + +This JSON column contains the transaction details, including event logs. + +{% enddocs %} + +{% docs evm_tx_nonce %} + +The number of transactions sent from a given address. + +{% enddocs %} + +{% docs evm_tx_origin_sig %} + +The function signature of the call that triggered this transaction. + +{% enddocs %} + +{% docs evm_origin_sig %} + +The function signature of the contract call that triggered this transaction. + +{% enddocs %} + +{% docs evm_tx_position %} + +The position of the transaction within the block. + +{% enddocs %} + +{% docs evm_tx_status %} + +Status of the transaction. + +{% enddocs %} + +{% docs evm_value %} + +The value transacted in the native asset. + +{% enddocs %} + +{% docs evm_effective_gas_price %} + +The total base charge plus tip paid for each unit of gas, in Gwei. + +{% enddocs %} + +{% docs evm_max_fee_per_gas %} + +The maximum fee per gas of the transaction, in Gwei. + +{% enddocs %} + +{% docs evm_max_priority_fee_per_gas %} + +The maximum priority fee per gas of the transaction, in Gwei. + +{% enddocs %} + +{% docs evm_r %} + +The r value of the transaction signature. + +{% enddocs %} + +{% docs evm_s %} + +The s value of the transaction signature. + +{% enddocs %} + +{% docs evm_v %} + +The v value of the transaction signature. + +{% enddocs %} + +{% docs evm_tx_succeeded %} + +Whether the transaction was successful, returned as a boolean. + +{% enddocs %} + +{% docs evm_tx_fee_precise %} + +The precise amount of the transaction fee. This is returned as a string to avoid precision loss. + +{% enddocs %} + +{% docs evm_tx_type %} + +The type of transaction. + +{% enddocs %} + +{% docs evm_mint %} + +The minting event associated with the transaction + +{% enddocs %} + +{% docs evm_source_hash %} + +The hash of the source transaction that created this transaction + +{% enddocs %} + +{% docs evm_eth_value %} + +The eth value for the transaction + +{% enddocs %} + +{% docs evm_chain_id %} + +The unique identifier for the chain the transaction was executed on. + +{% enddocs %} diff --git a/models/doc_descriptions/fsc_evm/transfers.md b/models/doc_descriptions/fsc_evm/transfers.md new file mode 100644 index 0000000..eafaca3 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/transfers.md @@ -0,0 +1,144 @@ +{% docs evm_transfers_table_doc %} + +This table contains all native asset transfers, including equivalent USD amounts. The origin addresses correspond to the to and from addresses from the `fact_transactions` table. The `identifier` and `tx_hash` columns relate this table back to `fact_traces`, which contains more details on the transfers. + +Below are the specific native tokens that correspond to each EVM chain: + +| Status | Description | +| --------- | ----------- | +| ETHEREUM | ETH | +| BINANCE | BNB | +| POLYGON | POL | +| AVALANCHE | AVAX | +| ARBITRUM | ETH | +| OPTIMISM | ETH | +| GNOSIS | xDAI | +| KAIA | KLAY | + +{% enddocs %} + +{% docs evm_transfer_table_doc %} + +This table contains all events in the `fact_token_transfers` table, along with joined columns such as token price, symbol, and decimals where possible that allow for easier analysis of token transfer events. Please note native asset transfers are not included here. + +{% enddocs %} + +{% docs evm_fact_token_transfers_table_doc %} + +This fact-based table contains emitted event logs for ERC-20 Token Transfers (e.g. `Transfer`: topic_0 = `0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef`). The contract address is the token transferred, and the raw amount field is the amount of tokens transferred. The values in this table are not decimal adjusted, instead please use `core.dim_contracts` or `core.ez_token_transfers` to reference decimals or decimal adjusted values. This table does not contain ERC-721 and ERC-1155 token transfers, instead please use `nft.ez_nft_transfers`. Additionally, this table does not contain transfers of the chain's native asset, instead please use `core.ez_native_transfers`. + +{% enddocs %} + +{% docs evm_ez_token_transfers_table_doc %} + +This convenience table contains emitted event logs for ERC-20 Token Transfers (e.g. `Transfer`: topic_0 = `0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef`), including decimal adjusted values, USD values, and other helpful token metadata where available for each transfer event. The contract address is the token transferred, and the raw amount field is the amount of tokens transferred. Note, this table does not contain ERC-721 and ERC-1155 token transfers, instead please use `nft.ez_nft_transfers`. Additionally, this table does not contain transfers of the chain's native asset, instead please use `core.ez_native_transfers`. + +{% enddocs %} + +{% docs evm_ez_native_transfers_table_doc %} + +This convenience table contains all transfers for the chain's native asset, sourced from internal traces (`core.fact_traces`), and includes decimal adjusted and USD values where available. The origin addresses correspond to the to and from addresses in the `core.fact_transactions` table. Note, this table does not contain ERC-721 and ERC-1155 token transfers, instead please use `nft.ez_nft_transfers`. + +{% enddocs %} + +{% docs evm_amount %} + +Native asset value transferred, this is imported from the fsc-evm package. + +{% enddocs %} + +{% docs evm_amount_usd %} + +Native asset value transferred, in USD. + +{% enddocs %} + +{% docs evm_log_id_transfers %} + +This is the primary key for this table. This is a concatenation of the transaction hash and the event index at which the transfer event occurred. This field can be used to find more details on the event within the `fact_event_logs` table. + +{% enddocs %} + +{% docs evm_origin_from %} + +The from address at the transaction level. + +{% enddocs %} + +{% docs evm_origin_to %} + +The to address at the transaction level. + +{% enddocs %} + +{% docs evm_transfer_amount %} + +The decimal transformed amount for this token. Tokens without a decimal adjustment will be nulled out here. + +{% enddocs %} + +{% docs evm_transfer_amount_precise %} + +The decimal transformed amount for this token returned as a string to preserve precision. Tokens without a decimal adjustment will be nulled out here. + +{% enddocs %} + +{% docs evm_transfer_amount_usd %} + +The amount in US dollars for this transfer at the time of the transfer. Tokens without a decimal adjustment or price will be nulled out here. + +{% enddocs %} + +{% docs evm_transfer_contract_address %} + +Contract address of the token being transferred. + +{% enddocs %} + +{% docs evm_transfer_from_address %} + +The sending address of this transfer. + +{% enddocs %} + +{% docs evm_transfer_has_decimal %} + +Whether or not our contracts model contains the necessary decimal adjustment for this token. + +{% enddocs %} + +{% docs evm_transfer_has_price %} + +Whether or not our prices model contains this hourly token price. + +{% enddocs %} + +{% docs evm_transfer_raw_amount %} + +The amount of tokens transferred. This value is not decimal adjusted. + +{% enddocs %} + +{% docs evm_transfer_raw_amount_precise %} + +The amount of tokens transferred returned as a string to preserve precision. This value is not decimal adjusted. + +{% enddocs %} + +{% docs evm_transfer_to_address %} + +The receiving address of this transfer. This can be a contract address. + +{% enddocs %} + +{% docs evm_transfer_token_price %} + +The price, if available, for this token at the transfer time. + +{% enddocs %} + +{% docs evm_transfer_tx_hash %} + +Transaction hash is a unique 66-character identifier that is generated when a transaction is executed. This will not be unique in this table as a transaction could include multiple transfer events. + +{% enddocs %} diff --git a/models/doc_descriptions/transfers/evm_transfers_table_doc.md b/models/doc_descriptions/transfers/evm_transfers_table_doc.md deleted file mode 100644 index 280f6f8..0000000 --- a/models/doc_descriptions/transfers/evm_transfers_table_doc.md +++ /dev/null @@ -1,17 +0,0 @@ -{% docs evm_fact_token_transfers_table_doc %} - -This fact-based table contains emitted event logs for ERC-20 Token Transfers (e.g. `Transfer`: topic_0 = `0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef`). The contract address is the token transferred, and the raw amount field is the amount of tokens transferred. The values in this table are not decimal adjusted, instead please use `core.dim_contracts` or `core.ez_token_transfers` to reference decimals or decimal adjusted values. This table does not contain ERC-721 and ERC-1155 token transfers, instead please use `nft.ez_nft_transfers`. Additionally, this table does not contain transfers of the chain's native asset, instead please use `core.ez_native_transfers`. - -{% enddocs %} - -{% docs evm_ez_token_transfers_table_doc %} - -This convenience table contains emitted event logs for ERC-20 Token Transfers (e.g. `Transfer`: topic_0 = `0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef`), including decimal adjusted values, usd values, and other helpful token metadata where available for each transfer event. The contract address is the token transferred, and the raw amount field is the amount of tokens transferred. Note, this table does not contain ERC-721 and ERC-1155 token transfers, instead please use `nft.ez_nft_transfers`. Additionally, this table does not contain transfers of the chain's native asset, instead please use `core.ez_native_transfers`. - -{% enddocs %} - -{% docs evm_ez_native_transfers_table_doc %} - -This convenience table contains all transfers for the chain's native asset, sourced from internal traces (`core.fact_traces`), and includes decimal adjusted and usd values where available. The origin addresses correspond to the to and from addresses in the `core.fact_transactions` table. Note, this table does not contain ERC-721 and ERC-1155 token transfers, instead please use `nft.ez_nft_transfers`. - -{% enddocs %} \ No newline at end of file diff --git a/models/gold/core/core__ez_decoded_event_logs.sql b/models/gold/core/core__ez_decoded_event_logs.sql index 1e1e3f6..d5b365a 100644 --- a/models/gold/core/core__ez_decoded_event_logs.sql +++ b/models/gold/core/core__ez_decoded_event_logs.sql @@ -1,35 +1,70 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true } +{{ config ( + materialized = "incremental", + unique_key = "ez_decoded_event_logs_id", + incremental_strategy = 'delete+insert', + cluster_by = "block_timestamp::date", + incremental_predicates = [standard_predicate()], + post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(ez_decoded_event_logs_id, contract_name, contract_address)", + tags = ['decoded_logs'] ) }} SELECT block_number, block_timestamp, tx_hash, + {# tx_position, #} -- new column event_index, contract_address, - token_name AS contract_name, - event_name, - decoded_flat AS decoded_log, - decoded_data AS full_decoded_log, - origin_function_signature, - origin_from_address, - origin_to_address, topics, + topics [0] :: STRING AS topic_0, + --new column + topics [1] :: STRING AS topic_1, + --new column + topics [2] :: STRING AS topic_2, + --new column + topics [3] :: STRING AS topic_3, + --new column DATA, event_removed, - tx_status, + origin_from_address, + origin_to_address, + origin_function_signature, + CASE + WHEN tx_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS tx_succeeded, + event_name, + decoded_data AS full_decoded_log, + decoded_flat AS decoded_log, + token_name AS contract_name, COALESCE ( decoded_logs_id, {{ dbt_utils.generate_surrogate_key( ['tx_hash', 'event_index'] ) }} ) AS ez_decoded_event_logs_id, - GREATEST(COALESCE(l.inserted_timestamp, '2000-01-01'), COALESCE(C.inserted_timestamp, '2000-01-01')) AS inserted_timestamp, - GREATEST(COALESCE(l.modified_timestamp, '2000-01-01'), COALESCE(C.modified_timestamp, '2000-01-01')) AS modified_timestamp +{% if is_incremental() %} + SYSDATE() AS inserted_timestamp, + SYSDATE() AS modified_timestamp, +{% else %} + GREATEST(block_timestamp, dateadd('day', -10, SYSDATE())) AS inserted_timestamp, + GREATEST(block_timestamp, dateadd('day', -10, SYSDATE())) AS modified_timestamp, +{% endif %} + tx_status --deprecate FROM {{ ref('silver__decoded_logs') }} l LEFT JOIN {{ ref('silver__contracts') }} C USING (contract_address) +WHERE 1=1 + + {% if is_incremental() %} + AND l.modified_timestamp > ( + SELECT + COALESCE( + MAX(modified_timestamp), + '2000-01-01'::TIMESTAMP + ) + FROM + {{ this }} + ) + {% endif %} \ No newline at end of file diff --git a/models/gold/core/core__ez_decoded_event_logs.yml b/models/gold/core/core__ez_decoded_event_logs.yml index c549c67..c63c89c 100644 --- a/models/gold/core/core__ez_decoded_event_logs.yml +++ b/models/gold/core/core__ez_decoded_event_logs.yml @@ -51,6 +51,14 @@ models: description: '{{ doc("avax_origin_to") }}' - name: TOPICS description: '{{ doc("avax_topics") }}' + - name: TOPIC_0 + description: '{{ doc("evm_topic_0") }}' + - name: TOPIC_1 + description: '{{ doc("evm_topic_1") }}' + - name: TOPIC_2 + description: '{{ doc("evm_topic_2") }}' + - name: TOPIC_3 + description: '{{ doc("evm_topic_3") }}' - name: DATA description: '{{ doc("avax_logs_data") }}' - name: EVENT_REMOVED @@ -58,7 +66,7 @@ models: - name: TX_STATUS description: '{{ doc("avax_tx_status") }}' - name: EZ_DECODED_EVENT_LOGS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP description: '{{ doc("inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP diff --git a/models/gold/core/core__ez_native_transfers.sql b/models/gold/core/core__ez_native_transfers.sql index 14d2cac..5f8cc7f 100644 --- a/models/gold/core/core__ez_native_transfers.sql +++ b/models/gold/core/core__ez_native_transfers.sql @@ -5,34 +5,23 @@ ) }} SELECT - tx_hash, block_number, block_timestamp, + tx_hash, tx_position, trace_index, - identifier, - origin_from_address, - origin_to_address, - origin_function_signature, from_address, to_address, amount, amount_precise_raw, amount_precise, amount_usd, - COALESCE ( - native_transfers_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'trace_index'] - ) }} - ) AS ez_native_transfers_id, - COALESCE( - inserted_timestamp, - '2000-01-01' - ) AS inserted_timestamp, - COALESCE( - modified_timestamp, - '2000-01-01' - ) AS modified_timestamp + origin_from_address, + origin_to_address, + origin_function_signature, + native_transfers_id AS ez_native_transfers_id, + inserted_timestamp, + modified_timestamp, + identifier -- deprecate FROM {{ ref('silver__native_transfers') }} diff --git a/models/gold/core/core__ez_native_transfers.yml b/models/gold/core/core__ez_native_transfers.yml index 7eb1f1d..5bd902d 100644 --- a/models/gold/core/core__ez_native_transfers.yml +++ b/models/gold/core/core__ez_native_transfers.yml @@ -15,7 +15,7 @@ models: - name: TRACE_INDEX description: '{{ doc("avax_trace_index") }}' - name: IDENTIFIER - description: '{{ doc("avax_traces_identifier") }}' + description: '{{ doc("evm_column_deprecation_notice_identifier") }}' - name: ORIGIN_FROM_ADDRESS description: '{{ doc("avax_origin_from") }}' - name: ORIGIN_TO_ADDRESS diff --git a/models/gold/core/core__ez_token_transfers.sql b/models/gold/core/core__ez_token_transfers.sql index 11def73..e62fc4c 100644 --- a/models/gold/core/core__ez_token_transfers.sql +++ b/models/gold/core/core__ez_token_transfers.sql @@ -22,11 +22,6 @@ SELECT amount_usd, decimals, symbol, - token_price, - has_decimal, - has_price, - _log_id, - _inserted_timestamp, COALESCE ( transfers_id, {{ dbt_utils.generate_surrogate_key( @@ -40,6 +35,15 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp + ) AS modified_timestamp, + token_price, + -- deprecate + has_decimal, + -- deprecate + has_price, + -- deprecate + _log_id, + -- deprecate + _inserted_timestamp -- deprecate FROM - {{ ref('silver__transfers') }} + {{ ref('silver__transfers') }} \ No newline at end of file diff --git a/models/gold/core/core__ez_token_transfers.yml b/models/gold/core/core__ez_token_transfers.yml index 6ecc8aa..2d9f130 100644 --- a/models/gold/core/core__ez_token_transfers.yml +++ b/models/gold/core/core__ez_token_transfers.yml @@ -31,7 +31,7 @@ models: - name: AMOUNT_PRECISE description: '{{ doc("avax_transfer_amount_precise") }}' - name: TOKEN_PRICE - description: '{{ doc("avax_transfer_token_price") }}' + description: '{{ doc("evm_column_deprecation_notice_token_price") }}' - name: AMOUNT description: '{{ doc("avax_transfer_amount") }}' - name: AMOUNT_USD @@ -43,16 +43,16 @@ models: - name: TOKEN_PRICE description: '{{ doc("avax_transfer_token_price") }}' - name: HAS_DECIMAL - description: '{{ doc("avax_transfer_has_decimal") }}' + description: '{{ doc("evm_column_deprecation_notice_has_decimal") }}' - name: HAS_PRICE - description: '{{ doc("avax_transfer_has_price") }}' + description: '{{ doc("evm_column_deprecation_notice_has_price") }}' - name: _LOG_ID - description: '{{ doc("internal_column") }}' + description: '{{ doc("evm_column_deprecation_notice_log_id") }}' - name: _INSERTED_TIMESTAMP - description: '{{ doc("internal_column") }}' + description: '{{ doc("evm_column_deprecation_notice_inserted_timestamp") }}' - name: EZ_TOKEN_TRANSFERS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/core/core__fact_blocks.sql b/models/gold/core/core__fact_blocks.sql index bae20fe..adf9494 100644 --- a/models/gold/core/core__fact_blocks.sql +++ b/models/gold/core/core__fact_blocks.sql @@ -6,21 +6,54 @@ SELECT block_number, + hash as block_hash, block_timestamp, 'mainnet' AS network, - 'avalanche' AS blockchain, tx_count, + size, + miner, + extra_data, + parent_hash, + gas_used, + gas_limit, + base_fee_per_gas, difficulty, total_difficulty, - extra_data, - gas_limit, - gas_used, - HASH, - parent_hash, - receipts_root, sha3_uncles, - SIZE, uncles AS uncle_blocks, + nonce, + receipts_root, + state_root, + transactions_root, + logs_bloom, + COALESCE ( + blocks_id, + {{ dbt_utils.generate_surrogate_key( + ['block_number'] + ) }} + ) AS fact_blocks_id, + GREATEST( + COALESCE( + A.inserted_timestamp, + '2000-01-01' + ), + COALESCE( + d.inserted_timestamp, + '2000-01-01' + ) + ) AS inserted_timestamp, + GREATEST( + COALESCE( + A.modified_timestamp, + '2000-01-01' + ), + COALESCE( + d.modified_timestamp, + '2000-01-01' + ) + ) AS modified_timestamp, + 'avalanche' AS blockchain, + hash, OBJECT_CONSTRUCT( 'baseFeePerGas', base_fee_per_gas, @@ -60,33 +93,7 @@ SELECT transactions_root, 'uncles', uncles - ) AS block_header_json, - COALESCE ( - blocks_id, - {{ dbt_utils.generate_surrogate_key( - ['block_number'] - ) }} - ) AS fact_blocks_id, - GREATEST( - COALESCE( - A.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - d.inserted_timestamp, - '2000-01-01' - ) - ) AS inserted_timestamp, - GREATEST( - COALESCE( - A.modified_timestamp, - '2000-01-01' - ), - COALESCE( - d.modified_timestamp, - '2000-01-01' - ) - ) AS modified_timestamp + ) AS block_header_json FROM {{ ref('silver__blocks') }} A LEFT JOIN {{ ref('silver__tx_count') }} diff --git a/models/gold/core/core__fact_blocks.yml b/models/gold/core/core__fact_blocks.yml index 158801b..a78f9a5 100644 --- a/models/gold/core/core__fact_blocks.yml +++ b/models/gold/core/core__fact_blocks.yml @@ -1,46 +1,62 @@ version: 2 models: - name: core__fact_blocks - description: '{{ doc("avax_blocks_table_doc") }}' + description: '{{ doc("evm_blocks_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("avax_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("avax_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: NETWORK - description: '{{ doc("avax_network") }}' + description: '{{ doc("evm_network") }}' - name: BLOCKCHAIN - description: '{{ doc("avax_blockchain") }}' + description: '{{ doc("evm_column_deprecation_notice_blockchain") }}' + - name: MINER + description: '{{ doc("evm_miner") }}' + - name: NONCE + description: '{{ doc("evm_blocks_nonce") }}' - name: TX_COUNT - description: '{{ doc("avax_tx_count") }}' + description: '{{ doc("evm_tx_count") }}' - name: DIFFICULTY - description: '{{ doc("avax_difficulty") }}' + description: '{{ doc("evm_difficulty") }}' - name: TOTAL_DIFFICULTY - description: '{{ doc("avax_total_difficulty") }}' + description: '{{ doc("evm_total_difficulty") }}' - name: EXTRA_DATA - description: '{{ doc("avax_extra_data") }}' + description: '{{ doc("evm_extra_data") }}' - name: GAS_LIMIT - description: '{{ doc("avax_gas_limit") }}' + description: '{{ doc("evm_gas_limit") }}' - name: GAS_USED - description: '{{ doc("avax_gas_used") }}' + description: '{{ doc("evm_gas_used") }}' + - name: BASE_FEE_PER_GAS + description: '{{ doc("evm_base_fee_per_gas") }}' + - name: BLOCK_HASH + description: '{{ doc("evm_blocks_hash") }}' - name: HASH - description: '{{ doc("avax_blocks_hash") }}' + description: '{{ doc("evm_column_deprecation_notice_hash") }}' - name: PARENT_HASH - description: '{{ doc("avax_parent_hash") }}' + description: '{{ doc("evm_parent_hash") }}' - name: RECEIPTS_ROOT - description: '{{ doc("avax_receipts_root") }}' + description: '{{ doc("evm_receipts_root") }}' - name: SHA3_UNCLES - description: '{{ doc("avax_sha3_uncles") }}' + description: '{{ doc("evm_sha3_uncles") }}' - name: SIZE - description: '{{ doc("avax_size") }}' + description: '{{ doc("evm_size") }}' - name: UNCLE_BLOCKS - description: '{{ doc("avax_uncle_blocks") }}' + description: '{{ doc("evm_uncle_blocks") }}' + - name: STATE_ROOT + description: '{{ doc("evm_state_root") }}' + - name: TRANSACTIONS_ROOT + description: '{{ doc("evm_transactions_root") }}' + - name: LOGS_BLOOM + description: '{{ doc("evm_logs_bloom") }}' - name: BLOCK_HEADER_JSON - description: '{{ doc("avax_block_header_json") }}' + description: '{{ doc("evm_column_deprecation_notice_block_header_json") }}' + - name: BASE_FEE_PER_GAS + description: '{{ doc("evm_base_fee_per_gas") }}' - name: FACT_BLOCKS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/core/core__fact_decoded_event_logs.yml b/models/gold/core/core__fact_decoded_event_logs.yml index 0f48f00..14f54be 100644 --- a/models/gold/core/core__fact_decoded_event_logs.yml +++ b/models/gold/core/core__fact_decoded_event_logs.yml @@ -1,30 +1,8 @@ version: 2 models: - name: core__fact_decoded_event_logs - description: > - 'For information on how to submit a contract for decoding, as well as how ABIs are sourced, please visit [here](https://science.flipsidecrypto.xyz/abi-requestor/). - This model contains decoded event logs for contracts that we have an ABI for. Please note, this table does not include all event logs, only those that we have an ABI for. - This table will perform better than the `core__ez_decoded_event_logs` table, but does not include as many columns. - The `decoded_log` column is the easiest place to query decoded data. It is a JSON object, where the keys are the names of the event parameters, and the values are the values of the event parameters. - You can select from this column using the following sample format, `decoded_log:from::string` or more generally, `decoded_log:::datatype`. See below for a full sample query. - The `full_decoded_logs` column contains the same information, as well as additional fields such as the datatype of the decoded data. You may need to laterally flatten this column to query the data. - - Sample query for USDC Transfer events: + description: '{{ doc("evm_table_deprecation_notice_fact_decoded_event_logs") }}' - ```sql - select - tx_hash, - block_number, - contract_address, - decoded_log:from::string as from_address, - decoded_log:to::string as to_address, - decoded_log:value::integer as value - from ethereum.core.fact_decoded_event_logs - where contract_address = lower('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') - and block_number between 16400000 and 16405000 - and event_name = 'Transfer' - limit 50```' - columns: - name: BLOCK_NUMBER description: '{{ doc("avax_block_number") }}' @@ -37,14 +15,14 @@ models: - name: CONTRACT_ADDRESS description: '{{ doc("avax_logs_contract_address") }}' - name: EVENT_NAME - description: 'The name of the event, as defined in the contract ABI.' + description: "The name of the event, as defined in the contract ABI." - name: DECODED_LOG - description: 'The flattened decoded log, where the keys are the names of the event parameters, and the values are the values of the event parameters.' + description: "The flattened decoded log, where the keys are the names of the event parameters, and the values are the values of the event parameters." - name: FULL_DECODED_LOG - description: 'The full decoded log, including the event name, the event parameters, and the data type of the event parameters.' + description: "The full decoded log, including the event name, the event parameters, and the data type of the event parameters." - name: FACT_DECODED_EVENT_LOGS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/core/core__fact_event_logs.sql b/models/gold/core/core__fact_event_logs.sql index e21eda0..d7d6e95 100644 --- a/models/gold/core/core__fact_event_logs.sql +++ b/models/gold/core/core__fact_event_logs.sql @@ -8,16 +8,28 @@ SELECT block_number, block_timestamp, tx_hash, - origin_function_signature, - origin_from_address, - origin_to_address, + {# tx_position, -- new column #} event_index, contract_address, topics, + topics [0] :: STRING AS topic_0, + --new column + topics [1] :: STRING AS topic_1, + --new column + topics [2] :: STRING AS topic_2, + --new column + topics [3] :: STRING AS topic_3, + --new column DATA, event_removed, - tx_status, - _log_id, + origin_from_address, + origin_to_address, + origin_function_signature, + CASE + WHEN tx_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS tx_succeeded, + -- new column COALESCE ( logs_id, {{ dbt_utils.generate_surrogate_key( @@ -31,6 +43,9 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp + ) AS modified_timestamp, + tx_status, + -- deprecate + _log_id -- deprecate FROM {{ ref('silver__logs') }} diff --git a/models/gold/core/core__fact_event_logs.yml b/models/gold/core/core__fact_event_logs.yml index e026898..edbf358 100644 --- a/models/gold/core/core__fact_event_logs.yml +++ b/models/gold/core/core__fact_event_logs.yml @@ -1,38 +1,48 @@ version: 2 models: - name: core__fact_event_logs - description: '{{ doc("avax_logs_table_doc") }}' + description: '{{ doc("evm_logs_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("avax_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("avax_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: TX_HASH - description: '{{ doc("avax_logs_tx_hash") }}' + description: '{{ doc("evm_logs_tx_hash") }}' - name: EVENT_INDEX - description: '{{ doc("avax_event_index") }}' + description: '{{ doc("evm_event_index") }}' - name: CONTRACT_ADDRESS - description: '{{ doc("avax_logs_contract_address") }}' + description: '{{ doc("evm_logs_contract_address") }}' - name: TOPICS - description: '{{ doc("avax_topics") }}' + description: '{{ doc("evm_topics") }}' + - name: TOPIC_0 + description: '{{ doc("evm_topic_0") }}' + - name: TOPIC_1 + description: '{{ doc("evm_topic_1") }}' + - name: TOPIC_2 + description: '{{ doc("evm_topic_2") }}' + - name: TOPIC_3 + description: '{{ doc("evm_topic_3") }}' - name: DATA - description: '{{ doc("avax_logs_data") }}' + description: '{{ doc("evm_logs_data") }}' - name: EVENT_REMOVED - description: '{{ doc("avax_event_removed") }}' + description: '{{ doc("evm_event_removed") }}' - name: _LOG_ID - description: '{{ doc("internal_column") }}' + description: '{{ doc("evm_column_deprecation_notice_log_id") }}' - name: TX_STATUS - description: '{{ doc("avax_tx_status") }}' + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("avax_origin_sig") }}' + description: '{{ doc("evm_origin_sig") }}' - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("avax_origin_from") }}' + description: '{{ doc("evm_origin_from") }}' - name: ORIGIN_TO_ADDRESS - description: '{{ doc("avax_origin_to") }}' + description: '{{ doc("evm_origin_to") }}' - name: FACT_EVENT_LOGS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/core/core__fact_token_transfers.yml b/models/gold/core/core__fact_token_transfers.yml index 8adc854..c523e79 100644 --- a/models/gold/core/core__fact_token_transfers.yml +++ b/models/gold/core/core__fact_token_transfers.yml @@ -1,7 +1,7 @@ version: 2 models: - name: core__fact_token_transfers - description: '{{ doc("evm_fact_token_transfers_table_doc") }}' + description: '{{ doc("evm_table_deprecation_notice_fact_token_transfers") }}' columns: - name: BLOCK_NUMBER diff --git a/models/gold/core/core__fact_traces.yml b/models/gold/core/core__fact_traces.yml index 4416ad3..eb1e2f1 100644 --- a/models/gold/core/core__fact_traces.yml +++ b/models/gold/core/core__fact_traces.yml @@ -1,68 +1,64 @@ version: 2 models: - name: core__fact_traces - description: '{{ doc("avax_traces_table_doc") }}' + description: '{{ doc("evm_traces_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("avax_traces_block_no") }}' + description: '{{ doc("evm_traces_block_no") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("avax_traces_blocktime") }}' + description: '{{ doc("evm_traces_blocktime") }}' - name: TX_HASH - description: '{{ doc("avax_traces_tx_hash") }}' + description: '{{ doc("evm_traces_tx_hash") }}' - name: TX_POSITION - description: The position of the transaction within the block. + description: '{{ doc("evm_tx_position") }}' + - name: FROM_ADDRESS + description: '{{ doc("evm_traces_from") }}' + - name: TO_ADDRESS + description: '{{ doc("evm_traces_to") }}' + - name: VALUE + description: '{{ doc("evm_traces_value") }}' + - name: VALUE_PRECISE_RAW + description: '{{ doc("evm_precise_amount_unadjusted") }}' + - name: VALUE_PRECISE + description: '{{ doc("evm_precise_amount_adjusted") }}' + - name: VALUE_HEX + description: '{{ doc("evm_value_hex") }}' + - name: GAS + description: '{{ doc("evm_traces_gas") }}' + - name: GAS_USED + description: '{{ doc("evm_traces_gas_used") }}' + - name: INPUT + description: '{{ doc("evm_traces_input") }}' + - name: OUTPUT + description: '{{ doc("evm_traces_output") }}' + - name: TYPE + description: '{{ doc("evm_traces_type") }}' + - name: IDENTIFIER + description: '{{ doc("evm_column_deprecation_notice_identifier") }}' + - name: TRACE_ADDRESS + description: '{{ doc("evm_trace_address") }}' + - name: DATA + description: '{{ doc("evm_column_deprecation_notice_data") }}' + - name: TX_STATUS + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' + - name: TRACE_SUCCEEDED + description: '{{ doc("evm_trace_succeeded") }}' + - name: SUB_TRACES + description: '{{ doc("evm_sub_traces") }}' + - name: TRACE_STATUS + description: '{{ doc("evm_column_deprecation_notice_trace_status") }}' + - name: ERROR_REASON + description: '{{ doc("evm_trace_error_reason") }}' + - name: REVERT_REASON + description: '{{ doc("evm_revert_reason") }}' - name: TRACE_INDEX description: The index of the trace within the transaction. - - name: FROM_ADDRESS - description: '{{ doc("avax_traces_from") }}' - - name: TO_ADDRESS - description: '{{ doc("avax_traces_to") }}' - - name: INPUT - description: '{{ doc("avax_traces_input") }}' - - name: OUTPUT - description: '{{ doc("avax_traces_output") }}' - - name: TYPE - description: '{{ doc("avax_traces_type") }}' - - name: TRACE_ADDRESS - description: This field represents the position of the trace within the transaction. - - name: SUB_TRACES - description: '{{ doc("avax_traces_sub") }}' - - name: IDENTIFIER - description: '{{ doc("avax_traces_identifier") }}' - - name: DATA - description: '{{ doc("avax_traces_call_data") }}' - - name: VALUE - description: '{{ doc("avax_traces_value") }}' - - name: VALUE_PRECISE_RAW - description: '{{ doc("precise_amount_unadjusted") }}' - - name: VALUE_PRECISE - description: '{{ doc("precise_amount_adjusted") }}' - - name: GAS - description: '{{ doc("avax_traces_gas") }}' - - name: GAS_USED - description: '{{ doc("avax_traces_gas_used") }}' - - name: ORIGIN_FROM_ADDRESS - description: The from address at the transaction level. - - name: ORIGIN_TO_ADDRESS - description: The to address at the transaction level. - - name: ORIGIN_FUNCTION_SIGNATURE - description: The function signature at the transaction level. - - name: TRACE_STATUS - description: The status of the trace, either `SUCCESS` or `FAIL` - - name: TRACE_SUCCEEDED - description: Whether the trace succeeded or failed - - name: ERROR_REASON - description: The reason for the trace failure, if any. - - name: REVERT_REASON - description: The reason for the trace revert, if any. - - name: TX_STATUS - description: '{{ doc("avax_tx_status") }}' - - name: TX_SUCCEEDED - description: Whether the transaction succeeded or failed - name: FACT_TRACES_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/core/core__fact_transactions.sql b/models/gold/core/core__fact_transactions.sql index 7f23d45..8cea79e 100644 --- a/models/gold/core/core__fact_transactions.sql +++ b/models/gold/core/core__fact_transactions.sql @@ -7,24 +7,27 @@ SELECT block_number, block_timestamp, - block_hash, tx_hash, - nonce, - POSITION, - origin_function_signature, from_address, to_address, - VALUE, + origin_function_signature, + value, value_precise_raw, value_precise, - tx_fee, + tx_fee, tx_fee_precise, + CASE + WHEN tx_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS tx_succeeded, + tx_type, + nonce, + position as tx_position, + input_data, gas_price, gas AS gas_limit, gas_used, cumulative_gas_used, - input_data, - tx_status AS status, effective_gas_price, max_fee_per_gas, max_priority_fee_per_gas, @@ -46,6 +49,9 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp + ) AS modified_timestamp, + block_hash, + tx_status as status, + position FROM {{ ref('silver__transactions') }} diff --git a/models/gold/core/core__fact_transactions.yml b/models/gold/core/core__fact_transactions.yml index e01af0f..9dff395 100644 --- a/models/gold/core/core__fact_transactions.yml +++ b/models/gold/core/core__fact_transactions.yml @@ -1,57 +1,57 @@ version: 2 models: - name: core__fact_transactions - description: '{{ doc("avax_tx_table_doc") }}' + description: '{{ doc("evm_tx_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("avax_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("avax_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: BLOCK_HASH - description: '{{ doc("avax_tx_block_hash") }}' + description: '{{ doc("evm_column_deprecation_notice_block_hash") }}' - name: TX_HASH - description: '{{ doc("avax_tx_hash") }}' + description: '{{ doc("evm_tx_hash") }}' - name: NONCE - description: '{{ doc("avax_tx_nonce") }}' + description: '{{ doc("evm_tx_nonce") }}' - name: POSITION - description: '{{ doc("avax_tx_position") }}' + description: '{{ doc("evm_column_deprecation_notice_position") }}' + - name: TX_POSITION + description: '{{ doc("evm_tx_position") }}' - name: FROM_ADDRESS - description: '{{ doc("avax_from_address") }}' + description: '{{ doc("evm_from_address") }}' - name: TO_ADDRESS - description: '{{ doc("avax_to_address") }}' + description: '{{ doc("evm_to_address") }}' - name: VALUE - description: '{{ doc("avax_value") }}' + description: '{{ doc("evm_value") }}' - name: VALUE_PRECISE_RAW description: '{{ doc("precise_amount_unadjusted") }}' - name: VALUE_PRECISE description: '{{ doc("precise_amount_adjusted") }}' - name: TX_FEE - description: '{{ doc("avax_tx_fee") }}' + description: '{{ doc("evm_tx_fee") }}' - name: TX_FEE_PRECISE - description: '{{ doc("tx_fee_precise") }}' + description: '{{ doc("tx_fee_precise") }}' - name: GAS_PRICE - description: '{{ doc("avax_tx_gas_price") }}' + description: '{{ doc("evm_tx_gas_price") }}' - name: GAS_LIMIT - description: '{{ doc("avax_tx_gas_limit") }}' + description: '{{ doc("evm_tx_gas_limit") }}' - name: GAS_USED - description: '{{ doc("avax_tx_gas_used") }}' + description: '{{ doc("evm_tx_gas_used") }}' - name: CUMULATIVE_GAS_USED - description: '{{ doc("avax_cumulative_gas_used") }}' - - name: STATUS - description: '{{ doc("avax_tx_status") }}' - - name: INPUT_DATA - description: '{{ doc("avax_tx_input_data") }}' - - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("avax_tx_origin_sig") }}' - - name: EFFECTIVE_GAS_PRICE - description: The effective gas price of the transaction, in nAVAX. + description: '{{ doc("evm_cumulative_gas_used") }}' - name: MAX_FEE_PER_GAS - description: The maximum fee per gas of the transaction, in nAVAX. + description: The maximum fee per gas of the transaction, in Gwei. - name: MAX_PRIORITY_FEE_PER_GAS - description: The maximum priority fee per gas of the transaction, in nAVAX. - - name: CHAIN_ID - description: The chain ID of the transaction. + description: The maximum priority fee per gas of the transaction, in Gwei. + - name: STATUS + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' + - name: INPUT_DATA + description: '{{ doc("evm_tx_input_data") }}' + - name: ORIGIN_FUNCTION_SIGNATURE + description: '{{ doc("evm_tx_origin_sig") }}' - name: TX_TYPE description: The type of the transaction, 2 for EIP-1559 transactions and 0 for legacy transactions. - name: r @@ -61,8 +61,8 @@ models: - name: v description: The v value of the transaction signature. - name: FACT_TRANSACTIONS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/defi/defi__ez_dex_swaps.sql b/models/gold/defi/defi__ez_dex_swaps.sql index 8960f14..c6bfc51 100644 --- a/models/gold/defi/defi__ez_dex_swaps.sql +++ b/models/gold/defi/defi__ez_dex_swaps.sql @@ -58,7 +58,6 @@ SELECT token_out, symbol_in, symbol_out, - _log_id, COALESCE ( complete_dex_swaps_id, {{ dbt_utils.generate_surrogate_key( @@ -72,6 +71,7 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp + ) AS modified_timestamp, + _log_id FROM {{ ref('silver_dex__complete_dex_swaps') }} \ No newline at end of file diff --git a/models/gold/defi/defi__ez_dex_swaps.yml b/models/gold/defi/defi__ez_dex_swaps.yml index 613b272..5562824 100644 --- a/models/gold/defi/defi__ez_dex_swaps.yml +++ b/models/gold/defi/defi__ez_dex_swaps.yml @@ -39,7 +39,7 @@ models: - name: EVENT_INDEX description: '{{ doc("avax_event_index") }}' - name: _LOG_ID - description: '{{ doc("internal_column") }}' + description: '{{ doc("evm_column_deprecation_notice_log_id") }}' - name: ORIGIN_FUNCTION_SIGNATURE description: '{{ doc("avax_tx_origin_sig") }}' - name: ORIGIN_FROM_ADDRESS @@ -51,9 +51,9 @@ models: - name: AMOUNT_OUT_UNADJ description: '{{ doc("eth_dex_swaps_amount_out_unadj") }}' - name: EZ_DEX_SWAPS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' + description: '{{ doc("evm_modified_timestamp") }}' diff --git a/models/gold/nft/nft__ez_nft_sales.sql b/models/gold/nft/nft__ez_nft_sales.sql index 89dc737..e20fc19 100644 --- a/models/gold/nft/nft__ez_nft_sales.sql +++ b/models/gold/nft/nft__ez_nft_sales.sql @@ -19,11 +19,15 @@ SELECT platform_exchange_version, aggregator_name, seller_address, - buyer_address, - nft_address, - project_name, - erc1155_value, - tokenId, + buyer_address, + nft_address as contract_address, -- new + project_name as name, -- new + tokenid as token_id, --new + COALESCE(erc1155_value, '1') :: STRING AS quantity, --new + CASE + WHEN erc1155_value IS NULL THEN 'erc721' + ELSE 'erc1155' + END AS token_standard, --new currency_symbol, currency_address, price, @@ -34,7 +38,7 @@ SELECT total_fees_usd, platform_fee_usd, creator_fee_usd, - tx_fee, + tx_fee, tx_fee_usd, origin_from_address, origin_to_address, @@ -52,6 +56,9 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp -FROM - {{ ref('silver__complete_nft_sales') }} + ) AS modified_timestamp, + tokenId, -- deprecate + erc1155_value, -- deprecate + project_name, -- deprecate + nft_address -- deprecate +FROM {{ ref('silver__complete_nft_sales') }} \ No newline at end of file diff --git a/models/gold/nft/nft__ez_nft_sales.yml b/models/gold/nft/nft__ez_nft_sales.yml index ed0b67f..39bb71e 100644 --- a/models/gold/nft/nft__ez_nft_sales.yml +++ b/models/gold/nft/nft__ez_nft_sales.yml @@ -1,17 +1,17 @@ version: 2 models: - name: nft__ez_nft_sales - description: This table contains NFT sales from Opensea Seaport 1.1, 1.4, 1.5 and 1.6, Joepegs, Salvor and Element on Avalanche. - + description: '{{ doc("evm_ez_nft_sales_table_doc") }}' + columns: - name: BLOCK_NUMBER - description: '{{ doc("nft_block_no") }}' + description: '{{ doc("nft_block_no") }}' - name: BLOCK_TIMESTAMP description: '{{ doc("nft_blocktime") }}' - name: TX_HASH description: '{{ doc("nft_tx_hash") }}' - name: EVENT_INDEX - description: '{{ doc("nft_event_index") }}' + description: '{{ doc("nft_event_index") }}' - name: EVENT_TYPE description: '{{ doc("nft_event_type") }}' - name: PLATFORM_ADDRESS @@ -27,13 +27,23 @@ models: - name: BUYER_ADDRESS description: '{{ doc("nft_buyer_address") }}' - name: NFT_ADDRESS + description: '{{ doc("evm_column_deprecation_notice_nft_address") }}' + - name: CONTRACT_ADDRESS description: '{{ doc("nft_nft_address") }}' - name: PROJECT_NAME - description: '{{ doc("nft_project_name") }}' - - name: ERC1155_VALUE - description: '{{ doc("nft_erc1155_value") }}' + description: '{{ doc("evm_column_deprecation_notice_project_name") }}' + - name: NAME + description: '{{ doc("evm_nft_project_name") }}' - name: TOKENID + description: '{{ doc("evm_column_deprecation_notice_tokenid") }}' + - name: TOKEN_ID description: '{{ doc("nft_tokenid") }}' + - name: ERC1155_VALUE + description: '{{ doc("evm_column_deprecation_notice_erc1155_value") }}' + - name: QUANTITY + description: '{{ doc("evm_nft_quantity") }}' + - name: TOKEN_STANDARD + description: '{{ doc("evm_nft_token_standard") }}' - name: CURRENCY_SYMBOL description: '{{ doc("nft_currency_symbol") }}' - name: CURRENCY_ADDRESS @@ -54,10 +64,6 @@ models: description: '{{ doc("nft_platform_fee_usd") }}' - name: CREATOR_FEE_USD description: '{{ doc("nft_creator_fee_usd") }}' - - name: TX_FEE - description: '{{ doc("nft_tx_fee") }}' - - name: TX_FEE_USD - description: '{{ doc("nft_tx_fee_usd") }}' - name: ORIGIN_FROM_ADDRESS description: '{{ doc("nft_origin_from") }}' - name: ORIGIN_TO_ADDRESS @@ -65,8 +71,8 @@ models: - name: ORIGIN_FUNCTION_SIGNATURE description: '{{ doc("nft_origin_sig") }}' - name: EZ_NFT_SALES_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/nft/nft__ez_nft_transfers.sql b/models/gold/nft/nft__ez_nft_transfers.sql index 3d7ea8c..fdf2de8 100644 --- a/models/gold/nft/nft__ez_nft_transfers.sql +++ b/models/gold/nft/nft__ez_nft_transfers.sql @@ -12,15 +12,28 @@ SELECT block_timestamp, block_number, tx_hash, + {#tx_position, -- new #} event_index, intra_event_index, - event_type, - contract_address as nft_address, - project_name, - from_address AS nft_from_address, - to_address AS nft_to_address, - tokenId, - erc1155_value, + token_transfer_type, + iff(from_address = '0x0000000000000000000000000000000000000000', TRUE, FALSE) AS is_mint, -- new + from_address, --new + to_address, --new + contract_address, --new + tokenId as token_id, --new + COALESCE( + erc1155_value, + '1' + ) :: STRING AS quantity, --new + CASE + WHEN token_transfer_type = 'erc721_Transfer' THEN 'erc721' + WHEN token_transfer_type = 'erc1155_TransferSingle' THEN 'erc1155' + WHEN token_transfer_type = 'erc1155_TransferBatch' THEN 'erc1155' + END AS token_standard, --new + project_name as name, --new + {#origin_function_signature, --new + origin_from_address, --new + origin_to_address, #} -- new COALESCE ( nft_transfers_id, {{ dbt_utils.generate_surrogate_key( @@ -34,7 +47,13 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp + ) AS modified_timestamp, + event_type, -- deprecate + from_address AS nft_from_address, -- deprecate + to_address AS nft_to_address, -- deprecate + contract_address AS nft_address, --deprecate + tokenId, -- deprecate + erc1155_value, --deprecate + project_name --deprecate FROM - {{ ref('silver__nft_transfers') }} - + {{ ref('silver__nft_transfers') }} \ No newline at end of file diff --git a/models/gold/nft/nft__ez_nft_transfers.yml b/models/gold/nft/nft__ez_nft_transfers.yml index dfc0c45..bfe9865 100644 --- a/models/gold/nft/nft__ez_nft_transfers.yml +++ b/models/gold/nft/nft__ez_nft_transfers.yml @@ -1,8 +1,8 @@ version: 2 models: - name: nft__ez_nft_transfers - description: '{{ doc("nft_transfer_doc") }}' - + description: '{{ doc("evm_ez_nft_transfer_table_doc") }}' + columns: - name: BLOCK_NUMBER description: '{{ doc("nft_block_no") }}' @@ -15,22 +15,36 @@ models: - name: INTRA_EVENT_INDEX description: '{{ doc("nft_intra_event_index") }}' - name: EVENT_TYPE - description: '{{ doc("nft_event_type") }}' + description: '{{ doc("evm_column_deprecation_notice_event_type") }}' - name: NFT_ADDRESS + description: '{{ doc("evm_column_deprecation_notice_nft_address") }}' + - name: CONTRACT_ADDRESS description: '{{ doc("nft_nft_address") }}' + - name: NAME + description: '{{ doc("evm_nft_project_name") }}' - name: PROJECT_NAME - description: '{{ doc("nft_project_name") }}' + description: '{{ doc("evm_column_deprecation_notice_project_name") }}' - name: NFT_FROM_ADDRESS + description: '{{ doc("evm_column_deprecation_notice_nft_from_address") }}' + - name: FROM_ADDRESS description: '{{ doc("nft_nft_from_address") }}' - name: NFT_TO_ADDRESS + description: '{{ doc("evm_column_deprecation_notice_nft_to_address") }}' + - name: TO_ADDRESS description: '{{ doc("nft_nft_to_address") }}' - name: TOKENID + description: '{{ doc("evm_column_deprecation_notice_tokenid") }}' + - name: TOKEN_ID description: '{{ doc("nft_tokenid") }}' - name: ERC1155_VALUE - description: '{{ doc("nft_erc1155_value") }}' + description: '{{ doc("evm_column_deprecation_notice_erc1155_value") }}' + - name: QUANTITY + description: '{{ doc("evm_nft_quantity") }}' + - name: TOKEN_STANDARD + description: '{{ doc("evm_nft_token_standard") }}' - name: EZ_NFT_TRANSFERS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("modified_timestamp") }}' \ No newline at end of file diff --git a/models/silver/abis/silver__proxies.sql b/models/silver/abis/silver__proxies.sql index 3cceeaf..a328b24 100644 --- a/models/silver/abis/silver__proxies.sql +++ b/models/silver/abis/silver__proxies.sql @@ -16,8 +16,8 @@ WITH base AS ( {{ ref('core__fact_traces') }} WHERE TYPE = 'DELEGATECALL' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded AND from_address != to_address -- exclude self-calls {% if is_incremental() %} diff --git a/models/silver/abis/silver__user_verified_abis.sql b/models/silver/abis/silver__user_verified_abis.sql index ac9d0cb..d3e7442 100644 --- a/models/silver/abis/silver__user_verified_abis.sql +++ b/models/silver/abis/silver__user_verified_abis.sql @@ -506,7 +506,7 @@ valid_traces AS ( SELECT base_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l JOIN event_mapping ia ON ia.contract_address = l.contract_address diff --git a/models/silver/core/silver__created_contracts.sql b/models/silver/core/silver__created_contracts.sql index acbd37d..f1818da 100644 --- a/models/silver/core/silver__created_contracts.sql +++ b/models/silver/core/silver__created_contracts.sql @@ -27,8 +27,8 @@ WHERE AND to_address IS NOT NULL AND input IS NOT NULL AND input != '0x' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/core/silver__logs.sql b/models/silver/core/silver__logs.sql index 292e911..b052ff2 100644 --- a/models/silver/core/silver__logs.sql +++ b/models/silver/core/silver__logs.sql @@ -16,6 +16,7 @@ WITH base AS ( from_address AS origin_from_address, to_address AS origin_to_address, tx_status, + {# position AS tx_position, --new column #} logs, _inserted_timestamp FROM @@ -39,6 +40,7 @@ flat_logs AS ( origin_from_address, origin_to_address, tx_status, + {# position AS tx_position, --new column #} VALUE :address :: STRING AS contract_address, VALUE :blockHash :: STRING AS block_hash, VALUE :data :: STRING AS DATA, @@ -63,6 +65,7 @@ new_records AS ( l.origin_to_address, txs.origin_function_signature, l.tx_status, + {# l.tx_position, --new column #} l.contract_address, l.block_hash, l.data, @@ -107,6 +110,7 @@ missing_data AS ( t.origin_to_address, txs.origin_function_signature, t.tx_status, + {# t.tx_position, --new column #} t.contract_address, t.block_hash, t.data, @@ -140,6 +144,7 @@ FINAL AS ( origin_to_address, origin_function_signature, tx_status, + {# tx_position, --new column #} contract_address, block_hash, DATA, @@ -162,6 +167,7 @@ SELECT origin_to_address, origin_function_signature, tx_status, + {# tx_position, --new column #} contract_address, block_hash, DATA, diff --git a/models/silver/core/silver__native_transfers.sql b/models/silver/core/silver__native_transfers.sql index 36d1e4f..6f5bf97 100644 --- a/models/silver/core/silver__native_transfers.sql +++ b/models/silver/core/silver__native_transfers.sql @@ -32,44 +32,21 @@ WITH avax_base AS ( value_precise_raw AS avax_value_precise_raw, value_precise AS avax_value_precise, tx_position, - trace_index + trace_index, + origin_from_address, + origin_to_address, + origin_function_signature FROM {{ ref('core__fact_traces') }} WHERE avax_value > 0 - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded AND TYPE NOT IN ( 'DELEGATECALL', 'STATICCALL' ) -{% if is_incremental() %} -AND _inserted_timestamp >= ( - SELECT - MAX(_inserted_timestamp) - INTERVAL '72 hours' - FROM - {{ this }} -) -{% endif %} -), -tx_table AS ( - SELECT - block_number, - tx_hash, - from_address AS origin_from_address, - to_address AS origin_to_address, - origin_function_signature - FROM - {{ ref('silver__transactions') }} - WHERE - tx_hash IN ( - SELECT - DISTINCT tx_hash - FROM - avax_base - ) - {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT @@ -80,10 +57,10 @@ AND _inserted_timestamp >= ( {% endif %} ) SELECT - tx_hash AS tx_hash, - block_number AS block_number, - block_timestamp AS block_timestamp, - identifier AS identifier, + tx_hash, + block_number, + block_timestamp, + identifier, origin_from_address, origin_to_address, origin_function_signature, @@ -97,7 +74,7 @@ SELECT 2 ) AS amount_usd, _call_id, - _inserted_timestamp, + a._inserted_timestamp, tx_position, trace_index, {{ dbt_utils.generate_surrogate_key( @@ -113,8 +90,4 @@ FROM 'hour', A.block_timestamp ) = HOUR - AND token_address = '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7' - JOIN tx_table USING ( - tx_hash, - block_number - ) + AND token_address = '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7' \ No newline at end of file diff --git a/models/silver/core/silver__relevant_contracts.sql b/models/silver/core/silver__relevant_contracts.sql index 23aefb7..083e8bc 100644 --- a/models/silver/core/silver__relevant_contracts.sql +++ b/models/silver/core/silver__relevant_contracts.sql @@ -36,8 +36,8 @@ function_calls AS ( FROM {{ ref('core__fact_traces') }} WHERE - tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + tx_succeeded + AND trace_succeeded AND to_address IS NOT NULL AND input IS NOT NULL AND input <> '0x' diff --git a/models/silver/core/silver__transfers.sql b/models/silver/core/silver__transfers.sql index dc688df..d98f573 100644 --- a/models/silver/core/silver__transfers.sql +++ b/models/silver/core/silver__transfers.sql @@ -11,7 +11,11 @@ WITH logs AS ( SELECT - _log_id, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, block_number, tx_hash, block_timestamp, @@ -24,12 +28,12 @@ WITH logs AS ( utils.udf_hex_to_int(SUBSTR(DATA, 3, 64)) AS raw_amount_precise, raw_amount_precise :: FLOAT AS raw_amount, event_index, - _inserted_timestamp + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/core/silver__tx_count.sql b/models/silver/core/silver__tx_count.sql index 0635342..c02c8aa 100644 --- a/models/silver/core/silver__tx_count.sql +++ b/models/silver/core/silver__tx_count.sql @@ -9,14 +9,14 @@ WITH base AS ( SELECT block_number, - MIN(_inserted_timestamp) AS _inserted_timestamp, + MIN(modified_timestamp) AS _inserted_timestamp, COUNT(*) AS tx_count FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} {% if is_incremental() %} WHERE - _inserted_timestamp >= ( + modified_timestamp >= ( SELECT MAX(_inserted_timestamp) _inserted_timestamp FROM @@ -27,7 +27,9 @@ GROUP BY block_number ) SELECT - *, + block_number, + _inserted_timestamp, + tx_count, {{ dbt_utils.generate_surrogate_key( ['block_number'] ) }} AS tx_count_id, @@ -35,4 +37,4 @@ SELECT SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - base + base \ No newline at end of file diff --git a/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_sent.sql b/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_sent.sql index 44d4fbf..819a45d 100644 --- a/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_sent.sql +++ b/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_sent.sql @@ -21,39 +21,47 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, utils.udf_hex_to_string( SUBSTRING( - decoded_flat :"destination" :: STRING, + decoded_log :"destination" :: STRING, 3 ) ) AS destination_chain_symbol, - decoded_flat :"lockId" :: STRING AS lockId, - decoded_flat :"recipient" :: STRING AS recipient, - decoded_flat :"sender" :: STRING AS sender, + decoded_log :"lockId" :: STRING AS lockId, + decoded_log :"recipient" :: STRING AS recipient, + decoded_log :"sender" :: STRING AS sender, utils.udf_hex_to_string( SUBSTRING( - decoded_flat :"tokenSource" :: STRING, + decoded_log :"tokenSource" :: STRING, 3 ) ) AS token_source, REGEXP_REPLACE( - decoded_flat :"tokenSourceAddress" :: STRING, + decoded_log :"tokenSourceAddress" :: STRING, '0+$', '' ) AS tokenSourceAddress, - decoded_flat, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x884a8def17f0d5bbb3fef53f3136b5320c9b39f75afb8985eeab9ea1153ee56d' AND contract_address = '0xbbbd1bbb4f9b936c3604906d7592a644071de884' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -63,6 +71,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_tokens_sent.sql b/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_tokens_sent.sql index 1401947..fc17c8a 100644 --- a/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_tokens_sent.sql +++ b/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_tokens_sent.sql @@ -26,10 +26,7 @@ WITH base_evt AS ( origin_from_address AS recipient, TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [4] :: STRING)) AS nonce, TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [5] :: STRING)) AS messenger, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash, '-', @@ -51,6 +48,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), lp_evt AS ( @@ -69,10 +67,7 @@ lp_evt AS ( TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [2] :: STRING)) AS amount, TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [3] :: STRING)) AS vUsdAmount, TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [4] :: STRING)) AS fee, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash, '-', @@ -104,6 +99,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/bridge/axelar/silver_bridge__axelar_contractcallwithtoken.sql b/models/silver/defi/bridge/axelar/silver_bridge__axelar_contractcallwithtoken.sql index fd8c7c4..d4cdc91 100644 --- a/models/silver/defi/bridge/axelar/silver_bridge__axelar_contractcallwithtoken.sql +++ b/models/silver/defi/bridge/axelar/silver_bridge__axelar_contractcallwithtoken.sql @@ -21,28 +21,36 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, - decoded_flat :"destinationChain" :: STRING AS destinationChain, + decoded_log :"destinationChain" :: STRING AS destinationChain, LOWER( - decoded_flat :"destinationContractAddress" :: STRING + decoded_log :"destinationContractAddress" :: STRING ) AS destinationContractAddress, - decoded_flat :"payload" :: STRING AS payload, + decoded_log :"payload" :: STRING AS payload, origin_from_address AS recipient, - decoded_flat :"payloadHash" :: STRING AS payloadHash, - decoded_flat :"sender" :: STRING AS sender, - decoded_flat :"symbol" :: STRING AS symbol, - decoded_flat, + decoded_log :"payloadHash" :: STRING AS payloadHash, + decoded_log :"sender" :: STRING AS sender, + decoded_log :"symbol" :: STRING AS symbol, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x7e50569d26be643bda7757722291ec66b1be66d8283474ae3fab5a98f878a7a2' AND contract_address = LOWER('0x5029C0EFf6C34351a0CEc334542cDb22c7928f78') - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -52,6 +60,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), native_gas_paid AS ( @@ -68,30 +77,34 @@ native_gas_paid AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, - decoded_flat :"destinationChain" :: STRING AS destinationChain, + decoded_log :"destinationChain" :: STRING AS destinationChain, LOWER( - decoded_flat :"destinationAddress" :: STRING + decoded_log :"destinationAddress" :: STRING ) AS destinationAddress, TRY_TO_NUMBER( - decoded_flat :"gasFeeAmount" :: STRING + decoded_log :"gasFeeAmount" :: STRING ) AS gasFeeAmount, - decoded_flat :"payloadHash" :: STRING AS payloadHash, - decoded_flat :"refundAddress" :: STRING AS refundAddress, - decoded_flat :"sourceAddress" :: STRING AS sourceAddress, - decoded_flat :"symbol" :: STRING AS symbol, - decoded_flat, + decoded_log :"payloadHash" :: STRING AS payloadHash, + decoded_log :"refundAddress" :: STRING AS refundAddress, + decoded_log :"sourceAddress" :: STRING AS sourceAddress, + decoded_log :"symbol" :: STRING AS symbol, + decoded_log, event_removed, - tx_status, + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, _log_id, _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x999d431b58761213cf53af96262b67a069cbd963499fd8effd1e21556217b841' AND contract_address = '0x2d5d7d31f671f86c782533cc367f14109a082712' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -101,6 +114,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), transfers AS ( @@ -109,10 +123,14 @@ transfers AS ( tx_hash, event_index, contract_address AS token_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__transfers') }} + {{ ref('core__ez_token_transfers') }} WHERE from_address = '0xce16f69375520ab01377ce7b88f5ba8c48f8d666' AND to_address IN ( @@ -128,6 +146,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), FINAL AS ( diff --git a/models/silver/defi/bridge/celer/silver_bridge__celer_cbridge_send.sql b/models/silver/defi/bridge/celer/silver_bridge__celer_cbridge_send.sql index ebf502c..f164df9 100644 --- a/models/silver/defi/bridge/celer/silver_bridge__celer_cbridge_send.sql +++ b/models/silver/defi/bridge/celer/silver_bridge__celer_cbridge_send.sql @@ -21,28 +21,36 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"dstChainId" :: STRING + decoded_log :"dstChainId" :: STRING ) AS dstChainId, TRY_TO_NUMBER( - decoded_flat :"maxSlippage" :: STRING + decoded_log :"maxSlippage" :: STRING ) AS maxSlippage, TRY_TO_NUMBER( - decoded_flat :"nonce" :: STRING + decoded_log :"nonce" :: STRING ) AS nonce, - decoded_flat :"receiver" :: STRING AS receiver, - decoded_flat :"sender" :: STRING AS sender, - decoded_flat :"token" :: STRING AS token, - decoded_flat :"transferId" :: STRING AS transferId, - decoded_flat, + decoded_log :"receiver" :: STRING AS receiver, + decoded_log :"sender" :: STRING AS sender, + decoded_log :"token" :: STRING AS token, + decoded_log :"transferId" :: STRING AS transferId, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x89d8051e597ab4178a863a5190407b98abfeff406aa8db90c59af76612e58f01' AND contract_address IN ( @@ -50,7 +58,7 @@ WITH base_evt AS ( '0x9b36f165bab9ebe611d491180418d8de4b8f3a1f', '0xef3c714c9425a8f3697a9c969dc1af30ba82e5d4' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -60,6 +68,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/bridge/dln/silver_bridge__dln_debridge_createdorder.sql b/models/silver/defi/bridge/dln/silver_bridge__dln_debridge_createdorder.sql index 6d17c75..ab4373c 100644 --- a/models/silver/defi/bridge/dln/silver_bridge__dln_debridge_createdorder.sql +++ b/models/silver/defi/bridge/dln/silver_bridge__dln_debridge_createdorder.sql @@ -23,54 +23,62 @@ WITH base_evt AS ( DATA, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, CONCAT('0x', SUBSTR(segmented_data [24] :: STRING, 1, 40)) AS token_address, - decoded_flat :"affiliateFee" :: STRING AS affiliateFee, - decoded_flat :"metadata" :: STRING AS metadata, + decoded_log :"affiliateFee" :: STRING AS affiliateFee, + decoded_log :"metadata" :: STRING AS metadata, TRY_TO_NUMBER( - decoded_flat :"nativeFixFee" :: STRING + decoded_log :"nativeFixFee" :: STRING ) AS nativeFixFee, - decoded_flat :"order" AS order_obj, - decoded_flat :"order" :"allowedCancelBeneficiarySrc" :: STRING AS allowedCancelBeneficiarySrc, - decoded_flat :"order" :"allowedTakerDst" :: STRING AS allowedTakerDst, - decoded_flat :"order" :"externalCall" :: STRING AS externalCall, + decoded_log :"order" AS order_obj, + decoded_log :"order" :"allowedCancelBeneficiarySrc" :: STRING AS allowedCancelBeneficiarySrc, + decoded_log :"order" :"allowedTakerDst" :: STRING AS allowedTakerDst, + decoded_log :"order" :"externalCall" :: STRING AS externalCall, TRY_TO_NUMBER( - decoded_flat :"order" :"giveAmount" :: STRING + decoded_log :"order" :"giveAmount" :: STRING ) AS giveAmount, TRY_TO_NUMBER( - decoded_flat :"order" :"giveChainId" :: STRING + decoded_log :"order" :"giveChainId" :: STRING ) AS giveChainId, - decoded_flat :"order" :"givePatchAuthoritySrc" :: STRING AS givePatchAuthoritySrc, - decoded_flat :"order" :"giveTokenAddress" :: STRING AS giveTokenAddress, + decoded_log :"order" :"givePatchAuthoritySrc" :: STRING AS givePatchAuthoritySrc, + decoded_log :"order" :"giveTokenAddress" :: STRING AS giveTokenAddress, TRY_TO_NUMBER( - decoded_flat :"order" :"makerOrderNonce" :: STRING + decoded_log :"order" :"makerOrderNonce" :: STRING ) AS makerOrderNonce, - decoded_flat :"order" :"makerSrc" :: STRING AS makerSrc, - decoded_flat :"order" :"orderAuthorityAddressDst" :: STRING AS orderAuthorityAddressDst, + decoded_log :"order" :"makerSrc" :: STRING AS makerSrc, + decoded_log :"order" :"orderAuthorityAddressDst" :: STRING AS orderAuthorityAddressDst, CONCAT('0x', LEFT(segmented_data [28] :: STRING, 40)) AS receiverDst, TRY_TO_NUMBER( - decoded_flat :"order" :"takeAmount" :: STRING + decoded_log :"order" :"takeAmount" :: STRING ) AS takeAmount, TRY_TO_NUMBER( - decoded_flat :"order" :"takeChainId" :: STRING + decoded_log :"order" :"takeChainId" :: STRING ) AS takeChainId, - decoded_flat :"order" :"takeTokenAddress" :: STRING AS takeTokenAddress, - decoded_flat :"orderId" :: STRING AS orderId, + decoded_log :"order" :"takeTokenAddress" :: STRING AS takeTokenAddress, + decoded_log :"orderId" :: STRING AS orderId, TRY_TO_NUMBER( - decoded_flat :"percentFee" :: STRING + decoded_log :"percentFee" :: STRING ) AS percentFee, TRY_TO_NUMBER( - decoded_flat :"referralCode" :: STRING + decoded_log :"referralCode" :: STRING ) AS referralCode, - decoded_flat, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xfc8703fd57380f9dd234a89dce51333782d49c5902f307b02f03e014d18fe471' --CreatedOrder AND contract_address = '0xef4fb24ad0916217251f553c0596f8edc630eb66' --Dln: Source - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -80,6 +88,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT @@ -112,7 +121,7 @@ SELECT WHEN token_address = '0x0000000000000000000000000000000000000000' THEN LOWER('0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7') ELSE token_address END AS token_address, - decoded_flat, + decoded_log, order_obj, _log_id, _inserted_timestamp diff --git a/models/silver/defi/bridge/eywa/silver_bridge__eywa_requestsent.sql b/models/silver/defi/bridge/eywa/silver_bridge__eywa_requestsent.sql index 269d6da..3c90927 100644 --- a/models/silver/defi/bridge/eywa/silver_bridge__eywa_requestsent.sql +++ b/models/silver/defi/bridge/eywa/silver_bridge__eywa_requestsent.sql @@ -20,13 +20,21 @@ WITH base_evt AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING IN ( '0x5566d73d091d945ab32ea023cd1930c0d43aa43bef9aee4cb029775cfc94bdae', @@ -40,7 +48,7 @@ WITH base_evt AS ( --PortalV2 '0xbf0b5d561b986809924f88099c4ff0e6bcce60c9' --PortalV2 ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -50,6 +58,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), requestsent AS ( @@ -65,11 +74,11 @@ requestsent AS ( event_index, topic_0, event_name, - decoded_flat :"chainIdTo" :: STRING AS chainIdTo, - decoded_flat :"data" :: STRING AS data_requestsent, - decoded_flat :"requestId" :: STRING AS requestId, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat, + decoded_log :"chainIdTo" :: STRING AS chainIdTo, + decoded_log :"data" :: STRING AS data_requestsent, + decoded_log :"requestId" :: STRING AS requestId, + decoded_log :"to" :: STRING AS to_address, + decoded_log, event_removed, tx_status, _log_id, @@ -93,12 +102,12 @@ locked AS ( topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, - decoded_flat :"from" :: STRING AS from_address, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat :"token" :: STRING AS token, - decoded_flat, + decoded_log :"from" :: STRING AS from_address, + decoded_log :"to" :: STRING AS to_address, + decoded_log :"token" :: STRING AS token, + decoded_log, event_removed, tx_status, _log_id, diff --git a/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql b/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql index 931c775..aef1553 100644 --- a/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql +++ b/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql @@ -20,22 +20,27 @@ WITH token_transfers AS ( from_address, to_address, raw_amount, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__transfers') }} + {{ ref('core__ez_token_transfers') }} WHERE from_address <> '0x0000000000000000000000000000000000000000' AND to_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), native_transfers AS ( @@ -50,12 +55,21 @@ native_transfers AS ( et.to_address, amount_precise_raw, identifier, - _call_id, - et._inserted_timestamp + concat_ws( + '-', + et.block_number, + et.tx_position, + CONCAT( + et.type, + '_', + et.trace_address + ) + ) AS _call_id, + et.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__native_transfers') }} + {{ ref('core__ez_native_transfers') }} et - INNER JOIN {{ ref('silver__transactions') }} + INNER JOIN {{ ref('core__fact_transactions') }} tx ON et.block_number = tx.block_number AND et.tx_hash = tx.tx_hash @@ -63,7 +77,7 @@ native_transfers AS ( et.to_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3' {% if is_incremental() %} -AND et._inserted_timestamp >= ( +AND et.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -120,14 +134,18 @@ dst_info AS ( tx_hash, topics [1] :: STRING AS encoded_data, SUBSTR(RIGHT(encoded_data, 12), 1, 4) AS destination_chain_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3' AND topics [0] :: STRING = '0x5ce4019f772fda6cb703b26bce3ec3006eb36b73f1d3a0eb441213317d9f5e9d' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/bridge/multichain/silver_bridge__multichain_v7_loganyswapout.sql b/models/silver/defi/bridge/multichain/silver_bridge__multichain_v7_loganyswapout.sql index 369affb..8fa3fd2 100644 --- a/models/silver/defi/bridge/multichain/silver_bridge__multichain_v7_loganyswapout.sql +++ b/models/silver/defi/bridge/multichain/silver_bridge__multichain_v7_loganyswapout.sql @@ -21,26 +21,34 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, - decoded_flat :"from" :: STRING AS from_address, - decoded_flat :"receiver" :: STRING AS receiver, - decoded_flat :"swapoutID" :: STRING AS swapoutID, + decoded_log :"from" :: STRING AS from_address, + decoded_log :"receiver" :: STRING AS receiver, + decoded_log :"swapoutID" :: STRING AS swapoutID, TRY_TO_NUMBER( - decoded_flat :"toChainID" :: STRING + decoded_log :"toChainID" :: STRING ) AS toChainID, - decoded_flat :"token" :: STRING AS token, - decoded_flat, + decoded_log :"token" :: STRING AS token, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x0d969ae475ff6fcaf0dcfa760d4d8607244e8d95e9bf426f8d5d69f9a3e525af' AND contract_address = '0x1633d66ca91ce4d81f63ea047b7b19beb92df7f3' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -50,6 +58,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/bridge/stargate/silver_bridge__stargate_createpool.sql b/models/silver/defi/bridge/stargate/silver_bridge__stargate_createpool.sql index 2622fd8..c110d96 100644 --- a/models/silver/defi/bridge/stargate/silver_bridge__stargate_createpool.sql +++ b/models/silver/defi/bridge/stargate/silver_bridge__stargate_createpool.sql @@ -29,8 +29,8 @@ WITH base_contracts AS ( WHERE from_address = LOWER('0x808d7c71ad2ba3FA531b068a2417C63106BC0949') AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/bridge/stargate/silver_bridge__stargate_swap.sql b/models/silver/defi/bridge/stargate/silver_bridge__stargate_swap.sql index 87420b6..74b485f 100644 --- a/models/silver/defi/bridge/stargate/silver_bridge__stargate_swap.sql +++ b/models/silver/defi/bridge/stargate/silver_bridge__stargate_swap.sql @@ -28,45 +28,53 @@ base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amountSD" :: STRING + decoded_log :"amountSD" :: STRING ) AS amountSD, TRY_TO_NUMBER( - decoded_flat :"chainId" :: STRING + decoded_log :"chainId" :: STRING ) AS chainId, CASE WHEN chainId < 100 THEN chainId + 100 ELSE chainId END AS destination_chain_id, TRY_TO_NUMBER( - decoded_flat :"dstPoolId" :: STRING + decoded_log :"dstPoolId" :: STRING ) AS dstPoolId, TRY_TO_NUMBER( - decoded_flat :"eqFee" :: STRING + decoded_log :"eqFee" :: STRING ) AS eqFee, TRY_TO_NUMBER( - decoded_flat :"eqReward" :: STRING + decoded_log :"eqReward" :: STRING ) AS eqReward, TRY_TO_NUMBER( - decoded_flat :"amountSD" :: STRING + decoded_log :"amountSD" :: STRING ) AS lpFee, TRY_TO_NUMBER( - decoded_flat :"amountSD" :: STRING + decoded_log :"amountSD" :: STRING ) AS protocolFee, - decoded_flat :"from" :: STRING AS from_address, - decoded_flat, + decoded_log :"from" :: STRING AS from_address, + decoded_log, token_address, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} d INNER JOIN pools p ON d.contract_address = p.pool_address WHERE topics [0] :: STRING = '0x34660fc8af304464529f48a778e03d03e4d34bcd5f9b6f0cfbf3cd238c642f7f' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -76,6 +84,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/bridge/symbiosis/silver_bridge__symbiosis_synthesizerequest.sql b/models/silver/defi/bridge/symbiosis/silver_bridge__symbiosis_synthesizerequest.sql index b91973a..cb3a073 100644 --- a/models/silver/defi/bridge/symbiosis/silver_bridge__symbiosis_synthesizerequest.sql +++ b/models/silver/defi/bridge/symbiosis/silver_bridge__symbiosis_synthesizerequest.sql @@ -21,27 +21,35 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"chainID" :: STRING + decoded_log :"chainID" :: STRING ) AS chainID, - decoded_flat :"from" :: STRING AS from_address, - decoded_flat :"id" :: STRING AS id, - decoded_flat :"revertableAddress" :: STRING AS revertableAddress, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat :"token" :: STRING AS token, - decoded_flat, + decoded_log :"from" :: STRING AS from_address, + decoded_log :"id" :: STRING AS id, + decoded_log :"revertableAddress" :: STRING AS revertableAddress, + decoded_log :"to" :: STRING AS to_address, + decoded_log :"token" :: STRING AS token, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x31325fe0a1a2e6a5b1e41572156ba5b4e94f0fae7e7f63ec21e9b5ce1e4b3eab' AND contract_address = '0xe75c7e85fe6add07077467064ad15847e6ba9877' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -51,6 +59,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql b/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql index cae5452..a81d008 100644 --- a/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql +++ b/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql @@ -21,20 +21,28 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"chainId" :: STRING + decoded_log :"chainId" :: STRING ) AS chainId, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat :"token" :: STRING AS token, - decoded_flat, + decoded_log :"to" :: STRING AS to_address, + decoded_log :"token" :: STRING AS token, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING IN ( '0xdc5bad4651c5fbe9977a696aadc65996c468cde1448dd468ec0d83bf61c4b57c', @@ -46,7 +54,7 @@ WITH base_evt AS ( '0xc05e61d0e7a63d27546389b7ad62fdff5a91aace' ) AND origin_to_address IS NOT NULL - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -56,6 +64,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql index 8f4661b..9416bc8 100644 --- a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql +++ b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql @@ -21,32 +21,40 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"chainId" :: STRING + decoded_log :"chainId" :: STRING ) AS chainId, TRY_TO_TIMESTAMP( - decoded_flat :"deadline" :: STRING + decoded_log :"deadline" :: STRING ) AS deadline, TRY_TO_NUMBER( - decoded_flat :"minDy" :: STRING + decoded_log :"minDy" :: STRING ) AS minDy, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat :"token" :: STRING AS token, + decoded_log :"to" :: STRING AS to_address, + decoded_log :"token" :: STRING AS token, TRY_TO_NUMBER( - decoded_flat :"tokenIndexFrom" :: STRING + decoded_log :"tokenIndexFrom" :: STRING ) AS tokenIndexFrom, TRY_TO_NUMBER( - decoded_flat :"tokenIndexTo" :: STRING + decoded_log :"tokenIndexTo" :: STRING ) AS tokenIndexTo, - decoded_flat, + decoded_log, event_removed, - tx_status, - _log_id, - _inserted_timestamp + IFF( + tx_succeeded, + 'SUCCESS', + 'FAIL' + ) AS tx_status, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING IN ( '0x91f25e9be0134ec851830e0e76dc71e06f9dade75a9b84e9524071dbbc319425', @@ -54,7 +62,7 @@ WITH base_evt AS ( '0x79c15604b92ef54d3f61f0c40caab8857927ca3d5092367163b4562c1699eb5f' --depositandswap ) AND contract_address = '0xc05e61d0e7a63d27546389b7ad62fdff5a91aace' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -64,6 +72,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/bridge/wormhole/silver_bridge__wormhole_transfers.sql b/models/silver/defi/bridge/wormhole/silver_bridge__wormhole_transfers.sql index ee5c00c..9272273 100644 --- a/models/silver/defi/bridge/wormhole/silver_bridge__wormhole_transfers.sql +++ b/models/silver/defi/bridge/wormhole/silver_bridge__wormhole_transfers.sql @@ -49,12 +49,16 @@ WITH token_transfers AS ( utils.udf_hex_to_int( segmented_data [5] :: STRING ) AS nonce, - _log_id, - tr._inserted_timestamp + CONCAT( + tr.tx_hash :: STRING, + '-', + tr.event_index :: STRING + ) AS _log_id, + tr.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__transfers') }} + {{ ref('core__ez_token_transfers') }} tr - INNER JOIN {{ ref('silver__transactions') }} + INNER JOIN {{ ref('core__fact_transactions') }} tx ON tr.block_number = tx.block_number AND tr.tx_hash = tx.tx_hash @@ -65,7 +69,7 @@ WITH token_transfers AS ( AND destination_chain_id <> 0 {% if is_incremental() %} -AND tr._inserted_timestamp >= ( +AND tr.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -112,12 +116,20 @@ native_transfers AS ( utils.udf_hex_to_int( segmented_data [3] :: STRING ) AS nonce, - _call_id, - et._inserted_timestamp + concat_ws( + '-', + et.block_number, + et.tx_position, + CONCAT( + et.type, + '_', + et.trace_address + ) AS _call_id, + et.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__native_transfers') }} + {{ ref('core__ez_native_transfers') }} et - INNER JOIN {{ ref('silver__transactions') }} + INNER JOIN {{ ref('core__fact_transactions') }} tx ON et.block_number = tx.block_number AND et.tx_hash = tx.tx_hash @@ -127,12 +139,13 @@ native_transfers AS ( AND destination_chain_id <> 0 {% if is_incremental() %} -AND et._inserted_timestamp >= ( +AND et.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) +AND et.modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ), all_transfers AS ( diff --git a/models/silver/defi/dex/balancer/silver_dex__balancer_pools.sql b/models/silver/defi/dex/balancer/silver_dex__balancer_pools.sql index c12be47..9f6815b 100644 --- a/models/silver/defi/dex/balancer/silver_dex__balancer_pools.sql +++ b/models/silver/defi/dex/balancer/silver_dex__balancer_pools.sql @@ -20,18 +20,22 @@ WITH pools_registered AS ( 1, 42 ) AS pool_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp ROW_NUMBER() over ( ORDER BY pool_address ) AS row_num FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x3c13bc30b8e878c53fd2a36b679409c073afd75950be43d8858768e956fbc20e' --PoolRegistered AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -41,6 +45,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), tokens_registered AS ( @@ -50,8 +55,8 @@ tokens_registered AS ( event_index, tx_hash, contract_address, - decoded_flat :poolId :: STRING AS pool_id, - decoded_flat :tokens AS tokens, + decoded_log :poolId :: STRING AS pool_id, + decoded_log :tokens AS tokens, tokens [0] :: STRING AS token0, tokens [1] :: STRING AS token1, tokens [2] :: STRING AS token2, @@ -60,11 +65,11 @@ tokens_registered AS ( tokens [5] :: STRING AS token5, tokens [6] :: STRING AS token6, tokens [7] :: STRING AS token7, - decoded_flat :assetManagers AS asset_managers, + decoded_log :assetManagers AS asset_managers, _log_id, _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xf5847d3f2197b16cdcd2098ec95d0905cd1abdaf415f07bb7cef2bba8ac5dec4' --TokensRegistered AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8' @@ -74,7 +79,7 @@ tokens_registered AS ( FROM pools_registered ) - AND tx_status = 'SUCCESS' + AND tx_succeeded ), function_sigs AS ( SELECT diff --git a/models/silver/defi/dex/balancer/silver_dex__balancer_swaps.sql b/models/silver/defi/dex/balancer/silver_dex__balancer_swaps.sql index a2e8257..c6d9460 100644 --- a/models/silver/defi/dex/balancer/silver_dex__balancer_swaps.sql +++ b/models/silver/defi/dex/balancer/silver_dex__balancer_swaps.sql @@ -44,17 +44,21 @@ swaps_base AS ( 1, 42 ) AS pool_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'balancer' AS platform, origin_from_address AS sender, origin_from_address AS tx_to FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x2170c741c41531aec20e7c107c24eecfdd15e69c9bb0a8dd37b1840b9e0b207b' AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -64,6 +68,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/curve/silver_dex__curve_pools.sql b/models/silver/defi/dex/curve/silver_dex__curve_pools.sql index 375c633..257467c 100644 --- a/models/silver/defi/dex/curve/silver_dex__curve_pools.sql +++ b/models/silver/defi/dex/curve/silver_dex__curve_pools.sql @@ -42,8 +42,8 @@ WITH contract_deployments AS ( '0xb17b674d9c5cb2e441f8e196a2f048a81355d031' ) AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -53,6 +53,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} qualify(ROW_NUMBER() over(PARTITION BY to_address diff --git a/models/silver/defi/dex/curve/silver_dex__curve_swaps.sql b/models/silver/defi/dex/curve/silver_dex__curve_swaps.sql index 4ad07b4..c55e72a 100644 --- a/models/silver/defi/dex/curve/silver_dex__curve_swaps.sql +++ b/models/silver/defi/dex/curve/silver_dex__curve_swaps.sql @@ -57,10 +57,14 @@ curve_base AS ( TRY_TO_NUMBER(utils.udf_hex_to_int( segmented_data [3] :: STRING )) AS tokens_bought, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} l + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address WHERE @@ -69,7 +73,7 @@ curve_base AS ( '0xb2e76ae99761dc136e598d4a629bb347eccb9532a5f8bbd72e18467c3c34cc98', --TokenExchange '0xd013ca23e77a65003c2c659c5442c00c805371b7fc1ebd4c206c41d1536bd90b' --TokenExchangeUnderlying ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -79,6 +83,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), @@ -108,7 +113,7 @@ token_transfers AS ( CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS from_address, CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS to_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' AND tx_hash IN ( @@ -127,6 +132,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), from_transfers AS ( diff --git a/models/silver/defi/dex/fraxswap/silver_dex__fraxswap_pools.sql b/models/silver/defi/dex/fraxswap/silver_dex__fraxswap_pools.sql index a15536e..6038f9b 100644 --- a/models/silver/defi/dex/fraxswap/silver_dex__fraxswap_pools.sql +++ b/models/silver/defi/dex/fraxswap/silver_dex__fraxswap_pools.sql @@ -20,17 +20,21 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( '0x5ca135cb8527d76e932f34b5145575f9d8cbe08e', --v1 factory '0xf77ca9b635898980fb219b4f4605c50e4ba58aff' --v2 factory ) AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --pairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -40,6 +44,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/fraxswap/silver_dex__fraxswap_swaps.sql b/models/silver/defi/dex/fraxswap/silver_dex__fraxswap_swaps.sql index f758c59..06ab4ae 100644 --- a/models/silver/defi/dex/fraxswap/silver_dex__fraxswap_swaps.sql +++ b/models/silver/defi/dex/fraxswap/silver_dex__fraxswap_swaps.sql @@ -50,16 +50,20 @@ swaps_base AS ( ) AS amount1Out, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools ON l.contract_address = pool_address WHERE l.topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' --Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -69,6 +73,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/gmx/silver_dex__gmx_swaps.sql b/models/silver/defi/dex/gmx/silver_dex__gmx_swaps.sql index 534e505..b762943 100644 --- a/models/silver/defi/dex/gmx/silver_dex__gmx_swaps.sql +++ b/models/silver/defi/dex/gmx/silver_dex__gmx_swaps.sql @@ -62,14 +62,18 @@ WITH swaps_base AS ( segmented_data [6] :: STRING ) ) AS feeBasisPoints, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x9ab2de34a33fb459b538c43f251eb825645e8595' AND topics [0] :: STRING = '0x0874b2d545cb271cdbda4e093020c452328b24af12382ed62c4d00f5c26709db' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -79,6 +83,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql b/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql index e36d572..bd159cc 100644 --- a/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql +++ b/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql @@ -22,8 +22,8 @@ WITH contract_deployments AS ( '0x7677bf119654d1fbcb46cb9014949bf16180b6ae' ) AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -33,6 +33,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} qualify(ROW_NUMBER() over(PARTITION BY to_address diff --git a/models/silver/defi/dex/hashflow/silver_dex__hashflow_swaps.sql b/models/silver/defi/dex/hashflow/silver_dex__hashflow_swaps.sql index f27fd12..7df3e1f 100644 --- a/models/silver/defi/dex/hashflow/silver_dex__hashflow_swaps.sql +++ b/models/silver/defi/dex/hashflow/silver_dex__hashflow_swaps.sql @@ -58,16 +58,20 @@ router_swaps_base AS ( l_segmented_data [6] :: STRING ) ) AS amountOut, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON l.contract_address = p.pool_address WHERE l.topics [0] :: STRING = '0xb709ddcc6550418e9b89df1f4938071eeaa3f6376309904c77e15d46b16066f5' --swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -77,6 +81,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), swaps_base AS ( @@ -124,25 +129,30 @@ swaps_base AS ( l_segmented_data [5] :: STRING ) ) AS amountOut, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON l.contract_address = p.pool_address WHERE l.topics [0] :: STRING = '0x8cf3dec1929508e5677d7db003124e74802bfba7250a572205a9986d86ca9f1e' --swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), FINAL AS ( diff --git a/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_pools.sql b/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_pools.sql index 807918d..cd757c7 100644 --- a/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_pools.sql +++ b/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_pools.sql @@ -14,14 +14,18 @@ WITH contract_deployments AS ( regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, origin_from_address AS deployer_address, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS pool_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0xde828fdc3f497f16416d1bb645261c7c6a62dab5' AND topics [0] :: STRING = '0xdbd2a1ea6808362e6adbec4db4969cbc11e3b0b28fb6c74cb342defaaf1daada' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -31,6 +35,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_swaps.sql b/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_swaps.sql index 02f2384..a082bc9 100644 --- a/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_swaps.sql +++ b/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_swaps.sql @@ -42,16 +42,20 @@ swaps AS ( segmented_data [6] :: STRING ) ) AS amountOut, - _log_id, - _inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON l.contract_address = p.pool_address WHERE l.topics [0] :: STRING = '0x34f57786fb01682fb4eec88d340387ef01a168fe345ea5b76f709d4e560c10eb' --Trade - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -61,6 +65,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_pools.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_pools.sql index 3034b44..9d49e6d 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_pools.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_pools.sql @@ -27,14 +27,18 @@ WITH pool_creation AS ( segmented_data [2] :: STRING ) ) AS totalPool, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x10908c875d865c66f271f5d3949848971c9595c9' --dynamic fee factory AND topics [0] :: STRING = '0xfc574402c445e75f2b79b67884ff9c662244dce454c5ae68935fcd0bebb7c8ff' --created pool - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT @@ -43,6 +47,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_swaps.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_swaps.sql index fca6cf8..757fd5d 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_swaps.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_swaps.sql @@ -55,16 +55,20 @@ swaps_base AS ( ) AS feeInPrecision, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address WHERE l.topics [0] :: STRING = '0x606ecd02b3e3b4778f8e97b2e03351de14224efaa5fa64e62200afc9395c2499' --Dynamic Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -74,6 +78,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_pools.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_pools.sql index eba70d1..1d5d8bc 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_pools.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_pools.sql @@ -32,14 +32,18 @@ WITH pool_creation AS ( segmented_data [3] :: STRING ) ) AS totalPool, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = LOWER('0x1c758aF0688502e49140230F6b0EBd376d429be5') --static pool factory AND topics [0] :: STRING = '0xb6bce363b712c921bead4bcc977289440eb6172eb89e258e3a25bd49ca806de6' --create pool - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -49,6 +53,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_swaps.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_swaps.sql index dcbda64..5606f8b 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_swaps.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_swaps.sql @@ -55,16 +55,20 @@ swaps_base AS ( ) AS feeInPrecision, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address WHERE l.topics [0] :: STRING = '0x606ecd02b3e3b4778f8e97b2e03351de14224efaa5fa64e62200afc9395c2499' -- static swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -74,6 +78,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_pools.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_pools.sql index 0245ee9..d222b44 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_pools.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_pools.sql @@ -23,14 +23,18 @@ WITH pool_creation AS ( ) ) AS tickDistance, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x5f1dddbf348ac2fbe22a163e30f99f9ece3dd50a' --Elastic Pool Deployer AND topics [0] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' --Create pool - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -40,6 +44,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_swaps.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_swaps.sql index 24ab80e..8ac89e4 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_swaps.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_swaps.sql @@ -68,16 +68,20 @@ swaps_base AS ( WHEN deltaQty0 > 0 THEN token0 ELSE token1 END AS token_out, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address WHERE topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' -- elastic swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -87,6 +91,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/pangolin/silver_dex__pangolin_pools.sql b/models/silver/defi/dex/pangolin/silver_dex__pangolin_pools.sql index fb36614..918c4ad 100644 --- a/models/silver/defi/dex/pangolin/silver_dex__pangolin_pools.sql +++ b/models/silver/defi/dex/pangolin/silver_dex__pangolin_pools.sql @@ -20,14 +20,18 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0xefa94de7a4656d787667c749f7e1223d71e9fd88' --factory AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --create pool - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -37,6 +41,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/pangolin/silver_dex__pangolin_swaps.sql b/models/silver/defi/dex/pangolin/silver_dex__pangolin_swaps.sql index e83ef59..d25f388 100644 --- a/models/silver/defi/dex/pangolin/silver_dex__pangolin_swaps.sql +++ b/models/silver/defi/dex/pangolin/silver_dex__pangolin_swaps.sql @@ -50,16 +50,20 @@ swaps_base AS ( ) AS amount1Out, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools ON l.contract_address = pool_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' --swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -69,6 +73,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v1_pools.sql b/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v1_pools.sql index c83b96c..ae263cd 100644 --- a/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v1_pools.sql +++ b/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v1_pools.sql @@ -20,14 +20,18 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [2] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = LOWER('0xaaa16c016bf556fcd620328f0759252e29b1ab57') AND topics [0] :: STRING = '0xc4805696c66d7cf352fc1d6bb633ad5ee82f6cb577c453024b6e0eb8306c6fc9' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -37,6 +41,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v1_swaps.sql b/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v1_swaps.sql index b44efe2..75be918 100644 --- a/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v1_swaps.sql +++ b/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v1_swaps.sql @@ -50,15 +50,19 @@ swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, token0, token1, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} INNER JOIN pools p ON p.pool_address = contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -68,6 +72,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v2_pools.sql b/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v2_pools.sql index 6322d29..919b910 100644 --- a/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v2_pools.sql +++ b/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v2_pools.sql @@ -25,14 +25,18 @@ WITH created_pools AS ( segmented_data [0] :: STRING )) AS tick_spacing, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' AND contract_address = '0xaaa32926fce6be95ea2c51cb4fcb60836d320c42' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -42,6 +46,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), initial_info AS ( @@ -55,10 +60,10 @@ initial_info AS ( init_tick ) AS init_price_1_0_unadj FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -68,6 +73,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), diff --git a/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v2_swaps.sql b/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v2_swaps.sql index bb8f192..c12841b 100644 --- a/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v2_swaps.sql +++ b/models/silver/defi/dex/pharaoh/silver_dex__pharaoh_v2_swaps.sql @@ -34,11 +34,11 @@ WITH base_swaps AS ( segmented_data [4] :: STRING ) :: FLOAT AS tick FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2023-03-23' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND event_removed = 'false' {% if is_incremental() %} @@ -49,6 +49,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), pool_data AS ( diff --git a/models/silver/defi/dex/platypus/silver_dex__platypus_pools.sql b/models/silver/defi/dex/platypus/silver_dex__platypus_pools.sql index a470556..ed723c2 100644 --- a/models/silver/defi/dex/platypus/silver_dex__platypus_pools.sql +++ b/models/silver/defi/dex/platypus/silver_dex__platypus_pools.sql @@ -19,8 +19,8 @@ WITH contract_deployments AS ( WHERE from_address = '0x416a7989a964c9ed60257b064efc3a30fe6bf2ee' AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -30,6 +30,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} qualify(ROW_NUMBER() over(PARTITION BY to_address diff --git a/models/silver/defi/dex/platypus/silver_dex__platypus_swaps.sql b/models/silver/defi/dex/platypus/silver_dex__platypus_swaps.sql index 77fa9ce..ce75391 100644 --- a/models/silver/defi/dex/platypus/silver_dex__platypus_swaps.sql +++ b/models/silver/defi/dex/platypus/silver_dex__platypus_swaps.sql @@ -54,16 +54,20 @@ swaps_base AS ( l_segmented_data [3] :: STRING ) ) AS toAmount, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON l.contract_address = p.pool_address WHERE topics [0] :: STRING = '0x54787c404bb33c88e86f4baf88183a3b0141d0a848e6a9f7a13b66ae3a9b73d1' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -73,6 +77,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/sushi/silver_dex__sushi_pools.sql b/models/silver/defi/dex/sushi/silver_dex__sushi_pools.sql index c5eb936..a7bd652 100644 --- a/models/silver/defi/dex/sushi/silver_dex__sushi_pools.sql +++ b/models/silver/defi/dex/sushi/silver_dex__sushi_pools.sql @@ -20,14 +20,18 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = LOWER('0xc35DADB65012eC5796536bD9864eD8773aBc74C4') AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -37,6 +41,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/sushi/silver_dex__sushi_swaps.sql b/models/silver/defi/dex/sushi/silver_dex__sushi_swaps.sql index 230d0ad..cfe911d 100644 --- a/models/silver/defi/dex/sushi/silver_dex__sushi_swaps.sql +++ b/models/silver/defi/dex/sushi/silver_dex__sushi_swaps.sql @@ -50,15 +50,19 @@ swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, token0, token1, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} INNER JOIN pools p ON p.pool_address = contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -68,6 +72,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v1_pools.sql b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v1_pools.sql index addff9a..5556a19 100644 --- a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v1_pools.sql +++ b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v1_pools.sql @@ -20,14 +20,18 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = LOWER('0x9Ad6C38BE94206cA50bb0d90783181662f0Cfa10') AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -37,6 +41,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v1_swaps.sql b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v1_swaps.sql index cbc581a..6d7be3c 100644 --- a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v1_swaps.sql +++ b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v1_swaps.sql @@ -50,16 +50,20 @@ swaps_base AS ( ) AS amount1Out, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address WHERE l.topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' --Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -69,6 +73,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_1_swaps.sql b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_1_swaps.sql index dcdf73d..378d2f3 100644 --- a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_1_swaps.sql +++ b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_1_swaps.sql @@ -72,16 +72,20 @@ swaps_base AS ( tokenX, tokenY, p.version, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON lb_pair = l.contract_address WHERE topics [0] :: STRING = '0xad7d6f97abf51ce18e17a38f4d70e975be9c0708474987bb3e26ad21bd93ca70' --Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -91,6 +95,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_pools.sql b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_pools.sql index e9814f4..be9c7c9 100644 --- a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_pools.sql +++ b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_pools.sql @@ -28,10 +28,14 @@ WITH pool_creation AS ( WHEN contract_address = '0x8e42f2f4101563bf679975178e880fd87d3efd4e' THEN 'v2.1' WHEN contract_address = '0xb43120c4745967fa9b93e79c149e66b0f2d6fe0c' THEN 'v2.2' END AS version, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( '0x8e42f2f4101563bf679975178e880fd87d3efd4e', @@ -41,7 +45,7 @@ WITH pool_creation AS ( '0xb43120c4745967fa9b93e79c149e66b0f2d6fe0c' --v2.2 ) AND topics [0] :: STRING = '0x2c8d104b27c6b7f4492017a6f5cf3803043688934ebcaa6a03540beeaf976aff' --LB PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -51,6 +55,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_swaps.sql b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_swaps.sql index 4837896..08da763 100644 --- a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_swaps.sql +++ b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_swaps.sql @@ -70,17 +70,21 @@ swaps_base AS ( WHEN swapForY THEN tokenX ELSE tokenY END AS token_in_address, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON lb_pair = l.contract_address WHERE topics [0] :: STRING = '0xc528cda9e500228b16ce84fadae290d9a49aecb17483110004c5af0a07f6fd73' --Swap AND version = 'v2' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -90,6 +94,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/uniswap/silver_dex__univ2_pools.sql b/models/silver/defi/dex/uniswap/silver_dex__univ2_pools.sql index 46fb553..ffe43c4 100644 --- a/models/silver/defi/dex/uniswap/silver_dex__univ2_pools.sql +++ b/models/silver/defi/dex/uniswap/silver_dex__univ2_pools.sql @@ -20,14 +20,18 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = LOWER('0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C') AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -37,6 +41,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/uniswap/silver_dex__univ2_swaps.sql b/models/silver/defi/dex/uniswap/silver_dex__univ2_swaps.sql index c2cc44c..a8d7ed1 100644 --- a/models/silver/defi/dex/uniswap/silver_dex__univ2_swaps.sql +++ b/models/silver/defi/dex/uniswap/silver_dex__univ2_swaps.sql @@ -50,15 +50,19 @@ swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, token0, token1, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} INNER JOIN pools p ON p.pool_address = contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -68,6 +72,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/dex/uniswap/silver_dex__univ3_pools.sql b/models/silver/defi/dex/uniswap/silver_dex__univ3_pools.sql index 6d16002..48e4553 100644 --- a/models/silver/defi/dex/uniswap/silver_dex__univ3_pools.sql +++ b/models/silver/defi/dex/uniswap/silver_dex__univ3_pools.sql @@ -25,14 +25,18 @@ WITH created_pools AS ( segmented_data [0] :: STRING )) AS tick_spacing, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' AND contract_address = '0x740b1c1de25031c31ff4fc9a62f554a55cdc1bad' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -42,6 +46,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), initial_info AS ( @@ -55,10 +60,10 @@ initial_info AS ( init_tick ) AS init_price_1_0_unadj FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -68,6 +73,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), diff --git a/models/silver/defi/dex/uniswap/silver_dex__univ3_swaps.sql b/models/silver/defi/dex/uniswap/silver_dex__univ3_swaps.sql index 5fd826e..cd3fd96 100644 --- a/models/silver/defi/dex/uniswap/silver_dex__univ3_swaps.sql +++ b/models/silver/defi/dex/uniswap/silver_dex__univ3_swaps.sql @@ -34,11 +34,11 @@ WITH base_swaps AS ( segmented_data [4] :: STRING ) :: FLOAT AS tick FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2023-03-23' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND event_removed = 'false' {% if is_incremental() %} @@ -49,6 +49,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), pool_data AS ( @@ -77,8 +78,12 @@ FINAL AS ( event_index, token0_address, token1_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, origin_function_signature, origin_from_address, origin_to_address, diff --git a/models/silver/defi/dex/woofi/silver_dex__woofi_swaps.sql b/models/silver/defi/dex/woofi/silver_dex__woofi_swaps.sql index 285bc2d..ab004a5 100644 --- a/models/silver/defi/dex/woofi/silver_dex__woofi_swaps.sql +++ b/models/silver/defi/dex/woofi/silver_dex__woofi_swaps.sql @@ -52,10 +52,14 @@ WITH router_swaps_base AS ( 40 ) ) AS rebateTo, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE contract_address IN ( @@ -65,7 +69,7 @@ WITH router_swaps_base AS ( '0x4c4af8dbc524681930a27b2f1af5bcc8062e6fb7' --v2 ) AND topics [0] :: STRING = '0x27c98e911efdd224f4002f6cd831c3ad0d2759ee176f9ee8466d95826af22a1c' --WooRouterSwap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -75,6 +79,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), swaps_base AS ( @@ -117,10 +122,14 @@ swaps_base AS ( 40 ) ) AS rebateTo, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash :: STRING, + '-', + l.event_index :: STRING + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE contract_address IN ( @@ -139,7 +148,7 @@ swaps_base AS ( FROM router_swaps_base ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -149,6 +158,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ) SELECT diff --git a/models/silver/defi/lending/aave/silver__aave_borrows.sql b/models/silver/defi/lending/aave/silver__aave_borrows.sql index f6697db..603ef79 100644 --- a/models/silver/defi/lending/aave/silver__aave_borrows.sql +++ b/models/silver/defi/lending/aave/silver__aave_borrows.sql @@ -61,10 +61,14 @@ borrow AS ( origin_to_address, contract_address ) AS lending_pool_contract, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b', @@ -78,9 +82,10 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} AND contract_address IN (SELECT distinct(aave_version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/aave/silver__aave_deposits.sql b/models/silver/defi/lending/aave/silver__aave_deposits.sql index d31f3c5..4091c11 100644 --- a/models/silver/defi/lending/aave/silver__aave_deposits.sql +++ b/models/silver/defi/lending/aave/silver__aave_deposits.sql @@ -55,10 +55,14 @@ deposits AS( origin_to_address, contract_address ) AS lending_pool_contract, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0xde6857219544bb5b7746f48ed30be6386fefc61b2f864cacf559893bf50fd951', @@ -72,9 +76,10 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} AND contract_address IN (SELECT distinct(aave_version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/aave/silver__aave_flashloans.sql b/models/silver/defi/lending/aave/silver__aave_flashloans.sql index d45b428..42c9c88 100644 --- a/models/silver/defi/lending/aave/silver__aave_flashloans.sql +++ b/models/silver/defi/lending/aave/silver__aave_flashloans.sql @@ -62,10 +62,14 @@ flashloan AS ( WHEN contract_address = '0x794a61358d6845594f94dc1db02a252b5b4814ad' THEN 'Aave V3' WHEN contract_address = '0x4f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c' THEN 'Aave V2' END AS aave_version, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0xefefaba5e921573100900a3ad9cf29f222d995fb3b6045797eaea7521bd8d6f0', --v3 @@ -79,9 +83,10 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} AND contract_address IN (SELECT distinct(aave_version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/aave/silver__aave_liquidations.sql b/models/silver/defi/lending/aave/silver__aave_liquidations.sql index f41a241..16ef720 100644 --- a/models/silver/defi/lending/aave/silver__aave_liquidations.sql +++ b/models/silver/defi/lending/aave/silver__aave_liquidations.sql @@ -55,10 +55,14 @@ liquidation AS( origin_to_address, contract_address ) AS lending_pool_contract, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0xe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e005286', @@ -72,9 +76,10 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} AND contract_address IN (SELECT distinct(aave_version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/aave/silver__aave_repayments.sql b/models/silver/defi/lending/aave/silver__aave_repayments.sql index 10bb48d..f7c2214 100644 --- a/models/silver/defi/lending/aave/silver__aave_repayments.sql +++ b/models/silver/defi/lending/aave/silver__aave_repayments.sql @@ -52,10 +52,14 @@ atoken_meta AS ( contract_address ) AS lending_pool_contract, origin_from_address AS repayer_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa', @@ -69,9 +73,10 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} AND contract_address IN (SELECT distinct(aave_version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/aave/silver__aave_tokens.sql b/models/silver/defi/lending/aave/silver__aave_tokens.sql index 358ba77..99637a0 100644 --- a/models/silver/defi/lending/aave/silver__aave_tokens.sql +++ b/models/silver/defi/lending/aave/silver__aave_tokens.sql @@ -14,9 +14,9 @@ logs AS ( SELECT * FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE - tx_status = 'SUCCESS' + tx_succeeded AND topics [0] IN ( '0xb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b', '0x3a0ca721fc364424566385a1aa271ed508cc2c0949c2272575fb3013a163a45f' diff --git a/models/silver/defi/lending/aave/silver__aave_withdraws.sql b/models/silver/defi/lending/aave/silver__aave_withdraws.sql index 10a184f..52020aa 100644 --- a/models/silver/defi/lending/aave/silver__aave_withdraws.sql +++ b/models/silver/defi/lending/aave/silver__aave_withdraws.sql @@ -51,10 +51,14 @@ withdraw AS( origin_to_address, contract_address ) AS lending_pool_contract, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f7', @@ -68,9 +72,10 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} AND contract_address IN (SELECT distinct(aave_version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/benqi/silver__benqi_asset_details.sql b/models/silver/defi/lending/benqi/silver__benqi_asset_details.sql index 73314f2..4ee0139 100644 --- a/models/silver/defi/lending/benqi/silver__benqi_asset_details.sql +++ b/models/silver/defi/lending/benqi/silver__benqi_asset_details.sql @@ -22,10 +22,10 @@ log_pull AS ( C.token_name, C.token_symbol, C.token_decimals, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + concat_ws('-', l.tx_hash, l.event_index) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l LEFT JOIN contracts C ON l.contract_address = C.contract_address @@ -34,15 +34,16 @@ log_pull AS ( AND token_name LIKE '%Benqi %' {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( - _inserted_timestamp + modified_timestamp ) - INTERVAL '12 hours' FROM {{ this }} ) -AND l._inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND l.modified_timestamp >= SYSDATE() - INTERVAL '7 day' +AND l.block_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ), traces_pull AS ( diff --git a/models/silver/defi/lending/benqi/silver__benqi_borrows.sql b/models/silver/defi/lending/benqi/silver__benqi_borrows.sql index b164b57..a8cd57c 100644 --- a/models/silver/defi/lending/benqi/silver__benqi_borrows.sql +++ b/models/silver/defi/lending/benqi/silver__benqi_borrows.sql @@ -43,10 +43,14 @@ benqi_borrows AS ( ) :: INTEGER AS totalBorrows, contract_address AS token, 'Benqi' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -55,7 +59,7 @@ benqi_borrows AS ( asset_details ) AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -65,6 +69,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), benqi_combine AS ( diff --git a/models/silver/defi/lending/benqi/silver__benqi_deposits.sql b/models/silver/defi/lending/benqi/silver__benqi_deposits.sql index 6cf629b..e0fed92 100644 --- a/models/silver/defi/lending/benqi/silver__benqi_deposits.sql +++ b/models/silver/defi/lending/benqi/silver__benqi_deposits.sql @@ -40,10 +40,14 @@ benqi_deposits AS ( ) :: INTEGER AS mintAmount_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS supplier, 'Benqi' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ benqi_deposits AS ( asset_details ) AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -62,6 +66,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), benqi_combine AS ( diff --git a/models/silver/defi/lending/benqi/silver__benqi_liquidations.sql b/models/silver/defi/lending/benqi/silver__benqi_liquidations.sql index c1faf48..d8c827c 100644 --- a/models/silver/defi/lending/benqi/silver__benqi_liquidations.sql +++ b/models/silver/defi/lending/benqi/silver__benqi_liquidations.sql @@ -43,10 +43,14 @@ benqi_liquidations AS ( ) :: INTEGER AS repayAmount_raw, CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS tokenCollateral, 'Benqi' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -55,7 +59,7 @@ benqi_liquidations AS ( asset_details ) AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -65,6 +69,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), liquidation_union AS ( diff --git a/models/silver/defi/lending/benqi/silver__benqi_repayments.sql b/models/silver/defi/lending/benqi/silver__benqi_repayments.sql index d1ea1a2..0747b85 100644 --- a/models/silver/defi/lending/benqi/silver__benqi_repayments.sql +++ b/models/silver/defi/lending/benqi/silver__benqi_repayments.sql @@ -38,10 +38,14 @@ benqi_repayments AS ( segmented_data [2] :: STRING ) :: INTEGER AS repayed_amount_raw, 'Benqi' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -50,7 +54,7 @@ benqi_repayments AS ( asset_details ) AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -60,6 +64,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), benqi_combine AS ( diff --git a/models/silver/defi/lending/benqi/silver__benqi_withdraws.sql b/models/silver/defi/lending/benqi/silver__benqi_withdraws.sql index b5e082f..e9cb52e 100644 --- a/models/silver/defi/lending/benqi/silver__benqi_withdraws.sql +++ b/models/silver/defi/lending/benqi/silver__benqi_withdraws.sql @@ -40,10 +40,14 @@ benqi_redemptions AS ( ) :: INTEGER AS redeemed_token_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS redeemer, 'Benqi' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ benqi_redemptions AS ( asset_details ) AND topics [0] :: STRING = '0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT @@ -61,6 +65,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), benqi_combine AS ( diff --git a/models/silver/defi/lending/trader_joe/silver__trader_joe_asset_details.sql b/models/silver/defi/lending/trader_joe/silver__trader_joe_asset_details.sql index b4d5897..55ab257 100644 --- a/models/silver/defi/lending/trader_joe/silver__trader_joe_asset_details.sql +++ b/models/silver/defi/lending/trader_joe/silver__trader_joe_asset_details.sql @@ -22,10 +22,10 @@ log_pull AS ( C.token_name, C.token_symbol, C.token_decimals, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + concat_ws('-', l.tx_hash, l.event_index) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l LEFT JOIN contracts C ON l.contract_address = C.contract_address @@ -34,7 +34,7 @@ log_pull AS ( AND token_name LIKE '%Banker Joe %' {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp @@ -42,7 +42,7 @@ AND l._inserted_timestamp >= ( FROM {{ this }} ) -AND l._inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND l.modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ), traces_pull AS ( diff --git a/models/silver/defi/lending/trader_joe/silver__trader_joe_borrows.sql b/models/silver/defi/lending/trader_joe/silver__trader_joe_borrows.sql index 1ae3357..6454488 100644 --- a/models/silver/defi/lending/trader_joe/silver__trader_joe_borrows.sql +++ b/models/silver/defi/lending/trader_joe/silver__trader_joe_borrows.sql @@ -43,10 +43,14 @@ trader_joe_borrows AS ( ) :: INTEGER AS totalBorrows, contract_address AS token, 'Trader-Joe' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -55,7 +59,7 @@ trader_joe_borrows AS ( asset_details ) AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -65,6 +69,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), trader_joe_combine AS ( diff --git a/models/silver/defi/lending/trader_joe/silver__trader_joe_deposits.sql b/models/silver/defi/lending/trader_joe/silver__trader_joe_deposits.sql index 120e8c8..804ac4e 100644 --- a/models/silver/defi/lending/trader_joe/silver__trader_joe_deposits.sql +++ b/models/silver/defi/lending/trader_joe/silver__trader_joe_deposits.sql @@ -40,10 +40,14 @@ trader_joe_deposits AS ( ) :: INTEGER AS mintAmount_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS supplier, 'Trader-Joe' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ trader_joe_deposits AS ( asset_details ) AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -62,6 +66,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), trader_joe_combine AS ( diff --git a/models/silver/defi/lending/trader_joe/silver__trader_joe_liquidations.sql b/models/silver/defi/lending/trader_joe/silver__trader_joe_liquidations.sql index c865fcf..f0001d7 100644 --- a/models/silver/defi/lending/trader_joe/silver__trader_joe_liquidations.sql +++ b/models/silver/defi/lending/trader_joe/silver__trader_joe_liquidations.sql @@ -43,10 +43,14 @@ trader_joe_liquidations AS ( ) :: INTEGER AS repayAmount_raw, CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS tokenCollateral, 'Trader-Joe' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -55,7 +59,7 @@ trader_joe_liquidations AS ( asset_details ) AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -65,6 +69,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), liquidation_union AS ( diff --git a/models/silver/defi/lending/trader_joe/silver__trader_joe_repayments.sql b/models/silver/defi/lending/trader_joe/silver__trader_joe_repayments.sql index f266c9c..1b09e8b 100644 --- a/models/silver/defi/lending/trader_joe/silver__trader_joe_repayments.sql +++ b/models/silver/defi/lending/trader_joe/silver__trader_joe_repayments.sql @@ -38,10 +38,14 @@ trader_joe_repayments AS ( segmented_data [2] :: STRING ) :: INTEGER AS repayed_amount_raw, 'Trader-Joe' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -50,7 +54,7 @@ trader_joe_repayments AS ( asset_details ) AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -60,6 +64,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), trader_joe_combine AS ( diff --git a/models/silver/defi/lending/trader_joe/silver__trader_joe_withdraws.sql b/models/silver/defi/lending/trader_joe/silver__trader_joe_withdraws.sql index 1c9ca5c..bd2c5e3 100644 --- a/models/silver/defi/lending/trader_joe/silver__trader_joe_withdraws.sql +++ b/models/silver/defi/lending/trader_joe/silver__trader_joe_withdraws.sql @@ -40,10 +40,14 @@ trader_joe_redemptions AS ( ) :: INTEGER AS redeemed_token_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS redeemer, 'Trader-Joe' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ trader_joe_redemptions AS ( asset_details ) AND topics [0] :: STRING = '0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT @@ -61,6 +65,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), trader_joe_combine AS ( diff --git a/models/silver/nft/sales/silver__element_sales.sql b/models/silver/nft/sales/silver__element_sales.sql index 48cc543..ab13d90 100644 --- a/models/silver/nft/sales/silver__element_sales.sql +++ b/models/silver/nft/sales/silver__element_sales.sql @@ -20,33 +20,33 @@ raw AS ( tx_hash, event_index, event_name, - decoded_flat, + decoded_log, IFF( event_name LIKE '%Buy%', 'bid_won', 'sale' ) AS event_type, - decoded_flat :erc20Token :: STRING AS currency_address_raw, + decoded_log :erc20Token :: STRING AS currency_address_raw, COALESCE( - decoded_flat :erc20TokenAmount, - decoded_flat :erc20FillAmount + decoded_log :erc20TokenAmount, + decoded_log :erc20FillAmount ) :: INT AS amount_raw, COALESCE( - decoded_flat :erc721Token, - decoded_flat :erc1155Token + decoded_log :erc721Token, + decoded_log :erc1155Token ) :: STRING AS nft_address, COALESCE( - decoded_flat :erc721TokenId, - decoded_flat :erc1155TokenId + decoded_log :erc721TokenId, + decoded_log :erc1155TokenId ) :: STRING AS tokenid, - decoded_flat :erc1155FillAmount :: STRING AS erc1155_value, + decoded_log :erc1155FillAmount :: STRING AS erc1155_value, IFF( erc1155_value IS NULL, 'erc721', 'erc1155' ) AS nft_type, - decoded_flat :maker :: STRING AS maker, - decoded_flat :taker :: STRING AS taker, + decoded_log :maker :: STRING AS maker, + decoded_log :taker :: STRING AS taker, IFF( event_name LIKE '%Buy%', taker, @@ -57,8 +57,8 @@ raw AS ( maker, taker ) AS buyer_address, - decoded_flat :fees AS fees_array, - decoded_flat :orderHash :: STRING AS orderhash, + decoded_log :fees AS fees_array, + decoded_log :orderHash :: STRING AS orderhash, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY @@ -66,10 +66,14 @@ raw AS ( ) AS intra_grouping_seller_fill, block_timestamp, block_number, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= ( SELECT @@ -98,6 +102,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), old_token_transfers AS ( @@ -133,7 +138,7 @@ old_token_transfers AS ( ELSE 0 END AS creator_amount_raw FROM - {{ ref('silver__transfers') }} + {{ ref('core__ez_token_transfers') }} WHERE block_timestamp :: DATE >= ( SELECT @@ -157,13 +162,14 @@ old_token_transfers AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), old_token_transfers_agg AS ( @@ -247,7 +253,7 @@ old_native_transfers AS ( AND TYPE = 'CALL' AND avax_value > 0 AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND trace_succeeded {% if is_incremental() %} AND modified_timestamp >= ( @@ -338,7 +344,7 @@ old_native_base AS ( intra_grouping_seller_fill, event_index, event_name, - decoded_flat, + decoded_log, event_type, currency_address_raw, amount_raw, @@ -381,7 +387,7 @@ old_token_base AS ( intra_grouping_seller_fill, event_index, event_name, - decoded_flat, + decoded_log, event_type, currency_address_raw, amount_raw, @@ -473,7 +479,7 @@ new_base AS ( intra_grouping_seller_fill, event_index, event_name, - decoded_flat, + decoded_log, event_type, currency_address_raw, amount_raw, @@ -546,7 +552,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= ( SELECT @@ -562,13 +568,13 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ) SELECT @@ -577,7 +583,7 @@ SELECT tx_hash, event_index, event_name, - decoded_flat, + decoded_log, event_type, ( SELECT diff --git a/models/silver/nft/sales/silver__joepegs_sales.sql b/models/silver/nft/sales/silver__joepegs_sales.sql index b721893..c23d763 100644 --- a/models/silver/nft/sales/silver__joepegs_sales.sql +++ b/models/silver/nft/sales/silver__joepegs_sales.sql @@ -11,7 +11,7 @@ WITH raw_decoded_logs AS ( SELECT * FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2022-04-01' AND contract_address IN ( @@ -34,6 +34,7 @@ AND _inserted_timestamp >= ( {{ this }} ) AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), sale_events AS ( @@ -41,13 +42,13 @@ sale_events AS ( tx_hash, event_name, contract_address AS platform_address, - decoded_flat, - decoded_flat :amount :: INT AS quantity, - decoded_flat :collection :: STRING AS nft_address, - decoded_flat :tokenId :: STRING AS tokenid, - decoded_flat :currency :: STRING AS currency_address, - decoded_flat :maker :: STRING AS maker, - decoded_flat :taker :: STRING AS taker, + decoded_log, + decoded_log :amount :: INT AS quantity, + decoded_log :collection :: STRING AS nft_address, + decoded_log :tokenId :: STRING AS tokenid, + decoded_log :currency :: STRING AS currency_address, + decoded_log :maker :: STRING AS maker, + decoded_log :taker :: STRING AS taker, IFF( event_name = 'TakerBid', taker, @@ -58,10 +59,10 @@ sale_events AS ( maker, taker ) AS seller_address, - decoded_flat :price :: INT AS total_price_raw, - decoded_flat :strategy :: STRING AS strategy, - decoded_flat :orderHash :: STRING AS orderhash, - decoded_flat :orderNonce :: STRING AS ordernonce, + decoded_log :price :: INT AS total_price_raw, + decoded_log :strategy :: STRING AS strategy, + decoded_log :orderHash :: STRING AS orderhash, + decoded_log :orderNonce :: STRING AS ordernonce, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY @@ -77,8 +78,12 @@ sale_events AS ( origin_from_address, origin_to_address, origin_function_signature, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM raw_decoded_logs WHERE @@ -92,12 +97,12 @@ royalty_events AS ( SELECT tx_hash, event_index AS royalty_event_index, - decoded_flat, - decoded_flat :amount :: INT AS creator_fee_raw_, - decoded_flat :currency :: STRING AS royalty_currency, - decoded_flat :collection :: STRING AS nft_address, - decoded_flat :tokenId :: STRING AS tokenid, - decoded_flat :royaltyRecipient :: STRING AS royalty_recipient, + decoded_log, + decoded_log :amount :: INT AS creator_fee_raw_, + decoded_log :currency :: STRING AS royalty_currency, + decoded_log :collection :: STRING AS nft_address, + decoded_log :tokenId :: STRING AS tokenid, + decoded_log :royaltyRecipient :: STRING AS royalty_recipient, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY @@ -178,9 +183,9 @@ platform_fee_transfers AS ( SELECT tx_hash, event_index AS platform_event_index, - decoded_flat :dst :: STRING AS platform_fee_recipient, - decoded_flat :src :: STRING AS platform_fee_payer, - decoded_flat :wad :: INT AS platform_fee_raw_ + decoded_log :dst :: STRING AS platform_fee_recipient, + decoded_log :src :: STRING AS platform_fee_payer, + decoded_log :wad :: INT AS platform_fee_raw_ FROM raw_decoded_logs WHERE @@ -241,7 +246,7 @@ nft_address_type AS ( contract_address AS nft_address, token_transfer_type FROM - {{ ref('silver__nft_transfers') }} + {{ ref('nft__ez_nft_transfers') }} WHERE block_timestamp :: DATE >= '2022-04-01' AND contract_address IN ( @@ -252,13 +257,14 @@ nft_address_type AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT - MAX(_inserted_timestamp) - INTERVAL '12 hours' + MAX(modified_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} qualify ROW_NUMBER() over ( @@ -316,7 +322,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2022-04-01' AND tx_hash IN ( @@ -327,13 +333,13 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ) SELECT diff --git a/models/silver/nft/sales/silver__salvor_sales.sql b/models/silver/nft/sales/silver__salvor_sales.sql index 4f0b481..3cd4426 100644 --- a/models/silver/nft/sales/silver__salvor_sales.sql +++ b/models/silver/nft/sales/silver__salvor_sales.sql @@ -19,7 +19,7 @@ WITH raw_logs AS ( WHEN topics [0] :: STRING = '0x2f258d8ad9499ea044033d10f2d28e770de5366a12c487afee76b4083e8edfb9' THEN 'ShareIncome' END AS topics_event_name FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2022-10-01' AND contract_address IN ( @@ -35,16 +35,17 @@ WITH raw_logs AS ( '0x15d4649ef85f6d7a1e2068dd3d0c51d49d0257fa627d1e46abe3e1b3458d8b00', '0x2f258d8ad9499ea044033d10f2d28e770de5366a12c487afee76b4083e8edfb9' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT - MAX(_inserted_timestamp) - INTERVAL '12 hours' + MAX(modified_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), auction_tag AS ( @@ -342,7 +343,7 @@ nft_transfers AS ( tokenid, erc1155_value FROM - {{ ref('silver__nft_transfers') }} + {{ ref('nft__ez_nft_transfers') }} WHERE block_timestamp :: DATE >= '2022-10-01' AND tx_hash IN ( @@ -358,7 +359,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2022-10-01' AND tx_hash IN ( @@ -369,13 +370,14 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), final_base AS ( diff --git a/models/silver/nft/sales/silver__seaport_1_1_sales.sql b/models/silver/nft/sales/silver__seaport_1_1_sales.sql index 5fda594..a7842b6 100644 --- a/models/silver/nft/sales/silver__seaport_1_1_sales.sql +++ b/models/silver/nft/sales/silver__seaport_1_1_sales.sql @@ -23,44 +23,48 @@ seaport_tx_table AS ( block_timestamp, tx_hash FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp >= '2022-07-01' AND contract_address = '0x00000000006c3852cbef3e08e8df289169ede581' AND topics [0] = '0x9d9af8e38d66c62e2c12f0225249fd9d721c54b83f48d9352c97c6cacdcb6f31' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ), decoded AS ( SELECT tx_hash, - decoded_flat, + decoded_log, event_index, - decoded_data, - _log_id, - _inserted_timestamp, + full_decoded_log, + CONCAT( + event_index :: STRING, + '-', + tx_hash :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, LOWER( - decoded_data :address :: STRING + full_decoded_log :address :: STRING ) AS contract_address, - decoded_data :name :: STRING AS event_name, + full_decoded_log :name :: STRING AS event_name, CASE - WHEN decoded_data :data [4] :value [0] [0] IN ( + WHEN full_decoded_log :data [4] :value [0] [0] IN ( 2, 3 ) THEN 'buy' - WHEN decoded_data :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' + WHEN full_decoded_log :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' ELSE NULL END AS trade_type FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2022-07-01' AND contract_address = '0x00000000006c3852cbef3e08e8df289169ede581' @@ -72,13 +76,13 @@ decoded AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ), offer_length_count_buy AS ( @@ -91,7 +95,11 @@ offer_length_count_buy AS ( ) AS offer_length_raw --> this is the number of nfts in a batch buy. If n = 1, then price is known. If n > 1 then price is estimated FROM decoded, - TABLE(FLATTEN(input => decoded_data :data [4] :value)) + TABLE( + FLATTEN( + input => full_decoded_log :data [4] :value + ) + ) WHERE trade_type = 'buy' AND VALUE [0] IN ( @@ -113,7 +121,11 @@ offer_length_count_offer AS ( ) AS offer_length_raw --> this is the number of nfts in a batch buy. If n = 1, then price is known. If n > 1 then price is estimated FROM decoded, - TABLE(FLATTEN(input => decoded_data :data [5] :value)) + TABLE( + FLATTEN( + input => full_decoded_log :data [5] :value + ) + ) WHERE trade_type = 'offer_accepted' AND VALUE [0] IN ( @@ -132,7 +144,7 @@ flat_raw AS ( contract_address, event_name, trade_type, - decoded_data :data AS full_data, + full_decoded_log :data AS full_data, _log_id, _inserted_timestamp, OBJECT_AGG( @@ -142,7 +154,7 @@ flat_raw AS ( FROM decoded, LATERAL FLATTEN( - input => decoded_data :data + input => full_decoded_log :data ) f WHERE event_name = 'OrderFulfilled' @@ -1037,7 +1049,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2022-07-01' AND tx_hash IN ( @@ -1048,13 +1060,13 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ), nft_transfer_operator AS ( @@ -1075,7 +1087,7 @@ nft_transfer_operator AS ( ) ) AS erc1155_value FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2022-07-01' AND tx_hash IN ( @@ -1090,13 +1102,13 @@ nft_transfer_operator AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ) SELECT diff --git a/models/silver/nft/sales/silver__seaport_1_4_sales.sql b/models/silver/nft/sales/silver__seaport_1_4_sales.sql index b04f890..0c1b783 100644 --- a/models/silver/nft/sales/silver__seaport_1_4_sales.sql +++ b/models/silver/nft/sales/silver__seaport_1_4_sales.sql @@ -22,19 +22,20 @@ raw_decoded_logs AS ( SELECT * FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-03-01' AND contract_address = '0x00000000000001ad428e4906ae43d8f9852d0dd6' AND event_name = 'OrderFulfilled' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '24 hours' FROM {{ this }} ) + {% endif %} ), mao_buy_tx AS ( @@ -42,11 +43,11 @@ mao_buy_tx AS ( tx_hash, event_index, CASE - WHEN decoded_data :data [4] :value [0] [0] IN ( + WHEN full_decoded_log :data [4] :value [0] [0] IN ( 2, 3 ) THEN 'buy' - WHEN decoded_data :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' + WHEN full_decoded_log :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' ELSE NULL END AS trade_type FROM @@ -59,11 +60,11 @@ mao_offer_accepted_tx AS ( block_number, tx_hash, CASE - WHEN decoded_data :data [4] :value [0] [0] IN ( + WHEN full_decoded_log :data [4] :value [0] [0] IN ( 2, 3 ) THEN 'buy' - WHEN decoded_data :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' + WHEN full_decoded_log :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' ELSE NULL END AS trade_type FROM @@ -81,13 +82,13 @@ raw_logs AS ( SELECT * FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2023-03-01' AND contract_address = '0x00000000000001ad428e4906ae43d8f9852d0dd6' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '24 hours' FROM @@ -159,18 +160,18 @@ mao_orderhash AS ( mao_raw_decoded AS ( SELECT CASE - WHEN decoded_data :data [4] :value [0] [0] IN ( + WHEN full_decoded_log :data [4] :value [0] [0] IN ( 2, 3 ) THEN 'buy' - WHEN decoded_data :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' + WHEN full_decoded_log :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' ELSE NULL END AS trade_type, - decoded_flat :orderHash :: STRING AS orderhash, + decoded_log :orderHash :: STRING AS orderhash, CONCAT( tx_hash, '-', - decoded_flat :orderHash :: STRING + decoded_log :orderHash :: STRING ) AS tx_hash_orderhash,* FROM raw_decoded_logs @@ -201,26 +202,30 @@ mao_orderhash AS ( decoded AS ( SELECT tx_hash, - decoded_flat, + decoded_log, event_index, - decoded_data, + full_decoded_log, CONCAT( tx_hash, '-', - decoded_flat :orderHash :: STRING + decoded_log :orderHash :: STRING ) AS tx_hash_orderhash, - _log_id, - _inserted_timestamp, + CONCAT( + event_index :: STRING, + '-', + tx_hash :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, LOWER( - decoded_data :address :: STRING + full_decoded_log :address :: STRING ) AS contract_address, - decoded_data :name :: STRING AS event_name, + full_decoded_log :name :: STRING AS event_name, CASE - WHEN decoded_data :data [4] :value [0] [0] IN ( + WHEN full_decoded_log :data [4] :value [0] [0] IN ( 2, 3 ) THEN 'buy' - WHEN decoded_data :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' + WHEN full_decoded_log :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' ELSE NULL END AS trade_type FROM @@ -242,42 +247,42 @@ mao_orderhash AS ( offer_length_match_advanced_order_oa AS ( SELECT tx_hash, - decoded_flat :orderHash :: STRING AS orderhash, + decoded_log :orderHash :: STRING AS orderhash, COUNT(1) AS offer_length_raw FROM mao_raw_decoded, - TABLE(FLATTEN(input => decoded_flat :consideration)) + TABLE(FLATTEN(input => decoded_log :consideration)) WHERE trade_type = 'offer_accepted' AND VALUE :itemType IN ( 2, 3 ) - AND decoded_flat :consideration [0] IS NOT NULL + AND decoded_log :consideration [0] IS NOT NULL GROUP BY tx_hash, - decoded_flat :orderHash :: STRING + decoded_log :orderHash :: STRING HAVING offer_length_raw IS NOT NULL ), offer_length_match_advanced_order_buy AS ( SELECT tx_hash, - decoded_flat :orderHash :: STRING AS orderhash, + decoded_log :orderHash :: STRING AS orderhash, COUNT(1) AS offer_length_raw FROM mao_raw_decoded, - TABLE(FLATTEN(input => decoded_flat :consideration)) + TABLE(FLATTEN(input => decoded_log :consideration)) WHERE trade_type = 'buy' AND VALUE :itemType IN ( 2, 3 ) - AND decoded_flat :consideration [0] IS NOT NULL + AND decoded_log :consideration [0] IS NOT NULL GROUP BY tx_hash, - decoded_flat :orderHash :: STRING + decoded_log :orderHash :: STRING ), offer_length_match_advanced_order_combined AS ( SELECT @@ -317,7 +322,11 @@ mao_orderhash AS ( ) AS offer_length_raw --> this is the number of nfts in a batch buy. If n = 1, then price is known. If n > 1 then price is estimated FROM decoded, - TABLE(FLATTEN(input => decoded_data :data [4] :value)) + TABLE( + FLATTEN( + input => full_decoded_log :data [4] :value + ) + ) WHERE trade_type = 'buy' AND VALUE [0] IN ( @@ -339,7 +348,11 @@ mao_orderhash AS ( ) AS offer_length_raw --> this is the number of nfts in a batch buy. If n = 1, then price is known. If n > 1 then price is estimated FROM decoded, - TABLE(FLATTEN(input => decoded_data :data [5] :value)) + TABLE( + FLATTEN( + input => full_decoded_log :data [5] :value + ) + ) WHERE trade_type = 'offer_accepted' AND VALUE [0] IN ( @@ -358,7 +371,7 @@ mao_orderhash AS ( contract_address, event_name, trade_type, - decoded_data :data AS full_data, + full_decoded_log :data AS full_data, _log_id, _inserted_timestamp, OBJECT_AGG( @@ -368,7 +381,7 @@ mao_orderhash AS ( FROM decoded, LATERAL FLATTEN( - input => decoded_data :data + input => full_decoded_log :data ) f WHERE event_name IN ( @@ -1194,31 +1207,35 @@ mao_orderhash AS ( contract_address, trade_type, offer_length_raw, - decoded_data, - decoded_flat, - decoded_flat :offerer :: STRING AS offerer, + full_decoded_log, + decoded_log, + decoded_log :offerer :: STRING AS offerer, -- or the one who proposed the sale so that they receive the nft - decoded_flat :zone :: STRING AS ZONE, - decoded_flat :recipient :: STRING AS recipient, - decoded_flat :orderHash :: STRING AS orderhash, + decoded_log :zone :: STRING AS ZONE, + decoded_log :recipient :: STRING AS recipient, + decoded_log :orderHash :: STRING AS orderhash, COALESCE( A.tx_hash_orderhash_full, b.tx_hash_orderhash_full ) AS tx_hash_orderhash_full, - decoded_flat :offer [0] :token :: STRING AS payment_token, + decoded_log :offer [0] :token :: STRING AS payment_token, ( - decoded_flat :offer [0] :amount :: INT + decoded_log :offer [0] :amount :: INT ) / offer_length_raw AS total_sale_price_raw, - _inserted_timestamp, - _log_id + r.modified_timestamp AS _inserted_timestamp, + CONCAT( + r.event_index :: STRING, + '-', + r.tx_hash :: STRING + ) AS _log_id FROM mao_raw_decoded r LEFT JOIN mao_orderhash_full A ON r.tx_hash = A.tx_hash - AND r.decoded_flat :orderHash :: STRING = A.orderhash_1 + AND r.decoded_log :orderHash :: STRING = A.orderhash_1 LEFT JOIN mao_orderhash_full b ON r.tx_hash = b.tx_hash - AND r.decoded_flat :orderHash :: STRING = b.orderhash_2 + AND r.decoded_log :orderHash :: STRING = b.orderhash_2 INNER JOIN offer_length_match_advanced_order o ON r.tx_hash = o.tx_hash AND COALESCE( @@ -1227,7 +1244,7 @@ mao_orderhash AS ( ) = o.tx_hash_orderhash_full WHERE trade_type = 'offer_accepted' - AND decoded_flat :offer [0] :itemType :: INT IN ( + AND decoded_log :offer [0] :itemType :: INT IN ( 0, 1 ) @@ -1236,9 +1253,9 @@ mao_orderhash AS ( SELECT tx_hash, event_index, - decoded_flat :orderHash :: STRING AS orderhash, - decoded_flat :offerer :: STRING AS transfers_nft_receiver, - decoded_flat :recipient :: STRING AS transfers_nft_seller, + decoded_log :orderHash :: STRING AS orderhash, + decoded_log :offerer :: STRING AS transfers_nft_receiver, + decoded_log :recipient :: STRING AS transfers_nft_seller, VALUE :token :: STRING AS nft_address, VALUE :identifier :: STRING AS tokenId, VALUE :amount :: INT AS nft_tokenid_quantity, @@ -1247,7 +1264,7 @@ mao_orderhash AS ( FROM mao_raw_decoded, LATERAL FLATTEN ( - input => decoded_flat :consideration + input => decoded_log :consideration ) WHERE trade_type = 'offer_accepted' @@ -1283,9 +1300,9 @@ mao_orderhash AS ( SELECT tx_hash, event_index, - decoded_flat :orderHash :: STRING AS orderhash, - decoded_flat :offerer :: STRING AS transfers_nft_seller, - decoded_flat :recipient :: STRING AS transfers_nft_receiver, + decoded_log :orderHash :: STRING AS orderhash, + decoded_log :offerer :: STRING AS transfers_nft_seller, + decoded_log :recipient :: STRING AS transfers_nft_receiver, VALUE :token :: STRING AS nft_address, VALUE :identifier :: STRING AS tokenId, VALUE :amount :: INT AS nft_tokenid_quantity, @@ -1294,7 +1311,7 @@ mao_orderhash AS ( FROM mao_raw_decoded, LATERAL FLATTEN ( - input => decoded_flat :consideration + input => decoded_log :consideration ) WHERE trade_type = 'buy' @@ -1340,7 +1357,7 @@ mao_orderhash AS ( match_advanced_orders_fees_oa_consideration AS ( SELECT tx_hash, - decoded_flat, + decoded_log, event_index, VALUE :token :: STRING AS payment_token, VALUE :amount :: INT AS raw_amount, @@ -1366,7 +1383,7 @@ mao_orderhash AS ( FROM mao_raw_decoded, LATERAL FLATTEN ( - input => decoded_flat :consideration + input => decoded_log :consideration ) f WHERE trade_type = 'offer_accepted' @@ -1390,8 +1407,8 @@ mao_orderhash AS ( match_advanced_orders_fees_buy_consideration AS ( SELECT tx_hash, - decoded_flat, - decoded_flat :orderHash :: STRING AS orderhash, + decoded_log, + decoded_log :orderHash :: STRING AS orderhash, VALUE :token :: STRING AS payment_token, VALUE :amount :: INT AS raw_amount, VALUE :recipient :: STRING AS royalty_recipient, @@ -1417,7 +1434,7 @@ mao_orderhash AS ( FROM mao_raw_decoded, LATERAL FLATTEN ( - input => decoded_flat :consideration + input => decoded_log :consideration ) WHERE trade_type = 'buy' @@ -1434,7 +1451,7 @@ mao_orderhash AS ( match_advanced_orders_fees_buy_consideration_filtered AS ( SELECT C.tx_hash, - decoded_flat, + decoded_log, C.orderhash, COALESCE( A.tx_hash_orderhash_full, @@ -1485,11 +1502,11 @@ mao_orderhash AS ( 'true', 'false' ) AS is_price_estimated, - decoded_flat, + decoded_log, -- using decoded flat here instead of decoded_output so that we're able to filter for match advanced orders - decoded_flat :consideration AS consideration, - decoded_flat :offer AS offer, - decoded_flat :consideration [0] :itemType AS tx_type, + decoded_log :consideration AS consideration, + decoded_log :offer AS offer, + decoded_log :consideration [0] :itemType AS tx_type, ZONE, transfers_nft_receiver AS recipient, --buyer_address in final @@ -1621,7 +1638,7 @@ mao_orderhash AS ( total_fees_raw, platform_fee_raw_total AS platform_fee_raw, creator_fee_raw_total AS creator_fee_raw, - decoded_flat, + decoded_log, consideration, offer, _log_id, @@ -1640,7 +1657,7 @@ mao_orderhash AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2023-03-01' AND tx_hash IN ( @@ -1651,12 +1668,14 @@ mao_orderhash AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '24 hours' FROM {{ this }} ) +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), nft_transfer_operator AS ( @@ -1677,7 +1696,7 @@ nft_transfer_operator AS ( ) ) AS erc1155_value FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2022-07-01' AND tx_hash IN ( @@ -1692,14 +1711,15 @@ nft_transfer_operator AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '24 hours' FROM {{ this }} ) {% endif %} -), final_seaport AS ( +), +final_seaport AS ( SELECT t.block_number, t.block_timestamp, @@ -1757,12 +1777,12 @@ AND _inserted_timestamp >= ( FROM base_sales_buy_and_offer s INNER JOIN tx_data t USING (tx_hash) - LEFT JOIN nft_transfer_operator o USING ( - tx_hash, - nft_address_temp, - tokenid, - recipient - ) qualify(ROW_NUMBER() over(PARTITION BY nft_log_id + LEFT JOIN nft_transfer_operator o USING ( + tx_hash, + nft_address_temp, + tokenid, + recipient + ) qualify(ROW_NUMBER() over(PARTITION BY nft_log_id ORDER BY _inserted_timestamp DESC)) = 1 ) diff --git a/models/silver/nft/sales/silver__seaport_1_5_sales.sql b/models/silver/nft/sales/silver__seaport_1_5_sales.sql index df3f324..9117587 100644 --- a/models/silver/nft/sales/silver__seaport_1_5_sales.sql +++ b/models/silver/nft/sales/silver__seaport_1_5_sales.sql @@ -21,10 +21,10 @@ WITH seaport_fees_wallet AS ( raw_decoded_logs AS ( SELECT *, - decoded_flat :orderHash :: STRING AS orderhash, - tx_hash || '-' || decoded_flat :orderHash AS tx_hash_orderhash + decoded_log :orderHash :: STRING AS orderhash, + tx_hash || '-' || decoded_log :orderHash AS tx_hash_orderhash FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND contract_address = '0x00000000000000adc04c56bf30ac9d3c0aaf14dc' @@ -34,13 +34,13 @@ raw_decoded_logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), raw_logs AS ( @@ -65,7 +65,7 @@ raw_logs AS ( NULL ) AS order_hash FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND contract_address = '0x00000000000000adc04c56bf30ac9d3c0aaf14dc' @@ -76,13 +76,13 @@ raw_logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ), raw_logs_event_index_fill AS ( @@ -134,26 +134,30 @@ mao_orderhash AS ( decoded AS ( SELECT tx_hash, - decoded_flat, + decoded_log, event_index, - decoded_data, + full_decoded_log, CONCAT( tx_hash, '-', - decoded_flat :orderHash :: STRING + decoded_log :orderHash :: STRING ) AS tx_hash_orderhash, - _log_id, - _inserted_timestamp, + CONCAT( + event_index :: STRING, + '-', + tx_hash :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, LOWER( - decoded_data :address :: STRING + full_decoded_log :address :: STRING ) AS contract_address, - decoded_data :name :: STRING AS event_name, + full_decoded_log :name :: STRING AS event_name, CASE - WHEN decoded_data :data [4] :value [0] [0] IN ( + WHEN full_decoded_log :data [4] :value [0] [0] IN ( 2, 3 ) THEN 'buy' - WHEN decoded_data :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' + WHEN full_decoded_log :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' ELSE NULL END AS trade_type FROM @@ -177,7 +181,11 @@ offer_length_count_buy AS ( ) AS offer_length_raw --> this is the number of nfts in a batch buy. If n = 1, then price is known. If n > 1 then price is estimated FROM decoded, - TABLE(FLATTEN(input => decoded_data :data [4] :value)) + TABLE( + FLATTEN( + input => full_decoded_log :data [4] :value + ) + ) WHERE trade_type = 'buy' AND VALUE [0] IN ( @@ -199,7 +207,11 @@ offer_length_count_offer AS ( ) AS offer_length_raw --> this is the number of nfts in a batch buy. If n = 1, then price is known. If n > 1 then price is estimated FROM decoded, - TABLE(FLATTEN(input => decoded_data :data [5] :value)) + TABLE( + FLATTEN( + input => full_decoded_log :data [5] :value + ) + ) WHERE trade_type = 'offer_accepted' AND VALUE [0] IN ( @@ -218,7 +230,7 @@ flat_raw AS ( contract_address, event_name, trade_type, - decoded_data :data AS full_data, + full_decoded_log :data AS full_data, _log_id, _inserted_timestamp, OBJECT_AGG( @@ -228,7 +240,7 @@ flat_raw AS ( FROM decoded, LATERAL FLATTEN( - input => decoded_data :data + input => full_decoded_log :data ) f WHERE event_name IN ( @@ -1098,22 +1110,22 @@ mao_consideration_all AS ( SELECT tx_hash, event_index, - decoded_flat, + decoded_log, INDEX, orderhash, tx_hash_orderhash, - decoded_flat :offerer :: STRING AS offerer, - decoded_flat :recipient :: STRING AS recipient, + decoded_log :offerer :: STRING AS offerer, + decoded_log :recipient :: STRING AS recipient, VALUE, VALUE :amount :: INT AS amount, VALUE :identifier :: STRING AS identifier, VALUE :itemType :: INT AS item_type, VALUE :recipient :: STRING AS item_recipient, VALUE :token :: STRING AS item_token_address, - decoded_flat :offer [0] :amount :: INT AS offer_amount, - decoded_flat :offer [0] :identifier :: STRING AS offer_identifier, - decoded_flat :offer [0] :itemType :: INT AS offer_item_type, - decoded_flat :offer [0] :token :: STRING AS offer_item_token_address, + decoded_log :offer [0] :amount :: INT AS offer_amount, + decoded_log :offer [0] :identifier :: STRING AS offer_identifier, + decoded_log :offer [0] :itemType :: INT AS offer_item_type, + decoded_log :offer [0] :token :: STRING AS offer_item_token_address, IFF(item_type NOT IN (0, 1), CONCAT(item_token_address, '-', identifier, '-', amount), CONCAT(offer_item_token_address, '-', offer_identifier, '-', offer_amount)) AS nft_address_identifier, IFF(item_type NOT IN (0, 1), nft_address_identifier, NULL) AS nft_address_identifier_null, CASE @@ -1150,12 +1162,16 @@ mao_consideration_all AS ( ORDER BY INDEX ASC ) AS orderhash_within_event_index_rn, - _log_id, - _inserted_timestamp + CONCAT( + event_index :: STRING, + '-', + tx_hash :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM raw_decoded_logs, LATERAL FLATTEN ( - input => decoded_flat :consideration + input => decoded_log :consideration ) WHERE event_name = 'OrderFulfilled' @@ -1182,7 +1198,7 @@ mao_consideration_all_joined AS ( END AS nft_address_identifier_fill, IFF(item_type NOT IN (0, 1) AND offer_item_type NOT IN (0, 1) - AND decoded_flat :consideration [0] :itemType :: INT NOT IN (0, 1), CONCAT(tx_hash_orderhash, '-', event_index), NULL) AS deals_tag, + AND decoded_log :consideration [0] :itemType :: INT NOT IN (0, 1), CONCAT(tx_hash_orderhash, '-', event_index), NULL) AS deals_tag, CONCAT( tx_hash_orderhash, '-', @@ -1416,7 +1432,7 @@ mao_deals_nft_transfers_sales AS ( 0 ) AS creator_fee_raw, currency_address, - decoded_flat, + decoded_log, offerer, recipient, _log_id, @@ -1471,7 +1487,7 @@ mao_nondeals_nft_transfers_sales AS ( ) AS seller_address, offerer, recipient, - decoded_flat, + decoded_log, currency_address, sale_amount_raw, platform_fee_raw, @@ -1602,7 +1618,7 @@ mao_nondeals_nft_transfers_sales_fill_offer_length AS ( seller_address, offerer, recipient, - decoded_flat, + decoded_log, currency_address_fill AS currency_address, offer_length, sale_amount_raw_fill / offer_length AS sale_amount_raw, @@ -1624,7 +1640,7 @@ mao_combined_base AS ( tx_hash, om_event_index_fill, IFF( - decoded_flat :consideration [0] :itemType :: INT IN ( + decoded_log :consideration [0] :itemType :: INT IN ( 0, 1 ), @@ -1661,7 +1677,7 @@ mao_combined_base AS ( sale_amount_raw + total_fees_raw AS total_price_raw, offerer, recipient, - decoded_flat, + decoded_log, _log_id, _inserted_timestamp FROM @@ -1672,7 +1688,7 @@ mao_combined_base AS ( om_event_index_fill, -- the event index for the ordermatched IFF( - decoded_flat :consideration [0] :itemType :: INT IN ( + decoded_log :consideration [0] :itemType :: INT IN ( 0, 1 ), @@ -1708,7 +1724,7 @@ mao_combined_base AS ( sale_amount_raw + total_fees_raw AS total_price_raw, offerer, recipient, - decoded_flat, + decoded_log, _log_id, _inserted_timestamp FROM @@ -1816,7 +1832,7 @@ base_sales_buy_and_offer AS ( 'true', 'false' ) AS is_price_estimated, - decoded_flat :zone :: STRING AS ZONE, + decoded_log :zone :: STRING AS ZONE, item_type AS tx_type, item_type AS token_type, nft_address AS nft_address_temp, @@ -1831,9 +1847,9 @@ base_sales_buy_and_offer AS ( total_fees_raw, platform_fee_raw, creator_fee_raw, - decoded_flat, - decoded_flat :consideration AS consideration, - decoded_flat :offer AS offer, + decoded_log, + decoded_log :consideration AS consideration, + decoded_log :offer AS offer, seller_address AS seller_address_temp, buyer_address AS buyer_address_temp, _log_id, @@ -1852,7 +1868,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND tx_hash IN ( @@ -1863,13 +1879,13 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), nft_transfer_operator AS ( @@ -1890,7 +1906,7 @@ nft_transfer_operator AS ( ) ) AS erc1155_value FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND tx_hash IN ( @@ -1905,13 +1921,13 @@ nft_transfer_operator AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), final_seaport AS ( diff --git a/models/silver/nft/sales/silver__seaport_1_6_sales.sql b/models/silver/nft/sales/silver__seaport_1_6_sales.sql index 8e1fce3..a2cd083 100644 --- a/models/silver/nft/sales/silver__seaport_1_6_sales.sql +++ b/models/silver/nft/sales/silver__seaport_1_6_sales.sql @@ -21,10 +21,10 @@ WITH seaport_fees_wallet AS ( raw_decoded_logs AS ( SELECT *, - decoded_flat :orderHash :: STRING AS orderhash, - tx_hash || '-' || decoded_flat :orderHash AS tx_hash_orderhash + decoded_log :orderHash :: STRING AS orderhash, + tx_hash || '-' || decoded_log :orderHash AS tx_hash_orderhash FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2024-03-15' AND contract_address = '0x0000000000000068f116a894984e2db1123eb395' @@ -34,13 +34,13 @@ raw_decoded_logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), raw_logs AS ( @@ -65,7 +65,7 @@ raw_logs AS ( NULL ) AS order_hash FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2024-03-15' AND contract_address = '0x0000000000000068f116a894984e2db1123eb395' @@ -76,13 +76,13 @@ raw_logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ), raw_logs_event_index_fill AS ( @@ -134,26 +134,30 @@ mao_orderhash AS ( decoded AS ( SELECT tx_hash, - decoded_flat, + decoded_log, event_index, - decoded_data, + full_decoded_log, CONCAT( tx_hash, '-', - decoded_flat :orderHash :: STRING + decoded_log :orderHash :: STRING ) AS tx_hash_orderhash, - _log_id, - _inserted_timestamp, + CONCAT( + event_index :: STRING, + '-', + tx_hash :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, LOWER( - decoded_data :address :: STRING + full_decoded_log :address :: STRING ) AS contract_address, - decoded_data :name :: STRING AS event_name, + full_decoded_log :name :: STRING AS event_name, CASE - WHEN decoded_data :data [4] :value [0] [0] IN ( + WHEN full_decoded_log :data [4] :value [0] [0] IN ( 2, 3 ) THEN 'buy' - WHEN decoded_data :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' + WHEN full_decoded_log :data [4] :value [0] [0] IN (1) THEN 'offer_accepted' ELSE NULL END AS trade_type FROM @@ -177,7 +181,11 @@ offer_length_count_buy AS ( ) AS offer_length_raw --> this is the number of nfts in a batch buy. If n = 1, then price is known. If n > 1 then price is estimated FROM decoded, - TABLE(FLATTEN(input => decoded_data :data [4] :value)) + TABLE( + FLATTEN( + input => full_decoded_log :data [4] :value + ) + ) WHERE trade_type = 'buy' AND VALUE [0] IN ( @@ -199,7 +207,11 @@ offer_length_count_offer AS ( ) AS offer_length_raw --> this is the number of nfts in a batch buy. If n = 1, then price is known. If n > 1 then price is estimated FROM decoded, - TABLE(FLATTEN(input => decoded_data :data [5] :value)) + TABLE( + FLATTEN( + input => full_decoded_log :data [5] :value + ) + ) WHERE trade_type = 'offer_accepted' AND VALUE [0] IN ( @@ -218,7 +230,7 @@ flat_raw AS ( contract_address, event_name, trade_type, - decoded_data :data AS full_data, + full_decoded_log :data AS full_data, _log_id, _inserted_timestamp, OBJECT_AGG( @@ -228,7 +240,7 @@ flat_raw AS ( FROM decoded, LATERAL FLATTEN( - input => decoded_data :data + input => full_decoded_log :data ) f WHERE event_name IN ( @@ -1098,22 +1110,22 @@ mao_consideration_all AS ( SELECT tx_hash, event_index, - decoded_flat, + decoded_log, INDEX, orderhash, tx_hash_orderhash, - decoded_flat :offerer :: STRING AS offerer, - decoded_flat :recipient :: STRING AS recipient, + decoded_log :offerer :: STRING AS offerer, + decoded_log :recipient :: STRING AS recipient, VALUE, VALUE :amount :: INT AS amount, VALUE :identifier :: STRING AS identifier, VALUE :itemType :: INT AS item_type, VALUE :recipient :: STRING AS item_recipient, VALUE :token :: STRING AS item_token_address, - decoded_flat :offer [0] :amount :: INT AS offer_amount, - decoded_flat :offer [0] :identifier :: STRING AS offer_identifier, - decoded_flat :offer [0] :itemType :: INT AS offer_item_type, - decoded_flat :offer [0] :token :: STRING AS offer_item_token_address, + decoded_log :offer [0] :amount :: INT AS offer_amount, + decoded_log :offer [0] :identifier :: STRING AS offer_identifier, + decoded_log :offer [0] :itemType :: INT AS offer_item_type, + decoded_log :offer [0] :token :: STRING AS offer_item_token_address, IFF(item_type NOT IN (0, 1), CONCAT(item_token_address, '-', identifier, '-', amount), CONCAT(offer_item_token_address, '-', offer_identifier, '-', offer_amount)) AS nft_address_identifier, IFF(item_type NOT IN (0, 1), nft_address_identifier, NULL) AS nft_address_identifier_null, CASE @@ -1150,12 +1162,16 @@ mao_consideration_all AS ( ORDER BY INDEX ASC ) AS orderhash_within_event_index_rn, - _log_id, - _inserted_timestamp + CONCAT( + event_index :: STRING, + '-', + tx_hash :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM raw_decoded_logs, LATERAL FLATTEN ( - input => decoded_flat :consideration + input => decoded_log :consideration ) WHERE event_name = 'OrderFulfilled' @@ -1182,7 +1198,7 @@ mao_consideration_all_joined AS ( END AS nft_address_identifier_fill, IFF(item_type NOT IN (0, 1) AND offer_item_type NOT IN (0, 1) - AND decoded_flat :consideration [0] :itemType :: INT NOT IN (0, 1), CONCAT(tx_hash_orderhash, '-', event_index), NULL) AS deals_tag, + AND decoded_log :consideration [0] :itemType :: INT NOT IN (0, 1), CONCAT(tx_hash_orderhash, '-', event_index), NULL) AS deals_tag, CONCAT( tx_hash_orderhash, '-', @@ -1416,7 +1432,7 @@ mao_deals_nft_transfers_sales AS ( 0 ) AS creator_fee_raw, currency_address, - decoded_flat, + decoded_log, offerer, recipient, _log_id, @@ -1471,7 +1487,7 @@ mao_nondeals_nft_transfers_sales AS ( ) AS seller_address, offerer, recipient, - decoded_flat, + decoded_log, currency_address, sale_amount_raw, platform_fee_raw, @@ -1602,7 +1618,7 @@ mao_nondeals_nft_transfers_sales_fill_offer_length AS ( seller_address, offerer, recipient, - decoded_flat, + decoded_log, currency_address_fill AS currency_address, offer_length, sale_amount_raw_fill / offer_length AS sale_amount_raw, @@ -1624,7 +1640,7 @@ mao_combined_base AS ( tx_hash, om_event_index_fill, IFF( - decoded_flat :consideration [0] :itemType :: INT IN ( + decoded_log :consideration [0] :itemType :: INT IN ( 0, 1 ), @@ -1661,7 +1677,7 @@ mao_combined_base AS ( sale_amount_raw + total_fees_raw AS total_price_raw, offerer, recipient, - decoded_flat, + decoded_log, _log_id, _inserted_timestamp FROM @@ -1672,7 +1688,7 @@ mao_combined_base AS ( om_event_index_fill, -- the event index for the ordermatched IFF( - decoded_flat :consideration [0] :itemType :: INT IN ( + decoded_log :consideration [0] :itemType :: INT IN ( 0, 1 ), @@ -1708,7 +1724,7 @@ mao_combined_base AS ( sale_amount_raw + total_fees_raw AS total_price_raw, offerer, recipient, - decoded_flat, + decoded_log, _log_id, _inserted_timestamp FROM @@ -1816,7 +1832,7 @@ base_sales_buy_and_offer AS ( 'true', 'false' ) AS is_price_estimated, - decoded_flat :zone :: STRING AS ZONE, + decoded_log :zone :: STRING AS ZONE, item_type AS tx_type, item_type AS token_type, nft_address AS nft_address_temp, @@ -1831,9 +1847,9 @@ base_sales_buy_and_offer AS ( total_fees_raw, platform_fee_raw, creator_fee_raw, - decoded_flat, - decoded_flat :consideration AS consideration, - decoded_flat :offer AS offer, + decoded_log, + decoded_log :consideration AS consideration, + decoded_log :offer AS offer, seller_address AS seller_address_temp, buyer_address AS buyer_address_temp, _log_id, @@ -1852,7 +1868,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2012-03-15' AND tx_hash IN ( @@ -1863,13 +1879,13 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), nft_transfer_operator AS ( @@ -1890,7 +1906,7 @@ nft_transfer_operator AS ( ) ) AS erc1155_value FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2024-03-15' AND tx_hash IN ( @@ -1905,13 +1921,13 @@ nft_transfer_operator AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM {{ this }} ) -AND _inserted_timestamp >= SYSDATE() - INTERVAL '7 day' + {% endif %} ), final_seaport AS ( diff --git a/models/silver/nft/silver__nft_transfers.sql b/models/silver/nft/silver__nft_transfers.sql index 62f39c0..725eff7 100644 --- a/models/silver/nft/silver__nft_transfers.sql +++ b/models/silver/nft/silver__nft_transfers.sql @@ -10,7 +10,7 @@ WITH base AS ( SELECT - _log_id, + concat_ws('-', tx_hash, event_index) AS _log_id, block_number, tx_hash, block_timestamp, @@ -19,11 +19,11 @@ WITH base AS ( topics, DATA, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, - TO_TIMESTAMP_NTZ(_inserted_timestamp) AS _inserted_timestamp + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE - tx_status = 'SUCCESS' + tx_succeeded AND ( ( topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' @@ -39,9 +39,9 @@ WITH base AS ( ) {% if is_incremental() %} -AND TO_TIMESTAMP_NTZ(_inserted_timestamp) >= ( +AND modified_timestamp >= ( SELECT - MAX(_inserted_timestamp) - INTERVAL '24 hours' + MAX(modified_timestamp) - INTERVAL '24 hours' FROM {{ this }} ) diff --git a/models/streamline/silver/decoded_logs/realtime/streamline__decoded_logs_realtime.sql b/models/streamline/silver/decoded_logs/realtime/streamline__decoded_logs_realtime.sql index 3c624d2..a0ff21b 100644 --- a/models/streamline/silver/decoded_logs/realtime/streamline__decoded_logs_realtime.sql +++ b/models/streamline/silver/decoded_logs/realtime/streamline__decoded_logs_realtime.sql @@ -72,7 +72,7 @@ candidate_logs AS ( INNER JOIN {{ ref('core__fact_event_logs') }} l USING (block_number) WHERE - l.tx_status = 'SUCCESS' + l.tx_succeeded AND l.inserted_timestamp :: DATE >= DATEADD('day', -2, SYSDATE()) ) SELECT