From 13ba135a6c0bcce09622209d6af6c93c38c3bb90 Mon Sep 17 00:00:00 2001 From: drethereum <71602799+drethereum@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:59:21 -0700 Subject: [PATCH] AN-5335-v2/blast-standardization (#79) * new columns ymls and docs * new column in silver logs * refs to core fact tables * ymls and new columns * minor updates * columns * docs * updates for native transfer * updates * deprecation notices * native transfers table * core column changes and docs * full_decoded_log changes * merge * misc updates for deprecating columns * tx and trace status * misc updates * remove comments * remove trace_address from native_transfers * timestamps for native * docs * token transfers * missing_decoding macro * l1 fee precise * removed trace address column from silver native transfers * deprecation date * ez decoded_event_logs * standard pred --- .gitignore | 3 +- macros/dbt/incremental_predicates.sql | 22 ++ macros/tests/missing_decoding.sql | 17 +- .../fsc_evm/L1_submission_fields.md | 95 +++++++ models/doc_descriptions/fsc_evm/blocks.md | 158 ++++++++++++ .../fsc_evm/complete_general.md | 65 +++++ models/doc_descriptions/fsc_evm/event_logs.md | 95 +++++++ .../fsc_evm/evm_deprecations.md | 240 ++++++++++++++++++ models/doc_descriptions/fsc_evm/traces.md | 136 ++++++++++ .../doc_descriptions/fsc_evm/transactions.md | 207 +++++++++++++++ models/doc_descriptions/fsc_evm/transfers.md | 167 ++++++++++++ .../transfers/evm_transfers_table_doc.md | 17 -- .../gold/core/core__ez_decoded_event_logs.sql | 72 ++++-- .../gold/core/core__ez_decoded_event_logs.yml | 10 + .../gold/core/core__ez_native_transfers.sql | 6 +- .../gold/core/core__ez_native_transfers.yml | 2 +- models/gold/core/core__ez_token_transfers.sql | 8 +- models/gold/core/core__ez_token_transfers.yml | 4 +- models/gold/core/core__fact_blocks.sql | 43 ++-- models/gold/core/core__fact_blocks.yml | 58 +++-- .../core/core__fact_decoded_event_logs.yml | 23 +- models/gold/core/core__fact_event_logs.sql | 20 +- models/gold/core/core__fact_event_logs.yml | 44 ++-- .../gold/core/core__fact_token_transfers.yml | 2 +- models/gold/core/core__fact_traces.sql | 8 +- models/gold/core/core__fact_traces.yml | 93 ++++--- models/gold/core/core__fact_transactions.sql | 37 +-- models/gold/core/core__fact_transactions.yml | 66 ++--- models/gold/defi/defi__ez_dex_swaps.sql | 6 +- models/gold/defi/defi__ez_dex_swaps.yml | 2 + models/silver/abis/silver__proxies.sql | 4 +- .../abis/silver__user_verified_abis.sql | 2 +- .../silver/core/silver__created_contracts.sql | 4 +- .../silver/core/silver__native_transfers.sql | 37 ++- .../core/silver__relevant_contracts.sql | 10 +- models/silver/core/silver__transfers.sql | 12 +- models/silver/core/silver__tx_count.sql | 8 +- ...silver_bridge__across_v3fundsdeposited.sql | 5 +- ...r_bridge__axelar_contractcallwithtoken.sql | 20 +- .../silver_bridge__hyperlane_bridge.sql | 22 +- .../silver_bridge__layerzero_bridge_v2.sql | 20 +- .../silver_bridge__orbiter_bridgerequest.sql | 6 +- ...er_bridge__symbiosis_synthesizerequest.sql | 5 +- .../silver_bridge__synapse_tokenredeem.sql | 5 +- .../dex/ambient/silver_dex__ambient_swaps.sql | 12 +- .../bladeswap/silver_dex__bladeswap_pools.sql | 12 +- .../silver_dex__bladeswap_pools_v3.sql | 24 +- .../bladeswap/silver_dex__bladeswap_swaps.sql | 14 +- .../silver_dex__bladeswap_swaps_v3.sql | 14 +- .../dex/blaster/silver_dex__blaster_pools.sql | 12 +- .../blaster/silver_dex__blaster_pools_v3.sql | 24 +- .../dex/blaster/silver_dex__blaster_swaps.sql | 14 +- .../blaster/silver_dex__blaster_swaps_v3.sql | 14 +- .../dex/fenix/silver_dex__fenix_pools_v3.sql | 24 +- .../dex/fenix/silver_dex__fenix_swaps_v3.sql | 16 +- .../defi/dex/ring/silver_dex__ring_pools.sql | 12 +- .../silver_dex__ring_pools_tokens_wrapped.sql | 12 +- .../dex/ring/silver_dex__ring_pools_v3.sql | 24 +- .../defi/dex/ring/silver_dex__ring_swaps.sql | 14 +- .../dex/ring/silver_dex__ring_swaps_v3.sql | 14 +- .../dex/sushi/silver_dex__sushi_pools.sql | 12 +- .../dex/sushi/silver_dex__sushi_pools_v3.sql | 24 +- .../dex/sushi/silver_dex__sushi_swaps.sql | 14 +- .../dex/sushi/silver_dex__sushi_swaps_v3.sql | 14 +- .../thruster/silver_dex__thruster_pools.sql | 12 +- .../silver_dex__thruster_pools_v3.sql | 24 +- .../thruster/silver_dex__thruster_swaps.sql | 14 +- .../silver_dex__thruster_swaps_v3.sql | 14 +- .../init/silver__init_asset_details.sql | 22 +- .../lending/init/silver__init_borrows.sql | 10 +- .../lending/init/silver__init_deposits.sql | 10 +- .../init/silver__init_liquidations.sql | 10 +- .../lending/init/silver__init_repayments.sql | 10 +- .../lending/init/silver__init_withdraws.sql | 10 +- .../juice/silver__juice_asset_details.sql | 27 +- .../lending/juice/silver__juice_borrows.sql | 5 +- .../lending/juice/silver__juice_deposits.sql | 5 +- .../juice/silver__juice_liquidations.sql | 15 +- .../juice/silver__juice_repayments.sql | 5 +- .../lending/juice/silver__juice_withdraws.sql | 6 +- .../orbit/silver__orbit_asset_details.sql | 5 +- .../lending/orbit/silver__orbit_borrows.sql | 5 +- .../lending/orbit/silver__orbit_deposits.sql | 5 +- .../orbit/silver__orbit_liquidations.sql | 5 +- .../orbit/silver__orbit_repayments.sql | 5 +- .../lending/orbit/silver__orbit_withdraws.sql | 5 +- .../blitz/silver__blitz_collateral.sql | 10 +- .../blitz/silver__blitz_dim_products.sql | 10 +- .../blitz/silver__blitz_liquidations.sql | 21 +- .../protocols/blitz/silver__blitz_perps.sql | 21 +- .../protocols/blitz/silver__blitz_spot.sql | 21 +- .../silver_stats__core_metrics_hourly.sql | 14 +- .../streamline__decode_logs_realtime.sql | 2 +- 93 files changed, 1932 insertions(+), 602 deletions(-) create mode 100644 macros/dbt/incremental_predicates.sql create mode 100644 models/doc_descriptions/fsc_evm/L1_submission_fields.md 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/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/.gitignore b/.gitignore index 2e8fe84..2b8d3a9 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ logs/ .env dbt-env/ -package-lock.yml \ No newline at end of file +package-lock.yml +.user.yml diff --git a/macros/dbt/incremental_predicates.sql b/macros/dbt/incremental_predicates.sql new file mode 100644 index 0000000..ba1bb2e --- /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 %} diff --git a/macros/tests/missing_decoding.sql b/macros/tests/missing_decoding.sql index ad4e2a8..5cc7065 100644 --- a/macros/tests/missing_decoding.sql +++ b/macros/tests/missing_decoding.sql @@ -1,17 +1,26 @@ {% 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('0x4300000000000000000000000000000000000004') -- WETH AND l.topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' -- Transfer AND l.block_timestamp BETWEEN DATEADD('hour', -48, SYSDATE()) AND DATEADD('hour', -6, SYSDATE()) - AND d._log_id IS NULL {% endtest %} + AND d._log_id IS NULL +{% endtest %} diff --git a/models/doc_descriptions/fsc_evm/L1_submission_fields.md b/models/doc_descriptions/fsc_evm/L1_submission_fields.md new file mode 100644 index 0000000..8dc0f39 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/L1_submission_fields.md @@ -0,0 +1,95 @@ +{% docs evm_batch_size %} + +Total transactions included within the batch on the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_max_block %} + +The max block on the OP stack L2 chain this batch relates to. + +{% enddocs %} + +{% docs evm_min_block %} + +The min block on the OP stack L2 chain this batch relates to. + +{% enddocs %} + +{% docs evm_batch_root %} + +Root of the batch, either for submission or state on the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_block_no %} + +The Ethereum block number that contained the batch from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_block_time %} + +The timestamp of the Ethereum block that contained this batch from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_fee %} + +The L1 portion of fees paid. + +{% enddocs %} + +{% docs evm_l1_fee_scalar %} + +This value covers the change in L1 gas price between the time the transaction is submitted and when it is published from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_gas_price %} + +The gas price for L1 transactions when the transaction was processed from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_gas_used %} + +The gas used on L1 to publish the transaction from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_state_batch %} + +The batch index of when this block was included in the Ethereum state root. This column will be deprecated 8/7 and will be consolidated into an array column consisting of all L1 submission details from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_state_tx_hash %} + +The L1 tx hash of when this block was included in the Ethereum state root. This column will be deprecated 8/7 and will be consolidated into an array column consisting of all L1 submission details from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_sub_batch %} + +The batch index of when this block was submitted to L1. This column will be deprecated 8/7 and will be consolidated into an array column consisting of all L1 submission details from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_sub_tx_hash %} + +The L1 tx hash of when this block was submitted to L1. This column will be deprecated 8/7 and will be consolidated into an array column consisting of all L1 submission details from the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_prev_total_elements %} + +Confirmed blocks prior to this batch on the OP stack L2 chain. + +{% enddocs %} + +{% docs evm_l1_fee_precise %} + +The precise amount of the L1 fee. This is returned as a string to avoid precision loss. + +{% enddocs %} \ No newline at end of file diff --git a/models/doc_descriptions/fsc_evm/blocks.md b/models/doc_descriptions/fsc_evm/blocks.md new file mode 100644 index 0000000..896609b --- /dev/null +++ b/models/doc_descriptions/fsc_evm/blocks.md @@ -0,0 +1,158 @@ +{% 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 %} \ No newline at end of file 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..b859d12 --- /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 %} \ No newline at end of file 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..52c8e0c --- /dev/null +++ b/models/doc_descriptions/fsc_evm/event_logs.md @@ -0,0 +1,95 @@ +{% 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 %} \ No newline at end of file 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..72d0bea --- /dev/null +++ b/models/doc_descriptions/fsc_evm/evm_deprecations.md @@ -0,0 +1,240 @@ +{% 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_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_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_nft_address %} + +This column is being removed for standardization purposes. Please update your queries to use the `contract_address` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_tokenid %} + +This column is being removed 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 removed for standardization purposes. Please update your queries to use the `quantity` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_project_name %} + +This column is being removed for standardization purposes. Please update your queries to use the `name` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_loanid %} + +This column is being removed for standardization purposes. Please update your queries to use the `loan_id` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_tokenid_name %} + +This column is being removed for standardization purposes. Please update your queries to use the `token_id_name` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_tokenid_description %} + +This column is being removed for standardization purposes. Please update your queries to use the `token_id_description` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_tokenid_image_url %} + +This column is being removed for standardization purposes. Please update your queries to use the `token_id_image_url` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_nft_address_tokenid %} + +This column is being removed for standardization purposes. Please update your queries to use the `nft_address_token_id` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_nft_from_address %} + +This column is being removed 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 removed for standardization purposes. Please update your queries to use the `to_address` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_mint_price_eth %} + +This column is being removed for standardization purposes. Please update your queries to use the `mint_price_native` column instead by March 10, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_event_type %} + +This column is being removed for standardization purposes. Please remove from your queries 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 %} \ No newline at end of file diff --git a/models/doc_descriptions/fsc_evm/traces.md b/models/doc_descriptions/fsc_evm/traces.md new file mode 100644 index 0000000..c6b601e --- /dev/null +++ b/models/doc_descriptions/fsc_evm/traces.md @@ -0,0 +1,136 @@ +{% 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_trace_address %} + +The trace address for this trace. + +{% enddocs %} + + +{% docs evm_revert_reason %} + +The reason for the revert, if available. + +{% 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..ec61ce7 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/transactions.md @@ -0,0 +1,207 @@ +{% 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 %} \ No newline at end of file diff --git a/models/doc_descriptions/fsc_evm/transfers.md b/models/doc_descriptions/fsc_evm/transfers.md new file mode 100644 index 0000000..583947a --- /dev/null +++ b/models/doc_descriptions/fsc_evm/transfers.md @@ -0,0 +1,167 @@ +{% 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 50c4358..d5b365a 100644 --- a/models/gold/core/core__ez_decoded_event_logs.sql +++ b/models/gold/core/core__ez_decoded_event_logs.sql @@ -1,30 +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, - decoded_logs_id 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 + 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, +{% 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) \ No newline at end of file + 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 a1b55fe..f042ed0 100644 --- a/models/gold/core/core__ez_decoded_event_logs.yml +++ b/models/gold/core/core__ez_decoded_event_logs.yml @@ -51,11 +51,21 @@ models: description: '{{ doc("blast_origin_to") }}' - name: TOPICS description: '{{ doc("blast_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("blast_logs_data") }}' - name: EVENT_REMOVED description: '{{ doc("blast_event_removed") }}' - name: TX_STATUS + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED description: '{{ doc("blast_tx_status") }}' - name: EZ_DECODED_EVENT_LOGS_ID description: '{{ doc("pk") }}' diff --git a/models/gold/core/core__ez_native_transfers.sql b/models/gold/core/core__ez_native_transfers.sql index 6976e82..a678413 100644 --- a/models/gold/core/core__ez_native_transfers.sql +++ b/models/gold/core/core__ez_native_transfers.sql @@ -10,7 +10,6 @@ SELECT block_timestamp, tx_position, trace_index, - identifier, origin_from_address, origin_to_address, origin_function_signature, @@ -22,6 +21,7 @@ SELECT amount_usd, native_transfers_id AS ez_native_transfers_id, inserted_timestamp, - modified_timestamp + modified_timestamp, + identifier --deprecate FROM - {{ ref('silver__native_transfers') }} + {{ ref('silver__native_transfers') }} \ No newline at end of file diff --git a/models/gold/core/core__ez_native_transfers.yml b/models/gold/core/core__ez_native_transfers.yml index 6b5d202..9d56994 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("blast_trace_index") }}' - name: IDENTIFIER - description: '{{ doc("blast_traces_identifier") }}' + description: '{{ doc("evm_column_deprecation_notice_identifier") }}' - name: ORIGIN_FROM_ADDRESS description: '{{ doc("blast_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 be64be1..7894042 100644 --- a/models/gold/core/core__ez_token_transfers.sql +++ b/models/gold/core/core__ez_token_transfers.sql @@ -22,10 +22,10 @@ SELECT amount_usd, decimals, symbol, - token_price, - _inserted_timestamp, transfers_id AS ez_token_transfers_id, inserted_timestamp, - modified_timestamp + modified_timestamp, + _inserted_timestamp, --deprecate + token_price --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 a754dbb..5c2558a 100644 --- a/models/gold/core/core__ez_token_transfers.yml +++ b/models/gold/core/core__ez_token_transfers.yml @@ -39,9 +39,9 @@ models: - name: SYMBOL description: '{{ doc("blast_symbol") }}' - name: TOKEN_PRICE - description: '{{ doc("blast_transfer_token_price") }}' + description: '{{ doc("evm_column_deprecation_notice_token_price") }}' - name: _INSERTED_TIMESTAMP - description: '{{ doc("internal_column") }}' + description: '{{ doc("evm_column_deprecation_notice_inserted_timestamp") }}' - name: EZ_TOKEN_TRANSFERS_ID description: '{{ doc("pk") }}' - name: INSERTED_TIMESTAMP diff --git a/models/gold/core/core__fact_blocks.sql b/models/gold/core/core__fact_blocks.sql index 6423ee3..a0e175b 100644 --- a/models/gold/core/core__fact_blocks.sql +++ b/models/gold/core/core__fact_blocks.sql @@ -6,22 +6,38 @@ SELECT A.block_number AS block_number, + HASH AS block_hash, --new column block_timestamp, 'mainnet' AS network, - 'blast' AS blockchain, d.tx_count, + SIZE, + miner, --new column + extra_data, + parent_hash, + gas_used, + gas_limit, difficulty, total_difficulty, - extra_data, - gas_limit, - gas_used, - HASH, - parent_hash, - receipts_root, sha3_uncles, - SIZE, uncles AS uncle_blocks, + nonce, --new column + receipts_root, + state_root, --new column + transactions_root, --new column + logs_bloom, --new column + base_fee_per_gas, --new column withdrawals_root, + blocks_id AS fact_blocks_id, + GREATEST( + A.inserted_timestamp, + d.inserted_timestamp + ) AS inserted_timestamp, + GREATEST( + A.modified_timestamp, + d.modified_timestamp + ) AS modified_timestamp, + 'blast' AS blockchain, --deprecate + HASH, --deprecate OBJECT_CONSTRUCT( 'baseFeePerGas', base_fee_per_gas, @@ -61,16 +77,7 @@ SELECT transactions_root, 'uncles', uncles - ) AS block_header_json, - blocks_id AS fact_blocks_id, - GREATEST( - A.inserted_timestamp, - d.inserted_timestamp - ) AS inserted_timestamp, - GREATEST( - A.modified_timestamp, - d.modified_timestamp - ) AS modified_timestamp + ) AS block_header_json --deprecate 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 d59e122..360c621 100644 --- a/models/gold/core/core__fact_blocks.yml +++ b/models/gold/core/core__fact_blocks.yml @@ -1,48 +1,62 @@ version: 2 models: - name: core__fact_blocks - description: '{{ doc("blast_blocks_table_doc") }}' + description: '{{ doc("evm_blocks_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("blast_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("blast_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: NETWORK - description: '{{ doc("blast_network") }}' + description: '{{ doc("evm_network") }}' - name: BLOCKCHAIN - description: '{{ doc("blast_blockchain") }}' + description: '{{ doc("evm_column_deprecation_notice_blockchain") }}' - name: TX_COUNT - description: '{{ doc("blast_tx_count") }}' + description: '{{ doc("evm_tx_count") }}' - name: DIFFICULTY - description: '{{ doc("blast_difficulty") }}' + description: '{{ doc("evm_difficulty") }}' - name: TOTAL_DIFFICULTY - description: '{{ doc("blast_total_difficulty") }}' + description: '{{ doc("evm_total_difficulty") }}' - name: EXTRA_DATA - description: '{{ doc("blast_extra_data") }}' + description: '{{ doc("evm_extra_data") }}' - name: GAS_LIMIT - description: '{{ doc("blast_gas_limit") }}' + description: '{{ doc("evm_gas_limit") }}' - name: GAS_USED - description: '{{ doc("blast_gas_used") }}' + description: '{{ doc("evm_gas_used") }}' + - name: BLOCK_HASH + description: '{{ doc("evm_blocks_hash") }}' - name: HASH - description: '{{ doc("blast_blocks_hash") }}' + description: '{{ doc("evm_column_deprecation_notice_hash") }}' - name: PARENT_HASH - description: '{{ doc("blast_parent_hash") }}' + description: '{{ doc("evm_parent_hash") }}' - name: RECEIPTS_ROOT - description: '{{ doc("blast_receipts_root") }}' + description: '{{ doc("evm_receipts_root") }}' - name: SHA3_UNCLES - description: '{{ doc("blast_sha3_uncles") }}' + description: '{{ doc("evm_sha3_uncles") }}' - name: SIZE - description: '{{ doc("blast_size") }}' + description: '{{ doc("evm_size") }}' + - name: MINER + description: '{{ doc("evm_miner") }}' + - name: NONCE + description: '{{ doc("evm_tx_nonce") }}' + - 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: UNCLE_BLOCKS - description: '{{ doc("blast_uncle_blocks") }}' + description: '{{ doc("evm_uncle_blocks") }}' - name: BLOCK_HEADER_JSON - description: '{{ doc("blast_block_header_json") }}' + description: '{{ doc("evm_column_deprecation_notice_block_header_json") }}' - 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") }}' + description: '{{ doc("evm_modified_timestamp") }}' - name: WITHDRAWALS_ROOT - description: A hash of the withdrawals that occurred in this block. \ No newline at end of file + description: '{{ doc("evm_withdrawals_root") }}' + - name: BASE_FEE_PER_GAS + description: '{{ doc("evm_base_fee_per_gas") }}' diff --git a/models/gold/core/core__fact_decoded_event_logs.yml b/models/gold/core/core__fact_decoded_event_logs.yml index 941ce9f..6948271 100644 --- a/models/gold/core/core__fact_decoded_event_logs.yml +++ b/models/gold/core/core__fact_decoded_event_logs.yml @@ -1,28 +1,7 @@ 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: - ```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```' + description: '{{ doc("evm_table_deprecation_notice_fact_decoded_event_logs") }}' columns: - name: BLOCK_NUMBER diff --git a/models/gold/core/core__fact_event_logs.sql b/models/gold/core/core__fact_event_logs.sql index c0fcf94..0811f1a 100644 --- a/models/gold/core/core__fact_event_logs.sql +++ b/models/gold/core/core__fact_event_logs.sql @@ -8,18 +8,26 @@ SELECT block_number, block_timestamp, tx_hash, - origin_function_signature, - origin_from_address, - origin_to_address, 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 logs_id AS fact_event_logs_id, inserted_timestamp, - modified_timestamp + 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 0131cad..7c19c47 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("blast_logs_table_doc") }}' + description: '{{ doc("evm_logs_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("blast_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("blast_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: TX_HASH - description: '{{ doc("blast_logs_tx_hash") }}' + description: '{{ doc("evm_logs_tx_hash") }}' - name: EVENT_INDEX - description: '{{ doc("blast_event_index") }}' + description: '{{ doc("evm_event_index") }}' - name: CONTRACT_ADDRESS - description: '{{ doc("blast_logs_contract_address") }}' + description: '{{ doc("evm_logs_contract_address") }}' - name: TOPICS - description: '{{ doc("blast_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("blast_logs_data") }}' + description: '{{ doc("evm_logs_data") }}' - name: EVENT_REMOVED - description: '{{ doc("blast_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("blast_tx_status") }}' + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("blast_origin_sig") }}' + description: '{{ doc("evm_origin_sig") }}' - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("blast_origin_from") }}' + description: '{{ doc("evm_origin_from") }}' - name: ORIGIN_TO_ADDRESS - description: '{{ doc("blast_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") }}' diff --git a/models/gold/core/core__fact_token_transfers.yml b/models/gold/core/core__fact_token_transfers.yml index d660434..3142822 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.sql b/models/gold/core/core__fact_traces.sql index 1447823..da80672 100644 --- a/models/gold/core/core__fact_traces.sql +++ b/models/gold/core/core__fact_traces.sql @@ -471,10 +471,10 @@ SELECT error_reason, revert_reason, tx_succeeded, - identifier, - DATA, - tx_status, - trace_status, + identifier, --deprecate + DATA, --deprecate + tx_status, --deprecate + trace_status, --deprecate {{ dbt_utils.generate_surrogate_key( ['tx_hash', 'trace_index'] ) }} AS fact_traces_id, diff --git a/models/gold/core/core__fact_traces.yml b/models/gold/core/core__fact_traces.yml index ba8a2e1..dd3f721 100644 --- a/models/gold/core/core__fact_traces.yml +++ b/models/gold/core/core__fact_traces.yml @@ -1,68 +1,67 @@ version: 2 models: - name: core__fact_traces - description: '{{ doc("blast_traces_table_doc") }}' + description: '{{ doc("evm_traces_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("blast_traces_block_no") }}' + description: '{{ doc("evm_traces_block_no") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("blast_traces_blocktime") }}' + description: '{{ doc("evm_traces_blocktime") }}' - name: TX_HASH - description: '{{ doc("blast_traces_tx_hash") }}' + description: '{{ doc("evm_traces_tx_hash") }}' - name: TX_POSITION - description: The position of the transaction within the block. - - name: TRACE_INDEX - description: The index of the trace within the transaction. + description: '{{ doc("evm_tx_position") }}' - name: FROM_ADDRESS - description: '{{ doc("blast_traces_from") }}' + description: '{{ doc("evm_traces_from") }}' - name: TO_ADDRESS - description: '{{ doc("blast_traces_to") }}' - - name: INPUT - description: '{{ doc("blast_traces_input") }}' - - name: OUTPUT - description: '{{ doc("blast_traces_output") }}' - - name: TYPE - description: '{{ doc("blast_traces_type") }}' - - name: TRACE_ADDRESS - description: This field represents the position of the trace within the transaction. - - name: SUB_TRACES - description: '{{ doc("blast_traces_sub") }}' - - name: IDENTIFIER - description: '{{ doc("blast_traces_identifier") }}' - - name: DATA - description: '{{ doc("blast_traces_call_data") }}' + description: '{{ doc("evm_traces_to") }}' - name: VALUE - description: '{{ doc("blast_traces_value") }}' + description: '{{ doc("evm_traces_value") }}' - name: VALUE_PRECISE_RAW - description: '{{ doc("precise_amount_unadjusted") }}' + description: '{{ doc("evm_precise_amount_unadjusted") }}' - name: VALUE_PRECISE - description: '{{ doc("precise_amount_adjusted") }}' + description: '{{ doc("evm_precise_amount_adjusted") }}' + - name: VALUE_HEX + description: '{{ doc("evm_value_hex") }}' - name: GAS - description: '{{ doc("blast_traces_gas") }}' + description: '{{ doc("evm_traces_gas") }}' - name: GAS_USED - description: '{{ doc("blast_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. + 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("blast_tx_status") }}' + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' - name: TX_SUCCEEDED - description: Whether the transaction succeeded or failed + 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: 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") }}' + + + diff --git a/models/gold/core/core__fact_transactions.sql b/models/gold/core/core__fact_transactions.sql index 12400fe..ccff434 100644 --- a/models/gold/core/core__fact_transactions.sql +++ b/models/gold/core/core__fact_transactions.sql @@ -7,39 +7,46 @@ SELECT block_number, block_timestamp, - block_hash, tx_hash, - nonce, - POSITION, - origin_function_signature, from_address, to_address, + origin_function_signature, VALUE, value_precise_raw, value_precise, tx_fee, tx_fee_precise, + CASE + WHEN tx_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS tx_succeeded, --new column + tx_type, + nonce, + POSITION AS tx_position, --new column + input_data, gas_price, - effective_gas_price, - gas AS gas_limit, gas_used, + gas AS gas_limit, + cumulative_gas_used, + effective_gas_price, + max_fee_per_gas, + max_priority_fee_per_gas, l1_gas_price, l1_gas_used, l1_fee_scalar, - l1_fee, l1_fee_precise, - cumulative_gas_used, - max_fee_per_gas, - max_priority_fee_per_gas, - input_data, - tx_status AS status, + l1_fee, + y_parity, --new column r, s, v, - deposit_nonce, - deposit_receipt_version, transactions_id AS fact_transactions_id, inserted_timestamp, - modified_timestamp + modified_timestamp, + block_hash, --deprecate + tx_status AS status, --deprecate + POSITION, --deprecate + deposit_nonce, --deprecate, may be separate table + deposit_receipt_version --deprecate, may be separate table FROM {{ ref('silver__transactions') }} diff --git a/models/gold/core/core__fact_transactions.yml b/models/gold/core/core__fact_transactions.yml index 26f25d5..e0db11c 100644 --- a/models/gold/core/core__fact_transactions.yml +++ b/models/gold/core/core__fact_transactions.yml @@ -1,65 +1,71 @@ version: 2 models: - name: core__fact_transactions - description: '{{ doc("blast_tx_table_doc") }}' + description: '{{ doc("evm_tx_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("blast_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("blast_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: BLOCK_HASH - description: '{{ doc("blast_tx_block_hash") }}' + description: '{{ doc("evm_column_deprecation_notice_block_hash") }}' - name: TX_HASH - description: '{{ doc("blast_tx_hash") }}' + description: '{{ doc("evm_tx_hash") }}' - name: NONCE - description: '{{ doc("blast_tx_nonce") }}' + description: '{{ doc("evm_tx_nonce") }}' - name: POSITION - description: '{{ doc("blast_tx_position") }}' + description: '{{ doc("evm_column_deprecation_notice_position") }}' + - name: TX_POSITION + description: '{{ doc("evm_tx_position") }}' - name: FROM_ADDRESS - description: '{{ doc("blast_from_address") }}' + description: '{{ doc("evm_from_address") }}' - name: TO_ADDRESS - description: '{{ doc("blast_to_address") }}' + description: '{{ doc("evm_to_address") }}' - name: VALUE - description: '{{ doc("blast_value") }}' + description: '{{ doc("evm_value") }}' - name: VALUE_PRECISE_RAW - description: '{{ doc("precise_amount_unadjusted") }}' + description: '{{ doc("evm_precise_amount_unadjusted") }}' - name: VALUE_PRECISE - description: '{{ doc("precise_amount_adjusted") }}' + description: '{{ doc("evm_precise_amount_adjusted") }}' - name: TX_FEE - description: '{{ doc("blast_tx_fee") }}' + description: '{{ doc("evm_tx_fee") }}' - name: TX_FEE_PRECISE - description: '{{ doc("tx_fee_precise") }}' + description: '{{ doc("evm_tx_fee_precise") }}' - name: GAS_PRICE - description: '{{ doc("blast_tx_gas_price") }}' + description: '{{ doc("evm_tx_gas_price") }}' - name: EFFECTIVE_GAS_PRICE description: The total base charge plus tip paid for each unit of gas, in Gwei. - name: GAS_LIMIT - description: '{{ doc("blast_tx_gas_limit") }}' + description: '{{ doc("evm_tx_gas_limit") }}' - name: GAS_USED - description: '{{ doc("blast_tx_gas_used") }}' + description: '{{ doc("evm_tx_gas_used") }}' - name: L1_GAS_PRICE - description: '{{ doc("blast_l1_gas_price") }}' + description: '{{ doc("evm_l1_gas_price") }}' - name: L1_GAS_USED - description: '{{ doc("blast_l1_gas_used") }}' + description: '{{ doc("evm_l1_gas_used") }}' - name: L1_FEE_SCALAR - description: '{{ doc("blast_l1_fee_scalar") }}' + description: '{{ doc("evm_l1_fee_scalar") }}' - name: L1_FEE description: The L1 portion of fees paid. - name: L1_FEE_PRECISE - description: '{{ doc("tx_fee_precise") }}' + description: '{{ doc("evm_l1_fee_precise") }}' - name: CUMULATIVE_GAS_USED - description: '{{ doc("blast_cumulative_gas_used") }}' + description: '{{ doc("evm_cumulative_gas_used") }}' - name: MAX_FEE_PER_GAS 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 Gwei. - name: STATUS - description: '{{ doc("blast_tx_status") }}' + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' - name: INPUT_DATA - description: '{{ doc("blast_tx_input_data") }}' + description: '{{ doc("evm_tx_input_data") }}' - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("blast_tx_origin_sig") }}' + description: '{{ doc("evm_tx_origin_sig") }}' + - name: Y_PARITY + description: The y parity of the transaction signature. - name: R description: The r value of the transaction signature. - name: S @@ -67,12 +73,12 @@ 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") }}' + description: '{{ doc("evm_modified_timestamp") }}' - name: DEPOSIT_NONCE - description: The nonce of the deposit transaction. + description: '{{ doc("evm_column_deprecation_notice_deposit_nonce") }}' - name: DEPOSIT_RECEIPT_VERSION - description: The version of the deposit receipt. \ No newline at end of file + description: '{{ doc("evm_column_deprecation_notice_deposit_receipt_version") }}' \ 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 e6759bf..730811b 100644 --- a/models/gold/defi/defi__ez_dex_swaps.sql +++ b/models/gold/defi/defi__ez_dex_swaps.sql @@ -53,9 +53,9 @@ SELECT token_out, symbol_in, symbol_out, - _log_id, complete_dex_swaps_id AS ez_dex_swaps_id, inserted_timestamp, - modified_timestamp + modified_timestamp, + _log_id --deprecate FROM - {{ ref('silver_dex__complete_dex_swaps') }} + {{ 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 6664e01..888172f 100644 --- a/models/gold/defi/defi__ez_dex_swaps.yml +++ b/models/gold/defi/defi__ez_dex_swaps.yml @@ -56,5 +56,7 @@ models: description: '{{ doc("inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP description: '{{ doc("modified_timestamp") }}' + - name: _LOG_ID + description: '{{ doc("evm_column_deprecation_notice_log_id") }}' 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 45dce7d..fe85969 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 bbc1f30..23b956e 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__native_transfers.sql b/models/silver/core/silver__native_transfers.sql index d96ec33..9eebd10 100644 --- a/models/silver/core/silver__native_transfers.sql +++ b/models/silver/core/silver__native_transfers.sql @@ -3,7 +3,6 @@ incremental_strategy = 'delete+insert', unique_key = 'block_number', cluster_by = ['block_timestamp::DATE'], - post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION", tags = ['non_realtime','reorg'] ) }} @@ -13,31 +12,31 @@ WITH eth_base AS ( tx_hash, block_number, block_timestamp, - identifier, + identifier, --deprecate from_address, to_address, - VALUE AS eth_value, + value, concat_ws( '-', block_number, tx_position, CONCAT( - TYPE, + type, '_', trace_address ) ) AS _call_id, modified_timestamp AS _inserted_timestamp, - value_precise_raw AS eth_value_precise_raw, - value_precise AS eth_value_precise, + value_precise_raw, + value_precise, tx_position, trace_index FROM {{ ref('core__fact_traces') }} WHERE - eth_value > 0 - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + value > 0 + AND tx_succeeded + AND trace_succeeded AND TYPE NOT IN ( 'DELEGATECALL', 'STATICCALL' @@ -60,7 +59,7 @@ tx_table AS ( to_address AS origin_to_address, origin_function_signature FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE tx_hash IN ( SELECT @@ -70,7 +69,7 @@ tx_table AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '72 hours' FROM @@ -79,20 +78,20 @@ 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, --deprecate origin_from_address, origin_to_address, origin_function_signature, from_address, to_address, - eth_value AS amount, - eth_value_precise_raw AS amount_precise_raw, - eth_value_precise AS amount_precise, + value AS amount, + value_precise_raw AS amount_precise_raw, + value_precise AS amount_precise, ROUND( - eth_value * price, + value * price, 2 ) AS amount_usd, _call_id, diff --git a/models/silver/core/silver__relevant_contracts.sql b/models/silver/core/silver__relevant_contracts.sql index 23aefb7..14ba6cf 100644 --- a/models/silver/core/silver__relevant_contracts.sql +++ b/models/silver/core/silver__relevant_contracts.sql @@ -10,14 +10,14 @@ WITH emitted_events AS ( SELECT contract_address, COUNT(*) AS event_count, - MAX(_inserted_timestamp) AS max_inserted_timestamp_logs, + MAX(modified_timestamp) AS max_inserted_timestamp_logs, MAX(block_number) AS latest_event_block FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} {% if is_incremental() %} WHERE - _inserted_timestamp > ( + modified_timestamp > ( SELECT MAX(max_inserted_timestamp_logs) FROM @@ -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..7aef67f 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, + '-', + event_index + ) 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..65146a2 100644 --- a/models/silver/core/silver__tx_count.sql +++ b/models/silver/core/silver__tx_count.sql @@ -9,16 +9,16 @@ 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 + MAX(_inserted_timestamp) FROM {{ this }} ) diff --git a/models/silver/defi/bridge/across/silver_bridge__across_v3fundsdeposited.sql b/models/silver/defi/bridge/across/silver_bridge__across_v3fundsdeposited.sql index a950e6c..8be07d3 100644 --- a/models/silver/defi/bridge/across/silver_bridge__across_v3fundsdeposited.sql +++ b/models/silver/defi/bridge/across/silver_bridge__across_v3fundsdeposited.sql @@ -49,10 +49,7 @@ WITH base_evt AS ( CONCAT('0x', SUBSTR(segmented_data [7] :: STRING, 25, 40)) AS recipient, CONCAT('0x', SUBSTR(segmented_data [8] :: STRING, 25, 40)) AS exclusiveRelayer, segmented_data [9] :: STRING AS message, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', 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 f1aac83..4975910 100644 --- a/models/silver/defi/bridge/axelar/silver_bridge__axelar_contractcallwithtoken.sql +++ b/models/silver/defi/bridge/axelar/silver_bridge__axelar_contractcallwithtoken.sql @@ -35,10 +35,7 @@ WITH base_evt AS ( decoded_log :"symbol" :: STRING AS symbol, decoded_log, event_removed, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -92,10 +89,7 @@ native_gas_paid AS ( decoded_log :"symbol" :: STRING AS symbol, decoded_log, event_removed, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -125,10 +119,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 = '0x492751ec3c57141deb205ec2da8bfcb410738630' AND to_address IN ( diff --git a/models/silver/defi/bridge/hyperlane/silver_bridge__hyperlane_bridge.sql b/models/silver/defi/bridge/hyperlane/silver_bridge__hyperlane_bridge.sql index b54fef4..994be2f 100644 --- a/models/silver/defi/bridge/hyperlane/silver_bridge__hyperlane_bridge.sql +++ b/models/silver/defi/bridge/hyperlane/silver_bridge__hyperlane_bridge.sql @@ -24,10 +24,7 @@ WITH dispatch AS ( CONCAT('0x', SUBSTR(topics [3] :: STRING, 27, 40)) AS dst_bridge_token, -- dst bridge token address, not recipient address DATA, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -58,10 +55,7 @@ dispatch_id AS ( tx_hash, event_index, topics [1] :: STRING AS messageId, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -96,10 +90,7 @@ gas_payment AS ( regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [0] :: STRING)) AS gasAmount, TRY_TO_NUMBER(utils.udf_hex_to_int(segmented_data [1] :: STRING)) AS payment, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -133,10 +124,7 @@ sent_transfer_remote AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS recipient, -- actual recipient TRY_TO_NUMBER(utils.udf_hex_to_int(DATA :: STRING)) AS amount, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -165,7 +153,7 @@ token_transfer AS ( tx_hash, contract_address AS token_address FROM - {{ ref('silver__transfers') }} + {{ ref('core__ez_token_transfers') }} WHERE tx_hash IN ( SELECT diff --git a/models/silver/defi/bridge/layerzero/silver_bridge__layerzero_bridge_v2.sql b/models/silver/defi/bridge/layerzero/silver_bridge__layerzero_bridge_v2.sql index 250e766..5105bbc 100644 --- a/models/silver/defi/bridge/layerzero/silver_bridge__layerzero_bridge_v2.sql +++ b/models/silver/defi/bridge/layerzero/silver_bridge__layerzero_bridge_v2.sql @@ -13,14 +13,8 @@ WITH oft_asset_contract_creation AS ( block_timestamp, tx_hash, from_address AS oft_address, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded, + tx_succeeded, + trace_succeeded, modified_timestamp FROM {{ ref('core__fact_traces') }} @@ -57,14 +51,8 @@ oft_asset_base_token AS ( tx_hash, from_address AS wrap_address, to_address AS underlying_address, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded, + tx_succeeded, + trace_succeeded, modified_timestamp FROM {{ ref('core__fact_traces') }} diff --git a/models/silver/defi/bridge/orbiter/silver_bridge__orbiter_bridgerequest.sql b/models/silver/defi/bridge/orbiter/silver_bridge__orbiter_bridgerequest.sql index 6029954..65b0a0a 100644 --- a/models/silver/defi/bridge/orbiter/silver_bridge__orbiter_bridgerequest.sql +++ b/models/silver/defi/bridge/orbiter/silver_bridge__orbiter_bridgerequest.sql @@ -27,12 +27,12 @@ WITH bridge_native AS ( origin_from_address AS recipient, et.to_address AS bridge_address, trace_index, - native_transfers_id, + ez_native_transfers_id AS native_transfers_id, et.modified_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 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 a45c7b0..eca6dea 100644 --- a/models/silver/defi/bridge/symbiosis/silver_bridge__symbiosis_synthesizerequest.sql +++ b/models/silver/defi/bridge/symbiosis/silver_bridge__symbiosis_synthesizerequest.sql @@ -36,10 +36,7 @@ WITH base_evt AS ( CONCAT('0x', SUBSTR(topics [3] :: STRING, 27, 40)) AS revertableAddress, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS to_address, CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS token, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.sql b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.sql index 65aa6d4..ef54be4 100644 --- a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.sql +++ b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenredeem.sql @@ -24,10 +24,7 @@ WITH base_evt AS ( topics [3] :: STRING AS topic_3, DATA, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/dex/ambient/silver_dex__ambient_swaps.sql b/models/silver/defi/dex/ambient/silver_dex__ambient_swaps.sql index fa85632..c0ac914 100644 --- a/models/silver/defi/dex/ambient/silver_dex__ambient_swaps.sql +++ b/models/silver/defi/dex/ambient/silver_dex__ambient_swaps.sql @@ -68,14 +68,18 @@ WITH swaps_base AS ( WHEN quote_qty > 0 THEN base_token ELSE NULL END AS token_out, - _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 = '0xaaaaaaaaffe404ee9433eef0094b6382d81fb958' --CrocSwapDex AND topics [0] :: STRING = '0x5d7a6c346454f5c536b7f52655e780f6db27b15b489f80f2dbb288c9e4f366bd' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_pools.sql b/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_pools.sql index e1467f3..a478fb5 100644 --- a/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_pools.sql +++ b/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_pools.sql @@ -23,14 +23,18 @@ WITH created_pools AS ( WHEN segmented_data [1] :: STRING = '000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' THEN '0x4300000000000000000000000000000000000004' ELSE CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) END AS 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') }} WHERE contract_address = LOWER('0x75cb3ec310d3d1e22637f79d61eab5d9abcd68bd') --XYKPoolFactory AND topics [0] :: STRING = '0x5f28326c23d3e7607ba7f55dcee451cc4dbb16e3f016b27f013c99fb1d7d4168' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_pools_v3.sql b/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_pools_v3.sql index c983191..5f3e2d0 100644 --- a/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_pools_v3.sql +++ b/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_pools_v3.sql @@ -18,14 +18,18 @@ WITH created_pools AS ( LOWER(CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40))) AS token0_address, LOWER(CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40))) AS token1_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 topics [0] :: STRING = '0x91ccaa7a278130b65168c3a0c8d3bcae84cf5e43704342bd3ec0b59e59c036db' AND contract_address = '0xa87dbf5082af26c9a6ab2b854e378f704638cca5' --AlgebraFactory - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -46,17 +50,21 @@ pool_info AS ( topics [3] :: STRING AS topics_3, DATA, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, - _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 ( '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95', '0x598b9f043c813aa6be3426ca60d1c65d17256312890be5118dab55b0775ebe2a', '0x01413b1d5d4c359e9a0daa7909ecda165f6e8c51fe2ff529d74b22a5a7c02645' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_swaps.sql b/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_swaps.sql index d4c1277..3888736 100644 --- a/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_swaps.sql +++ b/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_swaps.sql @@ -42,20 +42,24 @@ WITH swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, 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 {{ ref('silver_dex__bladeswap_pools') }} p ON p.pool_address = l.contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_swaps_v3.sql b/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_swaps_v3.sql index be0ad13..4f73274 100644 --- a/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_swaps_v3.sql +++ b/models/silver/defi/dex/bladeswap/silver_dex__bladeswap_swaps_v3.sql @@ -45,10 +45,14 @@ WITH swaps_base AS ( pool_address, tick_spacing, fee, - 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 {{ ref('silver_dex__bladeswap_pools_v3') }} p @@ -56,10 +60,10 @@ WITH swaps_base AS ( WHERE l.block_timestamp :: DATE >= '2024-01-01' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/dex/blaster/silver_dex__blaster_pools.sql b/models/silver/defi/dex/blaster/silver_dex__blaster_pools.sql index 647a2f9..feb9127 100644 --- a/models/silver/defi/dex/blaster/silver_dex__blaster_pools.sql +++ b/models/silver/defi/dex/blaster/silver_dex__blaster_pools.sql @@ -22,14 +22,18 @@ WITH created_pools AS ( segmented_data [1] :: STRING ) ) 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('0x9cc1599d4378ea41d444642d18aa9be44f709ffd') --BlasterswapV2Factory AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/blaster/silver_dex__blaster_pools_v3.sql b/models/silver/defi/dex/blaster/silver_dex__blaster_pools_v3.sql index c1a4b53..af45678 100644 --- a/models/silver/defi/dex/blaster/silver_dex__blaster_pools_v3.sql +++ b/models/silver/defi/dex/blaster/silver_dex__blaster_pools_v3.sql @@ -30,14 +30,18 @@ WITH created_pools AS ( ) ) 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] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' AND contract_address = '0x1a8027625c830aac43ad82a3f7cd6d5fdce89d78' --BlasterSwapV3Factory - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -59,13 +63,17 @@ initial_info AS ( 1.0001, init_tick ) AS init_price_1_0_unadj, - _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 = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/blaster/silver_dex__blaster_swaps.sql b/models/silver/defi/dex/blaster/silver_dex__blaster_swaps.sql index 05dd461..4d811f1 100644 --- a/models/silver/defi/dex/blaster/silver_dex__blaster_swaps.sql +++ b/models/silver/defi/dex/blaster/silver_dex__blaster_swaps.sql @@ -42,20 +42,24 @@ WITH swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, 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 {{ ref('silver_dex__blaster_pools') }} p ON p.pool_address = l.contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/defi/dex/blaster/silver_dex__blaster_swaps_v3.sql b/models/silver/defi/dex/blaster/silver_dex__blaster_swaps_v3.sql index 3de2a45..018fc45 100644 --- a/models/silver/defi/dex/blaster/silver_dex__blaster_swaps_v3.sql +++ b/models/silver/defi/dex/blaster/silver_dex__blaster_swaps_v3.sql @@ -45,10 +45,14 @@ WITH swaps_base AS ( pool_address, tick_spacing, fee, - 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 {{ ref('silver_dex__blaster_pools_v3') }} p @@ -56,10 +60,10 @@ WITH swaps_base AS ( WHERE l.block_timestamp :: DATE >= '2024-01-01' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/dex/fenix/silver_dex__fenix_pools_v3.sql b/models/silver/defi/dex/fenix/silver_dex__fenix_pools_v3.sql index c0115e8..77e2623 100644 --- a/models/silver/defi/dex/fenix/silver_dex__fenix_pools_v3.sql +++ b/models/silver/defi/dex/fenix/silver_dex__fenix_pools_v3.sql @@ -18,14 +18,18 @@ WITH created_pools AS ( LOWER(CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40))) AS token0_address, LOWER(CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40))) AS token1_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 topics [0] :: STRING = '0x91ccaa7a278130b65168c3a0c8d3bcae84cf5e43704342bd3ec0b59e59c036db' AND contract_address = '0x7a44cd060afc1b6f4c80a2b9b37f4473e74e25df' --Fenix Finance : Algebra Factory - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -46,17 +50,21 @@ pool_info AS ( topics [3] :: STRING AS topics_3, DATA, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, - _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 ( '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95', '0x598b9f043c813aa6be3426ca60d1c65d17256312890be5118dab55b0775ebe2a', '0x01413b1d5d4c359e9a0daa7909ecda165f6e8c51fe2ff529d74b22a5a7c02645' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/fenix/silver_dex__fenix_swaps_v3.sql b/models/silver/defi/dex/fenix/silver_dex__fenix_swaps_v3.sql index db47050..7087719 100644 --- a/models/silver/defi/dex/fenix/silver_dex__fenix_swaps_v3.sql +++ b/models/silver/defi/dex/fenix/silver_dex__fenix_swaps_v3.sql @@ -45,10 +45,14 @@ WITH swaps_base AS ( pool_address, tick_spacing, fee, - 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 {{ ref('silver_dex__fenix_pools_v3') }} p @@ -56,10 +60,10 @@ WITH swaps_base AS ( WHERE l.block_timestamp :: DATE >= '2024-01-01' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp @@ -67,7 +71,7 @@ AND l._inserted_timestamp >= ( FROM {{ this }} ) -AND l._inserted_timestamp >= SYSDATE() - INTERVAL '7 day' +AND l.modified_timestamp >= SYSDATE() - INTERVAL '7 day' {% endif %} ) SELECT diff --git a/models/silver/defi/dex/ring/silver_dex__ring_pools.sql b/models/silver/defi/dex/ring/silver_dex__ring_pools.sql index a0b8d9e..0512b6e 100644 --- a/models/silver/defi/dex/ring/silver_dex__ring_pools.sql +++ b/models/silver/defi/dex/ring/silver_dex__ring_pools.sql @@ -22,14 +22,18 @@ WITH created_pools AS ( segmented_data [1] :: STRING ) ) 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('0x24f5ac9a706de0cf795a8193f6ab3966b14ecfe6') --SwapV2Factory AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/ring/silver_dex__ring_pools_tokens_wrapped.sql b/models/silver/defi/dex/ring/silver_dex__ring_pools_tokens_wrapped.sql index 73035c5..67a8e6b 100644 --- a/models/silver/defi/dex/ring/silver_dex__ring_pools_tokens_wrapped.sql +++ b/models/silver/defi/dex/ring/silver_dex__ring_pools_tokens_wrapped.sql @@ -16,14 +16,18 @@ SELECT utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INTEGER AS asset_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x455b20131d59f01d082df1225154fda813e8cee9' --FewFactory AND topics [0] :: STRING = '0x940398321949af993516f7d144a2b9f43100b1de59365ba376e2b458d840c091' --WrappedTokenCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/ring/silver_dex__ring_pools_v3.sql b/models/silver/defi/dex/ring/silver_dex__ring_pools_v3.sql index cbde5d6..a62489d 100644 --- a/models/silver/defi/dex/ring/silver_dex__ring_pools_v3.sql +++ b/models/silver/defi/dex/ring/silver_dex__ring_pools_v3.sql @@ -26,14 +26,18 @@ WITH created_pools AS ( segmented_data [0] :: STRING ) :: INTEGER 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] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' AND contract_address = '0x890509fab3dd11d4ff57d8471b5eac74687e4c75' --Ring/UniswapV3Factory - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -55,13 +59,17 @@ initial_info AS ( 1.0001, init_tick ) AS init_price_1_0_unadj, - _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 = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/ring/silver_dex__ring_swaps.sql b/models/silver/defi/dex/ring/silver_dex__ring_swaps.sql index e9ad354..1e20790 100644 --- a/models/silver/defi/dex/ring/silver_dex__ring_swaps.sql +++ b/models/silver/defi/dex/ring/silver_dex__ring_swaps.sql @@ -42,20 +42,24 @@ WITH swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, 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 {{ ref('silver_dex__ring_pools') }} p ON p.pool_address = l.contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/defi/dex/ring/silver_dex__ring_swaps_v3.sql b/models/silver/defi/dex/ring/silver_dex__ring_swaps_v3.sql index 9f30975..9d6cb8e 100644 --- a/models/silver/defi/dex/ring/silver_dex__ring_swaps_v3.sql +++ b/models/silver/defi/dex/ring/silver_dex__ring_swaps_v3.sql @@ -45,10 +45,14 @@ WITH swaps_base AS ( pool_address, tick_spacing, fee, - 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 {{ ref('silver_dex__ring_pools_v3') }} p @@ -56,10 +60,10 @@ WITH swaps_base AS ( WHERE l.block_timestamp :: DATE >= '2024-01-01' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp 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 09cbf90..e734b06 100644 --- a/models/silver/defi/dex/sushi/silver_dex__sushi_pools.sql +++ b/models/silver/defi/dex/sushi/silver_dex__sushi_pools.sql @@ -22,14 +22,18 @@ WITH created_pools AS ( segmented_data [1] :: STRING ) ) 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('0x42fa929fc636e657ac568c0b5cf38e203b67ac2b') --Sushi/UniswapV2Factory AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/sushi/silver_dex__sushi_pools_v3.sql b/models/silver/defi/dex/sushi/silver_dex__sushi_pools_v3.sql index 0cbf73f..a6b7b84 100644 --- a/models/silver/defi/dex/sushi/silver_dex__sushi_pools_v3.sql +++ b/models/silver/defi/dex/sushi/silver_dex__sushi_pools_v3.sql @@ -26,14 +26,18 @@ WITH created_pools AS ( segmented_data [0] :: STRING ) :: INTEGER 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] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' AND contract_address = '0x7680d4b43f3d1d54d6cfeeb2169463bfa7a6cf0d' --Sushi/UniswapV3Factory - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -55,13 +59,17 @@ initial_info AS ( 1.0001, init_tick ) AS init_price_1_0_unadj, - _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 = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( 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 0e90713..f4c932f 100644 --- a/models/silver/defi/dex/sushi/silver_dex__sushi_swaps.sql +++ b/models/silver/defi/dex/sushi/silver_dex__sushi_swaps.sql @@ -42,20 +42,24 @@ WITH swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, 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 {{ ref('silver_dex__sushi_pools') }} p ON p.pool_address = l.contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/defi/dex/sushi/silver_dex__sushi_swaps_v3.sql b/models/silver/defi/dex/sushi/silver_dex__sushi_swaps_v3.sql index 3419feb..8265b8a 100644 --- a/models/silver/defi/dex/sushi/silver_dex__sushi_swaps_v3.sql +++ b/models/silver/defi/dex/sushi/silver_dex__sushi_swaps_v3.sql @@ -45,10 +45,14 @@ WITH swaps_base AS ( pool_address, tick_spacing, fee, - 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 {{ ref('silver_dex__sushi_pools_v3') }} p @@ -56,10 +60,10 @@ WITH swaps_base AS ( WHERE l.block_timestamp :: DATE >= '2024-01-01' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/dex/thruster/silver_dex__thruster_pools.sql b/models/silver/defi/dex/thruster/silver_dex__thruster_pools.sql index fcce86a..ffe860c 100644 --- a/models/silver/defi/dex/thruster/silver_dex__thruster_pools.sql +++ b/models/silver/defi/dex/thruster/silver_dex__thruster_pools.sql @@ -22,14 +22,18 @@ WITH created_pools AS ( segmented_data [1] :: STRING ) ) 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('0xb4a7d971d0adea1c73198c97d7ab3f9ce4aafa13') --Thruster: ThrusterRouter (0.30%) AND topics [0] :: STRING = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' --PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/thruster/silver_dex__thruster_pools_v3.sql b/models/silver/defi/dex/thruster/silver_dex__thruster_pools_v3.sql index 87c2a74..9a5846c 100644 --- a/models/silver/defi/dex/thruster/silver_dex__thruster_pools_v3.sql +++ b/models/silver/defi/dex/thruster/silver_dex__thruster_pools_v3.sql @@ -26,14 +26,18 @@ WITH created_pools AS ( segmented_data [0] :: STRING ) :: INTEGER 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] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' AND contract_address = '0x71b08f13b3c3af35aadeb3949afeb1ded1016127' --ThrusterPoolFactory - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -55,13 +59,17 @@ initial_info AS ( 1.0001, init_tick ) AS init_price_1_0_unadj, - _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 = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/thruster/silver_dex__thruster_swaps.sql b/models/silver/defi/dex/thruster/silver_dex__thruster_swaps.sql index f868f13..572774c 100644 --- a/models/silver/defi/dex/thruster/silver_dex__thruster_swaps.sql +++ b/models/silver/defi/dex/thruster/silver_dex__thruster_swaps.sql @@ -42,20 +42,24 @@ WITH swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, 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 {{ ref('silver_dex__thruster_pools') }} p ON p.pool_address = l.contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/defi/dex/thruster/silver_dex__thruster_swaps_v3.sql b/models/silver/defi/dex/thruster/silver_dex__thruster_swaps_v3.sql index 273740b..fc8e127 100644 --- a/models/silver/defi/dex/thruster/silver_dex__thruster_swaps_v3.sql +++ b/models/silver/defi/dex/thruster/silver_dex__thruster_swaps_v3.sql @@ -45,10 +45,14 @@ WITH swaps_base AS ( pool_address, tick_spacing, fee, - 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 {{ ref('silver_dex__thruster_pools_v3') }} p @@ -56,10 +60,10 @@ WITH swaps_base AS ( WHERE l.block_timestamp :: DATE >= '2024-01-01' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/init/silver__init_asset_details.sql b/models/silver/defi/lending/init/silver__init_asset_details.sql index 9f177c1..6d1d41b 100644 --- a/models/silver/defi/lending/init/silver__init_asset_details.sql +++ b/models/silver/defi/lending/init/silver__init_asset_details.sql @@ -44,16 +44,17 @@ underlying AS ( tx_hash, block_timestamp, block_number, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded, + trace_succeeded, from_address AS token_address, to_address AS underlying_asset_address FROM {{ ref('core__fact_traces') }} WHERE - identifier = 'CALL_0_1' + CONCAT( + TYPE, + '_', + trace_address + ) = 'CALL_0_1' AND LEFT( input, 10 @@ -70,14 +71,15 @@ unwrapped AS ( SELECT from_address AS underlying_asset_address, to_address AS underlying_unwrap_address, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded + trace_succeeded FROM {{ ref('core__fact_traces') }} WHERE - identifier = 'CALL_0_0' + CONCAT( + TYPE, + '_', + trace_address + ) = 'CALL_0_0' AND LEFT( input, 10 diff --git a/models/silver/defi/lending/init/silver__init_borrows.sql b/models/silver/defi/lending/init/silver__init_borrows.sql index 86c81c4..466b9e8 100644 --- a/models/silver/defi/lending/init/silver__init_borrows.sql +++ b/models/silver/defi/lending/init/silver__init_borrows.sql @@ -48,10 +48,7 @@ init_borrows AS ( contract_address AS token, 'INIT Capital' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -121,10 +118,7 @@ native_transfer AS ( to_address, value_precise_raw AS eth_value, 'WETH' AS eth_symbol, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded, + trace_succeeded, 18 AS eth_decimals, '0x4300000000000000000000000000000000000004' AS eth_address FROM diff --git a/models/silver/defi/lending/init/silver__init_deposits.sql b/models/silver/defi/lending/init/silver__init_deposits.sql index 1722679..1cef3b0 100644 --- a/models/silver/defi/lending/init/silver__init_deposits.sql +++ b/models/silver/defi/lending/init/silver__init_deposits.sql @@ -50,10 +50,7 @@ init_deposits AS ( -- receipt token 'INIT Capital' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -226,10 +223,7 @@ native_transfer AS ( to_address, value_precise_raw AS eth_value, 'WETH' AS eth_symbol, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded, + trace_succeeded, 18 AS eth_decimals, '0x4300000000000000000000000000000000000004' AS eth_address FROM diff --git a/models/silver/defi/lending/init/silver__init_liquidations.sql b/models/silver/defi/lending/init/silver__init_liquidations.sql index 02cec83..106051c 100644 --- a/models/silver/defi/lending/init/silver__init_liquidations.sql +++ b/models/silver/defi/lending/init/silver__init_liquidations.sql @@ -51,10 +51,7 @@ init_liquidations AS ( contract_address AS token, 'INIT Capital' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -132,10 +129,7 @@ position_owner AS ( utils.udf_hex_to_int( topics [2] :: STRING ) :: STRING AS posId, -- using string as it handles better than float - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/init/silver__init_repayments.sql b/models/silver/defi/lending/init/silver__init_repayments.sql index 6140cb3..007ca0b 100644 --- a/models/silver/defi/lending/init/silver__init_repayments.sql +++ b/models/silver/defi/lending/init/silver__init_repayments.sql @@ -51,10 +51,7 @@ init_repayments AS ( contract_address AS token, 'INIT Capital' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -84,10 +81,7 @@ native_transfer AS ( to_address AS wrapped_address, value_precise_raw AS eth_value, 'WETH' AS eth_symbol, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded, + trace_succeeded, 18 AS eth_decimals, '0x4300000000000000000000000000000000000004' AS eth_address FROM diff --git a/models/silver/defi/lending/init/silver__init_withdraws.sql b/models/silver/defi/lending/init/silver__init_withdraws.sql index 6120660..4be9346 100644 --- a/models/silver/defi/lending/init/silver__init_withdraws.sql +++ b/models/silver/defi/lending/init/silver__init_withdraws.sql @@ -49,10 +49,7 @@ init_redemption AS ( ) :: FLOAT AS redeemed_token_raw, 'INIT Capital' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -232,10 +229,7 @@ native_transfer AS ( from_address AS wrapped_address, to_address, value_precise_raw AS eth_value, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded, + trace_succeeded, 'WETH' AS eth_symbol, 18 AS eth_decimals, '0x4300000000000000000000000000000000000004' AS eth_address diff --git a/models/silver/defi/lending/juice/silver__juice_asset_details.sql b/models/silver/defi/lending/juice/silver__juice_asset_details.sql index 4a926ff..c1408bf 100644 --- a/models/silver/defi/lending/juice/silver__juice_asset_details.sql +++ b/models/silver/defi/lending/juice/silver__juice_asset_details.sql @@ -78,10 +78,7 @@ tx_pull AS ( topics, DATA, event_removed, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -127,14 +124,14 @@ trace_pull AS ( input, output, TYPE, - identifier, + CONCAT( + TYPE, + '_', + trace_address + ) AS identifier, DATA, - tx_status, sub_traces, - CASE - WHEN trace_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS trace_succeeded, + trace_succeeded, error_reason, trace_index, fact_traces_id, @@ -250,10 +247,7 @@ logs_pull AS ( regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, CONCAT('0x', SUBSTR(segmented_data [0], 25, 40)) AS contract_address, event_removed, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -287,10 +281,7 @@ get_underlying AS ( topics, DATA, event_removed, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/juice/silver__juice_borrows.sql b/models/silver/defi/lending/juice/silver__juice_borrows.sql index c7ba704..ec477d1 100644 --- a/models/silver/defi/lending/juice/silver__juice_borrows.sql +++ b/models/silver/defi/lending/juice/silver__juice_borrows.sql @@ -43,10 +43,7 @@ juice_borrows AS ( contract_address AS pool_address, 'Juice' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/juice/silver__juice_deposits.sql b/models/silver/defi/lending/juice/silver__juice_deposits.sql index 4184f4d..4b1d857 100644 --- a/models/silver/defi/lending/juice/silver__juice_deposits.sql +++ b/models/silver/defi/lending/juice/silver__juice_deposits.sql @@ -38,10 +38,7 @@ deposit_logs AS ( topics, DATA, event_removed, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/juice/silver__juice_liquidations.sql b/models/silver/defi/lending/juice/silver__juice_liquidations.sql index 7bf66cc..318e5cf 100644 --- a/models/silver/defi/lending/juice/silver__juice_liquidations.sql +++ b/models/silver/defi/lending/juice/silver__juice_liquidations.sql @@ -51,10 +51,7 @@ juice_liquidations AS ( ) :: INTEGER AS debtamountneeded_raw, 'Juice' AS platform, l.modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -87,10 +84,7 @@ token_transfer AS ( tx_hash, utils.udf_hex_to_int(DATA) AS seizeTokens_raw, event_index, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', @@ -130,10 +124,7 @@ debt_transfer AS ( debt_name, debt_address AS debt_token, debt_symbol AS debt_token_symbol, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/juice/silver__juice_repayments.sql b/models/silver/defi/lending/juice/silver__juice_repayments.sql index 997c66b..6a6fe92 100644 --- a/models/silver/defi/lending/juice/silver__juice_repayments.sql +++ b/models/silver/defi/lending/juice/silver__juice_repayments.sql @@ -43,10 +43,7 @@ juice_repayments AS ( ) :: INTEGER AS repayed_amount_raw, 'Juice' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/juice/silver__juice_withdraws.sql b/models/silver/defi/lending/juice/silver__juice_withdraws.sql index 1180831..9c09b06 100644 --- a/models/silver/defi/lending/juice/silver__juice_withdraws.sql +++ b/models/silver/defi/lending/juice/silver__juice_withdraws.sql @@ -37,12 +37,8 @@ withdraw_logs AS ( contract_address, DATA, topics, - tx_status, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/orbit/silver__orbit_asset_details.sql b/models/silver/defi/lending/orbit/silver__orbit_asset_details.sql index a4053e9..2511521 100644 --- a/models/silver/defi/lending/orbit/silver__orbit_asset_details.sql +++ b/models/silver/defi/lending/orbit/silver__orbit_asset_details.sql @@ -14,10 +14,7 @@ WITH log_pull_1 AS ( block_timestamp, contract_address, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/orbit/silver__orbit_borrows.sql b/models/silver/defi/lending/orbit/silver__orbit_borrows.sql index f0f853b..e5dd334 100644 --- a/models/silver/defi/lending/orbit/silver__orbit_borrows.sql +++ b/models/silver/defi/lending/orbit/silver__orbit_borrows.sql @@ -44,10 +44,7 @@ orbit_borrows AS ( contract_address AS token, 'Orbit' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/orbit/silver__orbit_deposits.sql b/models/silver/defi/lending/orbit/silver__orbit_deposits.sql index 4f3c78e..87178ee 100644 --- a/models/silver/defi/lending/orbit/silver__orbit_deposits.sql +++ b/models/silver/defi/lending/orbit/silver__orbit_deposits.sql @@ -41,10 +41,7 @@ orbit_deposits AS ( CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS supplier, 'Orbit' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/orbit/silver__orbit_liquidations.sql b/models/silver/defi/lending/orbit/silver__orbit_liquidations.sql index e53d709..e7c8a71 100644 --- a/models/silver/defi/lending/orbit/silver__orbit_liquidations.sql +++ b/models/silver/defi/lending/orbit/silver__orbit_liquidations.sql @@ -43,10 +43,7 @@ orbit_liquidations AS ( CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS tokenCollateral, 'Orbit' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/orbit/silver__orbit_repayments.sql b/models/silver/defi/lending/orbit/silver__orbit_repayments.sql index 27d7bef..08ba20d 100644 --- a/models/silver/defi/lending/orbit/silver__orbit_repayments.sql +++ b/models/silver/defi/lending/orbit/silver__orbit_repayments.sql @@ -38,10 +38,7 @@ orbit_repayments AS ( ) :: INTEGER AS repayed_amount_raw, 'Orbit' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/defi/lending/orbit/silver__orbit_withdraws.sql b/models/silver/defi/lending/orbit/silver__orbit_withdraws.sql index bb8e9a3..deff93f 100644 --- a/models/silver/defi/lending/orbit/silver__orbit_withdraws.sql +++ b/models/silver/defi/lending/orbit/silver__orbit_withdraws.sql @@ -41,10 +41,7 @@ orbit_redemptions AS ( CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS redeemer, 'Orbit' AS platform, modified_timestamp, - CASE - WHEN tx_status = 'SUCCESS' THEN TRUE - ELSE FALSE - END AS tx_succeeded, + tx_succeeded, CONCAT( tx_hash :: STRING, '-', diff --git a/models/silver/protocols/blitz/silver__blitz_collateral.sql b/models/silver/protocols/blitz/silver__blitz_collateral.sql index f16d3cf..c2cf675 100644 --- a/models/silver/protocols/blitz/silver__blitz_collateral.sql +++ b/models/silver/protocols/blitz/silver__blitz_collateral.sql @@ -31,10 +31,14 @@ WITH logs_pull AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS product_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 topics [0] :: STRING = '0xfe53084a731040f869d38b1dcd00fbbdbc14e10d7d739160559d77f5bc80cf05' AND contract_address = '0xc748532c202828969b2ee68e0f8487e69cc1d800' --clearing house diff --git a/models/silver/protocols/blitz/silver__blitz_dim_products.sql b/models/silver/protocols/blitz/silver__blitz_dim_products.sql index 8e98d08..107cc5c 100644 --- a/models/silver/protocols/blitz/silver__blitz_dim_products.sql +++ b/models/silver/protocols/blitz/silver__blitz_dim_products.sql @@ -15,10 +15,14 @@ WITH logs_pull AS ( tx_hash, block_number, block_timestamp, - _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 ( '0x3286b0394bf1350245290b7226c92ed186bd716f28938e62dbb895298f018172', diff --git a/models/silver/protocols/blitz/silver__blitz_liquidations.sql b/models/silver/protocols/blitz/silver__blitz_liquidations.sql index a763532..98ce171 100644 --- a/models/silver/protocols/blitz/silver__blitz_liquidations.sql +++ b/models/silver/protocols/blitz/silver__blitz_liquidations.sql @@ -19,9 +19,26 @@ WITH health_groups AS ( ), logs AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + 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 = '0x494f937f5cc892f798248aa831acfb4ad7c4bf35edd8498c5fb431ce1e38b035' AND contract_address = LOWER('0xC748532C202828969b2Ee68E0F8487E69cC1d800') diff --git a/models/silver/protocols/blitz/silver__blitz_perps.sql b/models/silver/protocols/blitz/silver__blitz_perps.sql index c8b13cd..371f540 100644 --- a/models/silver/protocols/blitz/silver__blitz_perps.sql +++ b/models/silver/protocols/blitz/silver__blitz_perps.sql @@ -24,9 +24,26 @@ WITH blitz_products AS ( ), logs AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + 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 = '0x7c57459d6f4f0fb2fc5b1e298c8c0eb238422944964aa1e249eaa78747f0cca9' AND contract_address = LOWER('0x6983B339922B5B35994B038e6e74ddd115e292f1') diff --git a/models/silver/protocols/blitz/silver__blitz_spot.sql b/models/silver/protocols/blitz/silver__blitz_spot.sql index 4f784f2..1986398 100644 --- a/models/silver/protocols/blitz/silver__blitz_spot.sql +++ b/models/silver/protocols/blitz/silver__blitz_spot.sql @@ -25,9 +25,26 @@ WITH blitz_products AS ( ), logs AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + 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 = '0x7c57459d6f4f0fb2fc5b1e298c8c0eb238422944964aa1e249eaa78747f0cca9' AND contract_address = LOWER('0x6983B339922B5B35994B038e6e74ddd115e292f1') diff --git a/models/silver/stats/silver_stats__core_metrics_hourly.sql b/models/silver/stats/silver_stats__core_metrics_hourly.sql index d16c1bb..5187cd4 100644 --- a/models/silver/stats/silver_stats__core_metrics_hourly.sql +++ b/models/silver/stats/silver_stats__core_metrics_hourly.sql @@ -14,9 +14,9 @@ SELECT MIN(DATE_TRUNC('hour', block_timestamp)) block_timestamp_hour FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE - _inserted_timestamp >= ( + modified_timestamp >= ( SELECT MAX(_inserted_timestamp) FROM @@ -40,12 +40,12 @@ SELECT ) AS transaction_count, COUNT( DISTINCT CASE - WHEN tx_success THEN tx_hash + WHEN tx_succeeded THEN tx_hash END ) AS transaction_count_success, COUNT( DISTINCT CASE - WHEN NOT tx_success THEN tx_hash + WHEN NOT tx_succeeded THEN tx_hash END ) AS transaction_count_failed, COUNT( @@ -55,7 +55,7 @@ SELECT DISTINCT to_address ) AS unique_to_count, SUM(tx_fee_precise) AS total_fees, - MAX(_inserted_timestamp) AS _inserted_timestamp, + MAX(modified_timestamp) AS _inserted_timestamp, {{ dbt_utils.generate_surrogate_key( ['block_timestamp_hour'] ) }} AS core_metrics_hourly_id, @@ -63,7 +63,7 @@ SELECT SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp_hour < DATE_TRUNC( 'hour', @@ -77,4 +77,4 @@ AND DATE_TRUNC( ) >= '{{ min_block_timestamp_hour }}' {% endif %} GROUP BY - 1 + 1 \ No newline at end of file diff --git a/models/streamline/silver/decoder/realtime/streamline__decode_logs_realtime.sql b/models/streamline/silver/decoder/realtime/streamline__decode_logs_realtime.sql index 2d5ad4f..0df4388 100644 --- a/models/streamline/silver/decoder/realtime/streamline__decode_logs_realtime.sql +++ b/models/streamline/silver/decoder/realtime/streamline__decode_logs_realtime.sql @@ -50,7 +50,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', -5, SYSDATE()) ) SELECT