diff --git a/models/beacon_chain/silver/silver__eth_staking_deposits.sql b/models/beacon_chain/silver/silver__eth_staking_deposits.sql index 71891ff55..9ac7e8b0a 100644 --- a/models/beacon_chain/silver/silver__eth_staking_deposits.sql +++ b/models/beacon_chain/silver/silver__eth_staking_deposits.sql @@ -54,15 +54,19 @@ WITH deposit_evt AS ( TRY_TO_NUMBER( utils.udf_hex_to_int(SUBSTR(INDEX, 15, 2) || SUBSTR(INDEX, 13, 2) || SUBSTR(INDEX, 11, 2) || SUBSTR(INDEX, 9, 2) || SUBSTR(INDEX, 7, 2) || SUBSTR(INDEX, 5, 2) || SUBSTR(INDEX, 3, 2)) ) AS deposit_index, - _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 = '0x00000000219ab540356cbb839cbe05303d7705fa' --BeaconDepositContract AND topics [0] :: STRING = '0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5' --DepositEvent AND block_number >= 11185300 - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -97,16 +101,16 @@ FINAL AS ( d._inserted_timestamp FROM deposit_evt d - LEFT JOIN {{ ref('silver__traces') }} + LEFT JOIN {{ ref('core__fact_traces') }} t ON d.block_number = t.block_number AND d.tx_hash = t.tx_hash - AND d.deposit_amount :: FLOAT = t.eth_value :: FLOAT - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND d.deposit_amount :: FLOAT = t.value :: FLOAT + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} -AND t._inserted_timestamp >= ( +AND t.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '48 hours' FROM diff --git a/models/beacon_chain/silver/silver__eth_staking_withdrawals.sql b/models/beacon_chain/silver/silver__eth_staking_withdrawals.sql index 4f0448cc0..9efec2fe6 100644 --- a/models/beacon_chain/silver/silver__eth_staking_withdrawals.sql +++ b/models/beacon_chain/silver/silver__eth_staking_withdrawals.sql @@ -37,9 +37,9 @@ WITH withdrawal_blocks AS ( {{ dbt_utils.generate_surrogate_key( ['block_number', 'withdrawal_address', 'withdrawal_index'] ) }} AS _unique_key, - _inserted_timestamp + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__blocks') }}, + {{ ref('core__fact_blocks') }}, LATERAL FLATTEN( input => withdrawals ) 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 000000000..828272ab6 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/L1_submission_fields.md @@ -0,0 +1,90 @@ +{% 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 %} + diff --git a/models/doc_descriptions/fsc_evm/blocks.md b/models/doc_descriptions/fsc_evm/blocks.md new file mode 100644 index 000000000..896609b5e --- /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 000000000..b859d1224 --- /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 000000000..52c8e0cce --- /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 000000000..bfc604186 --- /dev/null +++ b/models/doc_descriptions/fsc_evm/evm_deprecations.md @@ -0,0 +1,138 @@ +{% docs evm_column_deprecation_notice %} + +This column is being deprecated for standardization purposes. Please update your queries by February 3, 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 February 3, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_block_hash %} + +This column is being deprecated for standardization purposes. Please remove from your queries by February 3, 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 February 3, 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 February 3, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_chain_id %} + +This column is being removed for standardization purposes. Please remove from your queries by February 3, 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 February 3, 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 February 3, 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 February 3, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_blockchain %} + +This column is being removed for standardization purposes. Please remove from your queries by February 3, 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 February 3, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_full_decoded_log %} + +This column is being deprecated for standardization purposes. Please update your queries to use the `full_decoded_data` column instead by February 3, 2025. + +{% enddocs %} + +{% docs evm_table_deprecation_notice %} + +This table is being deprecated for standardization purposes. Please update your queries by February 3, 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 February 3, 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 February 3, 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 February 3, 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 February 3, 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 February 3, 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 February 3, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_l1_submission_details %} + +This column is being deprecated for standardization purposes. Please remove from your queries by February 3, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_data %} + +This column is being deprecated for standardization purposes. Please remove from your queries by February 3, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_deposit_nonce %} + +This column is being deprecated for standardization purposes. Please remove from your queries by February 3, 2025. + +{% enddocs %} + +{% docs evm_column_deprecation_notice_deposit_receipt_version %} + +This column is being deprecated for standardization purposes. Please remove from your queries by February 3, 2025. + +{% enddocs %} \ No newline at end of file diff --git a/models/doc_descriptions/fsc_evm/nft.md b/models/doc_descriptions/fsc_evm/nft.md new file mode 100644 index 000000000..8ac9daeea --- /dev/null +++ b/models/doc_descriptions/fsc_evm/nft.md @@ -0,0 +1,577 @@ +{% docs evm_nft_events_table_doc %} + +This table contains NFT sales on this EVM blockchain. More NFT marketplaces will be added over time. + +{% enddocs %} + + +{% docs evm_ez_nft_sales_table_doc %} + +This table contains NFT sale events from various marketplaces. + +{% enddocs %} + + +{% docs evm_ez_nft_mint_table_doc %} + +This table contains NFT mint events, defined as NFT transfers from a burn address to an address, on this EVM blockchain. + +{% enddocs %} + +{% docs evm_ez_nft_transfer_table_doc %} + +This table contains NFT transfer events on this EVM blockchain. + +{% enddocs %} + +{% docs evm_lending_repayments_table_doc %} + +This table contains repayment events for loans backed by collateralized NFTs on this EVM blockchain. Events in this table can be a full repayment either by the borrower to get their collateral back or by a new lender to repay the borrower's previous loan. The latter is labeled as refinance where the same borrower takes on a new loan from a new lender and repays the past loan. The NFT collateral is still locked in this scenario. + +{% enddocs %} + +{% docs evm_nft_aggregator_name %} + +The name of the aggregator platform where the sale took place. If the sale did not take place via an aggregator platform, then the value will be null. + +{% enddocs %} + +{% docs evm_nft_amount %} + +The total amount, specified by the mint token address, used as payment to mint the specified number of NFTs corresponding to this token id. + +{% enddocs %} + +{% docs evm_nft_amount_usd %} + +The USD value of amount. + +{% enddocs %} + +{% docs evm_nft_block_no %} + +The block number at which the NFT event occurred. + +{% enddocs %} + +{% docs evm_nft_blocktime %} + +The block timestamp at which the NFT event occurred. + +{% enddocs %} + +{% docs evm_nft_buyer_address %} + +The address of the buyer of the NFT in the transaction. + +{% enddocs %} + +{% docs evm_nft_creator_fee %} + +The decimal adjusted amount of fees paid to the NFT collection as royalty payments for this NFT event in the transaction's currency. + +{% enddocs %} + +{% docs evm_nft_creator_fee_usd %} + +The amount of fees paid to the NFT collection as royalty payments for this NFT event in US dollars. + +{% enddocs %} + +{% docs evm_nft_currency_address %} + +The token contract address for this NFT event. This will be the native asset for native transactions. + +{% enddocs %} + +{% docs evm_nft_currency_symbol %} + +The token symbol for this NFT event. + +{% enddocs %} + +{% docs evm_nft_erc1155_value %} + +If the NFT is an ERC-1155 contract, this field may be one or greater, representing the number of tokens. If it is not an ERC-1155 token, this value will be null. + +{% enddocs %} + +{% docs evm_nft_event_index %} + +The event number within a transaction. + +{% enddocs %} + +{% docs evm_nft_event_type %} + +The type of NFT event in this transaction, either sale, bid_won, redeem, or mint. + +{% enddocs %} + +{% docs evm_nft_from_address %} + +The sending address of the NFT in the transaction. + +{% enddocs %} + +{% docs evm_nft_intra_event_index %} + +The order of events within a single event index. This is primarily used for ERC1155 NFT batch transfer events. + +{% enddocs %} + +{% docs evm_nft_metadata %} + +The token metadata for this NFT. This may be blank for many NFTs. We are working to expand this field. + +{% enddocs %} + +{% docs evm_nft_mint_count %} + +The number of NFTs minted in this event. + +{% enddocs %} + +{% docs evm_nft_mint_price %} + +The price paid in the native asset to mint the NFT(s). + +{% enddocs %} + +{% docs evm_nft_mint_price_usd %} + +The price paid in US dollars to mint the NFT(s). + +{% enddocs %} + +{% docs evm_nft_mints_symbol %} + +The symbol of the token supplied to mint the NFT, if applicable. This field may not handle all edge cases. + +{% enddocs %} + +{% docs evm_nft_mints_token_address %} + +The contract address of the token supplied to mint the NFT, if applicable. This field may not handle all edge cases. + +{% enddocs %} + +{% docs evm_nft_mints_token_price %} + +The decimal adjusted amount of tokens supplied within the same transaction to mint the NFT. This field may not handle all edge cases. + +{% enddocs %} + +{% docs evm_nft_mints_token_price_usd %} + +The amount of tokens supplied in US dollars within the same transaction to mint the NFT. This field may not handle all edge cases. + +{% enddocs %} + +{% docs evm_nft_nft_address %} + +The contract address of the NFT. + +{% enddocs %} + +{% docs evm_nft_origin_from %} + +The from address of this transaction. In most cases, this is the NFT buyer. However, for some more complex transactions, it may not be the NFT buyer. + +{% enddocs %} + +{% docs evm_nft_origin_sig %} + +The function signature of this transaction. + +{% enddocs %} + +{% docs evm_nft_origin_to %} + +The to address of this transaction. In most cases, this is the exchange contract. However, for some more complex NFT events, such as aggregate buys with tools, this may not be the exchange address. + +{% enddocs %} + +{% docs evm_nft_platform_address %} + +The address of the exchange used for the transaction. + +{% enddocs %} + +{% docs evm_nft_platform_exchange_version %} + +The version of the exchange contract used for the transaction. + +{% enddocs %} + +{% docs evm_nft_platform_fee %} + +The decimal adjusted amount of fees paid to the platform for this NFT event in the transaction's currency. There are cases where there are fees paid to multiple marketplaces. In those cases, the fee in the platform_fee column will only reflect the platform fee related to the platform exchange contract. + +{% enddocs %} + +{% docs evm_nft_platform_fee_usd %} + +The amount of fees paid to the platform for this NFT event in US dollars. There are cases where there are fees paid to multiple marketplaces. In those cases, the fee in the platform_fee column will only reflect the platform fee related to the platform exchange contract. + +{% enddocs %} + +{% docs evm_nft_platform_name %} + +The name of the exchange used for the trade. + +{% enddocs %} + +{% docs evm_nft_price %} + +The total price of the NFT, in the currency in which the transaction occurred and decimal adjusted where possible. Please note that the price of the NFT, after subtracting total fees, may not represent the net amount paid to the seller in all cases. You may refer to the platform fee description for more info. + +{% enddocs %} + +{% docs evm_nft_price_usd %} + +The total price of the NFT in US dollars. This will be 0 for tokens without a decimal adjustment or hourly price. Please note that the price of the NFT, after subtracting total fees, may not represent the net amount paid to the seller in all cases. You may refer to the platform fee description for more info. + +{% enddocs %} + +{% docs evm_nft_project_name %} + +The name of the NFT project. This field, along with metadata, will be filled in over time. + +{% enddocs %} + +{% docs evm_nft_seller_address %} + +The address of the seller of the NFT in the transaction. + +{% enddocs %} + +{% docs evm_nft_to_address %} + +The receiving address of the NFT in the transaction. + +{% enddocs %} + +{% docs evm_nft_tokenid %} + +The token ID for this NFT contract. + +{% enddocs %} + +{% docs evm_nft_total_fees %} + +The total amount of fees paid relating to the NFT purchase in the transaction currency. This includes royalty payments to creators and platform fees. Please note, this does not include the gas fee. + +{% enddocs %} + +{% docs evm_nft_total_fees_usd %} + +The total amount of fees paid relating to the NFT purchase in US dollars. This includes royalty payments to creators and platform fees. Please note, this does not include the gas fee. + +{% enddocs %} + +{% docs evm_nft_tx_fee %} + +The gas fee for this transaction in the native asset. + +{% enddocs %} + +{% docs evm_nft_tx_fee_usd %} + +The gas fee for this transaction in US dollars. + +{% enddocs %} + +{% docs evm_nft_tx_hash %} + +The transaction hash for the NFT event. This is not necessarily unique in this table as a transaction may contain multiple NFT events. + +{% enddocs %} + +{% docs evm_nft_lending_liquidations_table_doc %} + +This table contains liquidation events for loans backed by collateralized NFTs on this EVM blockchain. This typically means the lender of the loan closes the loan and receives the NFT collateral. + +{% enddocs %} + +{% docs evm_platform_address %} + +The contract address of the platform's lending contract. + +{% enddocs %} + +{% docs evm_platform_name %} + +The name of the platform. + +{% enddocs %} + +{% docs evm_platform_exchange_version %} + +The version of the platform's lending contract. + +{% enddocs %} + +{% docs evm_loanid %} + +The ID associated with the loan, often times tied to the borrower's address and collateral. This ID can be used as a unique identifier when tracking active loans. However, note that refinances can happen while still maintaining the same loanId. For some platforms, loanids of previously paid loans are reused hence they can't be reliably used as a unique identifier without appropriate timestamp filters. Instead, use the unique_loan_id column. + +{% enddocs %} + +{% docs evm_unique_loan_id %} + +The unique ID that can be used to represent a loan within the same platform. For the same loan, the value of this ID will remain the same across the loans taken, liquidations and repayment tables. For some platforms where the lender is issued a promissory note, the lender can send this note to any address, making the receiver the new lender. However, the unique_loan_id still remains the same although the final lender is different. The unique_loan_id changes only if the loanId and lender changes which would also indicate the previous loan has been fully paid off. + +{% enddocs %} + +{% docs evm_lender_address %} + +The address that gives out a loan to the borrower. When a loan is issued, a promissory note (an ERC721) is issued to the lender. The lender can transfer this note to any address which makes any receiving address the new lender. + +{% enddocs %} + +{% docs evm_borrower_address %} + +The address that receives the loan and has an NFT locked as collateral. + +{% enddocs %} + +{% docs evm_nft_address %} + +The address of the NFT used as collateral. + +{% enddocs %} + +{% docs evm_tokenid %} + +The tokenId of the NFT used as collateral. + +{% enddocs %} + +{% docs evm_loan_token_address %} + +The contract address of what the loan is denominated in. This could be either the native asset or other tokens. + +{% enddocs %} + +{% docs evm_loan_token_symbol %} + +The symbol of the loan token address. + +{% enddocs %} + +{% docs evm_principal_unadj %} + +The principal amount of the loan taken with unadjusted decimal places. + +{% enddocs %} + +{% docs evm_principal %} + +The principal amount of the loan taken with adjusted decimal places. + +{% enddocs %} + +{% docs evm_principal_usd %} + +The principal amount of the loan taken in USD terms. + +{% enddocs %} + +{% docs evm_interest_rate %} + +The non-annualized rate charged by the lender on the principal amount of the loan denominated in percentage (%). For fixed term loans, it is calculated by taking the difference between total debt and principal amount divided by principal amount. For perpetual term loans, interest rate is usually on an annual basis and total debt is calculated prorated. + +{% enddocs %} + +{% docs evm_apr %} + +The annualized interest rate denominated in percentage (%). + +{% enddocs %} + +{% docs evm_loan_term_type %} + +The type of loan terms, could be either a fixed loan or a perpetual loan. A fixed term loan has a fixed repayment date while a perpetual loan does not. + +{% enddocs %} + +{% docs evm_loan_start_timestamp %} + +The timestamp of when the loan offer is accepted. + +{% enddocs %} + +{% docs evm_loan_due_timestamp %} + +The timestamp of when the loan is due. For perpetual term loan, the value will be null. + +{% enddocs %} + +{% docs evm_loan_tenure %} + +The tenure of the loan denominated in seconds. For perpetual term loan, the value will be null. + +{% enddocs %} + +{% docs evm_lending_loans %} + +This table contains NFT lending events for loans backed by collateralized NFTs on this EVM blockchain. This could be depositing an NFT and taking out a loan or using the Buy Now Pay Later (BNPL) feature to take a loan out of the newly bought NFT. This NFT will remain locked until the loan is cleared. + +{% enddocs %} + +{% docs evm_nft_lending_event_type %} + +There are 2 types of loan creation events. It can either be a new loan or a refinance of an existing loan. Note that renegotiation events are categorized as refinance events in this table. Old loans are repaid and new loan ids are reissued so these would be new loan entries in this table. + +{% enddocs %} + +{% docs evm_debt_unadj %} + +The total debt of the loan (principal amount plus interests) with unadjusted decimal places. + +{% enddocs %} + +{% docs evm_debt %} + +The total debt of the loan (principal amount plus interests) with adjusted decimal places. + +{% enddocs %} + +{% docs evm_debt_usd %} + +The total debt of the loan (principal amount plus interests) in USD terms. + +{% enddocs %} + +{% docs evm_platform_fee_unadj %} + +The fee charged by the lending platform with unadjusted decimal places. + +{% enddocs %} + +{% docs evm_platform_fee %} + +The fee charged by the lending platform with adjusted decimal places. + +{% enddocs %} + +{% docs evm_platform_fee_usd %} + +The fee charged by the lending platform in USD terms. + +{% enddocs %} + +{% docs evm_mev_arbitrage %} + +This table contains the financial metrics from NFT arbitrage transactions including cost, revenue and profits. + +{% enddocs %} + +{% docs evm_mev_searcher %} + +The address of the MEV finder, taken from the origin address that initiated the transaction. + +{% enddocs %} + +{% docs evm_mev_contract %} + +The contract address that the MEV searcher uses to execute mev transactions, taken from the origin to address of the transaction. + +{% enddocs %} + +{% docs evm_cost_usd %} + +The total cost in USD to purchase the NFT(s) in the transaction. + +{% enddocs %} + +{% docs evm_revenue_usd %} + +The total revenue in USD from selling the NFT(s) and other related tokens in the transaction. + +{% enddocs %} + +{% docs evm_miner_tip_usd %} + +The total amount in USD sent to the block miner/builder as a tip to include the transaction in the block. + +{% enddocs %} + +{% docs evm_profit_usd %} + +The remainder in USD after subtracting cost, miner tip and transaction fee from revenue. + +{% enddocs %} + +{% docs evm_funding_source %} + +The source of the funds used to perform the arbitrage. Currently there are three sources. Existing funds indicate that the user uses funds that are already in their balance while flash loan and flash swaps indicate that the user took a flash loan in the transaction. + +{% enddocs %} + +{% docs evm_arbitrage_direction %} + +The direction in which the arbitrage is performed. There are two possibilities of origin and destination: pool and marketplace. Pool represents marketplaces where users swap from a pool whereas marketplace represents regular marketplaces that are not pool-based. + +{% enddocs %} + +{% docs evm_fact_mev_arbitrage_events %} + +This table contains information about the NFTs involved in arbitrage transactions, documenting events from both the buy and sell sides. + +{% enddocs %} + +{% docs evm_trade_side %} + +The side of the trade that this event represents. This can be either buy or sell. Buy would represent the events where NFTs are bought while sell would present the events where the bought NFTs are sold. Note that the number of events for buy and sell may not be the same for a given transaction. + +{% enddocs %} + +{% docs evm_dim_nft_collection_metadata %} + +This table contains the metadata for popular NFT collections on this EVM blockchain. + +{% enddocs %} + +{% docs evm_nft_blockchain %} + +Blockchain where the NFT metadata is retrieved from. + +{% enddocs %} + +{% docs evm_collection_name %} + +The name for this NFT collection. + +{% enddocs %} + +{% docs evm_tokenid_name %} + +The name for this specific tokenId. This may be the same for all tokenIds within the same collection. + +{% enddocs %} + +{% docs evm_traits %} + +The traits for this tokenId in a key-value pair format. + +{% enddocs %} + +{% docs evm_tokenid_description %} + +The description for this specific tokenId. This may be the same for all tokenIds within the same collection. + +{% enddocs %} + +{% docs evm_tokenid_image_url %} + +The url of the image for this tokenId. + +{% enddocs %} + +{% docs evm_nft_address_tokenid %} + +The concatenation of NFT address and tokenId. + +{% enddocs %} \ 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 000000000..c6b601e1f --- /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 000000000..ec61ce70e --- /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 000000000..583947ad3 --- /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 280f6f830..000000000 --- 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 d647568cc..712ca71cb 100644 --- a/models/gold/core/core__ez_decoded_event_logs.sql +++ b/models/gold/core/core__ez_decoded_event_logs.sql @@ -8,19 +8,27 @@ SELECT block_number, block_timestamp, tx_hash, + {# tx_position, --new column, requires FR on silver.decoded_logs #} event_index, contract_address, - C.name AS contract_name, - event_name, - decoded_flat AS decoded_log, - decoded_data AS full_decoded_log, - origin_function_signature, - origin_from_address, - origin_to_address, topics, + topics[0]::STRING AS topic_0, --new column + topics[1]::STRING AS topic_1, --new column + topics[2]::STRING AS topic_2, --new column + topics[3]::STRING AS topic_3, --new column DATA, event_removed, - tx_status, + origin_from_address, + origin_to_address, + origin_function_signature, + CASE + WHEN tx_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS tx_succeeded, --new column + event_name, + decoded_data AS full_decoded_data, --new column + decoded_flat AS decoded_log, + C.name AS contract_name, COALESCE ( decoded_logs_id, {{ dbt_utils.generate_surrogate_key( @@ -28,7 +36,9 @@ SELECT ) }} ) 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 + GREATEST(COALESCE(l.modified_timestamp, '2000-01-01'), COALESCE(C.modified_timestamp, '2000-01-01')) AS modified_timestamp, + decoded_data AS full_decoded_log, --deprecate + tx_status --deprecate FROM {{ ref('silver__decoded_logs') }} l diff --git a/models/gold/core/core__ez_decoded_event_logs.yml b/models/gold/core/core__ez_decoded_event_logs.yml index 6391b16be..78df37ab8 100644 --- a/models/gold/core/core__ez_decoded_event_logs.yml +++ b/models/gold/core/core__ez_decoded_event_logs.yml @@ -42,20 +42,32 @@ models: - name: DECODED_LOG description: 'The flattened decoded log, where the keys are the names of the event parameters, and the values are the values of the event parameters.' - name: FULL_DECODED_LOG + description: '{{ doc("evm_column_deprecation_notice") }}' + - name: FULL_DECODED_DATA description: 'The full decoded log, including the event name, the event parameters, and the data type of the event parameters.' - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("nft_origin_sig") }}' + description: '{{ doc("eth_tx_origin_sig") }}' - name: ORIGIN_FROM_ADDRESS description: '{{ doc("eth_origin_from") }}' - name: ORIGIN_TO_ADDRESS description: '{{ doc("eth_origin_to") }}' - name: TOPICS description: '{{ doc("eth_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("eth_logs_data") }}' - name: EVENT_REMOVED description: '{{ doc("eth_event_removed") }}' - name: TX_STATUS + description: '{{ doc("evm_column_deprecation_notice") }}' + - name: TX_SUCCEEDED description: '{{ doc("eth_tx_status") }}' - name: EZ_DECODED_EVENT_LOGS_ID description: '{{ doc("pk") }}' diff --git a/models/gold/core/core__ez_decoded_traces.sql b/models/gold/core/core__ez_decoded_traces.sql index 17994cc17..1db4bd849 100644 --- a/models/gold/core/core__ez_decoded_traces.sql +++ b/models/gold/core/core__ez_decoded_traces.sql @@ -6,33 +6,43 @@ SELECT block_number, - tx_hash, block_timestamp, - tx_status, + tx_hash, tx_position, - trace_index, + trace_index, from_address, c0.name AS from_address_name, to_address, c1.name AS to_address_name, + input, + output, + decoded_data :function_name :: STRING AS function_name, + decoded_data AS full_decoded_data, --new column + decoded_data :decoded_input_data AS decoded_input_data, + decoded_data :decoded_output_data AS decoded_output_data, + TYPE, + {# trace_address, --new column, requires FR on silver.decoded_traces #} + sub_traces, VALUE, value_precise_raw, value_precise, gas, gas_used, - TYPE, - identifier, - sub_traces, + CASE + WHEN trace_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS trace_succeeded, --new column error_reason, - trace_status, - input, - output, - decoded_data :function_name :: STRING AS function_name, - decoded_data :decoded_input_data AS decoded_input_data, - decoded_data :decoded_output_data AS decoded_output_data, + CASE + WHEN tx_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS tx_succeeded, --new column decoded_traces_id AS fact_decoded_traces_id, GREATEST(COALESCE(t.inserted_timestamp, '2000-01-01'), COALESCE(c0.inserted_timestamp, '2000-01-01'), COALESCE(c1.inserted_timestamp, '2000-01-01')) AS inserted_timestamp, - GREATEST(COALESCE(t.modified_timestamp, '2000-01-01'), COALESCE(c0.modified_timestamp, '2000-01-01'), COALESCE(c1.modified_timestamp, '2000-01-01')) AS modified_timestamp + GREATEST(COALESCE(t.modified_timestamp, '2000-01-01'), COALESCE(c0.modified_timestamp, '2000-01-01'), COALESCE(c1.modified_timestamp, '2000-01-01')) AS modified_timestamp, + identifier, --deprecate + trace_status, --deprecate + tx_status --deprecate FROM {{ ref('silver__decoded_traces') }} t diff --git a/models/gold/core/core__ez_decoded_traces.yml b/models/gold/core/core__ez_decoded_traces.yml index a16a640c8..59fa581af 100644 --- a/models/gold/core/core__ez_decoded_traces.yml +++ b/models/gold/core/core__ez_decoded_traces.yml @@ -13,7 +13,7 @@ models: - name: BLOCK_TIMESTAMP description: '{{ doc("eth_traces_blocktime") }}' - name: TX_STATUS - description: '{{ doc("eth_tx_status") }}' + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' - name: TX_POSITION description: The position of the transaction within the block. - name: TRACE_INDEX @@ -39,13 +39,19 @@ models: - name: TYPE description: '{{ doc("eth_traces_type") }}' - name: IDENTIFIER - description: '{{ doc("eth_traces_identifier") }}' + description: '{{ doc("evm_column_deprecation_notice_identifier") }}' + - name: TRACE_ADDRESS + description: '{{ doc("evm_trace_address") }}' - name: SUB_TRACES description: '{{ doc("eth_traces_sub") }}' - name: ERROR_REASON description: The reason for the trace failure, if any. - name: TRACE_STATUS - description: The status of the trace, either `SUCCESS` or `FAIL` + description: '{{ doc("evm_column_deprecation_notice_trace_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' + - name: TRACE_SUCCEEDED + description: '{{ doc("evm_trace_succeeded") }}' - name: INPUT description: '{{ doc("eth_traces_input") }}' - name: OUTPUT @@ -56,6 +62,8 @@ models: description: Decoded input data for the trace. - name: DECODED_OUTPUT_DATA description: Decoded output data for the trace. + - name: FULL_DECODED_DATA + description: 'The full decoded trace.' - name: FACT_DECODED_TRACES_ID description: '{{ doc("pk") }}' - name: INSERTED_TIMESTAMP diff --git a/models/gold/core/core__ez_native_transfers.sql b/models/gold/core/core__ez_native_transfers.sql index 14d2cac41..467272d3d 100644 --- a/models/gold/core/core__ez_native_transfers.sql +++ b/models/gold/core/core__ez_native_transfers.sql @@ -1,7 +1,10 @@ {{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true } + materialized = 'incremental', + incremental_strategy = 'delete+insert', + unique_key = 'block_number', + cluster_by = ['block_timestamp::DATE'], + post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION ON EQUALITY(trace_address, from_address, to_address)", + tags = ['core','non_realtime','reorg'] ) }} SELECT @@ -10,7 +13,8 @@ SELECT block_timestamp, tx_position, trace_index, - identifier, + identifier, --deprecate + trace_address, --new column origin_from_address, origin_to_address, origin_function_signature, @@ -20,19 +24,17 @@ SELECT amount_precise_raw, amount_precise, amount_usd, - COALESCE ( - native_transfers_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'trace_index'] - ) }} - ) AS ez_native_transfers_id, - COALESCE( - inserted_timestamp, - '2000-01-01' - ) AS inserted_timestamp, - COALESCE( - modified_timestamp, - '2000-01-01' - ) AS modified_timestamp + native_transfers_id AS ez_native_transfers_id, + SYSDATE() AS inserted_timestamp, + SYSDATE() AS modified_timestamp FROM {{ ref('silver__native_transfers') }} + +{% if is_incremental() %} +AND modified_timestamp > ( + SELECT + COALESCE(MAX(modified_timestamp), '1970-01-01' :: TIMESTAMP) AS modified_timestamp + FROM + {{ this }} +) +{% endif %} diff --git a/models/gold/core/core__ez_native_transfers.yml b/models/gold/core/core__ez_native_transfers.yml index ead27c580..b67273972 100644 --- a/models/gold/core/core__ez_native_transfers.yml +++ b/models/gold/core/core__ez_native_transfers.yml @@ -15,7 +15,9 @@ models: - name: TRACE_INDEX description: '{{ doc("eth_trace_index") }}' - name: IDENTIFIER - description: '{{ doc("eth_traces_identifier") }}' + description: '{{ doc("evm_column_deprecation_notice_identifier") }}' + - name: TRACE_ADDRESS + description: '{{ doc("evm_trace_address") }}' - name: ORIGIN_FROM_ADDRESS description: '{{ doc("eth_origin_from") }}' - name: ORIGIN_TO_ADDRESS diff --git a/models/gold/core/core__fact_blocks.sql b/models/gold/core/core__fact_blocks.sql index 9da9276a6..d125d8aa9 100644 --- a/models/gold/core/core__fact_blocks.sql +++ b/models/gold/core/core__fact_blocks.sql @@ -6,23 +6,46 @@ SELECT block_number, + HASH AS block_hash, --new column block_timestamp, 'mainnet' AS network, - 'ethereum' AS blockchain, tx_count, - difficulty, - total_difficulty, + SIZE, + miner, extra_data, - gas_limit, - gas_used, - HASH, parent_hash, - miner, - nonce, - receipts_root, + gas_used, + gas_limit, + base_fee_per_gas, --new column + excess_blob_gas, + blob_gas_used, + difficulty, + total_difficulty, sha3_uncles, - SIZE, uncles AS uncle_blocks, + nonce, + receipts_root, + state_root, --new column + transactions_root, --new column + logs_bloom, --new column + withdrawals, + withdrawals_root, + COALESCE ( + blocks_id, + {{ dbt_utils.generate_surrogate_key( + ['block_number'] + ) }} + ) AS fact_blocks_id, + COALESCE( + inserted_timestamp, + '2000-01-01' + ) AS inserted_timestamp, + COALESCE( + modified_timestamp, + '2000-01-01' + ) AS modified_timestamp, + 'ethereum' AS blockchain, --deprecate + HASH, --deprecate OBJECT_CONSTRUCT( 'baseFeePerGas', base_fee_per_gas, @@ -66,24 +89,6 @@ SELECT excess_blob_gas, 'blobGasUsed', blob_gas_used - ) AS block_header_json, - excess_blob_gas, - blob_gas_used, - COALESCE ( - blocks_id, - {{ dbt_utils.generate_surrogate_key( - ['block_number'] - ) }} - ) AS fact_blocks_id, - COALESCE( - inserted_timestamp, - '2000-01-01' - ) AS inserted_timestamp, - COALESCE( - modified_timestamp, - '2000-01-01' - ) AS modified_timestamp, - withdrawals, - withdrawals_root + ) AS block_header_json --deprecate FROM {{ ref('silver__blocks') }} diff --git a/models/gold/core/core__fact_blocks.yml b/models/gold/core/core__fact_blocks.yml index 89a437810..c0f73388c 100644 --- a/models/gold/core/core__fact_blocks.yml +++ b/models/gold/core/core__fact_blocks.yml @@ -1,58 +1,68 @@ version: 2 models: - name: core__fact_blocks - description: '{{ doc("eth_blocks_table_doc") }}' + description: '{{ doc("evm_blocks_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("eth_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("eth_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: NETWORK - description: '{{ doc("eth_network") }}' + description: '{{ doc("evm_network") }}' - name: BLOCKCHAIN - description: '{{ doc("eth_blockchain") }}' + description: '{{ doc("evm_column_deprecation_notice_blockchain") }}' - name: TX_COUNT - description: '{{ doc("eth_tx_count") }}' + description: '{{ doc("evm_tx_count") }}' - name: DIFFICULTY - description: '{{ doc("eth_difficulty") }}' + description: '{{ doc("evm_difficulty") }}' - name: TOTAL_DIFFICULTY - description: '{{ doc("eth_total_difficulty") }}' + description: '{{ doc("evm_total_difficulty") }}' - name: EXTRA_DATA - description: '{{ doc("eth_extra_data") }}' + description: '{{ doc("evm_extra_data") }}' - name: GAS_LIMIT - description: '{{ doc("eth_gas_limit") }}' + description: '{{ doc("evm_gas_limit") }}' - name: GAS_USED - description: '{{ doc("eth_gas_used") }}' + description: '{{ doc("evm_gas_used") }}' + - name: BLOCK_HASH + description: '{{ doc("evm_blocks_hash") }}' - name: HASH - description: '{{ doc("eth_blocks_hash") }}' + description: '{{ doc("evm_column_deprecation_notice_hash") }}' - name: PARENT_HASH - description: '{{ doc("eth_parent_hash") }}' + description: '{{ doc("evm_parent_hash") }}' - name: MINER - description: '{{ doc("eth_miner") }}' + description: '{{ doc("evm_miner") }}' - name: NONCE - description: '{{ doc("eth_blocks_nonce") }}' + description: '{{ doc("evm_blocks_nonce") }}' - name: RECEIPTS_ROOT - description: '{{ doc("eth_receipts_root") }}' + description: '{{ doc("evm_receipts_root") }}' - name: SHA3_UNCLES - description: '{{ doc("eth_sha3_uncles") }}' + description: '{{ doc("evm_sha3_uncles") }}' - name: SIZE - description: '{{ doc("eth_size") }}' + description: '{{ doc("evm_size") }}' - name: UNCLE_BLOCKS - description: '{{ doc("eth_uncle_blocks") }}' + description: '{{ doc("evm_uncle_blocks") }}' + - name: STATE_ROOT + description: '{{ doc("evm_state_root") }}' + - name: TRANSACTIONS_ROOT + description: '{{ doc("evm_transactions_root") }}' + - name: LOGS_BLOOM + description: '{{ doc("evm_logs_bloom") }}' - name: BLOCK_HEADER_JSON - description: '{{ doc("eth_block_header_json") }}' + description: '{{ doc("evm_column_deprecation_notice_block_header_json") }}' + - name: BASE_FEE_PER_GAS + description: '{{ doc("evm_base_fee_per_gas") }}' - name: BLOB_GAS_USED description: The total amount of blob gas consumed by transactions in the block. - name: EXCESS_BLOB_GAS description: A running total of blob gas consumed in excess of the target, prior to the block. This is used to set blob gas pricing. - 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 description: An array of withdrawals that occurred in this block. - name: WITHDRAWALS_ROOT - description: A hash of the withdrawals that occurred in this block. + description: '{{ doc("evm_withdrawals_root") }}' diff --git a/models/gold/core/core__fact_decoded_event_logs.yml b/models/gold/core/core__fact_decoded_event_logs.yml index f503d4c23..914f1ae60 100644 --- a/models/gold/core/core__fact_decoded_event_logs.yml +++ b/models/gold/core/core__fact_decoded_event_logs.yml @@ -1,29 +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_decoded_traces.yml b/models/gold/core/core__fact_decoded_traces.yml index 98a9d6264..cd3e9a300 100644 --- a/models/gold/core/core__fact_decoded_traces.yml +++ b/models/gold/core/core__fact_decoded_traces.yml @@ -1,10 +1,7 @@ version: 2 models: - name: core__fact_decoded_traces - description: > - This model contains decoded data for traces on the Ethereum blockchain. It will not contain all records, but only those for which we have a valid ABI. - If you are interested in submitting a contract for decoding, please visit [here](https://science.flipsidecrypto.xyz/abi-requestor/). - + description: '{{ doc("evm_table_deprecation_notice_fact_decoded_traces")}}' columns: - name: BLOCK_NUMBER description: '{{ doc("eth_traces_block_no") }}' diff --git a/models/gold/core/core__fact_event_logs.sql b/models/gold/core/core__fact_event_logs.sql index e21eda0ec..45d8fd34f 100644 --- a/models/gold/core/core__fact_event_logs.sql +++ b/models/gold/core/core__fact_event_logs.sql @@ -8,16 +8,23 @@ SELECT block_number, block_timestamp, tx_hash, - origin_function_signature, - origin_from_address, - origin_to_address, + {# tx_position, --new column, requires FR on silver.logs #} event_index, contract_address, topics, + topics[0]::STRING AS topic_0, --new column + topics[1]::STRING AS topic_1, --new column + topics[2]::STRING AS topic_2, --new column + topics[3]::STRING AS topic_3, --new column DATA, event_removed, - tx_status, - _log_id, + origin_from_address, + origin_to_address, + origin_function_signature, + CASE + WHEN tx_status = 'SUCCESS' THEN TRUE + ELSE FALSE + END AS tx_succeeded, --new column COALESCE ( logs_id, {{ dbt_utils.generate_surrogate_key( @@ -31,6 +38,8 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp + ) AS modified_timestamp, + tx_status, --deprecate + _log_id --deprecate FROM {{ ref('silver__logs') }} diff --git a/models/gold/core/core__fact_event_logs.yml b/models/gold/core/core__fact_event_logs.yml index f40fe43d6..2da973a07 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("eth_logs_table_doc") }}' + description: '{{ doc("evm_logs_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("eth_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("eth_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: TX_HASH - description: '{{ doc("eth_logs_tx_hash") }}' + description: '{{ doc("evm_logs_tx_hash") }}' - name: EVENT_INDEX - description: '{{ doc("eth_event_index") }}' + description: '{{ doc("evm_event_index") }}' - name: CONTRACT_ADDRESS - description: '{{ doc("eth_logs_contract_address") }}' + description: '{{ doc("evm_logs_contract_address") }}' - name: TOPICS - description: '{{ doc("eth_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("eth_logs_data") }}' + description: '{{ doc("evm_logs_data") }}' - name: EVENT_REMOVED - description: '{{ doc("eth_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("eth_tx_status") }}' + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("nft_origin_sig") }}' + description: '{{ doc("evm_nft_origin_sig") }}' - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("eth_origin_from") }}' + description: '{{ doc("evm_origin_from") }}' - name: ORIGIN_TO_ADDRESS - description: '{{ doc("eth_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_traces.sql b/models/gold/core/core__fact_traces.sql index f87f6d8ca..5232e6d26 100644 --- a/models/gold/core/core__fact_traces.sql +++ b/models/gold/core/core__fact_traces.sql @@ -5,32 +5,32 @@ ) }} SELECT - tx_hash, block_number, block_timestamp, + tx_hash, + tx_position, --new column + trace_index, from_address, to_address, - eth_value AS VALUE, - eth_value_precise_raw AS value_precise_raw, - eth_value_precise AS value_precise, - gas, - gas_used, input, output, TYPE, - identifier, - DATA, - tx_status, + trace_address, --new column sub_traces, - trace_status, + VALUE, + value_precise_raw, + value_precise, + value_hex, --new column + gas, + gas_used, + origin_from_address, --new column + origin_to_address, --new column + origin_function_signature, --new column + trace_succeeded, --new column error_reason, - trace_index, - COALESCE ( - traces_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'trace_index'] - ) }} - ) AS fact_traces_id, + revert_reason, --new column + tx_succeeded, --new column + fact_traces_id, COALESCE( inserted_timestamp, '2000-01-01' @@ -38,6 +38,11 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp + ) AS modified_timestamp, + identifier, --deprecate + tx_status, --deprecate + DATA, --deprecate + trace_status --deprecate FROM - {{ ref('silver__traces') }} + {{ ref('silver__fact_traces2') }} +--ideal state = source from silver.traces2 and materialize this model as a table (core.fact_traces2) \ No newline at end of file diff --git a/models/gold/core/core__fact_traces.yml b/models/gold/core/core__fact_traces.yml index bc8899b91..9ba5b24fe 100644 --- a/models/gold/core/core__fact_traces.yml +++ b/models/gold/core/core__fact_traces.yml @@ -1,52 +1,64 @@ version: 2 models: - name: core__fact_traces - description: '{{ doc("eth_traces_table_doc") }}' + description: '{{ doc("evm_traces_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("eth_traces_block_no") }}' + description: '{{ doc("evm_traces_block_no") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("eth_traces_blocktime") }}' + description: '{{ doc("evm_traces_blocktime") }}' - name: TX_HASH - description: '{{ doc("eth_traces_tx_hash") }}' + description: '{{ doc("evm_traces_tx_hash") }}' + - name: TX_POSITION + description: '{{ doc("evm_tx_position") }}' - name: FROM_ADDRESS - description: '{{ doc("eth_traces_from") }}' + description: '{{ doc("evm_traces_from") }}' - name: TO_ADDRESS - description: '{{ doc("eth_traces_to") }}' + description: '{{ doc("evm_traces_to") }}' - name: VALUE - description: '{{ doc("eth_traces_eth_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("eth_traces_gas") }}' + description: '{{ doc("evm_traces_gas") }}' - name: GAS_USED - description: '{{ doc("eth_traces_gas_used") }}' + description: '{{ doc("evm_traces_gas_used") }}' - name: INPUT - description: '{{ doc("eth_traces_input") }}' + description: '{{ doc("evm_traces_input") }}' - name: OUTPUT - description: '{{ doc("eth_traces_output") }}' + description: '{{ doc("evm_traces_output") }}' - name: TYPE - description: '{{ doc("eth_traces_type") }}' + description: '{{ doc("evm_traces_type") }}' - name: IDENTIFIER - description: '{{ doc("eth_traces_identifier") }}' + description: '{{ doc("evm_column_deprecation_notice_identifier") }}' + - name: TRACE_ADDRESS + description: '{{ doc("evm_trace_address") }}' - name: DATA - description: '{{ doc("eth_traces_call_data") }}' + description: '{{ doc("evm_column_deprecation_notice_data") }}' - name: TX_STATUS - description: '{{ doc("eth_tx_status") }}' + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' + - name: TRACE_SUCCEEDED + description: '{{ doc("evm_trace_succeeded") }}' - name: SUB_TRACES - description: '{{ doc("eth_traces_sub") }}' + description: '{{ doc("evm_sub_traces") }}' - name: TRACE_STATUS - description: The status of the trace, either `SUCCESS` or `FAIL` + description: '{{ doc("evm_column_deprecation_notice_trace_status") }}' - name: ERROR_REASON - description: The reason for the trace failure, if any. + 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. + 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") }}' \ No newline at end of file + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/core/core__fact_transactions.sql b/models/gold/core/core__fact_transactions.sql index d2583a0ff..de81810e0 100644 --- a/models/gold/core/core__fact_transactions.sql +++ b/models/gold/core/core__fact_transactions.sql @@ -7,36 +7,37 @@ 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, - gas AS gas_limit, gas_used, + gas AS gas_limit, cumulative_gas_used, - input_data, - tx_status AS status, effective_gas_price, max_fee_per_gas, max_priority_fee_per_gas, - r, - s, - v, - tx_type, - chain_id, blob_versioned_hashes, max_fee_per_blob_gas, blob_gas_used, blob_gas_price, + r, + s, + v, COALESCE ( transactions_id, {{ dbt_utils.generate_surrogate_key( @@ -50,6 +51,10 @@ SELECT COALESCE( modified_timestamp, '2000-01-01' - ) AS modified_timestamp + ) AS modified_timestamp, + block_hash, --deprecate + POSITION, --deprecate + tx_status AS status, --deprecate + chain_id --deprecate FROM {{ ref('silver__transactions') }} diff --git a/models/gold/core/core__fact_transactions.yml b/models/gold/core/core__fact_transactions.yml index 2d1e134cc..217a0988a 100644 --- a/models/gold/core/core__fact_transactions.yml +++ b/models/gold/core/core__fact_transactions.yml @@ -1,47 +1,51 @@ version: 2 models: - name: core__fact_transactions - description: '{{ doc("eth_tx_table_doc") }}' + description: '{{ doc("evm_tx_table_doc") }}' columns: - name: BLOCK_NUMBER - description: '{{ doc("eth_block_number") }}' + description: '{{ doc("evm_block_number") }}' - name: BLOCK_TIMESTAMP - description: '{{ doc("eth_block_timestamp") }}' + description: '{{ doc("evm_block_timestamp") }}' - name: BLOCK_HASH - description: '{{ doc("eth_tx_block_hash") }}' + description: '{{ doc("evm_column_deprecation_notice_block_hash") }}' - name: TX_HASH - description: '{{ doc("eth_tx_hash") }}' + description: '{{ doc("evm_tx_hash") }}' - name: NONCE - description: '{{ doc("eth_tx_nonce") }}' + description: '{{ doc("evm_tx_nonce") }}' - name: POSITION - description: '{{ doc("eth_tx_position") }}' + description: '{{ doc("evm_column_deprecation_notice_position") }}' + - name: TX_POSITION + description: '{{ doc("evm_tx_position") }}' - name: FROM_ADDRESS - description: '{{ doc("eth_from_address") }}' + description: '{{ doc("evm_from_address") }}' - name: TO_ADDRESS - description: '{{ doc("eth_to_address") }}' + description: '{{ doc("evm_to_address") }}' - name: VALUE - description: '{{ doc("eth_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("eth_tx_fee") }}' + description: '{{ doc("evm_tx_fee") }}' - name: GAS_PRICE - description: '{{ doc("eth_tx_gas_price") }}' + description: '{{ doc("evm_tx_gas_price") }}' - name: GAS_LIMIT - description: '{{ doc("eth_tx_gas_limit") }}' + description: '{{ doc("evm_tx_gas_limit") }}' - name: GAS_USED - description: '{{ doc("eth_tx_gas_used") }}' + description: '{{ doc("evm_tx_gas_used") }}' - name: CUMULATIVE_GAS_USED - description: '{{ doc("eth_cumulative_gas_used") }}' + description: '{{ doc("evm_cumulative_gas_used") }}' - name: STATUS - description: '{{ doc("eth_tx_status") }}' + description: '{{ doc("evm_column_deprecation_notice_tx_status") }}' + - name: TX_SUCCEEDED + description: '{{ doc("evm_tx_succeeded") }}' - name: INPUT_DATA - description: '{{ doc("eth_tx_input_data") }}' + description: '{{ doc("evm_tx_input_data") }}' - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("eth_tx_origin_sig") }}' + description: '{{ doc("evm_tx_origin_sig") }}' - name: EFFECTIVE_GAS_PRICE description: The effective gas price of the transaction, in wei. - name: MAX_FEE_PER_GAS @@ -49,7 +53,7 @@ models: - name: MAX_PRIORITY_FEE_PER_GAS description: The maximum priority fee per gas of the transaction, in wei. - name: CHAIN_ID - description: The chain ID of the transaction. + description: '{{ doc("evm_column_deprecation_notice_chain_id") }}' - name: TX_TYPE description: The type of the transaction, 2 for EIP-1559 transactions and 0 for legacy transactions. - name: r @@ -67,8 +71,8 @@ models: - name: BLOB_GAS_PRICE description: The price of blob gas in wei. - name: FACT_TRANSACTIONS_ID - description: '{{ doc("pk") }}' + description: '{{ doc("evm_pk") }}' - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' + description: '{{ doc("evm_inserted_timestamp") }}' - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file + description: '{{ doc("evm_modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/nft/lending/nft__ez_lending_liquidations.sql b/models/gold/nft/lending/nft__ez_lending_liquidations.sql index 29962c7e0..484f9f4f0 100644 --- a/models/gold/nft/lending/nft__ez_lending_liquidations.sql +++ b/models/gold/nft/lending/nft__ez_lending_liquidations.sql @@ -14,12 +14,16 @@ SELECT platform_address, platform_exchange_version, loanId, + loanid AS loan_id, unique_loan_id, lender_address, borrower_address, project_name, + project_name AS name, nft_address, + nft_address AS contract_address, tokenId, + tokenid AS token_id, loan_token_address, loan_token_symbol, principal_unadj, diff --git a/models/gold/nft/lending/nft__ez_lending_loans.sql b/models/gold/nft/lending/nft__ez_lending_loans.sql index 6c23118a8..e937b84fd 100644 --- a/models/gold/nft/lending/nft__ez_lending_loans.sql +++ b/models/gold/nft/lending/nft__ez_lending_loans.sql @@ -15,12 +15,16 @@ SELECT platform_address, platform_exchange_version, loanId, + loanid AS loan_id, unique_loan_id, lender_address, borrower_address, project_name, + project_name AS name, nft_address, + nft_address AS contract_address, tokenId, + tokenid AS token_id, loan_token_address, loan_token_symbol, principal_unadj, diff --git a/models/gold/nft/lending/nft__ez_lending_repayments.sql b/models/gold/nft/lending/nft__ez_lending_repayments.sql index c2be42199..1109ac8f6 100644 --- a/models/gold/nft/lending/nft__ez_lending_repayments.sql +++ b/models/gold/nft/lending/nft__ez_lending_repayments.sql @@ -15,12 +15,16 @@ SELECT platform_address, platform_exchange_version, loanId, + loanid AS loan_id, unique_loan_id, lender_address, borrower_address, project_name, + project_name AS name, nft_address, + nft_address AS contract_address, tokenId, + tokenid AS token_id, loan_token_address, loan_token_symbol, principal_unadj, diff --git a/models/gold/nft/mev/nft__fact_mev_arbitrage_events.sql b/models/gold/nft/mev/nft__fact_mev_arbitrage_events.sql index 4634927a6..2a6bd3c09 100644 --- a/models/gold/nft/mev/nft__fact_mev_arbitrage_events.sql +++ b/models/gold/nft/mev/nft__fact_mev_arbitrage_events.sql @@ -16,9 +16,14 @@ SELECT buyer_address, seller_address, nft_address, + nft_address AS contract_address, tokenid, + tokenid AS token_id, erc1155_value, + coalesce(erc1155_value, '1')::STRING AS quantity, + iff(erc1155_value IS NULL, 'erc721', 'erc1155') AS token_standard, project_name, + project_name AS name, nft_arbitrage_events_id AS ez_mev_arbitrage_events_id, COALESCE( inserted_timestamp, diff --git a/models/gold/nft/nft__dim_nft_collection_metadata.sql b/models/gold/nft/nft__dim_nft_collection_metadata.sql index 8e52eed0b..3c7497a62 100644 --- a/models/gold/nft/nft__dim_nft_collection_metadata.sql +++ b/models/gold/nft/nft__dim_nft_collection_metadata.sql @@ -14,8 +14,10 @@ SELECT blockchain, nft_address, + nft_address AS contract_address, collection_name, tokenid, + tokenid AS token_id, traits, tokenid_name, tokenid_description, diff --git a/models/gold/nft/nft__ez_nft_mints.sql b/models/gold/nft/nft__ez_nft_mints.sql index 19082e249..f0f8ee420 100644 --- a/models/gold/nft/nft__ez_nft_mints.sql +++ b/models/gold/nft/nft__ez_nft_mints.sql @@ -11,11 +11,18 @@ SELECT tx_hash, event_type, nft_address, + nft_address AS contract_address, project_name, + project_name AS name, nft_from_address, + nft_from_address AS from_address, nft_to_address, + nft_to_address AS to_address, tokenId, + tokenId AS token_id, erc1155_value, + coalesce(erc1155_value, '1')::STRING AS quantity, + iff(erc1155_value IS NULL, 'erc721', 'erc1155') AS token_standard, mint_price_eth, mint_price_usd, nft_count, diff --git a/models/gold/nft/nft__ez_nft_sales.sql b/models/gold/nft/nft__ez_nft_sales.sql index 5197fc0de..234b8a5f8 100644 --- a/models/gold/nft/nft__ez_nft_sales.sql +++ b/models/gold/nft/nft__ez_nft_sales.sql @@ -18,9 +18,14 @@ SELECT seller_address, buyer_address, nft_address, + nft_address AS contract_address, project_name, + project_name AS name, erc1155_value, + coalesce(erc1155_value, '1')::STRING AS quantity, + iff(erc1155_value IS NULL, 'erc721', 'erc1155') AS token_standard, tokenId, + tokenId AS token_id, currency_symbol, currency_address, price, diff --git a/models/gold/nft/nft__ez_nft_transfers.sql b/models/gold/nft/nft__ez_nft_transfers.sql index 9612510e2..9d7f427ab 100644 --- a/models/gold/nft/nft__ez_nft_transfers.sql +++ b/models/gold/nft/nft__ez_nft_transfers.sql @@ -13,11 +13,18 @@ SELECT intra_event_index, event_type, contract_address AS nft_address, + contract_address, project_name, + project_name AS name, from_address AS nft_from_address, + from_address, to_address AS nft_to_address, + to_address, tokenId, + tokenId AS token_id, erc1155_value, + COALESCE(erc1155_value, '1') ::STRING AS quantity, + IFF(erc1155_value IS NULL, 'erc721', 'erc1155') AS token_standard, COALESCE ( nft_transfers_id, {{ dbt_utils.generate_surrogate_key( diff --git a/models/gold/protocols/chainlink/chainlink__ez_oracle_feeds.sql b/models/gold/protocols/chainlink/chainlink__ez_oracle_feeds.sql index d948a31b0..50588e047 100644 --- a/models/gold/protocols/chainlink/chainlink__ez_oracle_feeds.sql +++ b/models/gold/protocols/chainlink/chainlink__ez_oracle_feeds.sql @@ -48,6 +48,6 @@ FROM ON contract_address = feed_address JOIN {{ ref('silver__contracts') }} ON contract_address = address - JOIN {{ ref('silver__blocks') }} + JOIN {{ ref('core__fact_blocks') }} b ON A.block_number = b.block_number diff --git a/models/silver/abis/silver__proxies.sql b/models/silver/abis/silver__proxies.sql index 3e5ae874e..b2e49e20e 100644 --- a/models/silver/abis/silver__proxies.sql +++ b/models/silver/abis/silver__proxies.sql @@ -14,11 +14,11 @@ WITH base AS ( MIN(block_timestamp) AS start_timestamp, MAX(_inserted_timestamp) AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ 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 071ce17b8..7f71f83ae 100644 --- a/models/silver/abis/silver__user_verified_abis.sql +++ b/models/silver/abis/silver__user_verified_abis.sql @@ -470,7 +470,7 @@ valid_traces AS ( SELECT base_address FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} JOIN function_mapping ON function_sig = LEFT( input, @@ -503,7 +503,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/base/silver__base_state_hashes.sql b/models/silver/base/silver__base_state_hashes.sql index 745efe039..06dd01d41 100644 --- a/models/silver/base/silver__base_state_hashes.sql +++ b/models/silver/base/silver__base_state_hashes.sql @@ -23,9 +23,9 @@ WITH base AS ( utils.udf_hex_to_int( DATA :: STRING ) :: TIMESTAMP AS l1_timestamp, - _inserted_timestamp + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xa7aaf2512769da4e444e3de247be2564225c2e7a8f74cfe528e46e17d24868e2' AND contract_address = LOWER('0x56315b90c40730925ec5485cf004d835058518A0') diff --git a/models/silver/core/silver__created_contracts.sql b/models/silver/core/silver__created_contracts.sql index 2dbf2ee3a..e58cc825c 100644 --- a/models/silver/core/silver__created_contracts.sql +++ b/models/silver/core/silver__created_contracts.sql @@ -14,7 +14,7 @@ SELECT to_address AS created_contract_address, from_address AS creator_address, input AS created_contract_input, - _inserted_timestamp, + modified_timestamp AS _inserted_timestamp, {{ dbt_utils.generate_surrogate_key( ['to_address'] ) }} AS created_contracts_id, @@ -22,14 +22,14 @@ SELECT SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE TYPE ILIKE 'create%' 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__eth_transfers.sql b/models/silver/core/silver__eth_transfers.sql index 8867c5798..591d66533 100644 --- a/models/silver/core/silver__eth_transfers.sql +++ b/models/silver/core/silver__eth_transfers.sql @@ -8,15 +8,23 @@ SELECT block_timestamp, from_address, to_address, - eth_value, - identifier, - _call_id, - _inserted_timestamp, + value AS eth_value, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp, input FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE TYPE = 'CALL' AND eth_value > 0 - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded diff --git a/models/silver/core/silver__logs.sql b/models/silver/core/silver__logs.sql index 06a3acc90..134489f72 100644 --- a/models/silver/core/silver__logs.sql +++ b/models/silver/core/silver__logs.sql @@ -16,6 +16,7 @@ WITH base AS ( from_address AS origin_from_address, to_address AS origin_to_address, tx_status, + {# position AS tx_position, --new column #} logs, _inserted_timestamp FROM @@ -39,6 +40,7 @@ flat_logs AS ( origin_from_address, origin_to_address, tx_status, + {# tx_position, #} VALUE :address :: STRING AS contract_address, VALUE :blockHash :: STRING AS block_hash, VALUE :data :: STRING AS DATA, @@ -63,6 +65,7 @@ new_records AS ( l.origin_to_address, txs.origin_function_signature, l.tx_status, + {# l.tx_position, #} l.contract_address, l.block_hash, l.data, @@ -107,6 +110,7 @@ missing_data AS ( t.origin_to_address, txs.origin_function_signature, t.tx_status, + {# t.tx_position, #} t.contract_address, t.block_hash, t.data, @@ -140,6 +144,7 @@ FINAL AS ( origin_to_address, origin_function_signature, tx_status, + {# tx_position, #} contract_address, block_hash, DATA, @@ -162,6 +167,7 @@ SELECT origin_to_address, origin_function_signature, tx_status, + {# tx_position, #} contract_address, block_hash, DATA, diff --git a/models/silver/core/silver__native_transfers.sql b/models/silver/core/silver__native_transfers.sql index 020617561..610fcbd94 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 = ['core','non_realtime','reorg'] ) }} @@ -13,22 +12,32 @@ WITH eth_base AS ( tx_hash, block_number, block_timestamp, - identifier, + identifier, --deprecate + trace_address, --new column from_address, to_address, - eth_value, - _call_id, - _inserted_timestamp, - eth_value_precise_raw, - eth_value_precise, + value, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp, + value_precise_raw, + value_precise, tx_position, trace_index FROM - {{ ref('silver__traces') }} + {{ 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' @@ -51,7 +60,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 @@ -61,7 +70,7 @@ tx_table AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '72 hours' FROM @@ -70,20 +79,21 @@ 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 + trace_address, --new column 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 36f33b16e..b3c7be0db 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 @@ -35,19 +35,19 @@ function_calls AS ( to_address ) AS contract_address, COUNT(*) AS function_call_count, - MAX(_inserted_timestamp) AS max_inserted_timestamp_traces, + MAX(modified_timestamp) AS max_inserted_timestamp_traces, MAX(block_number) AS latest_call_block FROM - {{ ref('silver__traces') }} + {{ 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' {% if is_incremental() %} -AND _inserted_timestamp > ( +AND modified_timestamp > ( SELECT MAX(max_inserted_timestamp_traces) FROM diff --git a/models/silver/core/silver__transfers.sql b/models/silver/core/silver__transfers.sql index 3470f7058..ab0ebe88a 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/defi/bridge/across/silver_bridge__across_fundsdeposited.sql b/models/silver/defi/bridge/across/silver_bridge__across_fundsdeposited.sql index 818f5d7ad..bfa2979bb 100644 --- a/models/silver/defi/bridge/across/silver_bridge__across_fundsdeposited.sql +++ b/models/silver/defi/bridge/across/silver_bridge__across_fundsdeposited.sql @@ -21,38 +21,42 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"depositId" :: STRING + decoded_log :"depositId" :: STRING ) AS depositId, - decoded_flat :"depositor" :: STRING AS depositor, + decoded_log :"depositor" :: STRING AS depositor, TRY_TO_NUMBER( - decoded_flat :"destinationChainId" :: STRING + decoded_log :"destinationChainId" :: STRING ) AS destinationChainId, - decoded_flat :"message" :: STRING AS message, + decoded_log :"message" :: STRING AS message, TRY_TO_NUMBER( - decoded_flat :"originChainId" :: STRING + decoded_log :"originChainId" :: STRING ) AS originChainId, - decoded_flat :"originToken" :: STRING AS originToken, + decoded_log :"originToken" :: STRING AS originToken, TRY_TO_TIMESTAMP( - decoded_flat :"quoteTimestamp" :: STRING + decoded_log :"quoteTimestamp" :: STRING ) AS quoteTimestamp, - decoded_flat :"recipient" :: STRING AS recipient, + decoded_log :"recipient" :: STRING AS recipient, TRY_TO_NUMBER( - decoded_flat :"relayerFeePct" :: STRING + decoded_log :"relayerFeePct" :: STRING ) AS relayerFeePct, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xafc4df6845a4ab948b492800d3d8a25d538a102a2bc07cd01f1cfa097fddcff6' AND contract_address = '0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -77,25 +81,29 @@ bridge_to AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"dstChainId" :: STRING + decoded_log :"dstChainId" :: STRING ) AS dstChainId, - decoded_flat :"dstToken" :: STRING AS dstToken, - decoded_flat :"from" :: STRING AS from_address, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat, + decoded_log :"dstToken" :: STRING AS dstToken, + decoded_log :"from" :: STRING AS from_address, + decoded_log :"to" :: STRING AS to_address, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x0cf77fd2585a4d672259e86a6adb2f6b05334cbb420727afcfbc689d018bb456' AND contract_address = '0x1a9f622dfafad5373741d821f1431abb23c30529' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -117,7 +125,7 @@ SELECT A.topic_0, A.event_name, A.event_removed, - A.tx_status, + A.tx_succeeded, A.contract_address AS bridge_address, A.name AS platform, A.depositor AS sender, 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 af89e6b23..271b72615 100644 --- a/models/silver/defi/bridge/across/silver_bridge__across_v3fundsdeposited.sql +++ b/models/silver/defi/bridge/across/silver_bridge__across_v3fundsdeposited.sql @@ -21,46 +21,50 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"depositId" :: STRING + decoded_log :"depositId" :: STRING ) AS depositId, - decoded_flat :"depositor" :: STRING AS depositor, + decoded_log :"depositor" :: STRING AS depositor, TRY_TO_NUMBER( - decoded_flat :"destinationChainId" :: STRING + decoded_log :"destinationChainId" :: STRING ) AS destinationChainId, - decoded_flat :"message" :: STRING AS message, + decoded_log :"message" :: STRING AS message, TRY_TO_TIMESTAMP( - decoded_flat :"quoteTimestamp" :: STRING + decoded_log :"quoteTimestamp" :: STRING ) AS quoteTimestamp, - decoded_flat :"recipient" :: STRING AS recipient, + decoded_log :"recipient" :: STRING AS recipient, TRY_TO_NUMBER( - decoded_flat :"relayerFeePct" :: STRING + decoded_log :"relayerFeePct" :: STRING ) AS relayerFeePct, - decoded_flat :"exclusiveRelayer" :: STRING AS exclusiveRelayer, + decoded_log :"exclusiveRelayer" :: STRING AS exclusiveRelayer, TRY_TO_NUMBER( - decoded_flat :"exclusivityDeadline" :: STRING + decoded_log :"exclusivityDeadline" :: STRING ) AS exclusivityDeadline, TRY_TO_NUMBER( - decoded_flat :"fillDeadline" :: STRING + decoded_log :"fillDeadline" :: STRING ) AS fillDeadline, TRY_TO_NUMBER( - decoded_flat :"inputAmount" :: STRING + decoded_log :"inputAmount" :: STRING ) AS inputAmount, - decoded_flat :"inputToken" :: STRING AS inputToken, + decoded_log :"inputToken" :: STRING AS inputToken, TRY_TO_NUMBER( - decoded_flat :"outputAmount" :: STRING + decoded_log :"outputAmount" :: STRING ) AS outputAmount, - decoded_flat :"outputToken" :: STRING AS outputToken, - decoded_flat, + decoded_log :"outputToken" :: STRING AS outputToken, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xa123dc29aebf7d0c3322c8eeb5b999e859f39937950ed31056532713d0de396f' AND contract_address = '0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -82,7 +86,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, depositor AS sender, diff --git a/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_sent.sql b/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_sent.sql index 45fd39341..25390e95c 100644 --- a/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_sent.sql +++ b/models/silver/defi/bridge/allbridge/silver_bridge__allbridge_sent.sql @@ -21,39 +21,43 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, utils.udf_hex_to_string( SUBSTRING( - decoded_flat :"destination" :: STRING, + decoded_log :"destination" :: STRING, 3 ) ) AS destination_chain_symbol, - decoded_flat :"lockId" :: STRING AS lockId, - decoded_flat :"recipient" :: STRING AS recipient, - decoded_flat :"sender" :: STRING AS sender, + decoded_log :"lockId" :: STRING AS lockId, + decoded_log :"recipient" :: STRING AS recipient, + decoded_log :"sender" :: STRING AS sender, utils.udf_hex_to_string( SUBSTRING( - decoded_flat :"tokenSource" :: STRING, + decoded_log :"tokenSource" :: STRING, 3 ) ) AS token_source, REGEXP_REPLACE( - decoded_flat :"tokenSourceAddress" :: STRING, + decoded_log :"tokenSourceAddress" :: STRING, '0+$', '' ) AS tokenSourceAddress, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x884a8def17f0d5bbb3fef53f3136b5320c9b39f75afb8985eeab9ea1153ee56d' AND contract_address = '0xbbbd1bbb4f9b936c3604906d7592a644071de884' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -75,7 +79,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, sender, 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 f91626531..443f73b65 100644 --- a/models/silver/defi/bridge/axelar/silver_bridge__axelar_contractcallwithtoken.sql +++ b/models/silver/defi/bridge/axelar/silver_bridge__axelar_contractcallwithtoken.sql @@ -21,28 +21,32 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, - decoded_flat :"destinationChain" :: STRING AS destinationChain, + decoded_log :"destinationChain" :: STRING AS destinationChain, LOWER( - decoded_flat :"destinationContractAddress" :: STRING + decoded_log :"destinationContractAddress" :: STRING ) AS destinationContractAddress, - decoded_flat :"payload" :: STRING AS payload, + decoded_log :"payload" :: STRING AS payload, origin_from_address AS recipient, - decoded_flat :"payloadHash" :: STRING AS payloadHash, - decoded_flat :"sender" :: STRING AS sender, - decoded_flat :"symbol" :: STRING AS symbol, - decoded_flat, + decoded_log :"payloadHash" :: STRING AS payloadHash, + decoded_log :"sender" :: STRING AS sender, + decoded_log :"symbol" :: STRING AS symbol, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x7e50569d26be643bda7757722291ec66b1be66d8283474ae3fab5a98f878a7a2' AND contract_address = '0x4f4495243837681061c4743b74b3eedf548d56a5' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -67,30 +71,34 @@ native_gas_paid AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, - decoded_flat :"destinationChain" :: STRING AS destinationChain, + decoded_log :"destinationChain" :: STRING AS destinationChain, LOWER( - decoded_flat :"destinationAddress" :: STRING + decoded_log :"destinationAddress" :: STRING ) AS destinationAddress, TRY_TO_NUMBER( - decoded_flat :"gasFeeAmount" :: STRING + decoded_log :"gasFeeAmount" :: STRING ) AS gasFeeAmount, - decoded_flat :"payloadHash" :: STRING AS payloadHash, - decoded_flat :"refundAddress" :: STRING AS refundAddress, - decoded_flat :"sourceAddress" :: STRING AS sourceAddress, - decoded_flat :"symbol" :: STRING AS symbol, - decoded_flat, + decoded_log :"payloadHash" :: STRING AS payloadHash, + decoded_log :"refundAddress" :: STRING AS refundAddress, + decoded_log :"sourceAddress" :: STRING AS sourceAddress, + decoded_log :"symbol" :: STRING AS symbol, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x999d431b58761213cf53af96262b67a069cbd963499fd8effd1e21556217b841' AND contract_address = '0x2d5d7d31f671f86c782533cc367f14109a082712' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -139,7 +147,7 @@ FINAL AS ( b.topic_0, b.event_name, b.event_removed, - b.tx_status, + b.tx_succeeded, b.contract_address AS bridge_address, b.name AS platform, b.origin_from_address AS sender, diff --git a/models/silver/defi/bridge/celer/silver_bridge__celer_cbridge_send.sql b/models/silver/defi/bridge/celer/silver_bridge__celer_cbridge_send.sql index 2484e082c..6cc57b2a5 100644 --- a/models/silver/defi/bridge/celer/silver_bridge__celer_cbridge_send.sql +++ b/models/silver/defi/bridge/celer/silver_bridge__celer_cbridge_send.sql @@ -21,32 +21,36 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"dstChainId" :: STRING + decoded_log :"dstChainId" :: STRING ) AS dstChainId, TRY_TO_NUMBER( - decoded_flat :"maxSlippage" :: STRING + decoded_log :"maxSlippage" :: STRING ) AS maxSlippage, TRY_TO_NUMBER( - decoded_flat :"nonce" :: STRING + decoded_log :"nonce" :: STRING ) AS nonce, - decoded_flat :"receiver" :: STRING AS receiver, - decoded_flat :"sender" :: STRING AS sender, - decoded_flat :"token" :: STRING AS token, - decoded_flat :"transferId" :: STRING AS transferId, - decoded_flat, + decoded_log :"receiver" :: STRING AS receiver, + decoded_log :"sender" :: STRING AS sender, + decoded_log :"token" :: STRING AS token, + decoded_log :"transferId" :: STRING AS transferId, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x89d8051e597ab4178a863a5190407b98abfeff406aa8db90c59af76612e58f01' AND contract_address = '0x5427fefa711eff984124bfbb1ab6fbf5e3da1820' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -68,7 +72,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, sender, diff --git a/models/silver/defi/bridge/dln/silver_bridge__dln_debridge_createdorder.sql b/models/silver/defi/bridge/dln/silver_bridge__dln_debridge_createdorder.sql index eb0411998..426e50928 100644 --- a/models/silver/defi/bridge/dln/silver_bridge__dln_debridge_createdorder.sql +++ b/models/silver/defi/bridge/dln/silver_bridge__dln_debridge_createdorder.sql @@ -20,57 +20,61 @@ WITH base_evt AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat :"affiliateFee" :: STRING AS affiliateFee, - decoded_flat :"metadata" :: STRING AS metadata, + decoded_log :"affiliateFee" :: STRING AS affiliateFee, + decoded_log :"metadata" :: STRING AS metadata, TRY_TO_NUMBER( - decoded_flat :"nativeFixFee" :: STRING + decoded_log :"nativeFixFee" :: STRING ) AS nativeFixFee, - decoded_flat :"order" AS order_obj, - decoded_flat :"order" :"allowedCancelBeneficiarySrc" :: STRING AS allowedCancelBeneficiarySrc, - decoded_flat :"order" :"allowedTakerDst" :: STRING AS allowedTakerDst, - decoded_flat :"order" :"externalCall" :: STRING AS externalCall, + decoded_log :"order" AS order_obj, + decoded_log :"order" :"allowedCancelBeneficiarySrc" :: STRING AS allowedCancelBeneficiarySrc, + decoded_log :"order" :"allowedTakerDst" :: STRING AS allowedTakerDst, + decoded_log :"order" :"externalCall" :: STRING AS externalCall, TRY_TO_NUMBER( - decoded_flat :"order" :"giveAmount" :: STRING + decoded_log :"order" :"giveAmount" :: STRING ) AS giveAmount, TRY_TO_NUMBER( - decoded_flat :"order" :"giveChainId" :: STRING + decoded_log :"order" :"giveChainId" :: STRING ) AS giveChainId, - decoded_flat :"order" :"givePatchAuthoritySrc" :: STRING AS givePatchAuthoritySrc, - decoded_flat :"order" :"giveTokenAddress" :: STRING AS giveTokenAddress, + decoded_log :"order" :"givePatchAuthoritySrc" :: STRING AS givePatchAuthoritySrc, + decoded_log :"order" :"giveTokenAddress" :: STRING AS giveTokenAddress, TRY_TO_NUMBER( - decoded_flat :"order" :"makerOrderNonce" :: STRING + decoded_log :"order" :"makerOrderNonce" :: STRING ) AS makerOrderNonce, - decoded_flat :"order" :"makerSrc" :: STRING AS makerSrc, - decoded_flat :"order" :"orderAuthorityAddressDst" :: STRING AS orderAuthorityAddressDst, - decoded_flat :"order" :"receiverDst" :: STRING AS receiverDst, + decoded_log :"order" :"makerSrc" :: STRING AS makerSrc, + decoded_log :"order" :"orderAuthorityAddressDst" :: STRING AS orderAuthorityAddressDst, + decoded_log :"order" :"receiverDst" :: STRING AS receiverDst, TRY_TO_NUMBER( - decoded_flat :"order" :"takeAmount" :: STRING + decoded_log :"order" :"takeAmount" :: STRING ) AS takeAmount, TRY_TO_NUMBER( - decoded_flat :"order" :"takeChainId" :: STRING + decoded_log :"order" :"takeChainId" :: STRING ) AS takeChainId, - decoded_flat :"order" :"takeTokenAddress" :: STRING AS takeTokenAddress, - decoded_flat :"orderId" :: STRING AS orderId, + decoded_log :"order" :"takeTokenAddress" :: STRING AS takeTokenAddress, + decoded_log :"orderId" :: STRING AS orderId, TRY_TO_NUMBER( - decoded_flat :"percentFee" :: STRING + decoded_log :"percentFee" :: STRING ) AS percentFee, TRY_TO_NUMBER( - decoded_flat :"referralCode" :: STRING + decoded_log :"referralCode" :: STRING ) AS referralCode, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, + tx_succeeded, DATA, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, CONCAT('0x', SUBSTR(segmented_data [24] :: STRING, 1, 40)) AS token_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xfc8703fd57380f9dd234a89dce51333782d49c5902f307b02f03e014d18fe471' --CreatedOrder AND contract_address = '0xef4fb24ad0916217251f553c0596f8edc630eb66' --Dln: Source - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -92,7 +96,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, origin_from_address AS sender, diff --git a/models/silver/defi/bridge/eywa/silver_bridge__eywa_requestsent.sql b/models/silver/defi/bridge/eywa/silver_bridge__eywa_requestsent.sql index 124dfba82..23577fee2 100644 --- a/models/silver/defi/bridge/eywa/silver_bridge__eywa_requestsent.sql +++ b/models/silver/defi/bridge/eywa/silver_bridge__eywa_requestsent.sql @@ -20,13 +20,17 @@ WITH base_evt AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING IN ( '0x5566d73d091d945ab32ea023cd1930c0d43aa43bef9aee4cb029775cfc94bdae', @@ -40,7 +44,7 @@ WITH base_evt AS ( --PortalV2 '0xbf0b5d561b986809924f88099c4ff0e6bcce60c9' --PortalV2 ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -70,7 +74,7 @@ requestsent AS ( decoded_flat :"to" :: STRING AS to_address, decoded_flat, event_removed, - tx_status, + tx_succeeded, _log_id, _inserted_timestamp FROM @@ -99,7 +103,7 @@ locked AS ( decoded_flat :"token" :: STRING AS token, decoded_flat, event_removed, - tx_status, + tx_succeeded, _log_id, _inserted_timestamp FROM @@ -118,7 +122,7 @@ SELECT r.topic_0, r.event_name, r.event_removed, - r.tx_status, + r.tx_succeeded, r.contract_address AS bridge_address, r.name AS platform, l.from_address AS sender, diff --git a/models/silver/defi/bridge/hop/silver_bridge__hop_l1canonicaltoken.sql b/models/silver/defi/bridge/hop/silver_bridge__hop_l1canonicaltoken.sql index a77031e1a..22fabdaea 100644 --- a/models/silver/defi/bridge/hop/silver_bridge__hop_l1canonicaltoken.sql +++ b/models/silver/defi/bridge/hop/silver_bridge__hop_l1canonicaltoken.sql @@ -11,13 +11,13 @@ WITH base_contracts AS ( contract_address, MAX(block_number) AS block_number FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x0a0607688c86ec1775abcdbab7b33a3a35a6c9cde677c9be880150c231cc6b0b' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/defi/bridge/hop/silver_bridge__hop_transfersenttol2.sql b/models/silver/defi/bridge/hop/silver_bridge__hop_transfersenttol2.sql index 0dee91513..9d0eb056c 100644 --- a/models/silver/defi/bridge/hop/silver_bridge__hop_transfersenttol2.sql +++ b/models/silver/defi/bridge/hop/silver_bridge__hop_transfersenttol2.sql @@ -21,33 +21,37 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"amountOutMin" :: STRING + decoded_log :"amountOutMin" :: STRING ) AS amountOutMin, TRY_TO_NUMBER( - decoded_flat :"chainId" :: STRING + decoded_log :"chainId" :: STRING ) AS chainId, TRY_TO_TIMESTAMP( - decoded_flat :"deadline" :: STRING + decoded_log :"deadline" :: STRING ) AS deadline, - decoded_flat :"recipient" :: STRING AS recipient, - decoded_flat :"relayer" :: STRING AS relayer, + decoded_log :"recipient" :: STRING AS recipient, + decoded_log :"relayer" :: STRING AS relayer, TRY_TO_NUMBER( - decoded_flat :"relayerFee" :: STRING + decoded_log :"relayerFee" :: STRING ) AS relayerFee, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x0a0607688c86ec1775abcdbab7b33a3a35a6c9cde677c9be880150c231cc6b0b' AND origin_to_address IS NOT NULL - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -78,7 +82,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, origin_from_address AS sender, diff --git a/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql b/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql index bf25c4a45..f519e10de 100644 --- a/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql +++ b/models/silver/defi/bridge/meson/silver_bridge__meson_transfers.sql @@ -48,13 +48,12 @@ native_transfers AS ( et.from_address, et.to_address, amount_precise_raw, - identifier, _call_id, et._inserted_timestamp FROM {{ ref('silver__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 @@ -119,14 +118,18 @@ dst_info AS ( tx_hash, topics [1] :: STRING AS encoded_data, SUBSTR(RIGHT(encoded_data, 12), 1, 4) AS destination_chain_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x25ab3efd52e6470681ce037cd546dc60726948d3' AND topics [0] :: STRING = '0x5ce4019f772fda6cb703b26bce3ec3006eb36b73f1d3a0eb441213317d9f5e9d' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/bridge/multichain/silver_bridge__multichain_v7_loganyswapout.sql b/models/silver/defi/bridge/multichain/silver_bridge__multichain_v7_loganyswapout.sql index 7acdabfaa..15a8bea9d 100644 --- a/models/silver/defi/bridge/multichain/silver_bridge__multichain_v7_loganyswapout.sql +++ b/models/silver/defi/bridge/multichain/silver_bridge__multichain_v7_loganyswapout.sql @@ -21,29 +21,33 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, - decoded_flat :"from" :: STRING AS from_address, - decoded_flat :"receiver" :: STRING AS receiver, - decoded_flat :"swapoutID" :: STRING AS swapoutID, + decoded_log :"from" :: STRING AS from_address, + decoded_log :"receiver" :: STRING AS receiver, + decoded_log :"swapoutID" :: STRING AS swapoutID, TRY_TO_NUMBER( - decoded_flat :"toChainID" :: STRING + decoded_log :"toChainID" :: STRING ) AS toChainID, - decoded_flat :"token" :: STRING AS token, - decoded_flat, + decoded_log :"token" :: STRING AS token, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x0d969ae475ff6fcaf0dcfa760d4d8607244e8d95e9bf426f8d5d69f9a3e525af' AND contract_address IN ( '0x1633d66ca91ce4d81f63ea047b7b19beb92df7f3', '0x93251f98acb0c83904320737aec091bce287f8f5' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -65,7 +69,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, LOWER(from_address) AS sender, diff --git a/models/silver/defi/bridge/native_bridges/silver_bridge__native_bridges_transfers_out.sql b/models/silver/defi/bridge/native_bridges/silver_bridge__native_bridges_transfers_out.sql index 1917e5818..6ee369259 100644 --- a/models/silver/defi/bridge/native_bridges/silver_bridge__native_bridges_transfers_out.sql +++ b/models/silver/defi/bridge/native_bridges/silver_bridge__native_bridges_transfers_out.sql @@ -64,7 +64,6 @@ native_transfers AS ( bridge_name, blockchain, amount_precise_raw, - identifier, _call_id, et._inserted_timestamp FROM @@ -72,7 +71,7 @@ native_transfers AS ( et INNER JOIN bridges b ON et.to_address = b.bridge_address - LEFT JOIN {{ ref('silver__transactions') }} + LEFT JOIN {{ ref('core__fact_transactions') }} t USING( block_number, tx_hash diff --git a/models/silver/defi/bridge/stargate/silver_bridge__stargate_createpool.sql b/models/silver/defi/bridge/stargate/silver_bridge__stargate_createpool.sql index 561729fdb..f83eaea38 100644 --- a/models/silver/defi/bridge/stargate/silver_bridge__stargate_createpool.sql +++ b/models/silver/defi/bridge/stargate/silver_bridge__stargate_createpool.sql @@ -13,15 +13,24 @@ WITH base_contracts AS ( block_timestamp, from_address, to_address AS contract_address, - _call_id, - _inserted_timestamp + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE from_address = '0x06d538690af257da524f25d0cd52fd85b1c2173e' AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/bridge/stargate/silver_bridge__stargate_swap.sql b/models/silver/defi/bridge/stargate/silver_bridge__stargate_swap.sql index 6fe44fbe2..ce1e18dba 100644 --- a/models/silver/defi/bridge/stargate/silver_bridge__stargate_swap.sql +++ b/models/silver/defi/bridge/stargate/silver_bridge__stargate_swap.sql @@ -28,45 +28,49 @@ base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amountSD" :: STRING + decoded_log :"amountSD" :: STRING ) AS amountSD, TRY_TO_NUMBER( - decoded_flat :"chainId" :: STRING + decoded_log :"chainId" :: STRING ) AS chainId, CASE WHEN chainId < 100 THEN chainId + 100 ELSE chainId END AS destination_chain_id, TRY_TO_NUMBER( - decoded_flat :"dstPoolId" :: STRING + decoded_log :"dstPoolId" :: STRING ) AS dstPoolId, TRY_TO_NUMBER( - decoded_flat :"eqFee" :: STRING + decoded_log :"eqFee" :: STRING ) AS eqFee, TRY_TO_NUMBER( - decoded_flat :"eqReward" :: STRING + decoded_log :"eqReward" :: STRING ) AS eqReward, TRY_TO_NUMBER( - decoded_flat :"amountSD" :: STRING + decoded_log :"amountSD" :: STRING ) AS lpFee, TRY_TO_NUMBER( - decoded_flat :"amountSD" :: STRING + decoded_log :"amountSD" :: STRING ) AS protocolFee, - decoded_flat :"from" :: STRING AS from_address, - decoded_flat, + decoded_log :"from" :: STRING AS from_address, + decoded_log AS decoded_flat, token_address, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} d INNER JOIN pools p ON d.contract_address = p.pool_address WHERE topics [0] :: STRING = '0x34660fc8af304464529f48a778e03d03e4d34bcd5f9b6f0cfbf3cd238c642f7f' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -88,7 +92,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, '0x296f55f8fb28e498b858d0bcda06d955b2cb3f97' AS bridge_address, NAME AS platform, from_address AS sender, 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 440b988a9..bc46171e6 100644 --- a/models/silver/defi/bridge/symbiosis/silver_bridge__symbiosis_synthesizerequest.sql +++ b/models/silver/defi/bridge/symbiosis/silver_bridge__symbiosis_synthesizerequest.sql @@ -21,30 +21,34 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"chainID" :: STRING + decoded_log :"chainID" :: STRING ) AS chainID, - decoded_flat :"from" :: STRING AS from_address, - decoded_flat :"id" :: STRING AS id, - decoded_flat :"revertableAddress" :: STRING AS revertableAddress, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat :"token" :: STRING AS token, - decoded_flat, + decoded_log :"from" :: STRING AS from_address, + decoded_log :"id" :: STRING AS id, + decoded_log :"revertableAddress" :: STRING AS revertableAddress, + decoded_log :"to" :: STRING AS to_address, + decoded_log :"token" :: STRING AS token, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x31325fe0a1a2e6a5b1e41572156ba5b4e94f0fae7e7f63ec21e9b5ce1e4b3eab' AND contract_address IN ( '0xb80fdaa74dda763a8a158ba85798d373a5e84d84', '0xb8f275fbf7a959f4bce59999a2ef122a099e81a8' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -66,7 +70,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, from_address AS sender, diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql b/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql index 77c05c297..e409d0fa0 100644 --- a/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql +++ b/models/silver/defi/bridge/synapse/silver_bridge__synapse_token_bridge.sql @@ -21,20 +21,24 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"chainId" :: STRING + decoded_log :"chainId" :: STRING ) AS chainId, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat :"token" :: STRING AS token, - decoded_flat, + decoded_log :"to" :: STRING AS to_address, + decoded_log :"token" :: STRING AS token, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING IN ( '0xdc5bad4651c5fbe9977a696aadc65996c468cde1448dd468ec0d83bf61c4b57c', @@ -43,7 +47,7 @@ WITH base_evt AS ( ) AND contract_address = '0x2796317b0ff8538f253012862c06787adfb8ceb6' AND origin_to_address IS NOT NULL - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -65,7 +69,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, amount, diff --git a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql index 682a77d9e..287bbeb86 100644 --- a/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql +++ b/models/silver/defi/bridge/synapse/silver_bridge__synapse_tokenbridgeandswap.sql @@ -21,36 +21,40 @@ WITH base_evt AS ( topics [0] :: STRING AS topic_0, event_name, TRY_TO_NUMBER( - decoded_flat :"amount" :: STRING + decoded_log :"amount" :: STRING ) AS amount, TRY_TO_NUMBER( - decoded_flat :"chainId" :: STRING + decoded_log :"chainId" :: STRING ) AS chainId, TRY_TO_TIMESTAMP( - decoded_flat :"deadline" :: STRING + decoded_log :"deadline" :: STRING ) AS deadline, TRY_TO_NUMBER( - decoded_flat :"minDy" :: STRING + decoded_log :"minDy" :: STRING ) AS minDy, - decoded_flat :"to" :: STRING AS to_address, - decoded_flat :"token" :: STRING AS token, + decoded_log :"to" :: STRING AS to_address, + decoded_log :"token" :: STRING AS token, TRY_TO_NUMBER( - decoded_flat :"tokenIndexFrom" :: STRING + decoded_log :"tokenIndexFrom" :: STRING ) AS tokenIndexFrom, TRY_TO_NUMBER( - decoded_flat :"tokenIndexTo" :: STRING + decoded_log :"tokenIndexTo" :: STRING ) AS tokenIndexTo, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x79c15604b92ef54d3f61f0c40caab8857927ca3d5092367163b4562c1699eb5f' AND contract_address = '0x2796317b0ff8538f253012862c06787adfb8ceb6' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -72,7 +76,7 @@ SELECT topic_0, event_name, event_removed, - tx_status, + tx_succeeded, contract_address AS bridge_address, NAME AS platform, origin_from_address AS sender, diff --git a/models/silver/defi/bridge/wormhole/silver_bridge__wormhole_transfers.sql b/models/silver/defi/bridge/wormhole/silver_bridge__wormhole_transfers.sql index 181fa237e..7877934ce 100644 --- a/models/silver/defi/bridge/wormhole/silver_bridge__wormhole_transfers.sql +++ b/models/silver/defi/bridge/wormhole/silver_bridge__wormhole_transfers.sql @@ -54,7 +54,7 @@ WITH token_transfers AS ( FROM {{ ref('silver__transfers') }} tr - INNER JOIN {{ ref('silver__transactions') }} + INNER JOIN {{ ref('core__fact_transactions') }} tx ON tr.block_number = tx.block_number AND tr.tx_hash = tx.tx_hash @@ -84,7 +84,6 @@ native_transfers AS ( et.from_address, et.to_address, amount_precise_raw, - identifier, regexp_substr_all(SUBSTR(input_data, 11, len(input_data)), '.{64}') AS segmented_data, TRY_TO_NUMBER( utils.udf_hex_to_int( @@ -117,7 +116,7 @@ native_transfers AS ( FROM {{ ref('silver__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/dex/balancer/silver_dex__balancer_pools.sql b/models/silver/defi/dex/balancer/silver_dex__balancer_pools.sql index 0631d7a91..f8c60bd97 100644 --- a/models/silver/defi/dex/balancer/silver_dex__balancer_pools.sql +++ b/models/silver/defi/dex/balancer/silver_dex__balancer_pools.sql @@ -20,18 +20,22 @@ WITH pools_registered AS ( 1, 42 ) AS pool_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, ROW_NUMBER() over ( ORDER BY pool_address ) AS row_num FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x3c13bc30b8e878c53fd2a36b679409c073afd75950be43d8858768e956fbc20e' --PoolRegistered AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -49,8 +53,8 @@ tokens_registered AS ( event_index, tx_hash, contract_address, - decoded_flat :poolId :: STRING AS pool_id, - decoded_flat :tokens AS tokens, + decoded_log :poolId :: STRING AS pool_id, + decoded_log :tokens AS tokens, tokens [0] :: STRING AS token0, tokens [1] :: STRING AS token1, tokens [2] :: STRING AS token2, @@ -59,11 +63,15 @@ tokens_registered AS ( tokens [5] :: STRING AS token5, tokens [6] :: STRING AS token6, tokens [7] :: STRING AS token7, - decoded_flat :assetManagers AS asset_managers, - _log_id, - _inserted_timestamp + decoded_log :assetManagers AS asset_managers, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xf5847d3f2197b16cdcd2098ec95d0905cd1abdaf415f07bb7cef2bba8ac5dec4' --TokensRegistered AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8' @@ -73,7 +81,7 @@ tokens_registered AS ( FROM pools_registered ) - AND tx_status = 'SUCCESS' + AND tx_succeeded ), function_sigs AS ( SELECT diff --git a/models/silver/defi/dex/balancer/silver_dex__balancer_swaps.sql b/models/silver/defi/dex/balancer/silver_dex__balancer_swaps.sql index d07b020bc..2570ea9ac 100644 --- a/models/silver/defi/dex/balancer/silver_dex__balancer_swaps.sql +++ b/models/silver/defi/dex/balancer/silver_dex__balancer_swaps.sql @@ -23,7 +23,7 @@ swaps_base AS ( origin_from_address, origin_to_address, contract_address, - _inserted_timestamp, + modified_timestamp AS _inserted_timestamp, 'Swap' AS event_name, event_index, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, @@ -51,16 +51,20 @@ swaps_base AS ( 1, 42 ) AS pool_address, - _log_id, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, 'balancer' AS platform, origin_from_address AS sender, origin_from_address AS tx_to FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x2170c741c41531aec20e7c107c24eecfdd15e69c9bb0a8dd37b1840b9e0b207b' AND contract_address = '0xba12222222228d8ba445958a75a0704d566bf2c8' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/curve/silver_dex__curve_pools.sql b/models/silver/defi/dex/curve/silver_dex__curve_pools.sql index 093ce078b..d5a81a446 100644 --- a/models/silver/defi/dex/curve/silver_dex__curve_pools.sql +++ b/models/silver/defi/dex/curve/silver_dex__curve_pools.sql @@ -14,15 +14,24 @@ WITH contract_deployments AS ( block_timestamp, from_address AS deployer_address, to_address AS contract_address, - _call_id, - _inserted_timestamp, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp, ROW_NUMBER() over ( ORDER BY contract_address ) AS row_num FROM {{ ref( - 'silver__traces' + 'core__fact_traces' ) }} WHERE -- curve contract deployers @@ -43,8 +52,8 @@ WITH contract_deployments AS ( '0x0c0e5f2ff0ff18a3be9b835635039256dc4b4963' ) AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/curve/silver_dex__curve_swaps.sql b/models/silver/defi/dex/curve/silver_dex__curve_swaps.sql index e0d967197..97b1fcc68 100644 --- a/models/silver/defi/dex/curve/silver_dex__curve_swaps.sql +++ b/models/silver/defi/dex/curve/silver_dex__curve_swaps.sql @@ -59,10 +59,14 @@ curve_base AS ( utils.udf_hex_to_int( segmented_data [3] :: STRING ) :: INTEGER AS tokens_bought, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address @@ -73,7 +77,7 @@ curve_base AS ( '0xd013ca23e77a65003c2c659c5442c00c805371b7fc1ebd4c206c41d1536bd90b', '0x143f1f8e861fbdeddd5b46e844b7d3ac7b86a122f36e8c463859ee6811b1f29c' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -132,7 +136,7 @@ token_transfers AS ( CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS from_address, CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS to_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' AND tx_hash IN ( @@ -142,10 +146,10 @@ token_transfers AS ( curve_base ) AND CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) <> '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/defi/dex/dodo/silver_dex__dodo_v1_pools.sql b/models/silver/defi/dex/dodo/silver_dex__dodo_v1_pools.sql index 86cc5d79a..a65fb0497 100644 --- a/models/silver/defi/dex/dodo/silver_dex__dodo_v1_pools.sql +++ b/models/silver/defi/dex/dodo/silver_dex__dodo_v1_pools.sql @@ -17,10 +17,14 @@ WITH pool_events AS ( CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS newBorn, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS baseToken, CONCAT('0x', SUBSTR(segmented_data [2] :: STRING, 25, 40)) AS quoteToken, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address IN ( '0xbd337924f000dceb119153d4d3b1744b22364d25', @@ -28,7 +32,7 @@ WITH pool_events AS ( '0x3a97247df274a17c59a3bd12735ea3fcdfb49950' ) --DODOZoo AND topics [0] :: STRING = '0x5c428a2e12ecaa744a080b25b4cda8b86359c82d726575d7d747e07708071f93' --DODOBirth - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -50,10 +54,19 @@ pool_calls AS ( quote_token, base_token_symbol, quote_token_symbol, - _call_id, - _inserted_timestamp + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} t INNER JOIN {{ ref('silver__dodo_v1_pools') }} s @@ -64,8 +77,8 @@ pool_calls AS ( '0x17dbfa501f2f376d092fa69d3223a09bba4efdf7' ) --DODO deployer contracts AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded AND block_timestamp :: DATE >= '2020-08-07' {% if is_incremental() %} diff --git a/models/silver/defi/dex/dodo/silver_dex__dodo_v1_swaps.sql b/models/silver/defi/dex/dodo/silver_dex__dodo_v1_swaps.sql index c27b25dcd..db91bb965 100644 --- a/models/silver/defi/dex/dodo/silver_dex__dodo_v1_swaps.sql +++ b/models/silver/defi/dex/dodo/silver_dex__dodo_v1_swaps.sql @@ -56,10 +56,14 @@ sell_base_token AS ( base_token AS tokenOut, receiveQuote AS amountIn, payBase AS amountOut, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address @@ -71,7 +75,7 @@ sell_base_token AS ( FROM proxies ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -110,10 +114,14 @@ buy_base_token AS ( base_token AS tokenOut, payQuote AS amountIn, receiveBase AS amountOut, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address diff --git a/models/silver/defi/dex/dodo/silver_dex__dodo_v2_pools.sql b/models/silver/defi/dex/dodo/silver_dex__dodo_v2_pools.sql index e3138964a..7dae0509f 100644 --- a/models/silver/defi/dex/dodo/silver_dex__dodo_v2_pools.sql +++ b/models/silver/defi/dex/dodo/silver_dex__dodo_v2_pools.sql @@ -18,10 +18,14 @@ WITH pools AS ( CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS quoteToken, CONCAT('0x', SUBSTR(segmented_data [2] :: STRING, 25, 40)) AS creator, CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS pool_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address IN ( '0x95e887adf9eaa22cc1c6e3cb7f07adc95b4b25a8', @@ -41,7 +45,7 @@ WITH pools AS ( --NewDSP '0xaf5c5f12a80fc937520df6fcaed66262a4cc775e0f3fceaf7a7cfe476d9a751d' --NewDVM ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/dodo/silver_dex__dodo_v2_swaps.sql b/models/silver/defi/dex/dodo/silver_dex__dodo_v2_swaps.sql index acc794188..91abede88 100644 --- a/models/silver/defi/dex/dodo/silver_dex__dodo_v2_swaps.sql +++ b/models/silver/defi/dex/dodo/silver_dex__dodo_v2_swaps.sql @@ -79,10 +79,14 @@ swaps_base AS ( 40 ) ) AS receiver_address, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON @@ -95,7 +99,7 @@ swaps_base AS ( FROM proxies ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/frax/silver_dex__fraxswap_pools.sql b/models/silver/defi/dex/frax/silver_dex__fraxswap_pools.sql index 434f344d9..723fdc3ab 100644 --- a/models/silver/defi/dex/frax/silver_dex__fraxswap_pools.sql +++ b/models/silver/defi/dex/frax/silver_dex__fraxswap_pools.sql @@ -20,10 +20,14 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address IN ( '0xb076b06f669e682609fb4a8c6646d2619717be4b', @@ -31,7 +35,7 @@ WITH pool_creation AS ( '0x43ec799eadd63848443e2347c49f5f52e8fe0f6f' --v2 factory ) 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/frax/silver_dex__fraxswap_swaps.sql b/models/silver/defi/dex/frax/silver_dex__fraxswap_swaps.sql index 378b4b7c4..95ac44e57 100644 --- a/models/silver/defi/dex/frax/silver_dex__fraxswap_swaps.sql +++ b/models/silver/defi/dex/frax/silver_dex__fraxswap_swaps.sql @@ -50,16 +50,20 @@ swaps_base AS ( ) AS amount1Out, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools ON l.contract_address = pool_address WHERE l.topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' --Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql b/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql index f42c8d3bd..1ba6b146a 100644 --- a/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql +++ b/models/silver/defi/dex/hashflow/silver_dex__hashflow_pools.sql @@ -13,10 +13,19 @@ WITH contract_deployments AS ( block_timestamp, from_address AS deployer_address, to_address AS contract_address, - _call_id, - _inserted_timestamp + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE from_address IN ( '0x63ae536fec0b57bdeb1fd6a893191b4239f61bff', @@ -24,8 +33,8 @@ WITH contract_deployments AS ( '0x596d32f9b7c1f2e73f5071c66b5e336e27d00da4' ) AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/hashflow/silver_dex__hashflow_swaps.sql b/models/silver/defi/dex/hashflow/silver_dex__hashflow_swaps.sql index 556f046a2..6522cfda6 100644 --- a/models/silver/defi/dex/hashflow/silver_dex__hashflow_swaps.sql +++ b/models/silver/defi/dex/hashflow/silver_dex__hashflow_swaps.sql @@ -58,16 +58,20 @@ router_swaps_base AS ( l_segmented_data [6] :: STRING ) ) AS amountOut, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON l.contract_address = p.pool_address WHERE l.topics [0] :: STRING = '0xb709ddcc6550418e9b89df1f4938071eeaa3f6376309904c77e15d46b16066f5' --swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -123,16 +127,20 @@ swaps_base AS ( l_segmented_data [5] :: STRING ) ) AS amountOut, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON l.contract_address = p.pool_address WHERE l.topics [0] :: STRING = '0x8cf3dec1929508e5677d7db003124e74802bfba7250a572205a9986d86ca9f1e' --swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_pools.sql b/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_pools.sql index 077dc2764..f35f496f3 100644 --- a/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_pools.sql +++ b/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_pools.sql @@ -14,14 +14,18 @@ WITH contract_deployments AS ( regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, origin_from_address AS deployer_address, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS pool_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0xde828fdc3f497f16416d1bb645261c7c6a62dab5' AND topics [0] :: STRING = '0xdbd2a1ea6808362e6adbec4db4969cbc11e3b0b28fb6c74cb342defaaf1daada' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_swaps.sql b/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_swaps.sql index d394fd445..0cd3dcd43 100644 --- a/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_swaps.sql +++ b/models/silver/defi/dex/hashflow/silver_dex__hashflow_v3_swaps.sql @@ -44,16 +44,20 @@ swaps AS ( segmented_data [6] :: STRING ) ) AS amountOut, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON l.contract_address = p.pool_address WHERE l.topics [0] :: STRING = '0x34f57786fb01682fb4eec88d340387ef01a168fe345ea5b76f709d4e560c10eb' --Trade - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_pools.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_pools.sql index bd62ae71b..0010391fd 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_pools.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_pools.sql @@ -27,14 +27,18 @@ WITH pool_creation AS ( segmented_data [2] :: STRING ) ) AS totalPool, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address = LOWER('0x833e4083B7ae46CeA85695c4f7ed25CDAd8886dE') --dynamic fee factory AND topics [0] :: STRING = '0xfc574402c445e75f2b79b67884ff9c662244dce454c5ae68935fcd0bebb7c8ff' --created pool - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_swaps.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_swaps.sql index 23c53dcad..2d8cbc2f6 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_swaps.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_dynamic_swaps.sql @@ -55,16 +55,20 @@ swaps_base AS ( ) AS feeInPrecision, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address WHERE l.topics [0] :: STRING = '0x606ecd02b3e3b4778f8e97b2e03351de14224efaa5fa64e62200afc9395c2499' --Dynamic Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_pools.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_pools.sql index 08b58bfbd..73ddc4d08 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_pools.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_pools.sql @@ -32,14 +32,18 @@ WITH pool_creation AS ( segmented_data [3] :: STRING ) ) AS totalPool, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address = LOWER('0x1c758aF0688502e49140230F6b0EBd376d429be5') --static pool factory AND topics [0] :: STRING = '0xb6bce363b712c921bead4bcc977289440eb6172eb89e258e3a25bd49ca806de6' --create pool - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_swaps.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_swaps.sql index d4d582b03..774a27793 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_swaps.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v1_static_swaps.sql @@ -55,16 +55,20 @@ swaps_base AS ( ) AS feeInPrecision, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address WHERE l.topics [0] :: STRING = '0x606ecd02b3e3b4778f8e97b2e03351de14224efaa5fa64e62200afc9395c2499' -- static swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_pools.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_pools.sql index 5a646e729..cf2278547 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_pools.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_pools.sql @@ -23,14 +23,18 @@ WITH pool_creation AS ( ) ) AS tickDistance, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address = '0x5f1dddbf348ac2fbe22a163e30f99f9ece3dd50a' --Elastic Pool Deployer AND topics [0] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' --Create pool - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_swaps.sql b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_swaps.sql index 1fc366d28..cf0afebc0 100644 --- a/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_swaps.sql +++ b/models/silver/defi/dex/kyberswap/silver_dex__kyberswap_v2_elastic_swaps.sql @@ -68,16 +68,20 @@ swaps_base AS ( WHEN deltaQty0 > 0 THEN token0 ELSE token1 END AS token_out, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON p.pool_address = l.contract_address WHERE topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' -- elastic swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/maverick/silver_dex__maverick_pools.sql b/models/silver/defi/dex/maverick/silver_dex__maverick_pools.sql index c5f6620f3..485050940 100644 --- a/models/silver/defi/dex/maverick/silver_dex__maverick_pools.sql +++ b/models/silver/defi/dex/maverick/silver_dex__maverick_pools.sql @@ -43,17 +43,21 @@ WITH pools AS ( ) AS protocolFeeRatio, CONCAT('0x', SUBSTR(segmented_data [6] :: STRING, 25, 40)) AS tokenA, CONCAT('0x', SUBSTR(segmented_data [7] :: STRING, 25, 40)) AS tokenB, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address IN ( '0x4faf448121bf2985b991c0261dd356a9803b3cae', '0xa5ebd82503c72299073657957f41b9cea6c0a43a' ) AND topics [0] :: STRING = '0x9b3fb3a17b4e94eb4d1217257372dcc712218fcd4bc1c28482bd8a6804a7c775' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/maverick/silver_dex__maverick_swaps.sql b/models/silver/defi/dex/maverick/silver_dex__maverick_swaps.sql index 6c0c3c144..6eacefd96 100644 --- a/models/silver/defi/dex/maverick/silver_dex__maverick_swaps.sql +++ b/models/silver/defi/dex/maverick/silver_dex__maverick_swaps.sql @@ -76,16 +76,20 @@ swaps_base AS ( ) AS activeTick, tokenA, tokenB, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools ON l.contract_address = pool_address WHERE l.topics [0] :: STRING = '0x3b841dc9ab51e3104bda4f61b41e4271192d22cd19da5ee6e292dc8e2744f713' --Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_amm_pools.sql b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_amm_pools.sql index 8a3af0c3d..a91fefce7 100644 --- a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_amm_pools.sql +++ b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_amm_pools.sql @@ -20,14 +20,18 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address = '0x1097053fd2ea711dad45caccc45eff7548fcb362' --factory 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/pancake/silver_dex__pancakeswap_v2_amm_swaps.sql b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_amm_swaps.sql index 0f12d5547..6ea2565a6 100644 --- a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_amm_swaps.sql +++ b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_amm_swaps.sql @@ -50,15 +50,19 @@ swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, token0, token1, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} INNER JOIN pools p ON p.pool_address = contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_mm_swaps.sql b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_mm_swaps.sql index 8de69e6a3..cd6fa10ae 100644 --- a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_mm_swaps.sql +++ b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v2_mm_swaps.sql @@ -50,15 +50,19 @@ WITH swaps_base AS ( quoteToken AS token_out, baseTokenAmount AS token_in_amount, quoteTokenAmount AS token_out_amount, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE contract_address = '0x9ca2a439810524250e543ba8fb6e88578af242bc' --router AND topics [0] :: STRING = '0xe7d6f812e1a54298ddef0b881cd08a4d452d9de35eb18b5145aa580fdda18b26' --swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v3_pools.sql b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v3_pools.sql index 02ba3ce62..e4d299f30 100644 --- a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v3_pools.sql +++ b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v3_pools.sql @@ -29,14 +29,18 @@ WITH created_pools AS ( ) ) AS tickSpacing, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x0bfbcf9fa4f9c56b0f40a671ad40e0805a091865' --factory AND topics [0] :: STRING = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' --paircreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v3_swaps.sql b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v3_swaps.sql index fb8213284..7780958fc 100644 --- a/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v3_swaps.sql +++ b/models/silver/defi/dex/pancake/silver_dex__pancakeswap_v3_swaps.sql @@ -84,17 +84,21 @@ base_swaps AS ( END AS token_out, fee, tick_spacing, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON l.contract_address = pool_address WHERE block_timestamp :: DATE > '2023-02-01' AND topics [0] :: STRING = '0x19b47279256b2a23a1665c810c8d55a1758940ee09377d4f8d26497a3577dc83' --swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/shibaswap/silver_dex__shibaswap_pools.sql b/models/silver/defi/dex/shibaswap/silver_dex__shibaswap_pools.sql index 5d2f100fe..dfe76aab4 100644 --- a/models/silver/defi/dex/shibaswap/silver_dex__shibaswap_pools.sql +++ b/models/silver/defi/dex/shibaswap/silver_dex__shibaswap_pools.sql @@ -20,14 +20,18 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref ('silver__logs') }} + {{ ref ('core__fact_event_logs') }} WHERE contract_address = LOWER('0x115934131916C8b277DD010Ee02de363c09d037c') 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/shibaswap/silver_dex__shibaswap_swaps.sql b/models/silver/defi/dex/shibaswap/silver_dex__shibaswap_swaps.sql index e18d4c562..1433a1e4d 100644 --- a/models/silver/defi/dex/shibaswap/silver_dex__shibaswap_swaps.sql +++ b/models/silver/defi/dex/shibaswap/silver_dex__shibaswap_swaps.sql @@ -50,15 +50,19 @@ swaps_base AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, token0, token1, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} INNER JOIN pools p ON p.pool_address = contract_address WHERE topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/synthetix/silver_dex__synthetix_swaps.sql b/models/silver/defi/dex/synthetix/silver_dex__synthetix_swaps.sql index 54e1d5049..a7d8911b4 100644 --- a/models/silver/defi/dex/synthetix/silver_dex__synthetix_swaps.sql +++ b/models/silver/defi/dex/synthetix/silver_dex__synthetix_swaps.sql @@ -41,20 +41,20 @@ WITH swaps_base AS ( event_index, 'synthetix' AS platform, CONCAT( - tx_hash, + tx_hash :: STRING, '-', - event_index + event_index :: STRING ) AS _log_id, - _inserted_timestamp + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f', '0xc011a72400e58ecd99ee497cf89e3775d4bd732f' ) -- synthetix proxy contracts (new / old) AND topics [0] = '0x65b6972c94204d84cffd3a95615743e31270f04fdf251f3dccc705cfbad44776' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_1_swaps.sql b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_1_swaps.sql index 9701bd496..f41599e5c 100644 --- a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_1_swaps.sql +++ b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_1_swaps.sql @@ -70,16 +70,20 @@ swaps_base AS ( ) AS protocolFee1, tokenX, tokenY, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools p ON lb_pair = l.contract_address WHERE topics [0] :: STRING = '0xad7d6f97abf51ce18e17a38f4d70e975be9c0708474987bb3e26ad21bd93ca70' --Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_pools.sql b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_pools.sql index ddfa259b4..6d1fcbd9c 100644 --- a/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_pools.sql +++ b/models/silver/defi/dex/trader_joe/silver_dex__trader_joe_v2_pools.sql @@ -23,14 +23,18 @@ WITH pool_creation AS ( utils.udf_hex_to_int( segmented_data [1] :: STRING ) :: INT AS pool_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0xdc8d77b69155c7e68a95a4fb0f06a71ff90b943a' AND topics [0] :: STRING = '0x2c8d104b27c6b7f4492017a6f5cf3803043688934ebcaa6a03540beeaf976aff' --LB PairCreated - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/uni_sushi_v2/silver_dex__pools.sql b/models/silver/defi/dex/uni_sushi_v2/silver_dex__pools.sql index 5978ec29f..360b06b2f 100644 --- a/models/silver/defi/dex/uni_sushi_v2/silver_dex__pools.sql +++ b/models/silver/defi/dex/uni_sushi_v2/silver_dex__pools.sql @@ -19,8 +19,12 @@ WITH univ2_sushi_pairs AS ( CONCAT('0x', SUBSTRING(segmented_data [0] :: STRING, 25, 40)) AS pool_address, CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS token0, CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS token1, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, CASE WHEN contract_address = '0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f' THEN 'uniswap-v2' WHEN contract_address = '0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac' THEN 'sushiswap' @@ -28,14 +32,14 @@ WITH univ2_sushi_pairs AS ( 1 AS model_weight, 'events' AS model_name FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( '0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f', '0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac' ) AND topics [0] = '0x0d3648bd0f6ba80134a33ba9275ac585d9d315f0ad8355cddefde31afa28d0e9' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -63,17 +67,21 @@ uniswap_v3_pools AS ( ) :: INTEGER AS tickSpacing, CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS token0, CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS token1, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'uniswap-v3' AS platform, 1 AS model_weight, 'events' AS model_name FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x1f98431c8ad98523631ae4a59f267346ea31f984' AND topics [0] = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/uni_sushi_v2/silver_dex__v2_swaps.sql b/models/silver/defi/dex/uni_sushi_v2/silver_dex__v2_swaps.sql index 4518cf07d..5a4907037 100644 --- a/models/silver/defi/dex/uni_sushi_v2/silver_dex__v2_swaps.sql +++ b/models/silver/defi/dex/uni_sushi_v2/silver_dex__v2_swaps.sql @@ -50,13 +50,17 @@ swap_events AS ( CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS sender, CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS tx_to, event_index, - _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] = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND contract_address IN ( SELECT DISTINCT pool_address diff --git a/models/silver/defi/dex/verse/silver_dex__verse_pools.sql b/models/silver/defi/dex/verse/silver_dex__verse_pools.sql index 0c9faac13..5abb56b1b 100644 --- a/models/silver/defi/dex/verse/silver_dex__verse_pools.sql +++ b/models/silver/defi/dex/verse/silver_dex__verse_pools.sql @@ -22,14 +22,18 @@ WITH pool_creation 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 = '0xee3e9e46e34a27dc755a63e2849c9913ee1a06e2' 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/verse/silver_dex__verse_swaps.sql b/models/silver/defi/dex/verse/silver_dex__verse_swaps.sql index bde3435f3..ed49dddb2 100644 --- a/models/silver/defi/dex/verse/silver_dex__verse_swaps.sql +++ b/models/silver/defi/dex/verse/silver_dex__verse_swaps.sql @@ -50,16 +50,20 @@ swaps_base AS ( ) AS amount1Out, token0, token1, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN pools ON l.contract_address = pool_address WHERE l.topics [0] :: STRING = '0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822' --Swap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/dex/woofi/silver_dex__woofi_swaps.sql b/models/silver/defi/dex/woofi/silver_dex__woofi_swaps.sql index b9deb5860..899dcd6a4 100644 --- a/models/silver/defi/dex/woofi/silver_dex__woofi_swaps.sql +++ b/models/silver/defi/dex/woofi/silver_dex__woofi_swaps.sql @@ -52,10 +52,14 @@ WITH router_swaps_base AS ( 40 ) ) AS rebateTo, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE contract_address IN ( @@ -63,7 +67,7 @@ WITH router_swaps_base AS ( '0x044c08639bd59beb4f6ec52c0da6cd47283534e8' --v2 ) AND topics [0] :: STRING = '0x27c98e911efdd224f4002f6cd831c3ad0d2759ee176f9ee8466d95826af22a1c' --WooRouterSwap - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/aave/silver__aave_borrows.sql b/models/silver/defi/lending/aave/silver__aave_borrows.sql index 11e8de63d..8daa38bd5 100644 --- a/models/silver/defi/lending/aave/silver__aave_borrows.sql +++ b/models/silver/defi/lending/aave/silver__aave_borrows.sql @@ -77,8 +77,12 @@ borrow AS ( segmented_data [3] :: STRING ) :: INTEGER END AS borrowrate, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, CASE WHEN contract_address = LOWER('0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9') THEN 'Aave V2' WHEN contract_address = LOWER('0x398eC7346DcD622eDc5ae82352F02bE94C62d119') THEN 'Aave V1' @@ -96,7 +100,7 @@ borrow AS ( ELSE reserve_1 END AS aave_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b', @@ -124,7 +128,7 @@ AND contract_address IN( --AMM LOWER('0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2') --v3 ) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ), atoken_meta AS ( SELECT diff --git a/models/silver/defi/lending/aave/silver__aave_deposits.sql b/models/silver/defi/lending/aave/silver__aave_deposits.sql index 98f84acb4..3aec93cae 100644 --- a/models/silver/defi/lending/aave/silver__aave_deposits.sql +++ b/models/silver/defi/lending/aave/silver__aave_deposits.sql @@ -55,10 +55,14 @@ WITH deposits AS( WHEN reserve_1 = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' THEN '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ELSE reserve_1 END AS aave_market, - _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 ( '0xde6857219544bb5b7746f48ed30be6386fefc61b2f864cacf559893bf50fd951', @@ -86,7 +90,7 @@ AND contract_address IN( --AMM LOWER('0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2') --v3 ) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ), atoken_meta AS ( SELECT diff --git a/models/silver/defi/lending/aave/silver__aave_flashloans.sql b/models/silver/defi/lending/aave/silver__aave_flashloans.sql index b229c189a..8c01cfa28 100644 --- a/models/silver/defi/lending/aave/silver__aave_flashloans.sql +++ b/models/silver/defi/lending/aave/silver__aave_flashloans.sql @@ -55,8 +55,12 @@ WITH flashloan AS ( segmented_data [2] :: STRING ) :: INTEGER END AS refferalCode, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, COALESCE( origin_to_address, contract_address @@ -73,7 +77,7 @@ WITH flashloan AS ( ELSE asset_1 END AS aave_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x631042c832b07452973831137f2d73e395028b44b250dedc5abb0ee766e168ac', @@ -101,7 +105,7 @@ AND contract_address IN( --AMM LOWER('0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2') --v3 ) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ), atoken_meta AS ( SELECT diff --git a/models/silver/defi/lending/aave/silver__aave_liquidations.sql b/models/silver/defi/lending/aave/silver__aave_liquidations.sql index 031cd9224..5c6ba1971 100644 --- a/models/silver/defi/lending/aave/silver__aave_liquidations.sql +++ b/models/silver/defi/lending/aave/silver__aave_liquidations.sql @@ -31,8 +31,12 @@ WITH liquidation AS( WHEN topics [0] :: STRING = '0xe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e005286' THEN CONCAT('0x', SUBSTR(segmented_data [2] :: STRING, 25, 40)) ELSE CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) END AS liquidator_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, CASE WHEN contract_address = LOWER('0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9') THEN 'Aave V2' WHEN contract_address = LOWER('0x398eC7346DcD622eDc5ae82352F02bE94C62d119') THEN 'Aave V1' @@ -53,7 +57,7 @@ WITH liquidation AS( ELSE collateralAsset_1 END AS collateral_asset FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0xe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e005286', @@ -80,7 +84,7 @@ AND contract_address IN( --AMM LOWER('0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2') --v3 ) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ), atoken_meta AS ( SELECT diff --git a/models/silver/defi/lending/aave/silver__aave_repayments.sql b/models/silver/defi/lending/aave/silver__aave_repayments.sql index 2455edae6..9e0ceb1cf 100644 --- a/models/silver/defi/lending/aave/silver__aave_repayments.sql +++ b/models/silver/defi/lending/aave/silver__aave_repayments.sql @@ -24,8 +24,12 @@ WITH repay AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS repayed_amount, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, CASE WHEN contract_address = LOWER('0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9') THEN 'Aave V2' WHEN contract_address = LOWER('0x398eC7346DcD622eDc5ae82352F02bE94C62d119') THEN 'Aave V1' @@ -43,7 +47,7 @@ WITH repay AS( ELSE reserve_1 END AS aave_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa', @@ -71,7 +75,7 @@ AND contract_address IN( --AMM LOWER('0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2') --v3 ) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ), atoken_meta AS ( SELECT diff --git a/models/silver/defi/lending/aave/silver__aave_token_backfill.sql b/models/silver/defi/lending/aave/silver__aave_token_backfill.sql index c470a2116..158a64f4d 100644 --- a/models/silver/defi/lending/aave/silver__aave_token_backfill.sql +++ b/models/silver/defi/lending/aave/silver__aave_token_backfill.sql @@ -27,10 +27,14 @@ aave_token_pull AS ( CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS underlying_address, c2.name AS underlying_name, c2.decimals AS underlying_decimals, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l LEFT JOIN contracts C ON a_token_address = C.address @@ -44,7 +48,7 @@ aave_token_pull AS ( ) {% if is_incremental() %} - AND l._inserted_timestamp >= ( + AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp @@ -71,10 +75,14 @@ aave_token_pull AS ( CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS underlying_address, c2.name AS underlying_name, c2.decimals AS underlying_decimals, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l LEFT JOIN contracts C ON a_token_address = C.address @@ -89,7 +97,7 @@ aave_token_pull AS ( ) {% if is_incremental() %} - AND l._inserted_timestamp >= ( + AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp @@ -165,10 +173,14 @@ decode AS ( (segmented_data [7] :: STRING) :: STRING AS atoken_name, utils.udf_hex_to_string (segmented_data [9] :: STRING) :: STRING AS atoken_symbol, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics [0] = '0xb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b' @@ -201,10 +213,14 @@ debt_tokens as ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS atoken_address, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 27, 40)) :: STRING AS atoken_stable_debt_address, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 27, 40)) :: STRING AS atoken_variable_debt_address, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0x3a0ca721fc364424566385a1aa271ed508cc2c0949c2272575fb3013a163a45f' AND diff --git a/models/silver/defi/lending/aave/silver__aave_withdraws.sql b/models/silver/defi/lending/aave/silver__aave_withdraws.sql index 01538e4a6..942256efe 100644 --- a/models/silver/defi/lending/aave/silver__aave_withdraws.sql +++ b/models/silver/defi/lending/aave/silver__aave_withdraws.sql @@ -26,8 +26,12 @@ WITH withdraw AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS withdraw_amount, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, tx_hash, CASE WHEN contract_address = LOWER('0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9') THEN 'Aave V2' @@ -45,7 +49,7 @@ WITH withdraw AS( ELSE reserve_1 END AS aave_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f7', @@ -72,7 +76,7 @@ AND contract_address IN( --AMM LOWER('0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2') --v3 ) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ), atoken_meta AS ( SELECT diff --git a/models/silver/defi/lending/compound/silver__comp_borrows.sql b/models/silver/defi/lending/compound/silver__comp_borrows.sql index 5ee44cf24..06f2552ce 100644 --- a/models/silver/defi/lending/compound/silver__comp_borrows.sql +++ b/models/silver/defi/lending/compound/silver__comp_borrows.sql @@ -45,10 +45,14 @@ compv2_borrows AS ( ) :: INTEGER AS totalBorrows, contract_address AS ctoken, 'Compound V2' AS compound_version, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -88,10 +92,14 @@ compv3_borrows AS ( origin_from_address AS borrower, contract_address AS ctoken, 'Compound V3' AS compound_version, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics [0] = '0x9b1bfa7fa9ee420a16e124f794c35ac9f90472acc99140eb2f6447c714cad8eb' --withdrawl @@ -101,7 +109,7 @@ compv3_borrows AS ( ) {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/compound/silver__comp_deposits.sql b/models/silver/defi/lending/compound/silver__comp_deposits.sql index c4360bc0c..96b2260f5 100644 --- a/models/silver/defi/lending/compound/silver__comp_deposits.sql +++ b/models/silver/defi/lending/compound/silver__comp_deposits.sql @@ -43,10 +43,14 @@ compv2_deposits AS ( ) :: INTEGER AS mintAmount_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS supplier, 'Compound V2' AS compound_version, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -88,10 +92,14 @@ compv3_deposits AS ( ) :: INTEGER AS mintAmount_raw, origin_from_address AS supplier, 'Compound V3' AS compound_version, - _log_id, - l._inserted_timestamp + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE contract_address IN ( @@ -105,7 +113,7 @@ compv3_deposits AS ( topics [0] = '0xfa56f7b24f17183d81894d3ac2ee654e3c26388d17a28dbd9549b8114304e1f4' --SupplyCollateral {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/compound/silver__comp_liquidations.sql b/models/silver/defi/lending/compound/silver__comp_liquidations.sql index 213e8cfb7..88a8d5368 100644 --- a/models/silver/defi/lending/compound/silver__comp_liquidations.sql +++ b/models/silver/defi/lending/compound/silver__comp_liquidations.sql @@ -46,10 +46,14 @@ compv2_liquidations AS ( ) :: INTEGER AS repayAmount_raw, CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS cTokenCollateral, 'Compound V2' AS compound_version, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -98,10 +102,14 @@ compv3_liquidations AS ( C.name, C.symbol, C.decimals, - _log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l LEFT JOIN {{ ref('silver__contracts') }} C @@ -119,7 +127,7 @@ compv3_liquidations AS ( ) {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/compound/silver__comp_market_stats.sql b/models/silver/defi/lending/compound/silver__comp_market_stats.sql index 47d05b241..95b14d15e 100644 --- a/models/silver/defi/lending/compound/silver__comp_market_stats.sql +++ b/models/silver/defi/lending/compound/silver__comp_market_stats.sql @@ -219,7 +219,7 @@ blocks AS ( block_number, block_timestamp FROM - {{ ref('silver__blocks') }} + {{ ref('core__fact_blocks') }} ) SELECT s.block_number, diff --git a/models/silver/defi/lending/compound/silver__comp_redemptions.sql b/models/silver/defi/lending/compound/silver__comp_redemptions.sql index 55e793880..801fa605a 100644 --- a/models/silver/defi/lending/compound/silver__comp_redemptions.sql +++ b/models/silver/defi/lending/compound/silver__comp_redemptions.sql @@ -43,10 +43,14 @@ compv2_redemptions AS ( ) :: INTEGER AS redeemed_ctoken_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS redeemer, 'Compound V2' AS compound_version, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -87,11 +91,14 @@ compv3_redemptions AS ( NULL AS redeemed_ctoken_raw, origin_from_address AS redeemer, 'Compound V3' AS compound_version, - _log_id, - l._inserted_timestamp + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} - l + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0xd6d480d5b3068db003533b170d67561494d72e3bf9fa40a266471351ebba9e16' --WithdrawCollateral AND contract_address IN ( @@ -100,7 +107,7 @@ compv3_redemptions AS ( ) {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND _inserted_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/compound/silver__comp_repayments.sql b/models/silver/defi/lending/compound/silver__comp_repayments.sql index e6000b99f..6af505bd9 100644 --- a/models/silver/defi/lending/compound/silver__comp_repayments.sql +++ b/models/silver/defi/lending/compound/silver__comp_repayments.sql @@ -41,10 +41,14 @@ comp_repayments AS ( segmented_data [2] :: STRING ) :: INTEGER AS repayed_amount_raw, 'Compound V2' as compound_version, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -85,10 +89,14 @@ v3_repayments AS ( segmented_data [0] :: STRING ) :: INTEGER AS repayed_amount_raw, 'Compound V3' AS compound_version, - _log_id, - l._inserted_timestamp + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics [0] = '0xd1cf3d156d5f8f0d50f6c122ed609cec09d35c9b9fb3fff6ea0959134dae424e' --Supply @@ -98,7 +106,7 @@ v3_repayments AS ( ) {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/cream/silver__cream_asset_details.sql b/models/silver/defi/lending/cream/silver__cream_asset_details.sql index 5540fb0bc..0cfe6f6df 100644 --- a/models/silver/defi/lending/cream/silver__cream_asset_details.sql +++ b/models/silver/defi/lending/cream/silver__cream_asset_details.sql @@ -22,10 +22,14 @@ log_pull AS ( c.name as token_name, c.symbol as token_symbol, c.decimals as token_decimals, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} l + {{ ref('core__fact_event_logs') }} l LEFT JOIN contracts c ON @@ -35,7 +39,7 @@ log_pull AS ( AND c.name like '%Cream%' {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp @@ -50,7 +54,7 @@ traces_pull AS ( from_address AS token_address, to_address AS underlying_asset FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE tx_hash IN ( SELECT diff --git a/models/silver/defi/lending/cream/silver__cream_borrows.sql b/models/silver/defi/lending/cream/silver__cream_borrows.sql index d8aa4fcef..da19c610c 100644 --- a/models/silver/defi/lending/cream/silver__cream_borrows.sql +++ b/models/silver/defi/lending/cream/silver__cream_borrows.sql @@ -43,10 +43,14 @@ cream_borrows AS ( ) :: INTEGER AS totalBorrows, contract_address AS token, 'Cream' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -55,7 +59,7 @@ cream_borrows AS ( asset_details ) AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/cream/silver__cream_deposits.sql b/models/silver/defi/lending/cream/silver__cream_deposits.sql index 91d1ad96f..4143da076 100644 --- a/models/silver/defi/lending/cream/silver__cream_deposits.sql +++ b/models/silver/defi/lending/cream/silver__cream_deposits.sql @@ -40,10 +40,14 @@ cream_deposits AS ( ) :: INTEGER AS mintAmount_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS supplier, 'Cream' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ cream_deposits AS ( asset_details ) AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/cream/silver__cream_liquidations.sql b/models/silver/defi/lending/cream/silver__cream_liquidations.sql index 9626cddeb..872b06f09 100644 --- a/models/silver/defi/lending/cream/silver__cream_liquidations.sql +++ b/models/silver/defi/lending/cream/silver__cream_liquidations.sql @@ -42,10 +42,14 @@ cream_liquidations AS ( ) :: INTEGER AS repayAmount_raw, CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS tokenCollateral, 'Cream' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -54,7 +58,7 @@ cream_liquidations AS ( asset_details ) AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/cream/silver__cream_repayments.sql b/models/silver/defi/lending/cream/silver__cream_repayments.sql index 6a83238d6..bde06b634 100644 --- a/models/silver/defi/lending/cream/silver__cream_repayments.sql +++ b/models/silver/defi/lending/cream/silver__cream_repayments.sql @@ -38,10 +38,14 @@ cream_repayments AS ( segmented_data [2] :: STRING ) :: INTEGER AS repayed_amount_raw, 'Cream' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -50,7 +54,7 @@ cream_repayments AS ( asset_details ) AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/cream/silver__cream_withdraws.sql b/models/silver/defi/lending/cream/silver__cream_withdraws.sql index 08dac0a8a..89dfb6a99 100644 --- a/models/silver/defi/lending/cream/silver__cream_withdraws.sql +++ b/models/silver/defi/lending/cream/silver__cream_withdraws.sql @@ -40,10 +40,14 @@ cream_redemptions AS ( ) :: INTEGER AS redeemed_token_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS redeemer, 'Cream' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ cream_redemptions AS ( asset_details ) AND topics [0] :: STRING = '0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/flux/silver__flux_asset_details.sql b/models/silver/defi/lending/flux/silver__flux_asset_details.sql index 778653392..fd1e2a92d 100644 --- a/models/silver/defi/lending/flux/silver__flux_asset_details.sql +++ b/models/silver/defi/lending/flux/silver__flux_asset_details.sql @@ -13,10 +13,14 @@ WITH log_pull AS ( block_number, block_timestamp, contract_address, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d' AND origin_from_address = LOWER('0x690043fB6826F9D9381C56f43971F4F044BcE3Aa') @@ -37,7 +41,7 @@ traces_pull AS ( from_address AS token_address, to_address AS underlying_asset FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE tx_hash IN ( SELECT @@ -45,7 +49,11 @@ traces_pull AS ( FROM log_pull ) - AND identifier = 'STATICCALL_0_2' + AND concat_ws( + '_', + TYPE, + trace_address + ) = 'STATICCALL_0_2' ), contracts AS ( SELECT @@ -59,10 +67,10 @@ contract_pull AS ( l.block_number, l.block_timestamp, l.contract_address, - C.name as token_name, - C.symbol as token_symbol, - C.decimals as token_decimals, - CASE + C.name AS token_name, + C.symbol AS token_symbol, + C.decimals AS token_decimals, + CASE WHEN token_symbol = 'fETH' THEN LOWER('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2') ELSE t.underlying_asset END AS underlying_asset, diff --git a/models/silver/defi/lending/flux/silver__flux_borrows.sql b/models/silver/defi/lending/flux/silver__flux_borrows.sql index c944fc32f..2afef4b4b 100644 --- a/models/silver/defi/lending/flux/silver__flux_borrows.sql +++ b/models/silver/defi/lending/flux/silver__flux_borrows.sql @@ -43,10 +43,14 @@ flux_borrows AS ( ) :: INTEGER AS totalBorrows, contract_address AS token, 'Flux' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -55,7 +59,7 @@ flux_borrows AS ( asset_details ) AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/flux/silver__flux_deposits.sql b/models/silver/defi/lending/flux/silver__flux_deposits.sql index 0994269f4..22a0dbf22 100644 --- a/models/silver/defi/lending/flux/silver__flux_deposits.sql +++ b/models/silver/defi/lending/flux/silver__flux_deposits.sql @@ -40,10 +40,14 @@ flux_deposits AS ( ) :: INTEGER AS mintAmount_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS supplier, 'Flux' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ flux_deposits AS ( asset_details ) AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/flux/silver__flux_liquidations.sql b/models/silver/defi/lending/flux/silver__flux_liquidations.sql index f0d6fe8c9..24eb13558 100644 --- a/models/silver/defi/lending/flux/silver__flux_liquidations.sql +++ b/models/silver/defi/lending/flux/silver__flux_liquidations.sql @@ -42,10 +42,14 @@ flux_liquidations AS ( ) :: INTEGER AS repayAmount_raw, CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS tokenCollateral, 'Flux' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -54,7 +58,7 @@ flux_liquidations AS ( asset_details ) AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/flux/silver__flux_repayments.sql b/models/silver/defi/lending/flux/silver__flux_repayments.sql index 900ccf413..596843fcb 100644 --- a/models/silver/defi/lending/flux/silver__flux_repayments.sql +++ b/models/silver/defi/lending/flux/silver__flux_repayments.sql @@ -38,10 +38,14 @@ flux_repayments AS ( segmented_data [2] :: STRING ) :: INTEGER AS repayed_amount_raw, 'Flux' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -50,7 +54,7 @@ flux_repayments AS ( asset_details ) AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/flux/silver__flux_withdraws.sql b/models/silver/defi/lending/flux/silver__flux_withdraws.sql index ed183c04d..c1782e4c1 100644 --- a/models/silver/defi/lending/flux/silver__flux_withdraws.sql +++ b/models/silver/defi/lending/flux/silver__flux_withdraws.sql @@ -40,10 +40,14 @@ flux_redemptions AS ( ) :: INTEGER AS redeemed_token_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS redeemer, 'Flux' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ flux_redemptions AS ( asset_details ) AND topics [0] :: STRING = '0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/fraxlend/silver__fraxlend_asset_details.sql b/models/silver/defi/lending/fraxlend/silver__fraxlend_asset_details.sql index 1f977cc74..40f8aed30 100644 --- a/models/silver/defi/lending/fraxlend/silver__fraxlend_asset_details.sql +++ b/models/silver/defi/lending/fraxlend/silver__fraxlend_asset_details.sql @@ -14,7 +14,7 @@ WITH logs AS ( WHEN topics [0] = '0xc6fa598658c9cdf9eaa5f76414ef17a38a7f74c0e719a0571a3f73d9ecd755b7' THEN CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 42)) END AS pool_address,* FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] IN ( '0xb7f7e57b7bb3a5186ad1bd43405339ba361555344aec7a4be01968e88ee3883e', @@ -23,7 +23,7 @@ WITH logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX( _inserted_timestamp @@ -40,8 +40,12 @@ logs_transform AS ( symbol AS frax_market_symbol, decimals, CONCAT('0x', SUBSTR(topics [3] :: STRING, 27, 42)) AS underlying_asset, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM logs l LEFT JOIN {{ ref('silver__contracts') }} diff --git a/models/silver/defi/lending/fraxlend/silver__fraxlend_borrows.sql b/models/silver/defi/lending/fraxlend/silver__fraxlend_borrows.sql index 42beb9a4a..302bf77f5 100644 --- a/models/silver/defi/lending/fraxlend/silver__fraxlend_borrows.sql +++ b/models/silver/defi/lending/fraxlend/silver__fraxlend_borrows.sql @@ -41,20 +41,24 @@ WITH log_join AS ( f.frax_market_symbol, f.underlying_asset, f.underlying_symbol, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM {{ ref('silver__fraxlend_asset_details') }} f - LEFT JOIN {{ ref('silver__logs') }} + LEFT JOIN {{ ref('core__fact_event_logs') }} l ON f.frax_market_address = l.contract_address WHERE topics [0] = '0x01348584ec81ac7acd52b7d66d9ade986dd909f3d513881c190fc31c90527efe' - 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/fraxlend/silver__fraxlend_deposits.sql b/models/silver/defi/lending/fraxlend/silver__fraxlend_deposits.sql index 63a374aa7..60b4ed051 100644 --- a/models/silver/defi/lending/fraxlend/silver__fraxlend_deposits.sql +++ b/models/silver/defi/lending/fraxlend/silver__fraxlend_deposits.sql @@ -32,20 +32,24 @@ WITH log_join AS ( f.underlying_asset, f.underlying_symbol, f.underlying_decimals, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM {{ ref('silver__fraxlend_asset_details') }} f - LEFT JOIN {{ ref('silver__logs') }} + LEFT JOIN {{ ref('core__fact_event_logs') }} l ON f.frax_market_address = l.contract_address WHERE topics [0] = '0xa32435755c235de2976ed44a75a2f85cb01faf0c894f639fe0c32bb9455fea8f' - 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/fraxlend/silver__fraxlend_liquidations.sql b/models/silver/defi/lending/fraxlend/silver__fraxlend_liquidations.sql index 78142a6fd..2b4b217a9 100644 --- a/models/silver/defi/lending/fraxlend/silver__fraxlend_liquidations.sql +++ b/models/silver/defi/lending/fraxlend/silver__fraxlend_liquidations.sql @@ -60,20 +60,24 @@ WITH log_join AS ( f.underlying_asset, f.underlying_symbol, f.underlying_decimals, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM {{ ref('silver__fraxlend_asset_details') }} f - LEFT JOIN {{ ref('silver__logs') }} + LEFT JOIN {{ ref('core__fact_event_logs') }} l ON f.frax_market_address = l.contract_address WHERE topics [0] = '0x35f432a64bd3767447a456650432406c6cacb885819947a202216eeea6820ecf' - 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/fraxlend/silver__fraxlend_repayments.sql b/models/silver/defi/lending/fraxlend/silver__fraxlend_repayments.sql index 79c90abbe..a20be3733 100644 --- a/models/silver/defi/lending/fraxlend/silver__fraxlend_repayments.sql +++ b/models/silver/defi/lending/fraxlend/silver__fraxlend_repayments.sql @@ -42,20 +42,24 @@ WITH log_join AS ( f.underlying_asset, f.underlying_symbol, f.underlying_decimals, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM {{ ref('silver__fraxlend_asset_details') }} f - LEFT JOIN {{ ref('silver__logs') }} + LEFT JOIN {{ ref('core__fact_event_logs') }} l ON f.frax_market_address = l.contract_address WHERE topics [0] = '0x9dc1449a0ff0c152e18e8289d865b47acc6e1b76b1ecb239c13d6ee22a9206a7' - 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/fraxlend/silver__fraxlend_withdraws.sql b/models/silver/defi/lending/fraxlend/silver__fraxlend_withdraws.sql index 60caf2a04..744dd3eee 100644 --- a/models/silver/defi/lending/fraxlend/silver__fraxlend_withdraws.sql +++ b/models/silver/defi/lending/fraxlend/silver__fraxlend_withdraws.sql @@ -33,20 +33,24 @@ WITH log_join AS ( f.underlying_asset, f.underlying_symbol, f.underlying_decimals, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM {{ ref('silver__fraxlend_asset_details') }} f - LEFT JOIN {{ ref('silver__logs') }} + LEFT JOIN {{ ref('core__fact_event_logs') }} l ON f.frax_market_address = l.contract_address WHERE topics [0] = '0xbc290bb45104f73cf92115c9603987c3f8fd30c182a13603d8cffa49b5f59952' - 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/morpho/silver__morpho_borrows.sql b/models/silver/defi/lending/morpho/silver__morpho_borrows.sql index 7f9224a60..7a37aeb0b 100644 --- a/models/silver/defi/lending/morpho/silver__morpho_borrows.sql +++ b/models/silver/defi/lending/morpho/silver__morpho_borrows.sql @@ -40,16 +40,25 @@ WITH traces AS ( ) AS shares, CONCAT('0x', SUBSTR(segmented_input [7] :: STRING, 25)) AS on_behalf_address, CONCAT('0x', SUBSTR(segmented_input [8] :: STRING, 25)) AS receiver_address, - _call_id, - _inserted_timestamp + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} t WHERE to_address = '0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb' --Morpho Blue AND function_sig = '0x50d8cd4b' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -82,7 +91,7 @@ tx_join AS ( t._inserted_timestamp FROM traces t - INNER JOIN {{ ref('silver__transactions') }} + INNER JOIN {{ ref('core__fact_transactions') }} tx ON tx.block_number = t.block_number AND tx.tx_hash = t.tx_hash diff --git a/models/silver/defi/lending/morpho/silver__morpho_deposits.sql b/models/silver/defi/lending/morpho/silver__morpho_deposits.sql index 523d26fbf..599d82a42 100644 --- a/models/silver/defi/lending/morpho/silver__morpho_deposits.sql +++ b/models/silver/defi/lending/morpho/silver__morpho_deposits.sql @@ -40,16 +40,25 @@ WITH traces AS ( ) AS shares, CONCAT('0x', SUBSTR(segmented_input [7] :: STRING, 25)) AS on_behalf_address, CONCAT('0x', SUBSTR(segmented_input [8] :: STRING, 25)) AS receiver_address, - _call_id, - _inserted_timestamp + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} t WHERE to_address = '0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb' --Morpho Blue AND function_sig = '0xa99aad89' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -82,7 +91,7 @@ tx_join AS ( t._inserted_timestamp FROM traces t - INNER JOIN {{ ref('silver__transactions') }} + INNER JOIN {{ ref('core__fact_transactions') }} tx ON tx.block_number = t.block_number AND tx.tx_hash = t.tx_hash diff --git a/models/silver/defi/lending/morpho/silver__morpho_flashloans.sql b/models/silver/defi/lending/morpho/silver__morpho_flashloans.sql index 5cc1a71cd..482c3f20e 100644 --- a/models/silver/defi/lending/morpho/silver__morpho_flashloans.sql +++ b/models/silver/defi/lending/morpho/silver__morpho_flashloans.sql @@ -25,16 +25,20 @@ with flashloan AS( segmented_data [0] :: STRING )) AS flashloan_quantity, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics[0]::STRING = '0xc76f1b4fe4396ac07a9fa55a415d4ca430e72651d37d3401f3bed7cb13fc4f12' AND contract_address = '0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb' {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/morpho/silver__morpho_liquidations.sql b/models/silver/defi/lending/morpho/silver__morpho_liquidations.sql index be5799823..552670a81 100644 --- a/models/silver/defi/lending/morpho/silver__morpho_liquidations.sql +++ b/models/silver/defi/lending/morpho/silver__morpho_liquidations.sql @@ -18,21 +18,30 @@ WITH traces AS ( input, 10 ) AS function_sig, - decoded_data:decoded_input_data:loanToken::STRING AS loan_token, - decoded_data:decoded_input_data:marketParams:collateralToken::STRING AS collateral_token, - decoded_data:decoded_input_data:marketParams:oracle::STRING AS oracle_address, - decoded_data:decoded_input_data:marketParams:irm::STRING AS irm_address, - decoded_data:decoded_input_data:borrower::STRING AS borrower, - decoded_data:decoded_output_data:output_1::INTEGER AS amount, - _call_id, - _inserted_timestamp + full_decoded_data:decoded_input_data:loanToken::STRING AS loan_token, + full_decoded_data:decoded_input_data:marketParams:collateralToken::STRING AS collateral_token, + full_decoded_data:decoded_input_data:marketParams:oracle::STRING AS oracle_address, + full_decoded_data:decoded_input_data:marketParams:irm::STRING AS irm_address, + full_decoded_data:decoded_input_data:borrower::STRING AS borrower, + full_decoded_data:decoded_output_data:output_1::INTEGER AS amount, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_index --replace with trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE to_address = '0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb' --Morpho Blue AND function_sig = '0xd8eabcb8' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -68,10 +77,14 @@ logs AS( l.origin_to_address, l.contract_address ) AS lending_pool_contract, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics [0] :: STRING = '0xa4946ede45d0c6f06a0f5ce92c9ad3b4751452d2fe0e25010783bcab57a67e41' diff --git a/models/silver/defi/lending/morpho/silver__morpho_repayments.sql b/models/silver/defi/lending/morpho/silver__morpho_repayments.sql index 77fcdddbe..b95fa17c3 100644 --- a/models/silver/defi/lending/morpho/silver__morpho_repayments.sql +++ b/models/silver/defi/lending/morpho/silver__morpho_repayments.sql @@ -40,15 +40,24 @@ WITH traces AS ( ) AS shares, CONCAT('0x', SUBSTR(segmented_input [7] :: STRING, 25)) AS on_behalf_address, CONCAT('0x', SUBSTR(segmented_input [8] :: STRING, 25)) AS receiver_address, - _call_id, - _inserted_timestamp + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE to_address = '0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb' --Morpho Blue AND function_sig = '0x20b76e81' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -81,7 +90,7 @@ tx_join AS ( t._inserted_timestamp FROM traces t - INNER JOIN {{ ref('silver__transactions') }} + INNER JOIN {{ ref('core__fact_transactions') }} tx ON tx.block_number = t.block_number AND tx.tx_hash = t.tx_hash diff --git a/models/silver/defi/lending/morpho/silver__morpho_withdraws.sql b/models/silver/defi/lending/morpho/silver__morpho_withdraws.sql index ef3db0c05..85abf0a2e 100644 --- a/models/silver/defi/lending/morpho/silver__morpho_withdraws.sql +++ b/models/silver/defi/lending/morpho/silver__morpho_withdraws.sql @@ -40,16 +40,25 @@ WITH traces AS ( ) AS shares, CONCAT('0x', SUBSTR(segmented_input [7] :: STRING, 25)) AS on_behalf_address, CONCAT('0x', SUBSTR(segmented_input [8] :: STRING, 25)) AS receiver_address, - _call_id, - _inserted_timestamp + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} t WHERE to_address = '0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb' --Morpho Blue AND function_sig = '0x5c2bea49' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -82,7 +91,7 @@ tx_join AS ( t._inserted_timestamp FROM traces t - INNER JOIN {{ ref('silver__transactions') }} + INNER JOIN {{ ref('core__fact_transactions') }} tx ON tx.block_number = t.block_number AND tx.tx_hash = t.tx_hash diff --git a/models/silver/defi/lending/radiant/silver__radiant_borrows.sql b/models/silver/defi/lending/radiant/silver__radiant_borrows.sql index 1cd6a48ee..78578878b 100644 --- a/models/silver/defi/lending/radiant/silver__radiant_borrows.sql +++ b/models/silver/defi/lending/radiant/silver__radiant_borrows.sql @@ -55,8 +55,12 @@ borrow AS ( segmented_data [3] :: STRING ) :: INTEGER AS borrowrate, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, 'Radiant' AS radiant_version, origin_from_address AS borrower_address, COALESCE( @@ -68,7 +72,7 @@ borrow AS ( ELSE reserve_1 END AS radiant_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b' @@ -83,7 +87,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/radiant/silver__radiant_deposits.sql b/models/silver/defi/lending/radiant/silver__radiant_deposits.sql index 682cd17f0..7defb74bc 100644 --- a/models/silver/defi/lending/radiant/silver__radiant_deposits.sql +++ b/models/silver/defi/lending/radiant/silver__radiant_deposits.sql @@ -57,10 +57,14 @@ deposits AS( WHEN reserve_1 = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' THEN '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ELSE reserve_1 END AS radiant_market, - _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 = '0xde6857219544bb5b7746f48ed30be6386fefc61b2f864cacf559893bf50fd951' @@ -75,7 +79,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/radiant/silver__radiant_flashloans.sql b/models/silver/defi/lending/radiant/silver__radiant_flashloans.sql index 0293171ef..df370c59d 100644 --- a/models/silver/defi/lending/radiant/silver__radiant_flashloans.sql +++ b/models/silver/defi/lending/radiant/silver__radiant_flashloans.sql @@ -49,8 +49,12 @@ flashloan AS ( utils.udf_hex_to_int( topics[2] :: STRING ) :: INTEGER AS refferalCode, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, COALESCE( origin_to_address, contract_address @@ -61,7 +65,7 @@ flashloan AS ( ELSE asset_1 END AS radiant_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x631042c832b07452973831137f2d73e395028b44b250dedc5abb0ee766e168ac' @@ -76,7 +80,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/radiant/silver__radiant_liquidations.sql b/models/silver/defi/lending/radiant/silver__radiant_liquidations.sql index 969829a06..c111a9468 100644 --- a/models/silver/defi/lending/radiant/silver__radiant_liquidations.sql +++ b/models/silver/defi/lending/radiant/silver__radiant_liquidations.sql @@ -47,8 +47,12 @@ liquidation AS( segmented_data [1] :: STRING ) :: INTEGER AS liquidated_amount, CONCAT('0x', SUBSTR(segmented_data [2] :: STRING, 25, 40)) AS liquidator_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'Radiant' AS radiant_version, COALESCE( origin_to_address, @@ -63,7 +67,7 @@ liquidation AS( ELSE collateralAsset_1 END AS collateral_asset FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xe76026d190f8c969db64638eaf9bc7087a3758e7fe58c017135a5051b4d7c4f8' @@ -78,7 +82,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/radiant/silver__radiant_repayments.sql b/models/silver/defi/lending/radiant/silver__radiant_repayments.sql index dbc8e6df5..c395db353 100644 --- a/models/silver/defi/lending/radiant/silver__radiant_repayments.sql +++ b/models/silver/defi/lending/radiant/silver__radiant_repayments.sql @@ -43,8 +43,12 @@ repay AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS repayed_amount, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'Radiant' AS radiant_version, COALESCE( origin_to_address, @@ -56,7 +60,7 @@ repay AS( ELSE reserve_1 END AS radiant_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa', @@ -75,7 +79,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/radiant/silver__radiant_tokens.sql b/models/silver/defi/lending/radiant/silver__radiant_tokens.sql index 03454f55f..1c26ae349 100644 --- a/models/silver/defi/lending/radiant/silver__radiant_tokens.sql +++ b/models/silver/defi/lending/radiant/silver__radiant_tokens.sql @@ -24,10 +24,14 @@ WITH DECODE AS ( utils.udf_hex_to_string ( segmented_data [9] :: STRING ) :: STRING AS atoken_symbol, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics [0] = '0xb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b' @@ -76,10 +80,14 @@ debt_tokens AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS atoken_address, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 27, 40)) :: STRING AS atoken_stable_debt_address, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 27, 40)) :: STRING AS atoken_variable_debt_address, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0x3a0ca721fc364424566385a1aa271ed508cc2c0949c2272575fb3013a163a45f' AND CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) IN ( diff --git a/models/silver/defi/lending/radiant/silver__radiant_withdraws.sql b/models/silver/defi/lending/radiant/silver__radiant_withdraws.sql index 7535072c9..9f387ba5b 100644 --- a/models/silver/defi/lending/radiant/silver__radiant_withdraws.sql +++ b/models/silver/defi/lending/radiant/silver__radiant_withdraws.sql @@ -42,8 +42,12 @@ withdraw AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS withdraw_amount, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, tx_hash, 'Radiant' AS radiant_version, COALESCE( @@ -55,7 +59,7 @@ withdraw AS( ELSE reserve_1 END AS radiant_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f7' @@ -70,7 +74,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/silo/silver__silo_borrows.sql b/models/silver/defi/lending/silo/silver__silo_borrows.sql index eb77f7109..17d44cdad 100644 --- a/models/silver/defi/lending/silo/silver__silo_borrows.sql +++ b/models/silver/defi/lending/silo/silver__silo_borrows.sql @@ -27,20 +27,24 @@ WITH borrows AS( segmented_data [1] :: STRING ) :: INTEGER AS collateral_only, p.token_address AS silo_market, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN {{ ref('silver__silo_pools') }} p ON l.contract_address = p.silo_address WHERE topics [0] :: STRING = '0x312a5e5e1079f5dda4e95dbbd0b908b291fd5b992ef22073643ab691572c5b52' - AND tx_status = 'SUCCESS' --excludes failed txs + AND tx_succeeded --excludes failed txs {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/silo/silver__silo_deposits.sql b/models/silver/defi/lending/silo/silver__silo_deposits.sql index 662a0239b..05a01b6d4 100644 --- a/models/silver/defi/lending/silo/silver__silo_deposits.sql +++ b/models/silver/defi/lending/silo/silver__silo_deposits.sql @@ -24,20 +24,24 @@ WITH deposits AS( segmented_data [0] :: STRING ) :: INTEGER AS amount_unadj, p.token_address AS silo_market, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN {{ ref('silver__silo_pools') }} p ON l.contract_address = p.silo_address WHERE topics [0] :: STRING = '0xdd160bb401ec5b5e5ca443d41e8e7182f3fe72d70a04b9c0ba844483d212bcb5' - AND tx_status = 'SUCCESS' --excludes failed txs + AND tx_succeeded --excludes failed txs {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/silo/silver__silo_liquidations.sql b/models/silver/defi/lending/silo/silver__silo_liquidations.sql index 61425a11a..a3801e381 100644 --- a/models/silver/defi/lending/silo/silver__silo_liquidations.sql +++ b/models/silver/defi/lending/silo/silver__silo_liquidations.sql @@ -33,20 +33,24 @@ WITH liquidations AS( WHEN shareamountrepaid > 0 THEN 'debt_token_event' ELSE 'collateral_token_event' END AS liquidation_event_type, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN {{ ref('silver__silo_pools') }} p ON l.contract_address = p.silo_address WHERE topics [0] :: STRING = '0xf3fa0eaee8f258c23b013654df25d1527f98a5c7ccd5e951dd77caca400ef972' - AND tx_status = 'SUCCESS' --excludes failed txs + AND tx_succeeded --excludes failed txs {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/silo/silver__silo_pools.sql b/models/silver/defi/lending/silo/silver__silo_pools.sql index fdf47145b..a0505ca99 100644 --- a/models/silver/defi/lending/silo/silver__silo_pools.sql +++ b/models/silver/defi/lending/silo/silver__silo_pools.sql @@ -13,7 +13,7 @@ WITH logs_pull AS ( ELSE NULL END AS tokens FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( LOWER('0x4D919CEcfD4793c0D47866C8d0a02a0950737589'), @@ -21,7 +21,7 @@ WITH logs_pull AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX( _inserted_timestamp @@ -59,8 +59,12 @@ silo_pull AS ( 40 ) ) :: INTEGER AS version, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM logs_pull l WHERE diff --git a/models/silver/defi/lending/silo/silver__silo_repayments.sql b/models/silver/defi/lending/silo/silver__silo_repayments.sql index 13ae1cd47..ffc3773f4 100644 --- a/models/silver/defi/lending/silo/silver__silo_repayments.sql +++ b/models/silver/defi/lending/silo/silver__silo_repayments.sql @@ -24,20 +24,24 @@ WITH deposits AS( segmented_data [0] :: STRING ) :: INTEGER AS amount, p.token_address AS silo_market, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN {{ ref('silver__silo_pools') }} p ON l.contract_address = p.silo_address WHERE topics [0] :: STRING = '0x05f2eeda0e08e4b437f487c8d7d29b14537d15e3488170dc3de5dbdf8dac4684' - AND tx_status = 'SUCCESS' --excludes failed txs + AND tx_succeeded --excludes failed txs {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/silo/silver__silo_withdraws.sql b/models/silver/defi/lending/silo/silver__silo_withdraws.sql index a33fea2f1..ff651f13a 100644 --- a/models/silver/defi/lending/silo/silver__silo_withdraws.sql +++ b/models/silver/defi/lending/silo/silver__silo_withdraws.sql @@ -28,20 +28,24 @@ WITH deposits AS( segmented_data [1] :: STRING ) :: INTEGER AS collateral_only, p.token_address AS silo_market, - l._log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN {{ ref('silver__silo_pools') }} p ON l.contract_address = p.silo_address WHERE topics [0] :: STRING = '0x3b5f15635b488fe265654176726b3222080f3d6500a562f4664233b3ea2f0283' - AND tx_status = 'SUCCESS' --excludes failed txs + AND tx_succeeded --excludes failed txs {% if is_incremental() %} -AND l._inserted_timestamp >= ( +AND l.modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/defi/lending/spark/silver__spark_borrows.sql b/models/silver/defi/lending/spark/silver__spark_borrows.sql index 8987d01c4..60738cc52 100644 --- a/models/silver/defi/lending/spark/silver__spark_borrows.sql +++ b/models/silver/defi/lending/spark/silver__spark_borrows.sql @@ -55,8 +55,12 @@ borrow AS ( segmented_data [3] :: STRING ) :: INTEGER AS borrowrate, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, 'Spark' AS spark_version, origin_from_address AS borrower_address, COALESCE( @@ -68,7 +72,7 @@ borrow AS ( ELSE reserve_1 END AS spark_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xb3d084820fb1a9decffb176436bd02558d15fac9b0ddfed8c465bc7359d7dce0' @@ -83,7 +87,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/spark/silver__spark_deposits.sql b/models/silver/defi/lending/spark/silver__spark_deposits.sql index 19fd401c7..5a2985681 100644 --- a/models/silver/defi/lending/spark/silver__spark_deposits.sql +++ b/models/silver/defi/lending/spark/silver__spark_deposits.sql @@ -57,10 +57,14 @@ deposits AS( WHEN reserve_1 = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' THEN '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ELSE reserve_1 END AS spark_market, - _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 = '0x2b627736bca15cd5381dcf80b0bf11fd197d01a037c52b927a881a10fb73ba61' @@ -75,7 +79,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/spark/silver__spark_flashloans.sql b/models/silver/defi/lending/spark/silver__spark_flashloans.sql index a9795dccf..0ab6424c0 100644 --- a/models/silver/defi/lending/spark/silver__spark_flashloans.sql +++ b/models/silver/defi/lending/spark/silver__spark_flashloans.sql @@ -49,8 +49,12 @@ flashloan AS ( utils.udf_hex_to_int( topics[3] :: STRING ) :: INTEGER AS refferalCode, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, COALESCE( origin_to_address, contract_address @@ -61,7 +65,7 @@ flashloan AS ( ELSE asset_1 END AS spark_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xefefaba5e921573100900a3ad9cf29f222d995fb3b6045797eaea7521bd8d6f0' @@ -76,7 +80,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/spark/silver__spark_liquidations.sql b/models/silver/defi/lending/spark/silver__spark_liquidations.sql index f606835a8..f5a83aa0a 100644 --- a/models/silver/defi/lending/spark/silver__spark_liquidations.sql +++ b/models/silver/defi/lending/spark/silver__spark_liquidations.sql @@ -47,8 +47,12 @@ liquidation AS( segmented_data [1] :: STRING ) :: INTEGER AS liquidated_amount, CONCAT('0x', SUBSTR(segmented_data [2] :: STRING, 25, 40)) AS liquidator_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'Spark' AS spark_version, COALESCE( origin_to_address, @@ -63,7 +67,7 @@ liquidation AS( ELSE collateralAsset_1 END AS collateral_asset FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e005286' @@ -78,7 +82,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/spark/silver__spark_repayments.sql b/models/silver/defi/lending/spark/silver__spark_repayments.sql index b6d67814d..2d94c6e4b 100644 --- a/models/silver/defi/lending/spark/silver__spark_repayments.sql +++ b/models/silver/defi/lending/spark/silver__spark_repayments.sql @@ -43,8 +43,12 @@ repay AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS repayed_amount, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'Spark' AS spark_version, COALESCE( origin_to_address, @@ -56,7 +60,7 @@ repay AS( ELSE reserve_1 END AS spark_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa', @@ -75,7 +79,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/spark/silver__spark_tokens.sql b/models/silver/defi/lending/spark/silver__spark_tokens.sql index a99bdf5bd..1ee251cbc 100644 --- a/models/silver/defi/lending/spark/silver__spark_tokens.sql +++ b/models/silver/defi/lending/spark/silver__spark_tokens.sql @@ -24,10 +24,14 @@ WITH DECODE AS ( utils.udf_hex_to_string ( segmented_data [9] :: STRING ) :: STRING AS atoken_symbol, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics [0] = '0xb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b' @@ -76,10 +80,14 @@ debt_tokens AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS atoken_address, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 27, 40)) :: STRING AS atoken_stable_debt_address, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 27, 40)) :: STRING AS atoken_variable_debt_address, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0x3a0ca721fc364424566385a1aa271ed508cc2c0949c2272575fb3013a163a45f' AND CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) IN ( diff --git a/models/silver/defi/lending/spark/silver__spark_withdraws.sql b/models/silver/defi/lending/spark/silver__spark_withdraws.sql index a6ef2bd63..7326e86c1 100644 --- a/models/silver/defi/lending/spark/silver__spark_withdraws.sql +++ b/models/silver/defi/lending/spark/silver__spark_withdraws.sql @@ -42,8 +42,12 @@ withdraw AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS withdraw_amount, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, tx_hash, 'Spark' AS spark_version, COALESCE( @@ -55,7 +59,7 @@ withdraw AS( ELSE reserve_1 END AS spark_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f7' @@ -70,7 +74,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/strike/silver__strike_asset_details.sql b/models/silver/defi/lending/strike/silver__strike_asset_details.sql index 1be84e619..27eca4d4d 100644 --- a/models/silver/defi/lending/strike/silver__strike_asset_details.sql +++ b/models/silver/defi/lending/strike/silver__strike_asset_details.sql @@ -13,10 +13,14 @@ WITH log_pull AS ( block_number, block_timestamp, contract_address, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d' AND origin_from_address = LOWER('0x752dfb1C709EeA4621c8e95F48F3D0B6dde5d126') @@ -37,7 +41,7 @@ traces_pull AS ( from_address AS token_address, to_address AS underlying_asset FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE tx_hash IN ( SELECT @@ -45,7 +49,11 @@ traces_pull AS ( FROM log_pull ) - AND identifier = 'STATICCALL_0_2' + AND concat_ws( + '_', + TYPE, + trace_address + ) = 'STATICCALL_0_2' ), contracts AS ( SELECT diff --git a/models/silver/defi/lending/strike/silver__strike_borrows.sql b/models/silver/defi/lending/strike/silver__strike_borrows.sql index 939fa5707..7ba4b3139 100644 --- a/models/silver/defi/lending/strike/silver__strike_borrows.sql +++ b/models/silver/defi/lending/strike/silver__strike_borrows.sql @@ -43,10 +43,14 @@ strike_borrows AS ( ) :: INTEGER AS totalBorrows, contract_address AS token, 'Strike' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -55,7 +59,7 @@ strike_borrows AS ( asset_details ) AND topics [0] :: STRING = '0x13ed6866d4e1ee6da46f845c46d7e54120883d75c5ea9a2dacc1c4ca8984ab80' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/strike/silver__strike_deposits.sql b/models/silver/defi/lending/strike/silver__strike_deposits.sql index 32fc3cc2b..ac4562c10 100644 --- a/models/silver/defi/lending/strike/silver__strike_deposits.sql +++ b/models/silver/defi/lending/strike/silver__strike_deposits.sql @@ -40,10 +40,14 @@ strike_deposits AS ( ) :: INTEGER AS mintAmount_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS supplier, 'Strike' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ strike_deposits AS ( asset_details ) AND topics [0] :: STRING = '0x4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/strike/silver__strike_liquidations.sql b/models/silver/defi/lending/strike/silver__strike_liquidations.sql index aa6eb7692..080d44745 100644 --- a/models/silver/defi/lending/strike/silver__strike_liquidations.sql +++ b/models/silver/defi/lending/strike/silver__strike_liquidations.sql @@ -42,10 +42,14 @@ strike_liquidations AS ( ) :: INTEGER AS repayAmount_raw, CONCAT('0x', SUBSTR(segmented_data [3] :: STRING, 25, 40)) AS tokenCollateral, 'Strike' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -54,7 +58,7 @@ strike_liquidations AS ( asset_details ) AND topics [0] :: STRING = '0x298637f684da70674f26509b10f07ec2fbc77a335ab1e7d6215a4b2484d8bb52' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/strike/silver__strike_repayments.sql b/models/silver/defi/lending/strike/silver__strike_repayments.sql index 3d12decb5..b1dae34b9 100644 --- a/models/silver/defi/lending/strike/silver__strike_repayments.sql +++ b/models/silver/defi/lending/strike/silver__strike_repayments.sql @@ -38,10 +38,14 @@ strike_repayments AS ( segmented_data [2] :: STRING ) :: INTEGER AS repayed_amount_raw, 'Strike' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -50,7 +54,7 @@ strike_repayments AS ( asset_details ) AND topics [0] :: STRING = '0x1a2a22cb034d26d1854bdc6666a5b91fe25efbbb5dcad3b0355478d6f5c362a1' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/strike/silver__strike_withdraws.sql b/models/silver/defi/lending/strike/silver__strike_withdraws.sql index 0cc4e4b1d..a441f246a 100644 --- a/models/silver/defi/lending/strike/silver__strike_withdraws.sql +++ b/models/silver/defi/lending/strike/silver__strike_withdraws.sql @@ -40,10 +40,14 @@ strike_redemptions AS ( ) :: INTEGER AS redeemed_token_raw, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 25, 40)) AS redeemer, 'Strike' AS platform, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -52,7 +56,7 @@ strike_redemptions AS ( asset_details ) AND topics [0] :: STRING = '0xe5b754fb1abb7f01b499791d0b820ae3b6af3424ac1c59768edb53f4ec31a929' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/lending/sturdy/silver__sturdy_borrows.sql b/models/silver/defi/lending/sturdy/silver__sturdy_borrows.sql index 5da35a77b..118d92745 100644 --- a/models/silver/defi/lending/sturdy/silver__sturdy_borrows.sql +++ b/models/silver/defi/lending/sturdy/silver__sturdy_borrows.sql @@ -55,8 +55,12 @@ borrow AS ( segmented_data [3] :: STRING ) :: INTEGER AS borrowrate, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, 'Sturdy' AS sturdy_version, origin_from_address AS borrower_address, COALESCE( @@ -68,7 +72,7 @@ borrow AS ( ELSE reserve_1 END AS sturdy_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b' @@ -83,7 +87,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/sturdy/silver__sturdy_deposits.sql b/models/silver/defi/lending/sturdy/silver__sturdy_deposits.sql index 046b0387e..fc5eb7f6d 100644 --- a/models/silver/defi/lending/sturdy/silver__sturdy_deposits.sql +++ b/models/silver/defi/lending/sturdy/silver__sturdy_deposits.sql @@ -57,10 +57,14 @@ deposits AS( WHEN reserve_1 = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' THEN '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ELSE reserve_1 END AS sturdy_market, - _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 = '0xde6857219544bb5b7746f48ed30be6386fefc61b2f864cacf559893bf50fd951' @@ -75,7 +79,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/sturdy/silver__sturdy_liquidations.sql b/models/silver/defi/lending/sturdy/silver__sturdy_liquidations.sql index b7179b41b..948237f36 100644 --- a/models/silver/defi/lending/sturdy/silver__sturdy_liquidations.sql +++ b/models/silver/defi/lending/sturdy/silver__sturdy_liquidations.sql @@ -47,8 +47,12 @@ liquidation AS( segmented_data [1] :: STRING ) :: INTEGER AS liquidated_amount, CONCAT('0x', SUBSTR(segmented_data [2] :: STRING, 25, 40)) AS liquidator_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'Sturdy' AS sturdy_version, COALESCE( origin_to_address, @@ -63,7 +67,7 @@ liquidation AS( ELSE collateralAsset_1 END AS collateral_asset FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e005286' @@ -78,7 +82,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/sturdy/silver__sturdy_repayments.sql b/models/silver/defi/lending/sturdy/silver__sturdy_repayments.sql index 2353b0b13..30cbd7c63 100644 --- a/models/silver/defi/lending/sturdy/silver__sturdy_repayments.sql +++ b/models/silver/defi/lending/sturdy/silver__sturdy_repayments.sql @@ -43,8 +43,12 @@ repay AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS repayed_amount, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'Sturdy' AS sturdy_version, COALESCE( origin_to_address, @@ -56,7 +60,7 @@ repay AS( ELSE reserve_1 END AS sturdy_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa', @@ -75,7 +79,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/sturdy/silver__sturdy_tokens.sql b/models/silver/defi/lending/sturdy/silver__sturdy_tokens.sql index 18affa7bc..f9240037a 100644 --- a/models/silver/defi/lending/sturdy/silver__sturdy_tokens.sql +++ b/models/silver/defi/lending/sturdy/silver__sturdy_tokens.sql @@ -24,10 +24,14 @@ WITH DECODE AS ( utils.udf_hex_to_string ( segmented_data [9] :: STRING ) :: STRING AS atoken_symbol, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics [0] = '0xb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b' @@ -75,10 +79,14 @@ debt_tokens AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS atoken_address, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 27, 40)) :: STRING AS atoken_stable_debt_address, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 27, 40)) :: STRING AS atoken_variable_debt_address, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0x3a0ca721fc364424566385a1aa271ed508cc2c0949c2272575fb3013a163a45f' AND CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) IN ( diff --git a/models/silver/defi/lending/sturdy/silver__sturdy_withdraws.sql b/models/silver/defi/lending/sturdy/silver__sturdy_withdraws.sql index 185eac996..681d5f757 100644 --- a/models/silver/defi/lending/sturdy/silver__sturdy_withdraws.sql +++ b/models/silver/defi/lending/sturdy/silver__sturdy_withdraws.sql @@ -42,8 +42,12 @@ withdraw AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS withdraw_amount, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, tx_hash, 'Sturdy' AS sturdy_version, COALESCE( @@ -55,7 +59,7 @@ withdraw AS( ELSE reserve_1 END AS sturdy_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f7' @@ -70,7 +74,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/uwu/silver__uwu_borrows.sql b/models/silver/defi/lending/uwu/silver__uwu_borrows.sql index 6d8400792..429b99c10 100644 --- a/models/silver/defi/lending/uwu/silver__uwu_borrows.sql +++ b/models/silver/defi/lending/uwu/silver__uwu_borrows.sql @@ -55,8 +55,12 @@ borrow AS ( segmented_data [3] :: STRING ) :: INTEGER AS borrowrate, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, 'UwU' AS uwu_version, origin_from_address AS borrower_address, COALESCE( @@ -68,7 +72,7 @@ borrow AS ( ELSE reserve_1 END AS uwu_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xc6a898309e823ee50bac64e45ca8adba6690e99e7841c45d754e2a38e9019d9b' @@ -83,7 +87,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/uwu/silver__uwu_deposits.sql b/models/silver/defi/lending/uwu/silver__uwu_deposits.sql index c433e0b39..034266e93 100644 --- a/models/silver/defi/lending/uwu/silver__uwu_deposits.sql +++ b/models/silver/defi/lending/uwu/silver__uwu_deposits.sql @@ -57,10 +57,14 @@ deposits AS( WHEN reserve_1 = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' THEN '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ELSE reserve_1 END AS uwu_market, - _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 = '0xde6857219544bb5b7746f48ed30be6386fefc61b2f864cacf559893bf50fd951' @@ -75,7 +79,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/uwu/silver__uwu_flashloans.sql b/models/silver/defi/lending/uwu/silver__uwu_flashloans.sql index 181ca4cc1..a7f03209e 100644 --- a/models/silver/defi/lending/uwu/silver__uwu_flashloans.sql +++ b/models/silver/defi/lending/uwu/silver__uwu_flashloans.sql @@ -49,8 +49,12 @@ flashloan AS ( utils.udf_hex_to_int( topics[2] :: STRING ) :: INTEGER AS refferalCode, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, COALESCE( origin_to_address, contract_address @@ -61,7 +65,7 @@ flashloan AS ( ELSE asset_1 END AS uwu_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x631042c832b07452973831137f2d73e395028b44b250dedc5abb0ee766e168ac' @@ -76,7 +80,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/uwu/silver__uwu_liquidations.sql b/models/silver/defi/lending/uwu/silver__uwu_liquidations.sql index fcb871de8..2be5c4f92 100644 --- a/models/silver/defi/lending/uwu/silver__uwu_liquidations.sql +++ b/models/silver/defi/lending/uwu/silver__uwu_liquidations.sql @@ -47,8 +47,12 @@ liquidation AS( segmented_data [1] :: STRING ) :: INTEGER AS liquidated_amount, CONCAT('0x', SUBSTR(segmented_data [2] :: STRING, 25, 40)) AS liquidator_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'UwU' AS uwu_version, COALESCE( origin_to_address, @@ -63,7 +67,7 @@ liquidation AS( ELSE collateralAsset_1 END AS collateral_asset FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xe413a321e8681d831f4dbccbca790d2952b56f977908e45be37335533e005286' @@ -78,7 +82,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/uwu/silver__uwu_repayments.sql b/models/silver/defi/lending/uwu/silver__uwu_repayments.sql index 329568b17..a4689c9c1 100644 --- a/models/silver/defi/lending/uwu/silver__uwu_repayments.sql +++ b/models/silver/defi/lending/uwu/silver__uwu_repayments.sql @@ -43,8 +43,12 @@ repay AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS repayed_amount, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, 'UwU' AS uwu_version, COALESCE( origin_to_address, @@ -56,7 +60,7 @@ repay AS( ELSE reserve_1 END AS uwu_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING IN ( '0x4cdde6e09bb755c9a5589ebaec640bbfedff1362d4b255ebf8339782b9942faa', @@ -75,7 +79,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/lending/uwu/silver__uwu_tokens.sql b/models/silver/defi/lending/uwu/silver__uwu_tokens.sql index 639fce8d6..c610b3fe8 100644 --- a/models/silver/defi/lending/uwu/silver__uwu_tokens.sql +++ b/models/silver/defi/lending/uwu/silver__uwu_tokens.sql @@ -24,10 +24,14 @@ WITH DECODE AS ( utils.udf_hex_to_string ( segmented_data [9] :: STRING ) :: STRING AS atoken_symbol, - l._inserted_timestamp, - l._log_id + l.modified_timestamp AS _inserted_timestamp, + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l WHERE topics [0] = '0xb19e051f8af41150ccccb3fc2c2d8d15f4a4cf434f32a559ba75fe73d6eea20b' @@ -75,10 +79,14 @@ debt_tokens AS ( CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS atoken_address, CONCAT('0x', SUBSTR(segmented_data [0] :: STRING, 27, 40)) :: STRING AS atoken_stable_debt_address, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 27, 40)) :: STRING AS atoken_variable_debt_address, - _inserted_timestamp, - _log_id + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0x3a0ca721fc364424566385a1aa271ed508cc2c0949c2272575fb3013a163a45f' AND CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) IN ( diff --git a/models/silver/defi/lending/uwu/silver__uwu_withdraws.sql b/models/silver/defi/lending/uwu/silver__uwu_withdraws.sql index 4296928d8..9587e6346 100644 --- a/models/silver/defi/lending/uwu/silver__uwu_withdraws.sql +++ b/models/silver/defi/lending/uwu/silver__uwu_withdraws.sql @@ -42,8 +42,12 @@ withdraw AS( utils.udf_hex_to_int( segmented_data [0] :: STRING ) :: INTEGER AS withdraw_amount, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, tx_hash, 'UwU' AS uwu_version, COALESCE( @@ -55,7 +59,7 @@ withdraw AS( ELSE reserve_1 END AS uwu_market FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x3115d1449a7b732c986cba18244e897a450f61e1bb8d589cd2e69e6c8924f9f7' @@ -70,7 +74,7 @@ AND _inserted_timestamp >= ( ) {% endif %} AND contract_address IN (SELECT distinct(version_pool) from atoken_meta) -AND tx_status = 'SUCCESS' --excludes failed txs +AND tx_succeeded --excludes failed txs ) SELECT tx_hash, diff --git a/models/silver/defi/liquid_staking/ankr/silver_lsd__ankr_deposits.sql b/models/silver/defi/liquid_staking/ankr/silver_lsd__ankr_deposits.sql index 7e915e739..56e9aa97f 100644 --- a/models/silver/defi/liquid_staking/ankr/silver_lsd__ankr_deposits.sql +++ b/models/silver/defi/liquid_staking/ankr/silver_lsd__ankr_deposits.sql @@ -26,14 +26,18 @@ WITH deposits AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0x995d6cdbf356b73aa4dff24e951558cc155c9bb0397786ec4a142f9470f50007' --StakeConfirmed AND contract_address = '0x84db6ee82b7cf3b47e8f19270abde5718b936670' --ankr ETH2 Staking - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/ankr/silver_lsd__ankr_withdrawals.sql b/models/silver/defi/liquid_staking/ankr/silver_lsd__ankr_withdrawals.sql index 492393d29..423e949de 100644 --- a/models/silver/defi/liquid_staking/ankr/silver_lsd__ankr_withdrawals.sql +++ b/models/silver/defi/liquid_staking/ankr/silver_lsd__ankr_withdrawals.sql @@ -36,14 +36,18 @@ WITH withdrawals AS ( WHEN isAETH = 1 THEN TRUE ELSE FALSE END AS is_aeth, - _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 = '0xc5130045b6f6c9e2944ccea448ad17c279db68237b8aa856ee12cbfaa25f7715' --PendingUnstake AND contract_address = '0x84db6ee82b7cf3b47e8f19270abde5718b936670' --ankr ETH2 Staking - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -74,15 +78,19 @@ burns AS ( ) ) AS VALUE, (VALUE / pow(10, 18)) :: FLOAT AS value_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer (Burn) AND contract_address = '0xe95a203b1a91a908f9b9ce46459d101078c2c3cb' --Ankr Staked ETH (ankrETH) AND to_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/binance/silver_lsd__binance_deposits.sql b/models/silver/defi/liquid_staking/binance/silver_lsd__binance_deposits.sql index 881b14af5..e625a8659 100644 --- a/models/silver/defi/liquid_staking/binance/silver_lsd__binance_deposits.sql +++ b/models/silver/defi/liquid_staking/binance/silver_lsd__binance_deposits.sql @@ -27,14 +27,18 @@ WITH deposit_logs AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0xab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8' --Mint/Deposit AND contract_address = '0xa2e3356610840701bdf5611a53974510ae27e2e1' --Wrapped Binance Beacon ETH (wBETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -52,15 +56,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2023-04-19' AND tx_hash IN ( @@ -75,8 +88,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/coinbase/silver_lsd__coinbase_deposits.sql b/models/silver/defi/liquid_staking/coinbase/silver_lsd__coinbase_deposits.sql index bb4c7d4b1..9c86e3ec1 100644 --- a/models/silver/defi/liquid_staking/coinbase/silver_lsd__coinbase_deposits.sql +++ b/models/silver/defi/liquid_staking/coinbase/silver_lsd__coinbase_deposits.sql @@ -27,14 +27,18 @@ WITH mints AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0xab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8' --Mint AND contract_address = '0xbe9895146f7af43049ca1c1ae358b0541ea49704' --Coinbase Wrapped Staked ETH (cbETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/coinbase/silver_lsd__coinbase_withdrawals.sql b/models/silver/defi/liquid_staking/coinbase/silver_lsd__coinbase_withdrawals.sql index e624421ab..46c6b77ce 100644 --- a/models/silver/defi/liquid_staking/coinbase/silver_lsd__coinbase_withdrawals.sql +++ b/models/silver/defi/liquid_staking/coinbase/silver_lsd__coinbase_withdrawals.sql @@ -26,14 +26,18 @@ WITH burns AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0xcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5' --Burn AND contract_address = '0xbe9895146f7af43049ca1c1ae358b0541ea49704' --Coinbase Wrapped Staked ETH (cbETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/cream/silver_lsd__cream_deposits.sql b/models/silver/defi/liquid_staking/cream/silver_lsd__cream_deposits.sql index a396a319b..9d0922ff2 100644 --- a/models/silver/defi/liquid_staking/cream/silver_lsd__cream_deposits.sql +++ b/models/silver/defi/liquid_staking/cream/silver_lsd__cream_deposits.sql @@ -39,14 +39,18 @@ WITH deposits AS ( ) ) AS creth2_amount, (creth2_amount / pow(10, 18)) :: FLOAT AS creth2_amount_adj, - _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 = '0xad40ae5dc69974ba932d08b0a608e89109412d41d04850f5196f144875ae2660' --DepositEvent AND contract_address = '0xcbc1065255cbc3ab41a6868c22d1f1c573ab89fd' --Cream ETH 2 (CRETH2) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/cream/silver_lsd__cream_withdrawals.sql b/models/silver/defi/liquid_staking/cream/silver_lsd__cream_withdrawals.sql index 96e705e18..566dd9b1a 100644 --- a/models/silver/defi/liquid_staking/cream/silver_lsd__cream_withdrawals.sql +++ b/models/silver/defi/liquid_staking/cream/silver_lsd__cream_withdrawals.sql @@ -39,14 +39,18 @@ WITH withdrawals AS ( ) ) AS creth2_amount, (creth2_amount / pow(10, 18)) :: FLOAT AS creth2_amount_adj, - _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 = '0x5bb95829671915ece371da722f91d5371159095dcabf2f75cd6c53facb7e1bab' --WithdrawEvent AND contract_address = '0xcbc1065255cbc3ab41a6868c22d1f1c573ab89fd' --Cream ETH 2 (CRETH2) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/etherfi/silver_lsd__etherfi_deposits.sql b/models/silver/defi/liquid_staking/etherfi/silver_lsd__etherfi_deposits.sql index cee2fe788..f162f579d 100644 --- a/models/silver/defi/liquid_staking/etherfi/silver_lsd__etherfi_deposits.sql +++ b/models/silver/defi/liquid_staking/etherfi/silver_lsd__etherfi_deposits.sql @@ -27,16 +27,20 @@ WITH deposit_logs AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 block_timestamp :: DATE >= '2023-07-01' AND topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Deposit/Mint (Transfer) AND contract_address = LOWER('0x35fA164735182de50811E8e2E824cFb9B6118ac2') --ether.fi: eETH Token (eETH) AND from_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -54,15 +58,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2023-07-01' AND tx_hash IN ( @@ -77,8 +90,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/etherfi/silver_lsd__etherfi_withdrawals.sql b/models/silver/defi/liquid_staking/etherfi/silver_lsd__etherfi_withdrawals.sql index 13aa6a679..de8a43d53 100644 --- a/models/silver/defi/liquid_staking/etherfi/silver_lsd__etherfi_withdrawals.sql +++ b/models/silver/defi/liquid_staking/etherfi/silver_lsd__etherfi_withdrawals.sql @@ -27,16 +27,20 @@ WITH withdrawals AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 block_timestamp :: DATE >= '2023-07-01' AND topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Withdraw/Burn (Transfer) AND contract_address = LOWER('0x35fA164735182de50811E8e2E824cFb9B6118ac2') --ether.fi: eETH Token (eETH) AND to_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/frax/silver_lsd__fraxether_deposits.sql b/models/silver/defi/liquid_staking/frax/silver_lsd__fraxether_deposits.sql index a2310de70..2b27f1294 100644 --- a/models/silver/defi/liquid_staking/frax/silver_lsd__fraxether_deposits.sql +++ b/models/silver/defi/liquid_staking/frax/silver_lsd__fraxether_deposits.sql @@ -33,14 +33,18 @@ WITH deposits AS ( ) AS shares, (assets / pow(10, 18)) :: FLOAT AS assets_adj, (shares / pow(10, 18)) :: FLOAT AS shares_adj, - _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 = '0xdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d7' --Deposit AND contract_address = '0xac3e018457b222d93114458476f3e3416abbe38f' --Staked Frax Ether (sfrxETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/frax/silver_lsd__fraxether_withdrawals.sql b/models/silver/defi/liquid_staking/frax/silver_lsd__fraxether_withdrawals.sql index f93e84c8b..1e001fa1f 100644 --- a/models/silver/defi/liquid_staking/frax/silver_lsd__fraxether_withdrawals.sql +++ b/models/silver/defi/liquid_staking/frax/silver_lsd__fraxether_withdrawals.sql @@ -34,14 +34,18 @@ WITH withdrawals AS ( ) AS shares, (assets / pow(10, 18)) :: FLOAT AS assets_adj, (shares / pow(10, 18)) :: FLOAT AS shares_adj, - _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 = '0xfbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db' --Withdraw AND contract_address = '0xac3e018457b222d93114458476f3e3416abbe38f' --Staked Frax Ether (sfrxETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/guarded/silver_lsd__guarded_deposits.sql b/models/silver/defi/liquid_staking/guarded/silver_lsd__guarded_deposits.sql index 756b3ad1a..c0087d60b 100644 --- a/models/silver/defi/liquid_staking/guarded/silver_lsd__guarded_deposits.sql +++ b/models/silver/defi/liquid_staking/guarded/silver_lsd__guarded_deposits.sql @@ -27,16 +27,20 @@ WITH deposit_logs AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Deposit/Mint (Transfer) AND contract_address = '0x3802c218221390025bceabbad5d8c59f40eb74b8' --Guarded Ether (GETH) AND from_address = '0x0000000000000000000000000000000000000000' AND origin_to_address IS NOT NULL - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -54,15 +58,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2021-10-20' AND tx_hash IN ( @@ -77,8 +90,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/hord/silver_lsd__hord_deposits.sql b/models/silver/defi/liquid_staking/hord/silver_lsd__hord_deposits.sql index 4747b25a0..a1eb8bb2e 100644 --- a/models/silver/defi/liquid_staking/hord/silver_lsd__hord_deposits.sql +++ b/models/silver/defi/liquid_staking/hord/silver_lsd__hord_deposits.sql @@ -26,14 +26,18 @@ WITH deposits AS ( ) ) AS eth_amount, (eth_amount / pow(10, 18)) :: FLOAT AS eth_amount_adj, - _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 = '0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c' --Deposit AND contract_address = '0x5bbe36152d3cd3eb7183a82470b39b29eedf068b' --Hord (hETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -63,14 +67,18 @@ mints AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 = '0x7fc2fd3fd75a3920468e7ebb35c1c6c24d63052113a15ce8a4d461bf9b8c7f84' --HETHMinted AND contract_address = '0x5bbe36152d3cd3eb7183a82470b39b29eedf068b' --HordETH (hETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/lido/silver_lsd__lido_deposits.sql b/models/silver/defi/liquid_staking/lido/silver_lsd__lido_deposits.sql index c055cc526..0a09a8149 100644 --- a/models/silver/defi/liquid_staking/lido/silver_lsd__lido_deposits.sql +++ b/models/silver/defi/liquid_staking/lido/silver_lsd__lido_deposits.sql @@ -27,14 +27,18 @@ WITH deposits AS ( ) AS amount, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS referral, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0x96a25c8ce0baabc1fdefd93e9ed25d8e092a3332f3aa9a41722b5697231d1d1a' --Submitted AND contract_address = '0xae7ab96520de3a18e5e111b5eaab095312d7fe84' --Lido stETH Token (stETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/lido/silver_lsd__lido_withdrawal_requests.sql b/models/silver/defi/liquid_staking/lido/silver_lsd__lido_withdrawal_requests.sql index 8a1f94e9f..7c273ff00 100644 --- a/models/silver/defi/liquid_staking/lido/silver_lsd__lido_withdrawal_requests.sql +++ b/models/silver/defi/liquid_staking/lido/silver_lsd__lido_withdrawal_requests.sql @@ -38,14 +38,18 @@ WITH requests AS ( ) AS amountOfShares, (amountOfStETH / pow(10, 18)) :: FLOAT AS amount_of_steth_adj, (amountOfShares / pow(10, 18)) :: FLOAT AS amount_of_shares_adj, - _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 = '0xf0cb471f23fb74ea44b8252eb1881a2dca546288d9f6e90d1a0e82fe0ed342ab' --WithdrawalRequested AND contract_address = '0x889edc2edab5f40e902b864ad4d7ade8e412f9b1' --Lido: stETH Withdrawal NFT (unstETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/lido/silver_lsd__lido_withdrawals_claimed.sql b/models/silver/defi/liquid_staking/lido/silver_lsd__lido_withdrawals_claimed.sql index 4d49d376c..152101331 100644 --- a/models/silver/defi/liquid_staking/lido/silver_lsd__lido_withdrawals_claimed.sql +++ b/models/silver/defi/liquid_staking/lido/silver_lsd__lido_withdrawals_claimed.sql @@ -31,14 +31,18 @@ WITH claims AS ( ) ) AS amountOfETH, (amountOfETH / pow(10, 18)) :: FLOAT AS amount_of_eth_adj, - _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 = '0x6ad26c5e238e7d002799f9a5db07e81ef14e37386ae03496d7a7ef04713e145b' --WithdrawalClaimed AND contract_address = '0x889edc2edab5f40e902b864ad4d7ade8e412f9b1' --Lido: stETH Withdrawal NFT (unstETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/liquidcollective/silver_lsd__liquidcollective_deposits.sql b/models/silver/defi/liquid_staking/liquidcollective/silver_lsd__liquidcollective_deposits.sql index 34adb82a9..5b8da6e2f 100644 --- a/models/silver/defi/liquid_staking/liquidcollective/silver_lsd__liquidcollective_deposits.sql +++ b/models/silver/defi/liquid_staking/liquidcollective/silver_lsd__liquidcollective_deposits.sql @@ -27,16 +27,20 @@ WITH deposit_logs AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 block_timestamp :: DATE >= '2022-10-01' AND topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Deposit/Mint (Transfer) AND contract_address = LOWER('0x8c1BEd5b9a0928467c9B1341Da1D7BD5e10b6549') --Liquid Staked ETH (LsETH) AND from_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -54,15 +58,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2022-10-01' AND tx_hash IN ( @@ -77,8 +90,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/liquidcollective/silver_lsd__liquidcollective_withdrawals.sql b/models/silver/defi/liquid_staking/liquidcollective/silver_lsd__liquidcollective_withdrawals.sql index 06c3457e9..bcd5c96ca 100644 --- a/models/silver/defi/liquid_staking/liquidcollective/silver_lsd__liquidcollective_withdrawals.sql +++ b/models/silver/defi/liquid_staking/liquidcollective/silver_lsd__liquidcollective_withdrawals.sql @@ -27,16 +27,20 @@ WITH withdrawals AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 block_timestamp :: DATE >= '2022-10-01' AND topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Withdraw/Burn (Transfer) AND contract_address = LOWER('0x8c1BEd5b9a0928467c9B1341Da1D7BD5e10b6549') --Liquid Staked ETH (LsETH) AND to_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/mantle/silver_lsd__mantle_deposits.sql b/models/silver/defi/liquid_staking/mantle/silver_lsd__mantle_deposits.sql index 1a2c887d7..8fc8b3b5e 100644 --- a/models/silver/defi/liquid_staking/mantle/silver_lsd__mantle_deposits.sql +++ b/models/silver/defi/liquid_staking/mantle/silver_lsd__mantle_deposits.sql @@ -32,10 +32,14 @@ WITH stake AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 = '0x1449c6dd7851abc30abf37f57715f492010519147cc2652fbc38202c18a6ee90' --Staked AND contract_address = LOWER('0xe3cBd06D7dadB3F4e6557bAb7EdD924CD1489E8f') --Mantle: LSP Staking diff --git a/models/silver/defi/liquid_staking/mantle/silver_lsd__mantle_withdrawals.sql b/models/silver/defi/liquid_staking/mantle/silver_lsd__mantle_withdrawals.sql index 01703cf38..d2f0f42cb 100644 --- a/models/silver/defi/liquid_staking/mantle/silver_lsd__mantle_withdrawals.sql +++ b/models/silver/defi/liquid_staking/mantle/silver_lsd__mantle_withdrawals.sql @@ -45,10 +45,14 @@ WITH unstake AS ( segmented_data [3] :: STRING ) ) AS block_number_requested, - _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 = '0x5de6f9e4fdf1b740a7ba3b485303743eec250be281a2dd4df046c7fcecbdb04d' --UnstakeRequestClaimed AND contract_address = LOWER('0x38fDF7b489316e03eD8754ad339cb5c4483FDcf9') --Mantle: Unstake Requests Manager diff --git a/models/silver/defi/liquid_staking/nodedao/silver_lsd__nodedao_deposits.sql b/models/silver/defi/liquid_staking/nodedao/silver_lsd__nodedao_deposits.sql index dff2e295d..50f802d41 100644 --- a/models/silver/defi/liquid_staking/nodedao/silver_lsd__nodedao_deposits.sql +++ b/models/silver/defi/liquid_staking/nodedao/silver_lsd__nodedao_deposits.sql @@ -37,14 +37,18 @@ WITH deposits AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 = '0x1cae59a31c3c6760aa08cb9c351432553e908b8e6f53e7c9ac22715c7d496179' --EthStake AND contract_address = '0x8103151e2377e78c04a3d2564e20542680ed3096' --ERC1967Proxy - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/nodedao/silver_lsd__nodedao_withdrawals.sql b/models/silver/defi/liquid_staking/nodedao/silver_lsd__nodedao_withdrawals.sql index 4fb6d156e..728ec80ef 100644 --- a/models/silver/defi/liquid_staking/nodedao/silver_lsd__nodedao_withdrawals.sql +++ b/models/silver/defi/liquid_staking/nodedao/silver_lsd__nodedao_withdrawals.sql @@ -42,14 +42,18 @@ WITH withdrawals AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 = '0xc2d18d1ab67a48ae80c3ef1d20c2f2a97201a23db7ca49e5de1edf05610fb003' --EthUnstake AND contract_address = '0x8103151e2377e78c04a3d2564e20542680ed3096' --ERC1967Proxy - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/origin/silver_lsd__origin_deposits.sql b/models/silver/defi/liquid_staking/origin/silver_lsd__origin_deposits.sql index 67235d7eb..b05281266 100644 --- a/models/silver/defi/liquid_staking/origin/silver_lsd__origin_deposits.sql +++ b/models/silver/defi/liquid_staking/origin/silver_lsd__origin_deposits.sql @@ -27,16 +27,20 @@ WITH deposit_logs AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 block_timestamp :: DATE >= '2023-03-01' AND topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Deposit/Mint (Transfer) AND contract_address = LOWER('0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3') --Origin Ether (OETH) AND from_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -54,15 +58,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2023-03-01' AND tx_hash IN ( @@ -77,8 +90,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/origin/silver_lsd__origin_withdrawals.sql b/models/silver/defi/liquid_staking/origin/silver_lsd__origin_withdrawals.sql index c4623b6ff..01c6e35a5 100644 --- a/models/silver/defi/liquid_staking/origin/silver_lsd__origin_withdrawals.sql +++ b/models/silver/defi/liquid_staking/origin/silver_lsd__origin_withdrawals.sql @@ -27,16 +27,20 @@ WITH withdrawals AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 block_timestamp :: DATE >= '2023-03-01' AND topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Withdraw/Burn (Transfer) AND contract_address = LOWER('0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3') --Origin Ether (OETH) AND to_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/rocketpool/silver_lsd__rocketpool_deposits.sql b/models/silver/defi/liquid_staking/rocketpool/silver_lsd__rocketpool_deposits.sql index bd79db2b6..ad5b5be78 100644 --- a/models/silver/defi/liquid_staking/rocketpool/silver_lsd__rocketpool_deposits.sql +++ b/models/silver/defi/liquid_staking/rocketpool/silver_lsd__rocketpool_deposits.sql @@ -30,10 +30,14 @@ WITH deposits AS ( ) AS TIME, TIME :: TIMESTAMP AS time_of_deposit, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0x7aa1a8eb998c779420645fc14513bf058edb347d95c2fc2e6845bdc22f888631' --DepositReceived AND contract_address IN ( @@ -41,7 +45,7 @@ WITH deposits AS ( '0x2cac916b2a963bf162f076c0a8a4a8200bcfbfb4', '0x4d05e3d48a938db4b7a9a59a802d5b45011bde58' ) --RocketDepositPool - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT @@ -80,10 +84,14 @@ mints AS ( TIME :: TIMESTAMP AS time_of_deposit, (amount / pow(10, 18)) :: FLOAT AS amount_adj, (eth_amount / pow(10, 18)) :: FLOAT AS eth_amount_adj, - _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 = '0x6155cfd0fd028b0ca77e8495a60cbe563e8bce8611f0aad6fedbdaafc05d44a2' --TokensMinted AND contract_address = '0xae78736cd615f374d3085123a210448e74fc6393' --rETH @@ -91,7 +99,7 @@ mints AS ( SELECT from_address FROM deposits ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/rocketpool/silver_lsd__rocketpool_withdrawals.sql b/models/silver/defi/liquid_staking/rocketpool/silver_lsd__rocketpool_withdrawals.sql index 68ff0858f..d1594e915 100644 --- a/models/silver/defi/liquid_staking/rocketpool/silver_lsd__rocketpool_withdrawals.sql +++ b/models/silver/defi/liquid_staking/rocketpool/silver_lsd__rocketpool_withdrawals.sql @@ -36,14 +36,18 @@ WITH burns AS ( segmented_data [2] :: STRING ) AS TIME, TIME :: TIMESTAMP AS time_of_burn, - _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 = '0x19783b34589160c168487dc7f9c51ae0bcefe67a47d6708fba90f6ce0366d3d1' --Burn AND contract_address = '0xae78736cd615f374d3085123a210448e74fc6393' --rETH - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_deposits.sql b/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_deposits.sql index b25e7f9d1..382897fb2 100644 --- a/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_deposits.sql +++ b/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_deposits.sql @@ -27,16 +27,20 @@ WITH deposit_logs AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Deposit/Mint (Transfer) AND contract_address = '0x898bad2774eb97cf6b94605677f43b41871410b1' --validator-Eth2 (vETH2) AND from_address = '0x0000000000000000000000000000000000000000' AND origin_to_address = '0xbca3b7b87dcb15f0efa66136bc0e4684a3e5da4d' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp > ( @@ -54,15 +58,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2020-12-10' AND tx_hash IN ( @@ -77,8 +90,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_v2_deposits.sql b/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_v2_deposits.sql index 352f6764f..e96992f3a 100644 --- a/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_v2_deposits.sql +++ b/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_v2_deposits.sql @@ -27,16 +27,20 @@ WITH deposit_logs AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Deposit/Mint (Transfer) AND contract_address = '0x9e52db44d62a8c9762fa847bd2eba9d0585782d1' --SharedStake Governed Staked Ether (sgETH) AND from_address = '0x0000000000000000000000000000000000000000' AND origin_to_address = '0x85bc06f4e3439d41f610a440ba0fbe333736b310' --SharedDepositMinterV2 - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -54,15 +58,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2023-04-01' AND tx_hash IN ( @@ -77,8 +90,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_v2_withdrawals.sql b/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_v2_withdrawals.sql index 24bcf13f9..4b7112097 100644 --- a/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_v2_withdrawals.sql +++ b/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_v2_withdrawals.sql @@ -27,16 +27,20 @@ WITH withdrawals AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Withdraw/Burn (Transfer) AND contract_address = '0x9e52db44d62a8c9762fa847bd2eba9d0585782d1' --SharedStake Governed Staked Ether (sgETH) AND to_address = '0x0000000000000000000000000000000000000000' AND origin_to_address = '0x85bc06f4e3439d41f610a440ba0fbe333736b310' --SharedDepositMinterV2 - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_withdrawals.sql b/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_withdrawals.sql index ddb8b86a9..138b437c9 100644 --- a/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_withdrawals.sql +++ b/models/silver/defi/liquid_staking/sharedstake/silver_lsd__sharedstake_withdrawals.sql @@ -27,16 +27,20 @@ WITH withdrawals AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Withdraw/Burn (Transfer) AND contract_address = '0x898bad2774eb97cf6b94605677f43b41871410b1' --validator-Eth2 (vETH2) AND to_address = '0x0000000000000000000000000000000000000000' AND origin_to_address = '0xbca3b7b87dcb15f0efa66136bc0e4684a3e5da4d' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/stader/silver_lsd__stader_deposits.sql b/models/silver/defi/liquid_staking/stader/silver_lsd__stader_deposits.sql index a7e389c13..85d3a1d14 100644 --- a/models/silver/defi/liquid_staking/stader/silver_lsd__stader_deposits.sql +++ b/models/silver/defi/liquid_staking/stader/silver_lsd__stader_deposits.sql @@ -33,14 +33,18 @@ WITH deposits AS ( ) ) AS releaseTime, (releaseTime / pow(10, 18)) :: FLOAT AS release_time_adj, - _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 = '0xf5681f9d0db1b911ac18ee83d515a1cf1051853a9eae418316a2fdf7dea427c5' --Deposited AND contract_address = '0xcf5ea1b38380f6af39068375516daf40ed70d299' --TransparentUpgradeableProxy - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/stader/silver_lsd__stader_withdrawals.sql b/models/silver/defi/liquid_staking/stader/silver_lsd__stader_withdrawals.sql index bb052786a..c5d92644e 100644 --- a/models/silver/defi/liquid_staking/stader/silver_lsd__stader_withdrawals.sql +++ b/models/silver/defi/liquid_staking/stader/silver_lsd__stader_withdrawals.sql @@ -45,14 +45,18 @@ WITH requests AS ( ) ) AS ether_amount, (shares_amount / pow(10, 18)) :: FLOAT AS ether_amount_adj, - _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 = '0x5b2ce38527d3f69f0bf03c1a363829ba12d09551f8778a9b0b9e1285ec19721a' --WithdrawRequestReceived AND contract_address = '0x9f0491b32dbce587c50c4c43ab303b06478193a7' --TransparentUpgradeableProxy - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/stafi/silver_lsd__stafi_deposits.sql b/models/silver/defi/liquid_staking/stafi/silver_lsd__stafi_deposits.sql index 376b7bb66..d9500aef3 100644 --- a/models/silver/defi/liquid_staking/stafi/silver_lsd__stafi_deposits.sql +++ b/models/silver/defi/liquid_staking/stafi/silver_lsd__stafi_deposits.sql @@ -30,14 +30,18 @@ WITH deposits AS ( ) AS TIME, TIME :: TIMESTAMP AS time_of_deposit, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0x2c7d80ba9bc6395644b4ff4a878353ac20adeed6e23cead48c8cec7a58b6e719' --EtherDeposited AND contract_address = '0x54896f542f044709807f0d79033934d661d39fc1' --StafiEther - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -77,14 +81,18 @@ mints AS ( TIME :: TIMESTAMP AS time_of_deposit, (amount / pow(10, 18)) :: FLOAT AS amount_adj, (eth_amount / pow(10, 18)) :: FLOAT AS eth_amount_adj, - _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 = '0x6155cfd0fd028b0ca77e8495a60cbe563e8bce8611f0aad6fedbdaafc05d44a2' --TokensMinted AND contract_address = '0x9559aaa82d9649c7a7b220e7c461d2e74c9a3593' --StaFi (rETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/stafi/silver_lsd__stafi_withdrawals.sql b/models/silver/defi/liquid_staking/stafi/silver_lsd__stafi_withdrawals.sql index 6035ed423..a16fe5670 100644 --- a/models/silver/defi/liquid_staking/stafi/silver_lsd__stafi_withdrawals.sql +++ b/models/silver/defi/liquid_staking/stafi/silver_lsd__stafi_withdrawals.sql @@ -32,14 +32,18 @@ WITH withdrawals AS ( ) AS ethAmount, (rethAmount / pow(10, 18)) :: FLOAT AS reth_amount_adj, (ethAmount / pow(10, 18)) :: FLOAT AS eth_amount_adj, - _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 = '0xc7ccdcb2d25f572c6814e377dbb34ea4318a4b7d3cd890f5cfad699d75327c7c' --Unstake AND contract_address = '0x27d64dd9172e4b59a444817d30f7af8228f174cc' --StafiWithdrawProxy - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/stakehound/silver_lsd__stakehound_deposits.sql b/models/silver/defi/liquid_staking/stakehound/silver_lsd__stakehound_deposits.sql index 524124764..5ae1e5b4b 100644 --- a/models/silver/defi/liquid_staking/stakehound/silver_lsd__stakehound_deposits.sql +++ b/models/silver/defi/liquid_staking/stakehound/silver_lsd__stakehound_deposits.sql @@ -27,16 +27,20 @@ WITH mints AS ( ) ) AS value, (value / pow(10, 18)) :: FLOAT AS value_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer (Mint) AND contract_address = '0xdfe66b14d37c77f4e9b180ceb433d1b164f0281d' --StakeHound: stakedETH (stETH) AND from_address = '0x0000000000000000000000000000000000000000' AND origin_to_address IS NOT NULL - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/stakestone/silver_lsd__stakestone_deposits.sql b/models/silver/defi/liquid_staking/stakestone/silver_lsd__stakestone_deposits.sql index e526fc563..7d0ea94b8 100644 --- a/models/silver/defi/liquid_staking/stakestone/silver_lsd__stakestone_deposits.sql +++ b/models/silver/defi/liquid_staking/stakestone/silver_lsd__stakestone_deposits.sql @@ -27,16 +27,20 @@ WITH deposit_logs AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 block_timestamp :: DATE >= '2023-09-01' AND topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Deposit/Mint (Transfer) AND contract_address = LOWER('0x7122985656e38BDC0302Db86685bb972b145bD3C') --StakeStone Ether (STONE) AND from_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -54,15 +58,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2023-09-01' AND tx_hash IN ( @@ -77,8 +90,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/stakestone/silver_lsd__stakestone_withdrawals.sql b/models/silver/defi/liquid_staking/stakestone/silver_lsd__stakestone_withdrawals.sql index 5c895ca7d..08ec156ca 100644 --- a/models/silver/defi/liquid_staking/stakestone/silver_lsd__stakestone_withdrawals.sql +++ b/models/silver/defi/liquid_staking/stakestone/silver_lsd__stakestone_withdrawals.sql @@ -27,16 +27,20 @@ WITH withdrawals AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 block_timestamp :: DATE >= '2023-09-01' AND topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Withdraw/Burn (Transfer) AND contract_address = LOWER('0x7122985656e38BDC0302Db86685bb972b145bD3C') --StakeStone Ether (STONE) AND to_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_deposits.sql b/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_deposits.sql index fc9e26967..2f9740b7f 100644 --- a/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_deposits.sql +++ b/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_deposits.sql @@ -27,15 +27,19 @@ WITH transfers AS ( ) ) AS VALUE, (VALUE / pow(10, 18)) :: FLOAT AS value_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer (Stake) AND contract_address = '0xfe2e637202056d30016725477c5da089ab0a043a' --StakeWise Staked ETH2 (sETH2) AND from_address = '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -65,14 +69,18 @@ referrers AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0x2f6cbf015ae7f747147c62891da8bad454d58bd9fe94d218ecc3dbbfbd48c16e' --StakedWithReferrer AND contract_address = '0xc874b064f465bdd6411d45734b56fac750cda29a' --Stakewise: ETH2 Staking - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_deposits.sql b/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_deposits.sql index 262287c1b..41a619382 100644 --- a/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_deposits.sql +++ b/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_deposits.sql @@ -42,17 +42,21 @@ deposits AS ( ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, CONCAT('0x', SUBSTR(segmented_data [2] :: STRING, 25, 40)) AS referrer, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} l + {{ ref('core__fact_event_logs') }} l INNER JOIN vaults v ON l.contract_address = v.vault_address WHERE topics [0] :: STRING = '0x861a4138e41fb21c121a7dbb1053df465c837fc77380cc7226189a662281be2c' --Deposited/Stake - 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/liquid_staking/stakewise/silver_lsd__stakewise_v3_vaults.sql b/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_vaults.sql index 94edebecf..ac514e24a 100644 --- a/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_vaults.sql +++ b/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_vaults.sql @@ -13,15 +13,24 @@ WITH factories AS ( block_timestamp, from_address AS deployer_address, to_address AS factory_address, - _call_id, - _inserted_timestamp + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE from_address = '0x229f53ef905545aa53a721d82dbfe4ced7aff65d' --StakeWise: Deployer 1 AND TYPE ILIKE 'create%' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -47,19 +56,23 @@ vaults AS ( factory_address, CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS admin, CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS vault, - _log_id, - l._inserted_timestamp + CONCAT( + l.tx_hash, + '-', + l.event_index + ) AS _log_id, + l.modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} l INNER JOIN factories f ON l.contract_address = f.factory_address WHERE topics [0] :: STRING = '0x0d606510f33b5e566ed1ca2b9e88d388ab81cea532909665d725b33134516aff' --VaultCreated - 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/liquid_staking/stakewise/silver_lsd__stakewise_v3_withdrawals.sql b/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_withdrawals.sql index f6b511d5a..2a627cd20 100644 --- a/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_withdrawals.sql +++ b/models/silver/defi/liquid_staking/stakewise/silver_lsd__stakewise_v3_withdrawals.sql @@ -44,17 +44,21 @@ withdrawals AS ( segmented_data [1] :: STRING ) ) AS newPositionTicket, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} l + {{ ref('core__fact_event_logs') }} l INNER JOIN vaults v ON l.contract_address = v.vault_address WHERE topics [0] :: STRING = '0xeb3b05c070c24f667611fdb3ff75fe007d42401c573aed8d8faca95fd00ccb56' --ExitedAssetsClaimed/Unstake - 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/liquid_staking/swell/silver_lsd__swell_deposits.sql b/models/silver/defi/liquid_staking/swell/silver_lsd__swell_deposits.sql index 4ea1c5038..353b6739c 100644 --- a/models/silver/defi/liquid_staking/swell/silver_lsd__swell_deposits.sql +++ b/models/silver/defi/liquid_staking/swell/silver_lsd__swell_deposits.sql @@ -38,14 +38,18 @@ WITH deposits_t1 AS ( (amount / pow(10, 18)) :: FLOAT AS amount_adj, (swETHMinted / pow(10, 18)) :: FLOAT AS sweth_minted_adj, (newTotalETHDeposited / pow(10, 18)) :: FLOAT AS new_total_eth_deposited_adj, - _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 = '0xcb2ce03599937ff3d73e67e71a0f37013a6d3b697487823e37bc94da69483986' --ETHDepositReceived AND contract_address = '0xf951e335afb289353dc249e82926178eac7ded78' --swETH (swETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT @@ -88,14 +92,18 @@ deposits_t2 AS ( (amount / pow(10, 18)) :: FLOAT AS amount_adj, (swETHMinted / pow(10, 18)) :: FLOAT AS sweth_minted_adj, (newTotalETHDeposited / pow(10, 18)) :: FLOAT AS new_total_eth_deposited_adj, - _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 = '0xe28a9e1df63912c0c77b586c53595df741cbbc554d6831e40f1b5453199a9630' --ETHDepositReceived AND contract_address = '0xf951e335afb289353dc249e82926178eac7ded78' --swETH (swETH) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( SELECT diff --git a/models/silver/defi/liquid_staking/unieth/silver_lsd__unieth_deposits.sql b/models/silver/defi/liquid_staking/unieth/silver_lsd__unieth_deposits.sql index 75cef6397..2b6f14361 100644 --- a/models/silver/defi/liquid_staking/unieth/silver_lsd__unieth_deposits.sql +++ b/models/silver/defi/liquid_staking/unieth/silver_lsd__unieth_deposits.sql @@ -27,16 +27,20 @@ WITH deposit_logs AS ( ) ) AS token_amount, (token_amount / pow(10, 18)) :: FLOAT AS token_amount_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Deposit/Mint (Transfer) AND contract_address = '0xf1376bcef0f78459c0ed0ba5ddce976f1ddf51f4' --Universal ETH (uniETH) AND from_address = '0x0000000000000000000000000000000000000000' AND origin_to_address = '0x4befa2aa9c305238aa3e0b5d17eb20c045269e9d' --RockXStaking Proxy - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -54,15 +58,24 @@ deposit_traces AS ( tx_hash, from_address, to_address, - eth_value * pow( + value * pow( 10, 18 ) AS eth_amount, - eth_value AS eth_amount_adj, - _call_id, - _inserted_timestamp + value AS eth_amount_adj, + concat_ws( + '-', + block_number, + tx_position, + CONCAT( + type, + '_', + trace_address + ) + ) AS _call_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2022-09-29' AND tx_hash IN ( @@ -77,8 +90,8 @@ deposit_traces AS ( FROM deposit_logs ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded ) SELECT l.block_number, diff --git a/models/silver/defi/liquid_staking/unieth/silver_lsd__unieth_withdrawals.sql b/models/silver/defi/liquid_staking/unieth/silver_lsd__unieth_withdrawals.sql index 7567f3751..780d48740 100644 --- a/models/silver/defi/liquid_staking/unieth/silver_lsd__unieth_withdrawals.sql +++ b/models/silver/defi/liquid_staking/unieth/silver_lsd__unieth_withdrawals.sql @@ -27,16 +27,20 @@ WITH withdrawals AS ( ) ) AS amount, (amount / pow(10, 18)) :: FLOAT AS amount_adj, - _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 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Withdraw/Burn (Transfer) AND contract_address = '0xf1376bcef0f78459c0ed0ba5ddce976f1ddf51f4' --Universal ETH (uniETH) AND to_address = '0x0000000000000000000000000000000000000000' AND origin_to_address = '0x4befa2aa9c305238aa3e0b5d17eb20c045269e9d' --RockXStaking Proxy - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_liquidations.sql b/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_liquidations.sql index d3ab23412..322fa2238 100644 --- a/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_liquidations.sql +++ b/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_liquidations.sql @@ -15,17 +15,21 @@ WITH base AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :loanId :: STRING AS loanid, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS rn, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2021-08-30' AND contract_address IN ( diff --git a/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_loans.sql b/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_loans.sql index e56c826b4..7e335c88b 100644 --- a/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_loans.sql +++ b/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_loans.sql @@ -15,11 +15,15 @@ WITH base AS ( event_index, event_name, contract_address, - decoded_flat, - _log_id, - _inserted_timestamp + decoded_log AS decoded_flat, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2021-08-30' AND contract_address IN ( @@ -171,10 +175,10 @@ origination_fee AS ( SELECT tx_hash, trace_index, - decoded_data :function_name :: STRING AS function_name, - decoded_data :decoded_output_data :output_1 :: INT AS origination_fee_bps + full_decoded_data :function_name :: STRING AS function_name, + full_decoded_data :decoded_output_data :output_1 :: INT AS origination_fee_bps FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE block_timestamp :: DATE >= '2021-07-16' AND from_address IN ( @@ -192,8 +196,8 @@ origination_fee AS ( '0x4cccc5c5ef1d8c4a6ad6765a36651ef523e42e75' -- fee controller v1.2 ) AND function_name = 'getOriginationFee' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' qualify ROW_NUMBER() over ( + AND trace_succeeded + AND tx_succeeded qualify ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY trace_index ASC diff --git a/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_repayments.sql b/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_repayments.sql index feae2c91c..cee566566 100644 --- a/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_repayments.sql +++ b/models/silver/nft/lending/arcade_v1/silver_nft__arcade_v1_repayments.sql @@ -15,17 +15,21 @@ WITH base AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :loanId :: STRING AS loanid, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS rn, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2021-08-30' AND contract_address IN ( diff --git a/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_liquidations.sql b/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_liquidations.sql index 55ce2fa28..d945e40e6 100644 --- a/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_liquidations.sql +++ b/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_liquidations.sql @@ -15,17 +15,21 @@ WITH base AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :loanId :: STRING AS loanid, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS rn, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2022-06-20' AND contract_address IN ( diff --git a/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_loans.sql b/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_loans.sql index 848386536..a3345f2ec 100644 --- a/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_loans.sql +++ b/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_loans.sql @@ -9,10 +9,37 @@ WITH raw_traces AS ( SELECT - *, - decoded_data :function_name :: STRING AS function_name + block_number, + block_timestamp, + tx_hash, + tx_position, + trace_index, + from_address, + from_address_name, + to_address, + to_address_name, + input, + output, + function_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_input_data, + decoded_output_data, + TYPE, + sub_traces, + VALUE, + value_precise_raw, + value_precise, + gas, + gas_used, + trace_succeeded, + error_reason, + tx_succeeded, + fact_decoded_traces_id, + inserted_timestamp, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE block_timestamp :: DATE >= '2022-06-20' AND to_address IN ( @@ -37,8 +64,8 @@ WITH raw_traces AS ( 'getOriginationFee', 'getRolloverFee' ) - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -200,8 +227,8 @@ origination AS ( 'getOriginationFee', 'getRolloverFee' ) - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' qualify ROW_NUMBER() over ( + AND trace_succeeded + AND tx_succeeded qualify ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY trace_index ASC @@ -213,10 +240,14 @@ logs AS ( event_index, event_name, contract_address, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2022-06-20' AND contract_address IN ( diff --git a/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_repayments.sql b/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_repayments.sql index ba7836f90..cf59ee6a9 100644 --- a/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_repayments.sql +++ b/models/silver/nft/lending/arcade_v2/silver_nft__arcade_v2_repayments.sql @@ -15,17 +15,21 @@ WITH base AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :loanId :: STRING AS loanid, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS rn, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2022-06-20' AND contract_address IN ( diff --git a/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_liquidations.sql b/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_liquidations.sql index 77ec0d5d8..aa85e8c2a 100644 --- a/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_liquidations.sql +++ b/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_liquidations.sql @@ -15,17 +15,21 @@ WITH base AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :loanId :: STRING AS loanid, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS rn, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-08-29' AND contract_address IN ( diff --git a/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_loans.sql b/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_loans.sql index b0bafa0a9..889a5c6c1 100644 --- a/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_loans.sql +++ b/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_loans.sql @@ -9,10 +9,37 @@ WITH raw_traces AS ( SELECT - *, - decoded_data :function_name :: STRING AS function_name + block_number, + block_timestamp, + tx_hash, + tx_position, + trace_index, + from_address, + from_address_name, + to_address, + to_address_name, + input, + output, + function_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_input_data, + decoded_output_data, + TYPE, + sub_traces, + VALUE, + value_precise_raw, + value_precise, + gas, + gas_used, + trace_succeeded, + error_reason, + tx_succeeded, + fact_decoded_traces_id, + inserted_timestamp, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE block_timestamp :: DATE >= '2023-08-29' AND to_address IN ( @@ -35,8 +62,8 @@ WITH raw_traces AS ( 'getFeesRollover', 'getFeesOrigination' ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -317,12 +344,16 @@ logs AS ( event_name, event_index, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :loanId :: STRING AS loanid, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-08-29' AND contract_address = LOWER('0x89bc08BA00f135d608bc335f6B33D7a9ABCC98aF') -- loan core v3 diff --git a/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_repayments.sql b/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_repayments.sql index 0870d6111..74665bd63 100644 --- a/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_repayments.sql +++ b/models/silver/nft/lending/arcade_v3/silver_nft__arcade_v3_repayments.sql @@ -15,17 +15,21 @@ WITH base AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :loanId :: STRING AS loanid, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS rn, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-08-29' AND contract_address IN ( diff --git a/models/silver/nft/lending/blur/silver_nft__blend_liquidations.sql b/models/silver/nft/lending/blur/silver_nft__blend_liquidations.sql index 4f21ae0c6..26011d01a 100644 --- a/models/silver/nft/lending/blur/silver_nft__blend_liquidations.sql +++ b/models/silver/nft/lending/blur/silver_nft__blend_liquidations.sql @@ -23,12 +23,12 @@ WITH raw_traces AS ( segmented_data [buffer] :: STRING ) AS seize_count FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND TYPE = 'DELEGATECALL' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded AND from_address = '0x29469395eaf6f95920e59f858042f0e28d98a20b' AND to_address IN ( '0x97bdb4aed0b50a335a78ed24f68528ce3222af72', @@ -39,7 +39,7 @@ WITH raw_traces AS ( AND function_sig = '0x5b43226f' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -136,13 +136,17 @@ raw_logs AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :collection :: STRING AS collection_address, decoded_flat :lienId AS lienId, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND contract_address = '0x29469395eaf6f95920e59f858042f0e28d98a20b' diff --git a/models/silver/nft/lending/blur/silver_nft__blend_loans.sql b/models/silver/nft/lending/blur/silver_nft__blend_loans.sql index d40823728..6b059fdbf 100644 --- a/models/silver/nft/lending/blur/silver_nft__blend_loans.sql +++ b/models/silver/nft/lending/blur/silver_nft__blend_loans.sql @@ -11,17 +11,17 @@ WITH raw_logs AS ( SELECT * FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND contract_address = '0x29469395eaf6f95920e59f858042f0e28d98a20b' AND event_name IN ( 'Refinance' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -70,7 +70,7 @@ refinance_raw AS ( tx_hash, event_index, event_name, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :newAuctionDuration AS auction_duration_blocks, decoded_flat :newLender :: STRING AS lender_address, decoded_flat :lienId :: STRING AS lienid, @@ -83,8 +83,12 @@ refinance_raw AS ( ) AS interest_rate, NULL AS offerhash, 'refinance' AS event_type, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM raw_logs ), diff --git a/models/silver/nft/lending/blur/silver_nft__blend_new_loans.sql b/models/silver/nft/lending/blur/silver_nft__blend_new_loans.sql index 14f4c9c50..a4b6de3df 100644 --- a/models/silver/nft/lending/blur/silver_nft__blend_new_loans.sql +++ b/models/silver/nft/lending/blur/silver_nft__blend_new_loans.sql @@ -14,12 +14,16 @@ WITH raw_logs AS ( tx_hash, event_index, event_name, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :lienId :: STRING AS lienid, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND contract_address = '0x29469395eaf6f95920e59f858042f0e28d98a20b' @@ -27,7 +31,7 @@ WITH raw_logs AS ( 'LoanOfferTaken', 'Refinance' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/nft/lending/blur/silver_nft__blend_repayments.sql b/models/silver/nft/lending/blur/silver_nft__blend_repayments.sql index c131d63a3..1037904a2 100644 --- a/models/silver/nft/lending/blur/silver_nft__blend_repayments.sql +++ b/models/silver/nft/lending/blur/silver_nft__blend_repayments.sql @@ -24,11 +24,15 @@ repay_txs AS ( event_index, contract_address, event_name, - decoded_flat :lienId AS lienId, - _log_id, - _inserted_timestamp + decoded_log :lienId AS lienId, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND contract_address = '0x29469395eaf6f95920e59f858042f0e28d98a20b' @@ -87,11 +91,11 @@ traces_raw AS ( ) AS loan_start_timestamp, block_timestamp AS loan_paid_timestamp FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp >= '2023-05-01' AND TYPE = 'DELEGATECALL' - AND trace_status = 'SUCCESS' + AND trace_succeeded AND from_address = '0x29469395eaf6f95920e59f858042f0e28d98a20b' AND to_address IN ( SELECT @@ -111,7 +115,7 @@ traces_raw AS ( ) = '0x1b70b278' --computeCurrentDebt {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/lending/complete_lending/silver_nft__complete_liquidations.sql b/models/silver/nft/lending/complete_lending/silver_nft__complete_liquidations.sql index 782701b79..46d3667e3 100644 --- a/models/silver/nft/lending/complete_lending/silver_nft__complete_liquidations.sql +++ b/models/silver/nft/lending/complete_lending/silver_nft__complete_liquidations.sql @@ -321,12 +321,12 @@ tx_data AS ( origin_function_signature, tx_fee FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2020-05-01' {% if is_incremental() and 'transactions' not in var('HEAL_MODELS') %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}' FROM diff --git a/models/silver/nft/lending/complete_lending/silver_nft__complete_loans.sql b/models/silver/nft/lending/complete_lending/silver_nft__complete_loans.sql index 9919ab8c0..a4764c5cf 100644 --- a/models/silver/nft/lending/complete_lending/silver_nft__complete_loans.sql +++ b/models/silver/nft/lending/complete_lending/silver_nft__complete_loans.sql @@ -333,12 +333,12 @@ tx_data AS ( origin_function_signature, tx_fee FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2020-05-01' {% if is_incremental() and 'transactions' not in var('HEAL_MODELS') %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}' FROM diff --git a/models/silver/nft/lending/complete_lending/silver_nft__complete_repayments.sql b/models/silver/nft/lending/complete_lending/silver_nft__complete_repayments.sql index f2a86e06b..e29ddf5c8 100644 --- a/models/silver/nft/lending/complete_lending/silver_nft__complete_repayments.sql +++ b/models/silver/nft/lending/complete_lending/silver_nft__complete_repayments.sql @@ -339,12 +339,12 @@ tx_data AS ( origin_function_signature, tx_fee FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2020-05-01' {% if is_incremental() and 'transactions' not in var('HEAL_MODELS') %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}' FROM diff --git a/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_liquidations.sql b/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_liquidations.sql index ef1b75a8a..2cb839c61 100644 --- a/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_liquidations.sql +++ b/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_liquidations.sql @@ -18,7 +18,7 @@ WITH raw_logs AS ( 'nftfi' AS platform_name, contract_address AS platform_address, 'nftfi v1' AS platform_exchange_version, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :borrower :: STRING AS borrower_address, decoded_flat :lender :: STRING AS lender_address, decoded_flat :loanId AS loanId, @@ -31,8 +31,12 @@ WITH raw_logs AS ( decoded_flat :loanPrincipalAmount :: INT AS principal_unadj, decoded_flat :nftCollateralContract :: STRING AS nft_address, decoded_flat :nftCollateralId AS tokenId, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, CONCAT( loanid, '-', @@ -42,7 +46,7 @@ WITH raw_logs AS ( ['loanid', 'borrower_address', 'nft_address','tokenId','platform_exchange_version'] ) }} AS unique_loan_id FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2020-05-01' AND contract_address = '0x88341d1a8f672d2780c8dc725902aae72f143b0c' diff --git a/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_loans.sql b/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_loans.sql index f4c4818f0..284182a52 100644 --- a/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_loans.sql +++ b/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_loans.sql @@ -15,7 +15,7 @@ WITH raw_logs AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :borrower :: STRING AS borrower_address, decoded_flat :lender :: STRING AS lender_address, decoded_flat :interestIsProRated AS interest_is_prorated, @@ -50,10 +50,14 @@ WITH raw_logs AS ( ) AS interest_rate_bps, decoded_flat :nftCollateralContract :: STRING AS nft_address, decoded_flat :nftCollateralId :: STRING AS tokenid, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2020-05-01' AND contract_address = '0x88341d1a8f672d2780c8dc725902aae72f143b0c' diff --git a/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_repayments.sql b/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_repayments.sql index daa23d4a8..f08141ea0 100644 --- a/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_repayments.sql +++ b/models/silver/nft/lending/nftfi_v1/silver_nft__nftfi_v1_repayments.sql @@ -18,7 +18,7 @@ WITH raw_logs AS ( 'nftfi' AS platform_name, contract_address AS platform_address, 'nftfi v1' AS platform_exchange_version, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :adminFee :: INT AS platform_fee_unadj, decoded_flat :amountPaidToLender :: INT AS amount_paid_to_lender, amount_paid_to_lender + platform_fee_unadj AS debt_unadj, @@ -29,8 +29,12 @@ WITH raw_logs AS ( decoded_flat: loanPrincipalAmount :: INT AS principal_unadj, decoded_flat :nftCollateralContract :: STRING AS nft_address, decoded_flat: nftCollateralId :: STRING AS tokenId, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, CONCAT( loanid, '-', @@ -40,7 +44,7 @@ WITH raw_logs AS ( ['loanid', 'borrower_address', 'nft_address','tokenId','platform_exchange_version'] ) }} AS unique_loan_id FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2020-05-01' AND contract_address = '0x88341d1a8f672d2780c8dc725902aae72f143b0c' diff --git a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_liquidations.sql b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_liquidations.sql index e1da92b9b..a62a1ebaa 100644 --- a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_liquidations.sql +++ b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_liquidations.sql @@ -18,7 +18,7 @@ WITH raw_logs AS ( 'nftfi' AS platform_name, contract_address AS platform_address, 'nftfi v2' AS platform_exchange_version, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :borrower :: STRING AS borrower_address, decoded_flat :lender :: STRING AS lender_address, decoded_flat :loanId AS loanid, @@ -31,8 +31,12 @@ WITH raw_logs AS ( decoded_flat :loanPrincipalAmount :: INT AS principal_unadj, decoded_flat :nftCollateralContract :: STRING AS nft_address, decoded_flat :nftCollateralId :: STRING AS tokenId, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, CONCAT( loanid, '-', @@ -42,7 +46,7 @@ WITH raw_logs AS ( ['loanid', 'borrower_address', 'nft_address','tokenId','platform_exchange_version'] ) }} AS unique_loan_id FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2022-03-01' AND contract_address IN ( diff --git a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_loans.sql b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_loans.sql index 16848a74a..15229413a 100644 --- a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_loans.sql +++ b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_loans.sql @@ -11,7 +11,7 @@ WITH raw_logs AS ( SELECT * FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2022-03-01' AND contract_address IN ( @@ -26,7 +26,7 @@ WITH raw_logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -42,7 +42,7 @@ renegotiated AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :borrower :: STRING AS borrower_address, decoded_flat :lender :: STRING AS lender_address, decoded_flat :loanId :: STRING AS loanId, @@ -50,8 +50,12 @@ renegotiated AS ( decoded_flat :newMaximumRepaymentAmount :: INT AS new_debt_amount, decoded_flat :renegotiationAdminFee :: INT AS renegotiationAdminFee, decoded_flat :renegotiationFee :: INT AS renegotiationFee, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM raw_logs ), diff --git a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_new_loans.sql b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_new_loans.sql index 7e017817f..52d9f9b6b 100644 --- a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_new_loans.sql +++ b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_new_loans.sql @@ -11,7 +11,7 @@ WITH raw_logs AS ( SELECT * FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2022-03-01' AND contract_address IN ( @@ -26,7 +26,7 @@ WITH raw_logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -85,7 +85,7 @@ loan_started AS ( tx_hash, event_index, event_name, - decoded_flat, + decoded_log AS decoded_flat, contract_address, decoded_flat :borrower :: STRING AS temp_borrower_address, decoded_flat :lender :: STRING AS lender_address, @@ -111,8 +111,12 @@ loan_started AS ( decoded_flat :loanTerms :nftCollateralContract :: STRING AS nft_address, decoded_flat :loanTerms :nftCollateralId :: STRING AS tokenid, decoded_flat :loanTerms :nftCollateralWrapper :: STRING AS nft_collateral_wrapper, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM raw_logs WHERE diff --git a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_obligation_receipts.sql b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_obligation_receipts.sql index 3d95e5301..058e52625 100644 --- a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_obligation_receipts.sql +++ b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_obligation_receipts.sql @@ -12,21 +12,21 @@ SELECT tx_hash, trace_index, utils.udf_hex_to_int( - decoded_data :decoded_input_data :_data :: STRING + full_decoded_data :decoded_input_data :_data :: STRING ) :: STRING AS loanid, - decoded_data :decoded_input_data :_to :: STRING AS mint_to_address, + full_decoded_data :decoded_input_data :_to :: STRING AS mint_to_address, to_address AS obligation_receipt_address, - decoded_data :decoded_input_data :_tokenId :: STRING AS tokenid, - _inserted_timestamp + full_decoded_data :decoded_input_data :_tokenId :: STRING AS tokenid, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE block_timestamp :: DATE >= '2023-11-04' - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded AND TYPE = 'CALL' AND to_address = '0xaabd3ebcc6ae1e87150c6184c038b94dc01a7708' -- obligation receipt - AND decoded_data :function_name :: STRING = 'mint' + AND full_decoded_data :function_name :: STRING = 'mint' {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_repayments.sql b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_repayments.sql index 04c90893d..6ba8ef653 100644 --- a/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_repayments.sql +++ b/models/silver/nft/lending/nftfi_v2/silver_nft__nftfi_v2_repayments.sql @@ -18,7 +18,7 @@ WITH raw_logs AS ( 'nftfi' AS platform_name, contract_address AS platform_address, 'nftfi v2' AS platform_exchange_version, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :adminFee :: INT AS platform_fee_unadj, decoded_flat :amountPaidToLender :: INT AS amount_paid_to_lender, amount_paid_to_lender + platform_fee_unadj AS debt_unadj, @@ -31,15 +31,19 @@ WITH raw_logs AS ( decoded_flat :nftCollateralId AS tokenId, decoded_flat :revenueShare AS revenueShare, decoded_flat :revenueSharePartner :: STRING AS revenueSharePartner, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, CONCAT( loanid, '-', _log_id ) AS nft_lending_id FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2022-03-01' AND contract_address IN ( diff --git a/models/silver/nft/mev/arbitrage/silver_nft__arbitrage_raw.sql b/models/silver/nft/mev/arbitrage/silver_nft__arbitrage_raw.sql index 8c95a9243..29594ffb6 100644 --- a/models/silver/nft/mev/arbitrage/silver_nft__arbitrage_raw.sql +++ b/models/silver/nft/mev/arbitrage/silver_nft__arbitrage_raw.sql @@ -298,15 +298,15 @@ SELECT tx_hash, event_index AS np_flashloan_event_index FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = LOWER('0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e') AND block_timestamp :: DATE >= '2021-01-01' AND topics [0] :: STRING = '0xbc83c08f0b269b1726990c8348ffdf1ae1696244a14868d766e542a2f18cd7d4' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/mev/arbitrage/silver_nft__arbitrage_trades.sql b/models/silver/nft/mev/arbitrage/silver_nft__arbitrage_trades.sql index f77cb4291..08db2ab8a 100644 --- a/models/silver/nft/mev/arbitrage/silver_nft__arbitrage_trades.sql +++ b/models/silver/nft/mev/arbitrage/silver_nft__arbitrage_trades.sql @@ -335,7 +335,7 @@ blocks AS ( block_number, miner FROM - {{ ref('silver__blocks') }} + {{ ref('core__fact_blocks') }} WHERE block_timestamp :: DATE >= '2021-01-01' AND block_number IN ( @@ -346,7 +346,7 @@ blocks AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/artblocks/silver_nft__artblocks_base_sales.sql b/models/silver/nft/sales/artblocks/silver_nft__artblocks_base_sales.sql index dc931b212..fe31dc05f 100644 --- a/models/silver/nft/sales/artblocks/silver_nft__artblocks_base_sales.sql +++ b/models/silver/nft/sales/artblocks/silver_nft__artblocks_base_sales.sql @@ -74,7 +74,7 @@ raw_traces AS ( regexp_substr_all(SUBSTR(input, 11, len(input)), '.{64}') AS segmented_input, regexp_substr_all(SUBSTR(output, 3, len(output)), '.{64}') AS segmented_output FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2020-11-01' AND to_address IN ( @@ -83,7 +83,7 @@ raw_traces AS ( FROM all_address ) - AND trace_status = 'SUCCESS' + AND trace_succeeded AND ( function_sig IN ( SELECT @@ -99,7 +99,7 @@ raw_traces AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -117,8 +117,8 @@ purchase_function AS ( trace_index, from_address, to_address, - eth_value, - eth_value_precise, + value AS eth_value, + value_precise AS eth_value_precise, function_sig, segmented_input, to_address AS purchase_contract, @@ -219,10 +219,14 @@ pre_settlement_nft_mints AS ( ORDER BY event_index ASC ) AS row_num, - _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 block_timestamp :: DATE >= '2020-11-01' AND contract_address IN ( diff --git a/models/silver/nft/sales/artblocks/silver_nft__artblocks_sales.sql b/models/silver/nft/sales/artblocks/silver_nft__artblocks_sales.sql index 8e22fcfa5..722eaed02 100644 --- a/models/silver/nft/sales/artblocks/silver_nft__artblocks_sales.sql +++ b/models/silver/nft/sales/artblocks/silver_nft__artblocks_sales.sql @@ -237,12 +237,12 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2020-11-01' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__blur_blend_sales.sql b/models/silver/nft/sales/silver_nft__blur_blend_sales.sql index d06dbfce3..8ef1324cd 100644 --- a/models/silver/nft/sales/silver_nft__blur_blend_sales.sql +++ b/models/silver/nft/sales/silver_nft__blur_blend_sales.sql @@ -22,7 +22,7 @@ WITH raw_traces AS ( ) AS function_sig, regexp_substr_all(SUBSTR(input, 11), '.{64}') AS segmented_data FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp >= '2023-05-01' AND from_address = '0x29469395eaf6f95920e59f858042f0e28d98a20b' @@ -33,7 +33,7 @@ WITH raw_traces AS ( '0xb258ca5559b11cd702f363796522b04d7722ea56' -- latest ) AND TYPE = 'DELEGATECALL' - AND trace_status = 'SUCCESS' + AND trace_succeeded AND function_sig IN ( '0xe7efc178', -- buyLocked @@ -45,7 +45,7 @@ WITH raw_traces AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -254,7 +254,7 @@ raw_logs AS ( event_index, event_name, contract_address, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :lienId :: STRING AS logs_lienId, decoded_flat :collection :: STRING AS logs_nft_address, decoded_flat :tokenId :: STRING AS logs_tokenId, @@ -266,17 +266,21 @@ raw_logs AS ( ORDER BY event_index ASC ) AS intra_tx_grouping, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2023-05-01' AND contract_address = '0x29469395eaf6f95920e59f858042f0e28d98a20b' AND event_name IN ( 'BuyLocked' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -337,7 +341,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND tx_hash IN ( @@ -348,7 +352,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__blur_decoded_sales.sql b/models/silver/nft/sales/silver_nft__blur_decoded_sales.sql index c7aea1899..327b85e4a 100644 --- a/models/silver/nft/sales/silver_nft__blur_decoded_sales.sql +++ b/models/silver/nft/sales/silver_nft__blur_decoded_sales.sql @@ -14,8 +14,8 @@ WITH base AS ( event_index, event_name, contract_address, - decoded_data, - decoded_flat, + full_decoded_log AS decoded_data, + decoded_log AS decoded_flat, decoded_flat: maker :: STRING AS maker, decoded_flat: taker :: STRING AS taker, decoded_flat: sell :trader :: STRING AS seller_address, @@ -40,10 +40,14 @@ WITH base AS ( '-', tokenId ) AS tx_nft_id, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2022-10-15' AND block_number >= 15779873 @@ -135,7 +139,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2022-10-01' AND tx_hash IN ( @@ -146,7 +150,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__blur_v2.sql b/models/silver/nft/sales/silver_nft__blur_v2.sql index 8d770dfdd..deff08580 100644 --- a/models/silver/nft/sales/silver_nft__blur_v2.sql +++ b/models/silver/nft/sales/silver_nft__blur_v2.sql @@ -13,8 +13,8 @@ WITH blur_v2_tx AS ( block_timestamp, tx_hash, event_index, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT(tx_hash, '-', event_index) AS _log_id, event_name, ROW_NUMBER() over ( PARTITION BY tx_hash @@ -22,7 +22,7 @@ WITH blur_v2_tx AS ( event_index ASC ) AS intra_tx_grouping FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp >= '2023-07-01' AND contract_address = '0xb2ecfe4e4d61f8790bbb9de2d1259b9e2410cea5' @@ -72,12 +72,12 @@ blur_v2_traces AS ( ) = '0xda815cb5' THEN 'takeBidSingle' END AS function_name FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp >= '2023-07-01' AND to_address = '0x5fa60726e62c50af45ff2f6280c468da438a7837' AND TYPE = 'DELEGATECALL' - AND trace_status = 'SUCCESS' + AND trace_succeeded AND LEFT( input, 10 @@ -102,7 +102,7 @@ blur_v2_traces AS ( ) -- some transactions have calldata to the contract but no actual sale took place. This excludes those tx {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1195,7 +1195,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2023-07-01' AND tx_hash IN ( @@ -1206,7 +1206,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__cryptopunk_bids.sql b/models/silver/nft/sales/silver_nft__cryptopunk_bids.sql index f293366d2..834fa22bb 100644 --- a/models/silver/nft/sales/silver_nft__cryptopunk_bids.sql +++ b/models/silver/nft/sales/silver_nft__cryptopunk_bids.sql @@ -27,17 +27,21 @@ WITH base AS ( DATA :: STRING ) :: INT ) AS bid_value, - _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 block_timestamp :: DATE >= '2017-06-20' AND contract_address = '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb' AND topics [0] :: STRING IN ( '0x5b859394fabae0c1ba88baffe67e751ab5248d2e879028b8c8d6897b0519f56a' -- PunkBidEntered ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/nft/sales/silver_nft__cryptopunk_sales.sql b/models/silver/nft/sales/silver_nft__cryptopunk_sales.sql index 3a6f03670..1b95082b8 100644 --- a/models/silver/nft/sales/silver_nft__cryptopunk_sales.sql +++ b/models/silver/nft/sales/silver_nft__cryptopunk_sales.sql @@ -11,7 +11,7 @@ WITH raw_traces AS ( SELECT block_number, block_timestamp, - _inserted_timestamp, + modified_timestamp AS _inserted_timestamp, tx_hash, trace_index, from_address, @@ -38,19 +38,18 @@ WITH raw_traces AS ( 0 ) AS accepted_bid_price, TYPE, - identifier, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY trace_index ASC ) AS buy_index FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2017-06-20' AND to_address = '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb' -- cryptopunksMarket - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded AND function_sig IN ( '0x23165b75', '0x8264fe98' @@ -73,19 +72,23 @@ raw_logs AS ( event_index, topics, DATA, - _log_id + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2017-06-20' AND contract_address = '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb' AND topics [0] :: STRING IN ( '0x58e5d5a525e3b40bc15abaa38b5882678db1ee68befd2f60bafe3a7fd06db9e3' -- punk bought ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -262,7 +265,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2017-06-20' AND tx_hash IN ( @@ -273,7 +276,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__element_sales.sql b/models/silver/nft/sales/silver_nft__element_sales.sql index 26fd4152d..e31fe59e3 100644 --- a/models/silver/nft/sales/silver_nft__element_sales.sql +++ b/models/silver/nft/sales/silver_nft__element_sales.sql @@ -20,7 +20,7 @@ raw AS ( tx_hash, event_index, event_name, - decoded_flat, + decoded_log AS decoded_flat, IFF( event_name LIKE '%Buy%', 'bid_won', @@ -66,10 +66,14 @@ raw AS ( ) AS intra_grouping_seller_fill, block_timestamp, block_number, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= ( SELECT @@ -182,7 +186,7 @@ old_eth_transfers AS ( trace_index, from_address, to_address, - eth_value, + value AS eth_value, eth_value * pow( 10, 18 @@ -198,7 +202,7 @@ old_eth_transfers AS ( 0 ) AS intra_grouping FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= ( SELECT @@ -244,11 +248,11 @@ old_eth_transfers AS ( ) AND TYPE = 'CALL' AND eth_value > 0 - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -543,7 +547,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= ( SELECT @@ -559,7 +563,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__looksrare_decoded_sales.sql b/models/silver/nft/sales/silver_nft__looksrare_decoded_sales.sql index dde82ef45..eea7fad7b 100644 --- a/models/silver/nft/sales/silver_nft__looksrare_decoded_sales.sql +++ b/models/silver/nft/sales/silver_nft__looksrare_decoded_sales.sql @@ -9,9 +9,38 @@ WITH raw_decoded_logs AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + event_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_log, + decoded_log AS decoded_flat, + contract_name, + ez_decoded_event_logs_id, + inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_number >= 13885625 AND contract_address = '0x59728544b08ab483533076417fbbb2fd0b17ce3a' @@ -195,7 +224,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2021-12-20' AND tx_hash IN ( @@ -206,7 +235,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__looksrare_v2.sql b/models/silver/nft/sales/silver_nft__looksrare_v2.sql index db5909df9..446955317 100644 --- a/models/silver/nft/sales/silver_nft__looksrare_v2.sql +++ b/models/silver/nft/sales/silver_nft__looksrare_v2.sql @@ -9,9 +9,38 @@ WITH raw_decoded_logs AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + event_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_log, + decoded_log AS decoded_flat, + contract_name, + ez_decoded_event_logs_id, + inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_number >= 16824890 AND contract_address = '0x0000000000e655fae4d56241588680f86e3b2377' @@ -205,7 +234,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2023-03-01' AND tx_hash IN ( @@ -216,7 +245,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__magiceden_sales.sql b/models/silver/nft/sales/silver_nft__magiceden_sales.sql index fe1d692ef..baa5b6efe 100644 --- a/models/silver/nft/sales/silver_nft__magiceden_sales.sql +++ b/models/silver/nft/sales/silver_nft__magiceden_sales.sql @@ -17,12 +17,12 @@ WITH decoded_trace AS ( input, 10 ) AS function_sig, - decoded_data :function_name :: STRING AS function_name, - decoded_data :decoded_input_data AS decoded_input, + full_decoded_data :function_name :: STRING AS function_name, + full_decoded_data :decoded_input_data AS decoded_input, input, regexp_substr_all(SUBSTR(input, 11, len(input)), '.{64}') AS segmented_input FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE block_timestamp :: DATE >= '2024-02-04' AND to_address IN ( @@ -42,10 +42,10 @@ WITH decoded_trace AS ( 'acceptOffer', 'sweepCollection' ) - AND trace_status = 'SUCCESS' + AND trace_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "12 hours") }}' FROM @@ -76,15 +76,15 @@ raw_traces AS ( ) AS function_sig, from_address, to_address, - eth_value, + value AS eth_value, input, output, regexp_substr_all(SUBSTR(input, 11, len(input)), '.{64}') AS segmented_input, regexp_substr_all(SUBSTR(output, 3, len(output)), '.{64}') AS segmented_output, - trace_status, + trace_succeeded, TYPE FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE tx_hash IN ( SELECT @@ -106,7 +106,7 @@ raw_traces AS ( AND from_address = LOWER('0x9A1D00bEd7CD04BCDA516d721A596eb22Aac6834') -- payment processor {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "12 hours") }}' FROM @@ -126,7 +126,7 @@ royalty_trace AS ( segmented_input [0] ) :: STRING AS trace_tokenId, IFF( - trace_status = 'FAIL', + NOT trace_succeeded, '0x0000000000000000000000000000000000000000', '0x' || SUBSTR( segmented_output [0] :: STRING, @@ -134,7 +134,7 @@ royalty_trace AS ( ) ) AS trace_royalty_receiver, IFF( - trace_status = 'FAIL', + NOT trace_succeeded, 0, utils.udf_hex_to_int( segmented_output [1] @@ -158,21 +158,25 @@ raw_events AS ( event_index, contract_address, event_name, - decoded_flat :seller :: STRING AS seller_address, - decoded_flat :buyer :: STRING AS buyer_address, - decoded_flat :tokenAddress :: STRING AS event_nft_address, - decoded_flat :tokenId :: STRING AS event_tokenid, - decoded_flat :amount :: STRING AS event_erc1155_value, - decoded_flat :salePrice :: INT AS event_sale_amount, + decoded_log :seller :: STRING AS seller_address, + decoded_log :buyer :: STRING AS buyer_address, + decoded_log :tokenAddress :: STRING AS event_nft_address, + decoded_log :tokenId :: STRING AS event_tokenid, + decoded_log :amount :: STRING AS event_erc1155_value, + decoded_log :salePrice :: INT AS event_sale_amount, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS intra_tx_grouping, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE contract_address = '0x9a1d00bed7cd04bcda516d721a596eb22aac6834' -- payment processor AND block_timestamp :: DATE >= '2024-02-04' @@ -571,7 +575,7 @@ royalty_for_tokens_raw AS ( segmented_input, segmented_output, TYPE, - trace_status, + trace_succeeded, function_sig, IFF(LEFT(input, 10) = '0x2a55205a', ROW_NUMBER() over (PARTITION BY tx_hash ORDER BY @@ -638,7 +642,7 @@ token_transfer_tags AS ( grouping_fill WHERE segmented_output IS NOT NULL - AND trace_status = 'SUCCESS' + AND trace_succeeded AND TYPE = 'CALL' AND eth_value = 0 AND function_sig = '0x23b872dd' @@ -696,7 +700,7 @@ eth_transfer_tags AS ( grouping_fill WHERE segmented_output IS NULL - AND trace_status = 'SUCCESS' + AND trace_succeeded AND TYPE = 'CALL' AND eth_value > 0 AND function_sig IN ( @@ -819,7 +823,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2024-02-04' AND tx_hash IN ( @@ -830,7 +834,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "12 hours") }}' FROM diff --git a/models/silver/nft/sales/silver_nft__nftx_decoded_sales.sql b/models/silver/nft/sales/silver_nft__nftx_decoded_sales.sql index 99f723feb..42e837420 100644 --- a/models/silver/nft/sales/silver_nft__nftx_decoded_sales.sql +++ b/models/silver/nft/sales/silver_nft__nftx_decoded_sales.sql @@ -24,7 +24,7 @@ direct_vault_redeems AS ( SELECT tx_hash FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE origin_function_signature = '0xc4a0db96' AND block_number >= 12676663 @@ -36,7 +36,7 @@ direct_vault_redeems AS ( ) {% if is_incremental() %} -AND TO_TIMESTAMP_NTZ(_inserted_timestamp) >= ( +AND TO_TIMESTAMP_NTZ(modified_timestamp) >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -46,9 +46,38 @@ AND TO_TIMESTAMP_NTZ(_inserted_timestamp) >= ( ), raw_decoded_logs AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + event_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_log, + decoded_log AS decoded_flat, + contract_name, + ez_decoded_event_logs_id, + inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_number >= 12676663 @@ -527,9 +556,9 @@ swap_nft_for_eth_logs AS ( 'Minted' AS event_name, 'sale' AS event_type, _log_id, - TO_TIMESTAMP_NTZ(_inserted_timestamp) AS _inserted_timestamp + TO_TIMESTAMP_NTZ(modified_timestamp) AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp >= '2021-06-01' AND contract_address IN ( @@ -672,7 +701,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp >= '2021-06-01' AND block_number >= 12676663 @@ -684,7 +713,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND TO_TIMESTAMP_NTZ(_inserted_timestamp) >= ( +AND TO_TIMESTAMP_NTZ(modified_timestamp) >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__nftx_vaults.sql b/models/silver/nft/sales/silver_nft__nftx_vaults.sql index 9c2652979..2ade50481 100644 --- a/models/silver/nft/sales/silver_nft__nftx_vaults.sql +++ b/models/silver/nft/sales/silver_nft__nftx_vaults.sql @@ -7,12 +7,12 @@ WITH vaults AS ( SELECT - decoded_flat :assetAddress :: STRING AS nft_address, - decoded_flat :vaultAddress :: STRING AS vault_address, - decoded_flat :vaultId :: STRING AS vault_id, - _inserted_timestamp + decoded_log :assetAddress :: STRING AS nft_address, + decoded_log :vaultAddress :: STRING AS vault_address, + decoded_log :vaultId :: STRING AS vault_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_number >= 12676663 AND contract_address = '0xbe86f647b167567525ccaafcd6f881f1ee558216' diff --git a/models/silver/nft/sales/silver_nft__rarible_decoded_sales.sql b/models/silver/nft/sales/silver_nft__rarible_decoded_sales.sql index 44529b64d..a40738f0a 100644 --- a/models/silver/nft/sales/silver_nft__rarible_decoded_sales.sql +++ b/models/silver/nft/sales/silver_nft__rarible_decoded_sales.sql @@ -22,9 +22,38 @@ WITH rarible_treasury_wallets AS ( ), raw_decoded_logs AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + event_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_log, + decoded_log AS decoded_flat, + contract_name, + ez_decoded_event_logs_id, + inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_number >= 11274515 @@ -45,7 +74,7 @@ v1_base_logs AS ( event_name, contract_address, decoded_data, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :buyer :: STRING AS buyer_temp, decoded_flat :owner :: STRING AS seller_temp, decoded_flat :amount AS amount, @@ -91,15 +120,19 @@ raw_traces AS ( SELECT * FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_number >= 11274515 - AND identifier != 'CALL_ORIGIN' - AND eth_value > 0 + AND concat_ws( + '_', + TYPE, + trace_address + ) != 'CALL_ORIGIN' + AND value > 0 AND TYPE = 'CALL' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -117,7 +150,7 @@ v1_payment_eth AS ( ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY - eth_value DESC + value DESC ) AS price_rank, CASE WHEN to_address IN ( @@ -125,20 +158,20 @@ v1_payment_eth AS ( address FROM rarible_treasury_wallets - ) THEN eth_value + ) THEN value ELSE 0 END AS treasury_label, CASE WHEN treasury_label = 0 - AND price_rank = 1 THEN eth_value + AND price_rank = 1 THEN value ELSE 0 END AS price_label, CASE WHEN treasury_label = 0 - AND price_rank != 1 THEN eth_value + AND price_rank != 1 THEN value ELSE 0 END AS royalty_label, - eth_value + value AS eth_value FROM raw_traces WHERE @@ -437,13 +470,13 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp >= '2020-11-01' AND block_number >= 11274515 {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__rarible_v2_sales.sql b/models/silver/nft/sales/silver_nft__rarible_v2_sales.sql index 601ec348f..85ecb92b4 100644 --- a/models/silver/nft/sales/silver_nft__rarible_v2_sales.sql +++ b/models/silver/nft/sales/silver_nft__rarible_v2_sales.sql @@ -9,10 +9,37 @@ WITH raw AS ( SELECT - *, - decoded_data :function_name :: STRING AS function_name + block_number, + block_timestamp, + tx_hash, + tx_position, + trace_index, + from_address, + from_address_name, + to_address, + to_address_name, + input, + output, + function_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_input_data, + decoded_output_data, + TYPE, + sub_traces, + VALUE, + value_precise_raw, + value_precise, + gas, + gas_used, + trace_succeeded, + error_reason, + tx_succeeded, + fact_decoded_traces_id, + inserted_timestamp, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE block_timestamp :: DATE >= '2021-06-01' AND to_address = '0x9757f2d2b135150bbeb65308d4a91804107cd8d6' @@ -21,8 +48,8 @@ WITH raw AS ( 'directAcceptBid', 'directPurchase' ) - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -692,7 +719,7 @@ match_orders_raw AS ( from_address AS origin_sender, to_address, FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2021-06-01' AND block_timestamp <= '2021-07-28 14:41:59.000' @@ -709,8 +736,8 @@ match_orders_raw AS ( input, 10 ) = '0xe99a3f80' - AND tx_status = 'SUCCESS' - AND trace_status = 'SUCCESS' + AND tx_succeeded + AND trace_succeeded AND to_address = '0x9757f2d2b135150bbeb65308d4a91804107cd8d6' ), unverified_nft_transfers AS ( @@ -872,7 +899,7 @@ payment_transfers AS ( trace_index, from_address, to_address, - eth_value, + value AS eth_value, regexp_substr_all(SUBSTR(input, 11, len(input)), '.{64}') AS segmented_input, LEFT( input, @@ -917,7 +944,7 @@ payment_transfers AS ( NULL ) AS intra_grouping_raw FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE >= '2021-06-01' AND ( @@ -933,8 +960,8 @@ payment_transfers AS ( AND eth_value > 0 ) ) - AND trace_status = 'SUCCESS' - AND tx_status = 'SUCCESS' + AND trace_succeeded + AND tx_succeeded AND function_sig IN ( '0x776062c3', -- erc20 transfer @@ -948,7 +975,7 @@ payment_transfers AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1097,10 +1124,14 @@ logs AS ( ) AS intra_grouping, block_number, block_timestamp, - _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 block_timestamp :: DATE >= '2021-06-01' AND contract_address = '0x9757f2d2b135150bbeb65308d4a91804107cd8d6' @@ -1108,7 +1139,7 @@ logs AS ( '0x268820db288a211986b26a8fda86b1e0046281b21206936bb0e61c67b5c79ef4', '0x956cd63ee4cdcd81fda5f0ec7c6c36dceda99e1b412f4a650a5d26055dc3c450' ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -1130,7 +1161,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2021-06-01' AND tx_hash IN ( @@ -1141,7 +1172,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__seaport_1_1_sales.sql b/models/silver/nft/sales/silver_nft__seaport_1_1_sales.sql index 0a1aeb2db..b33053d29 100644 --- a/models/silver/nft/sales/silver_nft__seaport_1_1_sales.sql +++ b/models/silver/nft/sales/silver_nft__seaport_1_1_sales.sql @@ -23,14 +23,14 @@ seaport_tx_table AS ( block_timestamp, tx_hash FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp >= '2022-06-01' AND contract_address = '0x00000000006c3852cbef3e08e8df289169ede581' AND topics [0] = '0x9d9af8e38d66c62e2c12f0225249fd9d721c54b83f48d9352c97c6cacdcb6f31' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -41,11 +41,15 @@ AND _inserted_timestamp >= ( decoded AS ( SELECT tx_hash, - decoded_flat, + decoded_log AS decoded_flat, event_index, - decoded_data, - _log_id, - _inserted_timestamp, + full_decoded_log AS decoded_data, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, LOWER( decoded_data :address :: STRING ) AS contract_address, @@ -59,7 +63,7 @@ decoded AS ( ELSE NULL END AS trade_type FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_number >= 14000000 AND contract_address = '0x00000000006c3852cbef3e08e8df289169ede581' @@ -1035,7 +1039,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2022-06-01' AND tx_hash IN ( @@ -1046,7 +1050,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1072,7 +1076,7 @@ nft_transfer_operator AS ( ) ) AS erc1155_value FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2022-06-01' AND tx_hash IN ( @@ -1087,7 +1091,7 @@ nft_transfer_operator AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__seaport_1_4_sales.sql b/models/silver/nft/sales/silver_nft__seaport_1_4_sales.sql index 6016c1e69..7c7c5ec1d 100644 --- a/models/silver/nft/sales/silver_nft__seaport_1_4_sales.sql +++ b/models/silver/nft/sales/silver_nft__seaport_1_4_sales.sql @@ -20,9 +20,38 @@ WITH seaport_fees_wallet AS ( ), raw_decoded_logs AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + event_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_log, + decoded_log AS decoded_flat, + contract_name, + ez_decoded_event_logs_id, + inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_number >= 16530300 AND contract_address = '0x00000000000001ad428e4906ae43d8f9852d0dd6' @@ -81,13 +110,13 @@ raw_logs AS ( SELECT * FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number >= 16530300 AND contract_address = '0x00000000000001ad428e4906ae43d8f9852d0dd6' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1640,7 +1669,7 @@ mao_orderhash AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2023-02-01' AND tx_hash IN ( @@ -1651,7 +1680,7 @@ mao_orderhash AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1677,7 +1706,7 @@ nft_transfer_operator AS ( ) ) AS erc1155_value FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2022-06-01' AND tx_hash IN ( @@ -1692,7 +1721,7 @@ nft_transfer_operator AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__seaport_1_5_sales.sql b/models/silver/nft/sales/silver_nft__seaport_1_5_sales.sql index 653d70e06..566b4a0ce 100644 --- a/models/silver/nft/sales/silver_nft__seaport_1_5_sales.sql +++ b/models/silver/nft/sales/silver_nft__seaport_1_5_sales.sql @@ -20,11 +20,40 @@ WITH seaport_fees_wallet AS ( ), raw_decoded_logs AS ( SELECT - *, + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + event_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_log, + decoded_log AS decoded_flat, + contract_name, + ez_decoded_event_logs_id, + inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, decoded_flat :orderHash :: STRING AS orderhash, tx_hash || '-' || decoded_flat :orderHash AS tx_hash_orderhash FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2023-04-25' AND block_number >= 17129530 @@ -65,7 +94,7 @@ raw_logs AS ( NULL ) AS order_hash FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2023-04-25' AND block_number >= 17129530 @@ -77,7 +106,7 @@ raw_logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1852,7 +1881,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2023-04-01' AND tx_hash IN ( @@ -1863,7 +1892,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1889,7 +1918,7 @@ nft_transfer_operator AS ( ) ) AS erc1155_value FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2022-06-01' AND tx_hash IN ( @@ -1904,7 +1933,7 @@ nft_transfer_operator AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__seaport_1_6_sales.sql b/models/silver/nft/sales/silver_nft__seaport_1_6_sales.sql index e2ce4db2f..cc5c55254 100644 --- a/models/silver/nft/sales/silver_nft__seaport_1_6_sales.sql +++ b/models/silver/nft/sales/silver_nft__seaport_1_6_sales.sql @@ -20,11 +20,40 @@ WITH seaport_fees_wallet AS ( ), raw_decoded_logs AS ( SELECT - *, + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + event_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_log, + decoded_log AS decoded_flat, + contract_name, + ez_decoded_event_logs_id, + inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, decoded_flat :orderHash :: STRING AS orderhash, tx_hash || '-' || decoded_flat :orderHash AS tx_hash_orderhash FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2024-03-15' AND block_number >= 19442152 @@ -65,7 +94,7 @@ raw_logs AS ( NULL ) AS order_hash FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2024-03-15' AND block_number >= 19442152 @@ -77,7 +106,7 @@ raw_logs AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1852,7 +1881,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2024-03-15' AND tx_hash IN ( @@ -1863,7 +1892,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -1889,7 +1918,7 @@ nft_transfer_operator AS ( ) ) AS erc1155_value FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE >= '2024-03-15' AND tx_hash IN ( @@ -1904,7 +1933,7 @@ nft_transfer_operator AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__wyvern_decoded_sales.sql b/models/silver/nft/sales/silver_nft__wyvern_decoded_sales.sql index 43a888f47..304ac2eed 100644 --- a/models/silver/nft/sales/silver_nft__wyvern_decoded_sales.sql +++ b/models/silver/nft/sales/silver_nft__wyvern_decoded_sales.sql @@ -11,12 +11,17 @@ WITH raw_logs AS ( SELECT block_number, block_timestamp, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, tx_hash, event_index, event_name, contract_address, + decoded_log AS decoded_flat, decoded_flat :price :: INT AS total_price_undivided, ROW_NUMBER() over ( PARTITION BY tx_hash @@ -29,7 +34,7 @@ WITH raw_logs AS ( event_index ASC ) AS prev_event_index FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE BETWEEN '2018-06-12' AND '2022-08-02' @@ -46,7 +51,7 @@ raw_traces AS ( TYPE, from_address, to_address, - eth_value, + value AS eth_value, input, LEFT( input, @@ -54,11 +59,11 @@ raw_traces AS ( ) AS function_sig, regexp_substr_all(SUBSTR(input, 11, len(input)), '.{64}') AS segmented_data FROM - {{ ref('silver__traces') }} + {{ ref('core__fact_traces') }} WHERE block_timestamp :: DATE BETWEEN '2018-06-12' AND '2022-08-02' - AND trace_status = 'SUCCESS' + AND trace_succeeded AND tx_hash IN ( SELECT tx_hash @@ -804,7 +809,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE BETWEEN '2018-06-12' AND '2022-08-02' @@ -816,7 +821,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/silver_nft__x2y2_decoded_sales.sql b/models/silver/nft/sales/silver_nft__x2y2_decoded_sales.sql index 8f1c78a03..1aaf9e91c 100644 --- a/models/silver/nft/sales/silver_nft__x2y2_decoded_sales.sql +++ b/models/silver/nft/sales/silver_nft__x2y2_decoded_sales.sql @@ -18,7 +18,8 @@ ev_inventory_base AS ( event_index, event_name, contract_address, - decoded_data, + full_decoded_log AS decoded_data, + decoded_log AS decoded_flat, CASE WHEN decoded_flat :currency :: STRING = '0x0000000000000000000000000000000000000000' THEN 'ETH' ELSE decoded_flat :currency :: STRING @@ -58,10 +59,14 @@ maker = nft buyer #} ) :: STRING AS tokenId_quantity, decoded_flat :detail :price :: INT AS price_raw, decoded_flat :detail :fees AS fee_details, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE block_timestamp :: DATE >= '2022-02-01' AND block_number >= 14139341 @@ -165,7 +170,7 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2022-01-01' AND block_number >= 14139341 @@ -177,7 +182,7 @@ tx_data AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v1_pools.sql b/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v1_pools.sql index e9376b5a1..f52d8a13c 100644 --- a/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v1_pools.sql +++ b/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v1_pools.sql @@ -9,14 +9,41 @@ WITH raw_traces AS ( SELECT - *, - decoded_data :function_name :: STRING AS function_name + block_number, + block_timestamp, + tx_hash, + tx_position, + trace_index, + from_address, + from_address_name, + to_address, + to_address_name, + input, + output, + function_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_input_data, + decoded_output_data, + TYPE, + sub_traces, + VALUE, + value_precise_raw, + value_precise, + gas, + gas_used, + trace_succeeded, + error_reason, + tx_succeeded, + fact_decoded_traces_id, + inserted_timestamp, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE block_timestamp :: DATE >= '2022-04-24' AND to_address = '0xb16c1342e617a5b6e4b631eb114483fdb289c0a4' -- sudoswap v1 pair factory - AND trace_status = 'SUCCESS' + AND trace_succeeded AND TYPE = 'CALL' AND function_name IN ( -- only 721 pairs diff --git a/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v1_sales.sql b/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v1_sales.sql index 3e3c37a54..2706a10e4 100644 --- a/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v1_sales.sql +++ b/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v1_sales.sql @@ -25,7 +25,7 @@ base AS ( trace_index, from_address, to_address, - decoded_data, + full_decoded_data AS decoded_data, decoded_data :function_name :: STRING AS function_name, pair_creation_function, pool_address, @@ -56,9 +56,9 @@ base AS ( 1, 0 ) AS group_tag, - trace_status + trace_succeeded FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} INNER JOIN pools ON from_address = pool_address WHERE @@ -92,10 +92,10 @@ base AS ( -- getBuyNFTQuote '0x0c295e56' -- getSellNFTQuote ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -221,7 +221,7 @@ combined_base AS ( intra_tx_grouping ) WHERE - trace_status = 'SUCCESS' + trace_succeeded ), nft_transfers AS ( SELECT @@ -410,15 +410,19 @@ raw_logs AS ( SELECT tx_hash, event_index, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS intra_tx_grouping_new FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -451,12 +455,12 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2022-04-24' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v2_pools.sql b/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v2_pools.sql index 7a8d28d32..385f5005a 100644 --- a/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v2_pools.sql +++ b/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v2_pools.sql @@ -9,14 +9,41 @@ WITH raw_traces AS ( SELECT - *, - decoded_data :function_name :: STRING AS function_name + block_number, + block_timestamp, + tx_hash, + tx_position, + trace_index, + from_address, + from_address_name, + to_address, + to_address_name, + input, + output, + function_name, + full_decoded_data, + full_decoded_data AS decoded_data, + decoded_input_data, + decoded_output_data, + TYPE, + sub_traces, + VALUE, + value_precise_raw, + value_precise, + gas, + gas_used, + trace_succeeded, + error_reason, + tx_succeeded, + fact_decoded_traces_id, + inserted_timestamp, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} WHERE block_timestamp :: DATE >= '2023-05-01' AND to_address = '0xa020d57ab0448ef74115c112d18a9c231cc86000' - AND trace_status = 'SUCCESS' + AND trace_succeeded AND TYPE = 'CALL' AND function_name IN ( 'createPairERC1155ETH', diff --git a/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v2_sales.sql b/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v2_sales.sql index 328809e76..ed08e9c77 100644 --- a/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v2_sales.sql +++ b/models/silver/nft/sales/sudoswap/silver_nft__sudoswap_v2_sales.sql @@ -30,7 +30,7 @@ base AS ( trace_index, from_address, to_address, - decoded_data, + full_decoded_data AS decoded_data, decoded_data :function_name :: STRING AS function_name, pair_creation_function, pool_address, @@ -60,9 +60,9 @@ base AS ( 1, 0 ) AS group_tag, - trace_status + trace_succeeded FROM - {{ ref('silver__decoded_traces') }} + {{ ref('core__ez_decoded_traces') }} INNER JOIN pools ON from_address = pool_address WHERE @@ -98,10 +98,10 @@ base AS ( -- getBuyNFTQuote '0x33b24a3a' -- getSellNFTQuote ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM @@ -267,7 +267,7 @@ combined_base AS ( intra_tx_grouping ) WHERE - trace_status = 'SUCCESS' + trace_succeeded ), base_721 AS ( SELECT @@ -411,15 +411,19 @@ raw_logs AS ( SELECT tx_hash, event_index, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, ROW_NUMBER() over ( PARTITION BY tx_hash ORDER BY event_index ASC ) AS intra_tx_grouping_new FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( SELECT @@ -456,12 +460,12 @@ tx_data AS ( tx_fee, input_data FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE block_timestamp :: DATE >= '2023-05-01' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/nft/silver__nft_mints.sql b/models/silver/nft/silver__nft_mints.sql index ab2361747..4da16a291 100644 --- a/models/silver/nft/silver__nft_mints.sql +++ b/models/silver/nft/silver__nft_mints.sql @@ -20,8 +20,12 @@ WITH nft_mints AS ( tokenId, erc1155_value, 'nft_mint' AS event_type, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM {{ ref('silver__nft_transfers') }} WHERE @@ -42,9 +46,9 @@ mint_price AS ( VALUE AS eth_value, tx_fee FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE - tx_status = 'SUCCESS' + tx_succeeded AND tx_hash IN ( SELECT tx_hash @@ -53,7 +57,7 @@ mint_price AS ( ) {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '{{ var("LOOKBACK", "4 hours") }}' FROM diff --git a/models/silver/nft/silver__nft_transfers.sql b/models/silver/nft/silver__nft_transfers.sql index eb1f89f39..ef9a7ca3f 100644 --- a/models/silver/nft/silver__nft_transfers.sql +++ b/models/silver/nft/silver__nft_transfers.sql @@ -10,7 +10,11 @@ WITH base AS ( SELECT - _log_id, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, block_number, tx_hash, block_timestamp, @@ -19,11 +23,11 @@ WITH base AS ( topics, DATA, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, - TO_TIMESTAMP_NTZ(_inserted_timestamp) AS _inserted_timestamp + TO_TIMESTAMP_NTZ(modified_timestamp) AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE - tx_status = 'SUCCESS' + tx_succeeded AND ( ( topics [0] :: STRING = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' diff --git a/models/silver/optimism/silver__optimism_bedrock_state_hashes.sql b/models/silver/optimism/silver__optimism_bedrock_state_hashes.sql index 9c21c2c38..46337c80b 100644 --- a/models/silver/optimism/silver__optimism_bedrock_state_hashes.sql +++ b/models/silver/optimism/silver__optimism_bedrock_state_hashes.sql @@ -23,9 +23,9 @@ WITH base AS ( utils.udf_hex_to_int( DATA :: STRING ) :: TIMESTAMP AS l1_timestamp, - _inserted_timestamp + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0xa7aaf2512769da4e444e3de247be2564225c2e7a8f74cfe528e46e17d24868e2' AND contract_address = '0xdfe97868233d1aa22e815a266982f2cf17685a27' diff --git a/models/silver/optimism/silver__optimism_state_hashes.sql b/models/silver/optimism/silver__optimism_state_hashes.sql index 91585f458..fe328ae46 100644 --- a/models/silver/optimism/silver__optimism_state_hashes.sql +++ b/models/silver/optimism/silver__optimism_state_hashes.sql @@ -9,7 +9,31 @@ WITH base AS ( SELECT - *, + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + fact_event_logs_id, + inserted_timestamp, + modified_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, utils.udf_hex_to_int( topics [1] :: STRING @@ -26,12 +50,12 @@ WITH base AS ( ) :: INTEGER AS prevTotalElements, segmented_data [3] :: STRING AS extraData FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE origin_from_address = '0x473300df21d047806a082244b417f96b32f13a33' AND origin_to_address = '0xbe5dab4a2e9cd0f27300db4ab94bee3a233aeb19' AND topics [0] :: STRING = '0x16be4c5129a4e03cf3350262e181dc02ddfb4a6008d925368c0899fcd97ca9c5' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND event_removed = 'false' {% if is_incremental() %} diff --git a/models/silver/optimism/silver__optimism_submission_hashes.sql b/models/silver/optimism/silver__optimism_submission_hashes.sql index d9080ad4e..df9c25e66 100644 --- a/models/silver/optimism/silver__optimism_submission_hashes.sql +++ b/models/silver/optimism/silver__optimism_submission_hashes.sql @@ -9,7 +9,31 @@ WITH base AS ( SELECT - *, + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + fact_event_logs_id, + inserted_timestamp, + modified_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, utils.udf_hex_to_int( topics [1] :: STRING @@ -26,12 +50,12 @@ WITH base AS ( ) :: INTEGER AS prevTotalElements, segmented_data [3] :: STRING AS extraData FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE origin_from_address = '0x6887246668a3b87f54deb3b94ba47a6f63f32985' AND origin_to_address = '0x5e4e65926ba27467555eb562121fac00d24e9dd2' AND topics [0] :: STRING = '0x127186556e7be68c7e31263195225b4de02820707889540969f62c05cf73525e' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND event_removed = 'false' {% if is_incremental() %} diff --git a/models/silver/protocols/ens/silver_ens__ens_dao_votes.sql b/models/silver/protocols/ens/silver_ens__ens_dao_votes.sql index a509a498f..e0c67733b 100644 --- a/models/silver/protocols/ens/silver_ens__ens_dao_votes.sql +++ b/models/silver/protocols/ens/silver_ens__ens_dao_votes.sql @@ -20,13 +20,17 @@ WITH base_events AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xb8e138887d0aa13bab447e82de9d5c1777041ecd21ca36ba824ff1e6c07ddda4' AND contract_address = '0x323a76393544d5ecca80cd6ef2a560c6a395b7e3' diff --git a/models/silver/protocols/ens/silver_ens__ens_domain_owners.sql b/models/silver/protocols/ens/silver_ens__ens_domain_owners.sql index 61c7d7079..d1a37c6d1 100644 --- a/models/silver/protocols/ens/silver_ens__ens_domain_owners.sql +++ b/models/silver/protocols/ens/silver_ens__ens_domain_owners.sql @@ -19,13 +19,17 @@ WITH base_events AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e82' --NewOwner AND contract_address IN ( diff --git a/models/silver/protocols/ens/silver_ens__ens_domain_registrations.sql b/models/silver/protocols/ens/silver_ens__ens_domain_registrations.sql index ef34a8360..ceb35d46e 100644 --- a/models/silver/protocols/ens/silver_ens__ens_domain_registrations.sql +++ b/models/silver/protocols/ens/silver_ens__ens_domain_registrations.sql @@ -19,13 +19,17 @@ WITH base_events AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING IN ( '0xca6abbe9d7f11422cb6ca7629fbf6fe9efb1c621f71ce8f02b9f2a230097404f', diff --git a/models/silver/protocols/ens/silver_ens__ens_domain_renewals.sql b/models/silver/protocols/ens/silver_ens__ens_domain_renewals.sql index 010138954..7f75b7b8c 100644 --- a/models/silver/protocols/ens/silver_ens__ens_domain_renewals.sql +++ b/models/silver/protocols/ens/silver_ens__ens_domain_renewals.sql @@ -19,13 +19,17 @@ WITH base_events AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x3da24c024582931cfaf8267d8ed24d13a82a8068d5bd337d30ec45cea4e506ae' AND contract_address IN ( diff --git a/models/silver/protocols/ens/silver_ens__ens_domain_resolvers.sql b/models/silver/protocols/ens/silver_ens__ens_domain_resolvers.sql index e23407ba6..12f9feaa5 100644 --- a/models/silver/protocols/ens/silver_ens__ens_domain_resolvers.sql +++ b/models/silver/protocols/ens/silver_ens__ens_domain_resolvers.sql @@ -19,13 +19,17 @@ WITH base_events AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0' --NewResolver AND contract_address IN ( diff --git a/models/silver/protocols/ens/silver_ens__ens_domain_set.sql b/models/silver/protocols/ens/silver_ens__ens_domain_set.sql index 5749afc00..5b890aa1a 100644 --- a/models/silver/protocols/ens/silver_ens__ens_domain_set.sql +++ b/models/silver/protocols/ens/silver_ens__ens_domain_set.sql @@ -64,12 +64,12 @@ WITH base AS ( AND part2 IS NOT NULL THEN part2 END AS top_level_domain, CONCAT(COALESCE(subdomain2,''),COALESCE(subdomain1,''),second_level_domain) AS set_ens_name_clean, - tx_status, - _inserted_timestamp + tx_succeeded, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__transactions') }} + {{ ref('core__fact_transactions') }} WHERE - tx_status = 'SUCCESS' + tx_succeeded AND origin_function_signature = '0xc47f0027' AND to_address IN ( '0x9062c0a6dbd6108336bcbe4593a3d1ce05512069', diff --git a/models/silver/protocols/ens/silver_ens__ens_domain_textchanged.sql b/models/silver/protocols/ens/silver_ens__ens_domain_textchanged.sql index 102a4e296..38d796ac4 100644 --- a/models/silver/protocols/ens/silver_ens__ens_domain_textchanged.sql +++ b/models/silver/protocols/ens/silver_ens__ens_domain_textchanged.sql @@ -18,16 +18,20 @@ WITH base_events AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat :"indexedKey" :: STRING AS indexedKey, - decoded_flat :"key" :: STRING AS key, - decoded_flat :"node" :: STRING AS node, - decoded_flat, + decoded_log :"indexedKey" :: STRING AS indexedKey, + decoded_log :"key" :: STRING AS key, + decoded_log :"node" :: STRING AS node, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0xd8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a7550' AND contract_address = '0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41' @@ -77,7 +81,7 @@ base_input_data AS ( _inserted_timestamp FROM base_events b - LEFT JOIN {{ ref('silver__transactions') }} + LEFT JOIN {{ ref('core__fact_transactions') }} t USING(tx_hash) qualify(ROW_NUMBER() over (PARTITION BY node, key ORDER BY block_timestamp DESC)) = 1 diff --git a/models/silver/protocols/ens/silver_ens__ens_domain_transfers.sql b/models/silver/protocols/ens/silver_ens__ens_domain_transfers.sql index 041645c08..acb123f91 100644 --- a/models/silver/protocols/ens/silver_ens__ens_domain_transfers.sql +++ b/models/silver/protocols/ens/silver_ens__ens_domain_transfers.sql @@ -19,13 +19,17 @@ WITH base_events AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING IN ( '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef', diff --git a/models/silver/protocols/ens/silver_ens__ens_domain_wrapped.sql b/models/silver/protocols/ens/silver_ens__ens_domain_wrapped.sql index 63ce6d03a..824f91f4d 100644 --- a/models/silver/protocols/ens/silver_ens__ens_domain_wrapped.sql +++ b/models/silver/protocols/ens/silver_ens__ens_domain_wrapped.sql @@ -19,13 +19,17 @@ WITH base_events AS ( event_index, topics [0] :: STRING AS topic_0, event_name, - decoded_flat, + decoded_log AS decoded_flat, event_removed, - tx_status, - _log_id, - _inserted_timestamp + tx_succeeded, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE topics [0] :: STRING = '0x8ce7013e8abebc55c3890a68f5a27c67c3f7efa64e584de5fb22363c606fd340' AND contract_address = '0xd4416b13d2b3a9abae7acd5d6c2bbdbe25686401' diff --git a/models/silver/protocols/maker/base/cat/silver_maker__cat_bite.sql b/models/silver/protocols/maker/base/cat/silver_maker__cat_bite.sql index 38808f8f9..f0357b062 100644 --- a/models/silver/protocols/maker/base/cat/silver_maker__cat_bite.sql +++ b/models/silver/protocols/maker/base/cat/silver_maker__cat_bite.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0xa5679c04fc3d9d8b0aab1f0ab83555b301ca70ea' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0xa716da86' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/cdp/silver_maker__cdp_flux.sql b/models/silver/protocols/maker/base/cdp/silver_maker__cdp_flux.sql index 8dc4a39fe..16df91c1c 100644 --- a/models/silver/protocols/maker/base/cdp/silver_maker__cdp_flux.sql +++ b/models/silver/protocols/maker/base/cdp/silver_maker__cdp_flux.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x5ef30b9986345249bc32d8928b7ee64de9435e39' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x9bb8f838' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/cdp/silver_maker__cdp_frob.sql b/models/silver/protocols/maker/base/cdp/silver_maker__cdp_frob.sql index 8e6e87a5b..e22825396 100644 --- a/models/silver/protocols/maker/base/cdp/silver_maker__cdp_frob.sql +++ b/models/silver/protocols/maker/base/cdp/silver_maker__cdp_frob.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x5ef30b9986345249bc32d8928b7ee64de9435e39' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x45e6bdcd' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/cdp/silver_maker__cdp_move.sql b/models/silver/protocols/maker/base/cdp/silver_maker__cdp_move.sql index e690dff3d..621ef256f 100644 --- a/models/silver/protocols/maker/base/cdp/silver_maker__cdp_move.sql +++ b/models/silver/protocols/maker/base/cdp/silver_maker__cdp_move.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x5ef30b9986345249bc32d8928b7ee64de9435e39' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0xf9f30db6' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/cdp/silver_maker__cdp_newcdp.sql b/models/silver/protocols/maker/base/cdp/silver_maker__cdp_newcdp.sql index 9ddf6bc51..a9366f5d8 100644 --- a/models/silver/protocols/maker/base/cdp/silver_maker__cdp_newcdp.sql +++ b/models/silver/protocols/maker/base/cdp/silver_maker__cdp_newcdp.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x5ef30b9986345249bc32d8928b7ee64de9435e39' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0xd6be0bc1' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/dai_join/silver_maker__dai_join_exit.sql b/models/silver/protocols/maker/base/dai_join/silver_maker__dai_join_exit.sql index 4b5015164..34f3db0b5 100644 --- a/models/silver/protocols/maker/base/dai_join/silver_maker__dai_join_exit.sql +++ b/models/silver/protocols/maker/base/dai_join/silver_maker__dai_join_exit.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x9759a6ac90977b93b58547b4a71c78317f391a28' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0xef693bed' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/dai_join/silver_maker__dai_join_join.sql b/models/silver/protocols/maker/base/dai_join/silver_maker__dai_join_join.sql index 43bcd303a..818a0fa7d 100644 --- a/models/silver/protocols/maker/base/dai_join/silver_maker__dai_join_join.sql +++ b/models/silver/protocols/maker/base/dai_join/silver_maker__dai_join_join.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x9759a6ac90977b93b58547b4a71c78317f391a28' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x3b4da69f' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/dog/silver_maker__dog_bark.sql b/models/silver/protocols/maker/base/dog/silver_maker__dog_bark.sql index aad89d81a..3eb1a62c0 100644 --- a/models/silver/protocols/maker/base/dog/silver_maker__dog_bark.sql +++ b/models/silver/protocols/maker/base/dog/silver_maker__dog_bark.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x135954d155898d42c90d2a57824c690e0c7bef1b' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x85258d09' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/dss_flash/silver_maker__dss_flashloan.sql b/models/silver/protocols/maker/base/dss_flash/silver_maker__dss_flashloan.sql index 64e916f0d..9d0c99b5a 100644 --- a/models/silver/protocols/maker/base/dss_flash/silver_maker__dss_flashloan.sql +++ b/models/silver/protocols/maker/base/dss_flash/silver_maker__dss_flashloan.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address IN ( @@ -33,7 +37,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x0d7d75e0' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/mcd_pot/silver_maker__pot_exit.sql b/models/silver/protocols/maker/base/mcd_pot/silver_maker__pot_exit.sql index ffc521ebf..ddb3bcb63 100644 --- a/models/silver/protocols/maker/base/mcd_pot/silver_maker__pot_exit.sql +++ b/models/silver/protocols/maker/base/mcd_pot/silver_maker__pot_exit.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x197e90f9fad81970ba7976f33cbd77088e5d7cf7' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x7f8661a1' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/mcd_pot/silver_maker__pot_join.sql b/models/silver/protocols/maker/base/mcd_pot/silver_maker__pot_join.sql index 42a794e35..d1a2599ab 100644 --- a/models/silver/protocols/maker/base/mcd_pot/silver_maker__pot_join.sql +++ b/models/silver/protocols/maker/base/mcd_pot/silver_maker__pot_join.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x197e90f9fad81970ba7976f33cbd77088e5d7cf7' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x049878f3' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/vat/silver_maker__vat_file.sql b/models/silver/protocols/maker/base/vat/silver_maker__vat_file.sql index 613a93185..c22d611e5 100644 --- a/models/silver/protocols/maker/base/vat/silver_maker__vat_file.sql +++ b/models/silver/protocols/maker/base/vat/silver_maker__vat_file.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x1a0b287e' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/vat/silver_maker__vat_flux.sql b/models/silver/protocols/maker/base/vat/silver_maker__vat_flux.sql index 447929edc..251a249dc 100644 --- a/models/silver/protocols/maker/base/vat/silver_maker__vat_flux.sql +++ b/models/silver/protocols/maker/base/vat/silver_maker__vat_flux.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x6111be2e' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/vat/silver_maker__vat_fold.sql b/models/silver/protocols/maker/base/vat/silver_maker__vat_fold.sql index b9ac7103f..6aa11def3 100644 --- a/models/silver/protocols/maker/base/vat/silver_maker__vat_fold.sql +++ b/models/silver/protocols/maker/base/vat/silver_maker__vat_fold.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0xb65337df' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/vat/silver_maker__vat_fork.sql b/models/silver/protocols/maker/base/vat/silver_maker__vat_fork.sql index dc739d4e1..cc59df33c 100644 --- a/models/silver/protocols/maker/base/vat/silver_maker__vat_fork.sql +++ b/models/silver/protocols/maker/base/vat/silver_maker__vat_fork.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x870c616d' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/vat/silver_maker__vat_frob.sql b/models/silver/protocols/maker/base/vat/silver_maker__vat_frob.sql index bd720f971..3bd747523 100644 --- a/models/silver/protocols/maker/base/vat/silver_maker__vat_frob.sql +++ b/models/silver/protocols/maker/base/vat/silver_maker__vat_frob.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x76088703' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/vat/silver_maker__vat_move.sql b/models/silver/protocols/maker/base/vat/silver_maker__vat_move.sql index 49f222f76..b935df068 100644 --- a/models/silver/protocols/maker/base/vat/silver_maker__vat_move.sql +++ b/models/silver/protocols/maker/base/vat/silver_maker__vat_move.sql @@ -16,11 +16,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b' @@ -28,7 +32,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0xbb35783b' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/vat/silver_maker__vat_slip.sql b/models/silver/protocols/maker/base/vat/silver_maker__vat_slip.sql index ce556422a..ecaff1cb7 100644 --- a/models/silver/protocols/maker/base/vat/silver_maker__vat_slip.sql +++ b/models/silver/protocols/maker/base/vat/silver_maker__vat_slip.sql @@ -18,11 +18,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b' @@ -30,7 +34,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0x7cdd3fde' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/base/vat/silver_maker__vat_suck.sql b/models/silver/protocols/maker/base/vat/silver_maker__vat_suck.sql index 81ebe6df2..c74d68dff 100644 --- a/models/silver/protocols/maker/base/vat/silver_maker__vat_suck.sql +++ b/models/silver/protocols/maker/base/vat/silver_maker__vat_suck.sql @@ -16,11 +16,15 @@ WITH base AS ( event_index, origin_from_address, origin_to_address, - _inserted_timestamp, - _log_id, + modified_timestamp AS _inserted_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, contract_address FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x35d1b3f3d7966a1dfe207aa4514c12a259a0492b' @@ -28,7 +32,7 @@ WITH base AS ( topics [0] :: STRING, 10 ) = '0xf24e23eb' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/maker/ez_models/silver_maker__delegations.sql b/models/silver/protocols/maker/ez_models/silver_maker__delegations.sql index f057fb827..4edfc678d 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__delegations.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__delegations.sql @@ -12,7 +12,7 @@ WITH txs_base AS ( SELECT tx_hash FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x0a3f6849f78076aefadf113f5bed87720274ddc0' -- MakerDAO general governance contract @@ -51,10 +51,10 @@ delegate_actions AS ( 10, 18 ) AS amount_delegated, - tx_status, + tx_succeeded, event_index FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE tx_hash IN ( SELECT @@ -84,7 +84,7 @@ SELECT block_timestamp, tx_hash, event_index, - tx_status, + tx_succeeded, origin_from_address, contract_address, tx_event, diff --git a/models/silver/protocols/maker/ez_models/silver_maker__deposits.sql b/models/silver/protocols/maker/ez_models/silver_maker__deposits.sql index 133dbac46..401a5c067 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__deposits.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__deposits.sql @@ -39,7 +39,7 @@ SELECT block_number, block_timestamp, tx_hash, - 'SUCCESS' AS tx_status, + 'SUCCESS' AS tx_succeeded, event_index, depositor, vault, diff --git a/models/silver/protocols/maker/ez_models/silver_maker__flash_loans.sql b/models/silver/protocols/maker/ez_models/silver_maker__flash_loans.sql index 51a419713..23b9e4b22 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__flash_loans.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__flash_loans.sql @@ -13,7 +13,7 @@ WITH base AS ( tx_hash, event_index, block_number, - 'SUCCESS' AS tx_status, + 'SUCCESS' AS tx_succeeded, block_timestamp, contract_address, origin_from_address, @@ -41,7 +41,7 @@ SELECT tx_hash, event_index, block_number, - tx_status, + tx_succeeded, block_timestamp, origin_from_address, contract_address AS lender, diff --git a/models/silver/protocols/maker/ez_models/silver_maker__governance_votes.sql b/models/silver/protocols/maker/ez_models/silver_maker__governance_votes.sql index 5c31b8337..aba845123 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__governance_votes.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__governance_votes.sql @@ -11,7 +11,7 @@ SELECT block_number, block_timestamp, tx_hash, - tx_status, + tx_succeeded, event_index, CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS voter, contract_address AS polling_contract, @@ -30,7 +30,7 @@ SELECT SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( '0xd3a9fe267852281a1e6307a1c37cdfd76d39b133', diff --git a/models/silver/protocols/maker/ez_models/silver_maker__liquidations.sql b/models/silver/protocols/maker/ez_models/silver_maker__liquidations.sql index 4c24c3bc4..eec479e99 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__liquidations.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__liquidations.sql @@ -112,7 +112,7 @@ SELECT event_index, block_number, block_timestamp, - 'SUCCESS' AS tx_status, + 'SUCCESS' AS tx_succeeded, contract_address, origin_from_address AS liquidator, origin_to_address AS liquidated_wallet, diff --git a/models/silver/protocols/maker/ez_models/silver_maker__repayments.sql b/models/silver/protocols/maker/ez_models/silver_maker__repayments.sql index 1e7d8897d..396d1ecf1 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__repayments.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__repayments.sql @@ -31,7 +31,7 @@ dai_burns AS ( block_number, block_timestamp, tx_hash, - 'SUCCESS' AS tx_status, + 'SUCCESS' AS tx_succeeded, event_index, origin_from_address AS payer, origin_to_address AS vault, @@ -69,7 +69,7 @@ SELECT block_number, block_timestamp, tx_hash, - tx_status, + tx_succeeded, event_index, payer, vault, diff --git a/models/silver/protocols/maker/ez_models/silver_maker__urns.sql b/models/silver/protocols/maker/ez_models/silver_maker__urns.sql index 93e9f830a..6eb5facae 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__urns.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__urns.sql @@ -41,7 +41,7 @@ block_no AS ( SELECT MAX(block_number) AS block_number FROM - {{ ref('silver__blocks') }} + {{ ref('core__fact_blocks') }} ), all_reads_market AS ( SELECT diff --git a/models/silver/protocols/maker/ez_models/silver_maker__vault_creation.sql b/models/silver/protocols/maker/ez_models/silver_maker__vault_creation.sql index 6ab50bbe1..d61b4969e 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__vault_creation.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__vault_creation.sql @@ -9,7 +9,21 @@ WITH logs_base 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, + fact_event_logs_id, + inserted_timestamp, + modified_timestamp, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, CASE WHEN LEFT( @@ -20,13 +34,14 @@ WITH logs_base AS ( topics [0] :: STRING, 10 ) = '0x6090dec5' THEN 'LogNote' - END AS event_type + END AS event_type, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_number > 8000000 AND contract_address = '0x5ef30b9986345249bc32d8928b7ee64de9435e39' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND LEFT( topics [0] :: STRING, 10 diff --git a/models/silver/protocols/maker/ez_models/silver_maker__withdrawals.sql b/models/silver/protocols/maker/ez_models/silver_maker__withdrawals.sql index e03666da7..d80727796 100644 --- a/models/silver/protocols/maker/ez_models/silver_maker__withdrawals.sql +++ b/models/silver/protocols/maker/ez_models/silver_maker__withdrawals.sql @@ -40,7 +40,7 @@ SELECT block_number, block_timestamp, tx_hash, - 'SUCCESS' AS tx_status, + 'SUCCESS' AS tx_succeeded, event_index, withdrawer, vault, diff --git a/models/silver/protocols/olas/silver_olas__create_bond.sql b/models/silver/protocols/olas/silver_olas__create_bond.sql index 9c2a579c3..f250a663d 100644 --- a/models/silver/protocols/olas/silver_olas__create_bond.sql +++ b/models/silver/protocols/olas/silver_olas__create_bond.sql @@ -62,14 +62,18 @@ WITH base_evt AS ( ) ) AS maturity, TO_TIMESTAMP(maturity) AS maturity_timestamp, - _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 = '0xff8697d8d2998d6aa2e09b405795c6f4beeb0c81' --Depository AND topic_0 = '0xfa892a5592accfded99f9df9ad2d678230f37aeeb8fde5dd3b73769b5069bc0e' --CreateBond - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/olas/silver_olas__create_service_multisigs.sql b/models/silver/protocols/olas/silver_olas__create_service_multisigs.sql index fa0d4f146..d922769ab 100644 --- a/models/silver/protocols/olas/silver_olas__create_service_multisigs.sql +++ b/models/silver/protocols/olas/silver_olas__create_service_multisigs.sql @@ -28,8 +28,12 @@ SELECT ) ) AS id, CONCAT('0x', SUBSTR(topic_2, 27, 40)) AS multisig_address, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, {{ dbt_utils.generate_surrogate_key( ['tx_hash','event_index'] ) }} AS create_service_multisigs_id, @@ -37,11 +41,11 @@ SELECT SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address = '0x48b6af7b12c71f09e2fc8af4855de4ff54e775ca' --Service Registry (AUTONOLAS-SERVICE-V1) AND topic_0 = '0x2d53f895cd5faf3cddba94a25c2ced2105885b5b37450ff430ffa3cbdf332c74' --CreateMultisigWithAgents - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/olas/silver_olas__olas_locking.sql b/models/silver/protocols/olas/silver_olas__olas_locking.sql index 870dc6e2a..86c424cb8 100644 --- a/models/silver/protocols/olas/silver_olas__olas_locking.sql +++ b/models/silver/protocols/olas/silver_olas__olas_locking.sql @@ -30,10 +30,14 @@ WITH event_logs AS ( END AS contract_name, 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 contract_address = '0x7e01a500805f8a52fad229b3015ad130a332b7b3' --Voting Escrow OLAS (veOLAS) AND topic_0 IN ( @@ -41,7 +45,7 @@ WITH event_logs AS ( --Deposit (veOLAS) '0xf279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568' --Withdraw (veOLAS) ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/olas/silver_olas__pol_transfers.sql b/models/silver/protocols/olas/silver_olas__pol_transfers.sql index 215821ce0..d26fe3015 100644 --- a/models/silver/protocols/olas/silver_olas__pol_transfers.sql +++ b/models/silver/protocols/olas/silver_olas__pol_transfers.sql @@ -48,8 +48,12 @@ SELECT WHEN contract_address = '0x9946d6fd1210d85ec613ca956f142d911c97a074' THEN 'base' WHEN contract_address = '0x3685b8cc36b8df09ed9e81c1690100306bf23e04' THEN 'solana' END AS source_chain, - _log_id, - _inserted_timestamp, + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, {{ dbt_utils.generate_surrogate_key( ['tx_hash','event_index'] ) }} AS pol_transfers_id, @@ -57,7 +61,7 @@ SELECT SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE contract_address IN ( '0x09d1d767edf8fa23a64c51fa559e0688e526812f', @@ -81,7 +85,7 @@ WHERE ) AND from_address <> '0x0000000000000000000000000000000000000000' AND to_address <> '0x0000000000000000000000000000000000000000' - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/olas/silver_olas__redeem_bond.sql b/models/silver/protocols/olas/silver_olas__redeem_bond.sql index 59ffdebb5..025c52593 100644 --- a/models/silver/protocols/olas/silver_olas__redeem_bond.sql +++ b/models/silver/protocols/olas/silver_olas__redeem_bond.sql @@ -35,14 +35,18 @@ WITH redeem AS ( segmented_data [0] :: STRING ) ) AS bond_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 = '0xff8697d8d2998d6aa2e09b405795c6f4beeb0c81' --Depository AND topic_0 = '0x97f4572ff501a5533a09cf8d7d39be87e303470dd8bc7cff4fe91212be76bc73' --RedeemBond - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( @@ -84,10 +88,14 @@ transfers AS ( 18 ) :: FLOAT AS amount_adj, --amount of OLAS tokens transferred for the redemption txn, only 1 transfer per redemption txn (not 1 per RedeemBond event) - _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('0x0001A500A6B18995B03f44bb040A5fFc28E45CB0') --Autonolas: OLAS Token AND topic_0 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer @@ -97,7 +105,7 @@ transfers AS ( FROM redeem ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/olas/silver_olas__service_donations.sql b/models/silver/protocols/olas/silver_olas__service_donations.sql index ec19f2cf9..55f5b3dca 100644 --- a/models/silver/protocols/olas/silver_olas__service_donations.sql +++ b/models/silver/protocols/olas/silver_olas__service_donations.sql @@ -22,7 +22,7 @@ WITH base_evt AS ( topics [1] :: STRING AS topic_1, topics [2] :: STRING AS topic_2, topics [3] :: STRING AS topic_3, - decoded_flat, + decoded_log AS decoded_flat, decoded_flat :sender :: STRING AS donor_address, decoded_flat :serviceIds AS service_ids, decoded_flat :amounts AS amounts_unadj, @@ -33,14 +33,18 @@ WITH base_evt AS ( 10, 18 ) :: FLOAT AS donation_adj, - _log_id, - _inserted_timestamp + CONCAT( + tx_hash :: STRING, + '-', + event_index :: STRING + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__decoded_logs') }} + {{ ref('core__ez_decoded_event_logs') }} WHERE contract_address = '0xa0da53447c0f6c4987964d8463da7e6628b30f82' --Treasury AND topic_0 = '0xb7c3b13b911bdc71cbcf384e470cad657b7da964c892dc2fdba1432ad64d8be0' --DonateToServicesETH - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/olas/silver_olas__service_event_logs.sql b/models/silver/protocols/olas/silver_olas__service_event_logs.sql index 23102e7b5..19954200a 100644 --- a/models/silver/protocols/olas/silver_olas__service_event_logs.sql +++ b/models/silver/protocols/olas/silver_olas__service_event_logs.sql @@ -31,8 +31,12 @@ SELECT d.topics [3] :: STRING AS topic_3, d.data, regexp_substr_all(SUBSTR(d.data, 3, len(d.data)), '.{64}') AS segmented_data, - d._log_id, - d._inserted_timestamp, + CONCAT( + d.tx_hash, + '-', + d.event_index + ) AS _log_id, + d.modified_timestamp AS _inserted_timestamp, {{ dbt_utils.generate_surrogate_key( ['d.tx_hash','d.event_index'] ) }} AS service_event_logs_id, @@ -40,15 +44,15 @@ SELECT SYSDATE() AS modified_timestamp, '{{ invocation_id }}' AS _invocation_id FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} d INNER JOIN service_multisigs s ON d.origin_to_address = s.multisig_address WHERE - d.tx_status = 'SUCCESS' + d.tx_succeeded {% if is_incremental() %} -AND d._inserted_timestamp >= ( +AND d.modified_timestamp >= ( SELECT MAX(_inserted_timestamp) - INTERVAL '12 hours' FROM diff --git a/models/silver/protocols/olas/silver_olas__service_registrations.sql b/models/silver/protocols/olas/silver_olas__service_registrations.sql index c626a56a5..9ef423b01 100644 --- a/models/silver/protocols/olas/silver_olas__service_registrations.sql +++ b/models/silver/protocols/olas/silver_olas__service_registrations.sql @@ -27,10 +27,14 @@ WITH registry_evt AS ( END AS event_name, 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 contract_address = '0x48b6af7b12c71f09e2fc8af4855de4ff54e775ca' --Service Registry (AUTONOLAS-SERVICE-V1) AND topic_0 IN ( @@ -38,7 +42,7 @@ WITH registry_evt AS ( --CreateService (for services) '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/olas/silver_olas__unit_registrations.sql b/models/silver/protocols/olas/silver_olas__unit_registrations.sql index ddbf20c46..aa6cfdbe9 100644 --- a/models/silver/protocols/olas/silver_olas__unit_registrations.sql +++ b/models/silver/protocols/olas/silver_olas__unit_registrations.sql @@ -27,10 +27,14 @@ WITH registry_evt AS ( END AS event_name, 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 contract_address IN ( '0x15bd56669f57192a97df41a2aa8f4403e9491776', @@ -42,7 +46,7 @@ WITH registry_evt AS ( --CreateUnit (for both agents and components) '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --Transfer ) - AND tx_status = 'SUCCESS' + AND tx_succeeded {% if is_incremental() %} AND _inserted_timestamp >= ( diff --git a/models/silver/protocols/uniswapv3/silver__univ3_lp_actions.sql b/models/silver/protocols/uniswapv3/silver__univ3_lp_actions.sql index 0a2aba54a..e0f18ed4d 100644 --- a/models/silver/protocols/uniswapv3/silver__univ3_lp_actions.sql +++ b/models/silver/protocols/uniswapv3/silver__univ3_lp_actions.sql @@ -9,13 +9,37 @@ WITH lp_actions_base AS ( SELECT - *, + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + fact_event_logs_id, + inserted_timestamp, + modified_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE > '2021-04-01' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND event_removed = 'false' AND topics [0] :: STRING IN ( '0x0c396cd989a39f4459b5fa1aed6a9a8dcdbc45908acfd67e028cd568da98982c', diff --git a/models/silver/protocols/uniswapv3/silver__univ3_pool_stats.sql b/models/silver/protocols/uniswapv3/silver__univ3_pool_stats.sql index c8628c33a..2ed1e5018 100644 --- a/models/silver/protocols/uniswapv3/silver__univ3_pool_stats.sql +++ b/models/silver/protocols/uniswapv3/silver__univ3_pool_stats.sql @@ -12,7 +12,7 @@ WITH block_date AS ( block_timestamp, block_number FROM - {{ ref("silver__blocks") }} + {{ ref("core__fact_blocks") }} ), base_pool_data AS ( SELECT diff --git a/models/silver/protocols/uniswapv3/silver__univ3_pools.sql b/models/silver/protocols/uniswapv3/silver__univ3_pools.sql index 3cf67fb6a..dcfc9edd8 100644 --- a/models/silver/protocols/uniswapv3/silver__univ3_pools.sql +++ b/models/silver/protocols/uniswapv3/silver__univ3_pools.sql @@ -24,9 +24,9 @@ WITH created_pools AS ( segmented_data [0] :: STRING ) :: INTEGER AS tick_spacing, CONCAT('0x', SUBSTR(segmented_data [1] :: STRING, 25, 40)) AS pool_address, - _inserted_timestamp + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] = '0x783cca1c0412dd0d695e784568c96da2e9c22ff989357a2e8b1d9b2b4e6b7118' AND contract_address = '0x1f98431c8ad98523631ae4a59f267346ea31f984' @@ -53,12 +53,12 @@ initial_info AS ( init_tick ) AS init_price_1_0_unadj FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE topics [0] :: STRING = '0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95' {% if is_incremental() %} -AND _inserted_timestamp >= ( +AND modified_timestamp >= ( SELECT MAX( _inserted_timestamp diff --git a/models/silver/protocols/uniswapv3/silver__univ3_position_collected_fees.sql b/models/silver/protocols/uniswapv3/silver__univ3_position_collected_fees.sql index 7fc9ccffc..6c79bf1b2 100644 --- a/models/silver/protocols/uniswapv3/silver__univ3_position_collected_fees.sql +++ b/models/silver/protocols/uniswapv3/silver__univ3_position_collected_fees.sql @@ -9,12 +9,36 @@ WITH all_collected AS ( SELECT - * + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + fact_event_logs_id, + inserted_timestamp, + modified_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE > '2021-04-01' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND event_removed = 'false' AND topics [0] :: STRING IN ( '0x70935338e69775456a85ddef226c395fb668b63fa0115f5f20610b388e6ca9c0', diff --git a/models/silver/protocols/uniswapv3/silver__univ3_swaps.sql b/models/silver/protocols/uniswapv3/silver__univ3_swaps.sql index 04ba2cc05..3dbfc5b1f 100644 --- a/models/silver/protocols/uniswapv3/silver__univ3_swaps.sql +++ b/models/silver/protocols/uniswapv3/silver__univ3_swaps.sql @@ -9,7 +9,31 @@ WITH base_swaps AS ( SELECT - *, + block_number, + block_timestamp, + tx_hash, + event_index, + contract_address, + topics, + topic_0, + topic_1, + topic_2, + topic_3, + DATA, + event_removed, + origin_from_address, + origin_to_address, + origin_function_signature, + tx_succeeded, + fact_event_logs_id, + inserted_timestamp, + modified_timestamp, + CONCAT( + tx_hash, + '-', + event_index + ) AS _log_id, + modified_timestamp AS _inserted_timestamp, regexp_substr_all(SUBSTR(DATA, 3, len(DATA)), '.{64}') AS segmented_data, CONCAT('0x', SUBSTR(topics [1] :: STRING, 27, 40)) AS sender, CONCAT('0x', SUBSTR(topics [2] :: STRING, 27, 40)) AS recipient, @@ -34,11 +58,11 @@ WITH base_swaps AS ( segmented_data [4] :: STRING ) :: FLOAT AS tick FROM - {{ ref('silver__logs') }} + {{ ref('core__fact_event_logs') }} WHERE block_timestamp :: DATE > '2021-04-01' AND topics [0] :: STRING = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67' - AND tx_status = 'SUCCESS' + AND tx_succeeded AND event_removed = 'false' {% if is_incremental() %} diff --git a/models/silver/stats/silver_stats__core_metrics_hourly.sql b/models/silver/stats/silver_stats__core_metrics_hourly.sql index d16c1bb72..b08810d31 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',