diff --git a/models/ethereum/aave/aave__market_stats.sql b/models/ethereum/aave/aave__market_stats.sql index 94038c31..429e6f8c 100644 --- a/models/ethereum/aave/aave__market_stats.sql +++ b/models/ethereum/aave/aave__market_stats.sql @@ -62,10 +62,38 @@ WITH aave_reads AS ( Table(Flatten(aave_reads.coins)) WHERE value::STRING <> '0x0000000000000000000000000000000000000000'-- AND inputs:address IS NULL ), - -- cast to a wide format next putting one column for every field in every read +-- cast to a wide format next putting one column for every field in every read wide_format AS ( - SELECT * - FROM long_format + SELECT + blockhour, + aave_version, + lending_pool_add, + lending_pool_type, + reserve_token, + "'averagestableborrowrate'", + "'id'", + "'interestratestrategyaddress'", + "'stabledebttokenaddress'", + "'currentstableborrowrate'", + "'currentvariableborrowrate'", + "'totalliquidity'", + "'currentliquidityrate'", + "'variableborrowindex'", + "'variableborrowrate'", + "'atokenaddress'", + "'availableliquidity'", + "'version'", + "'liquidityrate'", + "'stableborrowrate'", + "'totalborrowsstable'", + "'totalborrowsvariable'", + "'lastupdatetimestamp'", + "'liquidityindex'", + "'utilizationrate'", + "'variabledebttokenaddress'", + "'totalstabledebt'", + "'totalvariabledebt'" + FROM long_format pivot(max(value) for field_name IN ('averagestableborrowrate', 'id', 'interestratestrategyaddress', 'stabledebttokenaddress', 'currentstableborrowrate', 'currentvariableborrowrate', 'totalliquidity', 'currentliquidityrate', @@ -96,11 +124,65 @@ reads_parsed AS ( ), -- splitting these up for organization lending_pools_v2 AS ( - SELECT * FROM reads_parsed WHERE lending_pool_type = 'LendingPool' AND aave_version <> 'Aave V1' + SELECT + blockhour, + aave_version, + lending_pool_add, + lending_pool_type, + reserve_token, + atoken_address, + stable_debt_token_address, + variable_debt_token_address, + available_liquidity, + liquidity_rate, + stbl_borrow_rate, + variable_borrow_rate, + total_stable_debt, + total_variable_debt, + utilization_rate + FROM reads_parsed + WHERE lending_pool_type = 'LendingPool' + AND aave_version <> 'Aave V1' ), data_providers_v2 AS ( - SELECT * FROM reads_parsed WHERE lending_pool_type = 'DataProvider' AND aave_version <> 'Aave V1' + SELECT + blockhour, + aave_version, + lending_pool_add, + lending_pool_type, + reserve_token, + atoken_address, + stable_debt_token_address, + variable_debt_token_address, + available_liquidity, + liquidity_rate, + stbl_borrow_rate, + variable_borrow_rate, + total_stable_debt, + total_variable_debt, + utilization_rate + FROM reads_parsed + WHERE lending_pool_type = 'DataProvider' + AND aave_version <> 'Aave V1' ), lending_pools_v1 AS ( - SELECT * FROM reads_parsed WHERE lending_pool_type = 'LendingPool' AND aave_version = 'Aave V1' + SELECT + blockhour, + aave_version, + lending_pool_add, + lending_pool_type, + reserve_token, + atoken_address, + stable_debt_token_address, + variable_debt_token_address, + available_liquidity, + liquidity_rate, + stbl_borrow_rate, + variable_borrow_rate, + total_stable_debt, + total_variable_debt, + utilization_rate + FROM reads_parsed + WHERE lending_pool_type = 'LendingPool' + AND aave_version = 'Aave V1' ), -- format v2/amm data. Need to combine reads from the lending pool and data provider aave_v2 AS ( @@ -156,9 +238,43 @@ aave_v1 AS ( ), aave AS ( - SELECT * FROM aave_v2 + SELECT + blockhour, + reserve_token, + aave_version, + lending_pool_add, + data_provider, + atoken_address, + stable_debt_token_address, + variable_debt_token_address, + total_liquidity, + liquidity_rate, + stbl_borrow_rate, + variable_borrow_rate, + total_stable_debt, + total_variable_debt, + utilization_rate + FROM aave_v2 + UNION - SELECT * FROM aave_v1 + + SELECT + blockhour, + reserve_token, + aave_version, + lending_pool_add, + data_provider, + atoken_address, + stable_debt_token_address, + variable_debt_token_address, + total_liquidity, + liquidity_rate, + stbl_borrow_rate, + variable_borrow_rate, + total_stable_debt, + total_variable_debt, + utilization_rate + FROM aave_v1 ), -- get decimals, preferably from contract reads but using the prices table as a fallback diff --git a/models/ethereum/compound/compound__market_stats.sql b/models/ethereum/compound/compound__market_stats.sql index f9da549e..55309af7 100644 --- a/models/ethereum/compound/compound__market_stats.sql +++ b/models/ethereum/compound/compound__market_stats.sql @@ -179,7 +179,17 @@ comptr AS ( p.token_price as comp_price, comp_price * comp_speed as comp_speed_usd FROM {{ref('ethereum__reads')}} erd - JOIN (SELECT * FROM prices WHERE symbol = 'COMP') p + JOIN ( + SELECT + block_hour, + token_price, + token_decimals, + symbol, + token_contract, + address + FROM prices + WHERE symbol = 'COMP' + ) p ON date_trunc('hour',erd.block_timestamp) = p.block_hour WHERE contract_address = '0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b' diff --git a/models/ethereum/dex/ethereum__dex_liquidity_pools.sql b/models/ethereum/dex/ethereum__dex_liquidity_pools.sql index ef0cd6bf..1cdb2893 100644 --- a/models/ethereum/dex/ethereum__dex_liquidity_pools.sql +++ b/models/ethereum/dex/ethereum__dex_liquidity_pools.sql @@ -121,7 +121,15 @@ WITH v3_pools AS ( -- uni v3 FROM flipside_dev_db.dbt.sushi_liquidity_pools ), new_sushi AS ( - SELECT s.* -- future proofing: once the eth backfill is done these manual write-ins will be dups + SELECT + s.creation_time, + s.creation_tx, + s.factory_address, + s.pool_name, + s.pool_address, + s.token0, + s.token1, + s.platform -- future proofing: once the eth backfill is done these manual write-ins will be dups FROM sushi_write_in s LEFT JOIN v2_pools v ON s.pool_address = v.pool_address @@ -131,26 +139,65 @@ WITH v3_pools AS ( -- uni v3 stack AS ( -- get pool info - SELECT * FROM - v2_pools + SELECT + creation_time, + creation_tx, + factory_address, + pool_name, + pool_address, + token0, + token1, + platform + FROM v2_pools UNION - SELECT * FROM - v2_redshift + SELECT + creation_time, + creation_tx, + factory_address, + pool_name, + pool_address, + token0, + token1, + platform + FROM v2_redshift UNION - SELECT * FROM - new_sushi + SELECT + creation_time, + creation_tx, + factory_address, + pool_name, + pool_address, + token0, + token1, + platform + FROM new_sushi UNION - SELECT * FROM - v3_pools + SELECT + creation_time, + creation_tx, + factory_address, + pool_name, + pool_address, + token0, + token1, + platform + FROM v3_pools ), curve AS ( SELECT - *, + creation_time, + creation_tx, + factory_address, + pool_name, + pool_address, + token0, + token1, + platform, ARRAY_CONSTRUCT(token0,token1) AS tokens FROM stack WHERE pool_address IS NOT NULL AND token0 IS NOT NULL AND token1 IS NOT NULL @@ -171,7 +218,18 @@ stack AS ( ) -SELECT DISTINCT * FROM +SELECT + DISTINCT + creation_time, + creation_tx, + factory_address, + pool_name, + pool_address, + token0, + token1, + platform, + tokens +FROM curve WHERE pool_address IS NOT NULL diff --git a/models/ethereum/dex/ethereum__dex_swaps.sql b/models/ethereum/dex/ethereum__dex_swaps.sql index cc42dfd6..a9adad57 100644 --- a/models/ethereum/dex/ethereum__dex_swaps.sql +++ b/models/ethereum/dex/ethereum__dex_swaps.sql @@ -208,7 +208,20 @@ prices_daily_backup AS( UNION - SELECT * + SELECT + block_timestamp, + pool_address, + pool_name, + token_address, + tx_id, + amount_in, + amount_out, + from_address, + to_address, + amount_usd, + platform, + event_index, + direction FROM v3_swaps UNION diff --git a/models/ethereum/ethereum__erc20_balances.sql b/models/ethereum/ethereum__erc20_balances.sql index e589bf32..133ce0c1 100644 --- a/models/ethereum/ethereum__erc20_balances.sql +++ b/models/ethereum/ethereum__erc20_balances.sql @@ -72,4 +72,19 @@ balances AS ( balance_date >= getdate() - interval '9 months' {% endif %} ) -SELECT * FROM balances ORDER BY balance_date DESC \ No newline at end of file +SELECT + balance_date, + user_address, + label, + address_name, + label_type, + label_subtype, + contract_address, + contract_label, + symbol, + price, + balance, + -- Value of the token in USD + amount_usd +FROM balances +ORDER BY balance_date DESC \ No newline at end of file diff --git a/models/ethereum/ethereum__udm_events.sql b/models/ethereum/ethereum__udm_events.sql index 5679d251..ea2f8a7b 100644 --- a/models/ethereum/ethereum__udm_events.sql +++ b/models/ethereum/ethereum__udm_events.sql @@ -258,9 +258,97 @@ logs AS ( event_name IS NOT NULL AND event_name != '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' ) -SELECT * FROM token_transfers +SELECT + block_timestamp, + block_id, + tx_id, + origin_address, + origin_label_type, + origin_label_subtype, + origin_label, + origin_address_name, + origin_function_signature, + origin_function_name, + from_address, + from_label_type, + from_label_subtype, + from_label, + from_address_name, + to_address, + to_label_type, + to_label_subtype, + to_label, + to_address_name, + event_name, + event_type, + event_id, + contract_address, + symbol, + amount, + amount_usd +FROM token_transfers + UNION ALL -SELECT * FROM eth_transfers + +SELECT + block_timestamp, + block_id, + tx_id, + origin_address, + origin_label_type, + origin_label_subtype, + origin_label, + origin_address_name, + origin_function_signature, + origin_function_name, + from_address, + from_label_type, + from_label_subtype, + from_label, + from_address_name, + to_address, + to_label_type, + to_label_subtype, + to_label, + to_address_name, + event_name, + event_type, + event_id, + contract_address, + symbol, + amount, + amount_usd +FROM eth_transfers + UNION ALL -SELECT * FROM logs + +SELECT + block_timestamp, + block_id, + tx_id, + origin_address, + origin_label_type, + origin_label_subtype, + origin_label, + origin_address_name, + origin_function_signature, + origin_function_name, + from_address, + from_label_type, + from_label_subtype, + from_label, + from_address_name, + to_address, + to_label_type, + to_label_subtype, + to_label, + to_address_name, + event_name, + event_type, + event_id, + contract_address, + symbol, + amount, + amount_usd +FROM logs ORDER BY block_timestamp diff --git a/models/ethereum/nft/cryptokitties/ethereum_dbt__ck_bids.sql b/models/ethereum/nft/cryptokitties/ethereum_dbt__ck_bids.sql index f5cd298b..a32f28c5 100644 --- a/models/ethereum/nft/cryptokitties/ethereum_dbt__ck_bids.sql +++ b/models/ethereum/nft/cryptokitties/ethereum_dbt__ck_bids.sql @@ -35,7 +35,33 @@ nf_token_transfers AS ( token_transfers AS ( SELECT - * + block_timestamp, + block_id, + tx_id, + origin_address, + origin_label_type, + origin_label_subtype, + origin_label, + origin_address_name, + origin_function_signature, + origin_function_name, + from_address, + from_label_type, + from_label_subtype, + from_label, + from_address_name, + to_address, + to_label_type, + to_label_subtype, + to_label, + to_address_name, + event_name, + event_type, + event_id, + contract_address, + symbol, + amount, + amount_usd FROM {{ ref('ethereum__udm_events') }} WHERE amount > 0 diff --git a/models/ethereum/nft/ethereum__nft_events.sql b/models/ethereum/nft/ethereum__nft_events.sql index 3daf8da2..60da00db 100644 --- a/models/ethereum/nft/ethereum__nft_events.sql +++ b/models/ethereum/nft/ethereum__nft_events.sql @@ -10,7 +10,18 @@ with nft as ( SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__art_blocks_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -20,7 +31,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__art_blocks_sales') }} WHERE 1=1 {% if is_incremental() %} @@ -30,7 +52,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__ck_bids') }} WHERE 1=1 {% if is_incremental() %} @@ -40,7 +73,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__ck_lists') }} WHERE 1=1 {% if is_incremental() %} @@ -50,7 +94,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__ck_unlists') }} WHERE 1=1 {% if is_incremental() %} @@ -60,7 +115,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__ck_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -70,7 +136,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__hashmasks_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -80,7 +157,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__hashmasks_sales') }} WHERE 1=1 {% if is_incremental() %} @@ -90,7 +178,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__known_origin_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -100,7 +199,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__makersplace_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -110,7 +220,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__makersplace_sales') }} WHERE 1=1 {% if is_incremental() %} @@ -120,7 +241,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__nifty_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -130,7 +262,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__opensea_sales') }} WHERE 1=1 {% if is_incremental() %} @@ -140,7 +283,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__opensea_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -150,7 +304,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__polkamon_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -160,7 +325,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__rarible_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -170,7 +346,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__rarible_sales') }} WHERE 1=1 {% if is_incremental() %} @@ -180,7 +367,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__sandbox_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -190,7 +388,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__superrare_buys') }} WHERE 1=1 {% if is_incremental() %} @@ -200,7 +409,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__superrare_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -210,7 +430,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__superrare_accept_bids') }} WHERE 1=1 {% if is_incremental() %} @@ -220,7 +451,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__superrare_auction_wins') }} WHERE 1=1 {% if is_incremental() %} @@ -230,7 +472,18 @@ with nft as ( UNION SELECT - * + event_platform, + tx_id, + block_timestamp, + event_type, + contract_address, + token_id, + event_from, + event_to, + price, + platform_fee, + creator_fee, + tx_currency FROM {{ ref('ethereum_dbt__zora_mints') }} WHERE 1=1 {% if is_incremental() %} @@ -241,7 +494,10 @@ with nft as ( price as ( SELECT - * + symbol, + hour, + price, + rn FROM ( SELECT symbol, diff --git a/models/polygon/polygon__transactions.sql b/models/polygon/polygon__transactions.sql index 30960396..efe2ad3b 100644 --- a/models/polygon/polygon__transactions.sql +++ b/models/polygon/polygon__transactions.sql @@ -38,7 +38,22 @@ GROUP BY ), txn AS ( SELECT - * + system_created_at, + chain_id, + block_id, + block_timestamp, + fee, + from_address, + gas_limit, + gas_price, + gas_used, + input_method, + native_value, + nonce, + success, + to_address, + tx_id, + tx_position FROM {{ ref('silver_polygon__transactions') }} diff --git a/models/polygon/polygon__udm_events.sql b/models/polygon/polygon__udm_events.sql index 513aeb33..51f71df0 100644 --- a/models/polygon/polygon__udm_events.sql +++ b/models/polygon/polygon__udm_events.sql @@ -54,7 +54,22 @@ poly_labels AS ( ), base_udm_events AS ( SELECT - * + system_created_at, + chain_id, + block_id, + block_timestamp, + contract_address, + fee, + from_address, + input_method, + log_index, + log_method, + name, + native_value, + symbol, + to_address, + token_value, + tx_id FROM {{ ref('silver_polygon__udm_events')}} where 1=1 @@ -65,7 +80,22 @@ base_udm_events AS ( ), base_tx AS ( SELECT - * + system_created_at, + chain_id, + block_id, + block_timestamp, + fee, + from_address, + gas_limit, + gas_price, + gas_used, + input_method, + native_value, + nonce, + success, + to_address, + tx_id, + tx_position FROM {{ ref('silver_polygon__transactions')}} WHERE 1=1 diff --git a/models/polygon/polygon_dbt__events_emitted.sql b/models/polygon/polygon_dbt__events_emitted.sql index 633cdc8f..3fef561a 100644 --- a/models/polygon/polygon_dbt__events_emitted.sql +++ b/models/polygon/polygon_dbt__events_emitted.sql @@ -8,7 +8,9 @@ }} with base_tables as ( - select * + select + record_metadata, + record_content from {{source('bronze', 'prod_matic_sink_510901820')}} where record_content:model:name::string = 'polygon_events_emitted_model' {% if is_incremental() %} diff --git a/models/polygon/polygon_dbt__transactions.sql b/models/polygon/polygon_dbt__transactions.sql index cbd1b507..6796834e 100644 --- a/models/polygon/polygon_dbt__transactions.sql +++ b/models/polygon/polygon_dbt__transactions.sql @@ -8,7 +8,9 @@ }} with base_tables as ( - select * + select + record_metadata, + record_content from {{source('bronze', 'prod_matic_sink_510901820')}} where record_content:model:name::string = 'polygon_txs_model' {% if is_incremental() %} diff --git a/models/polygon/polygon_dbt__udm_events.sql b/models/polygon/polygon_dbt__udm_events.sql index 3f021b76..d0b3850c 100644 --- a/models/polygon/polygon_dbt__udm_events.sql +++ b/models/polygon/polygon_dbt__udm_events.sql @@ -8,7 +8,9 @@ }} with base_tables as ( - select * + select + record_metadata, + record_content from {{source('bronze', 'prod_matic_sink_510901820')}} where record_content:model:name::string = 'polygon_udm_events_model' {% if is_incremental() %} diff --git a/models/polygon/silver/silver_polygon__events_emitted.sql b/models/polygon/silver/silver_polygon__events_emitted.sql index c115f330..e5b7aa9d 100644 --- a/models/polygon/silver/silver_polygon__events_emitted.sql +++ b/models/polygon/silver/silver_polygon__events_emitted.sql @@ -8,9 +8,37 @@ ) }} -select * +select + system_created_at, + chain_id, + block_id, + block_timestamp, + contract_address, + contract_name, + event_index, + event_inputs, + event_name, + event_removed, + tx_from, + tx_id, + tx_succeeded, + tx_to from ( -select * +select + system_created_at, + chain_id, + block_id, + block_timestamp, + contract_address, + contract_name, + event_index, + event_inputs, + event_name, + event_removed, + tx_from, + tx_id, + tx_succeeded, + tx_to from {{ ref('polygon_dbt__events_emitted')}} WHERE 1=1 {% if is_incremental() %} diff --git a/models/polygon/silver/silver_polygon__transactions.sql b/models/polygon/silver/silver_polygon__transactions.sql index 07b00fb8..b6a8ebcd 100644 --- a/models/polygon/silver/silver_polygon__transactions.sql +++ b/models/polygon/silver/silver_polygon__transactions.sql @@ -8,7 +8,23 @@ ) }} -select * +select + system_created_at, + chain_id, + block_id, + block_timestamp, + fee, + from_address, + gas_limit, + gas_price, + gas_used, + input_method, + native_value, + nonce, + success, + to_address, + tx_id, + tx_position from {{ ref('polygon_dbt__transactions')}} WHERE 1=1 {% if is_incremental() %} diff --git a/models/polygon/silver/silver_polygon__udm_events.sql b/models/polygon/silver/silver_polygon__udm_events.sql index 21b325e0..270e50d9 100644 --- a/models/polygon/silver/silver_polygon__udm_events.sql +++ b/models/polygon/silver/silver_polygon__udm_events.sql @@ -8,9 +8,41 @@ ) }} -select * +select + system_created_at, + chain_id, + block_id, + block_timestamp, + contract_address, + fee, + from_address, + input_method, + log_index, + log_method, + name, + native_value, + symbol, + to_address, + token_value, + tx_id from ( -select * +select + system_created_at, + chain_id, + block_id, + block_timestamp, + contract_address, + fee, + from_address, + input_method, + log_index, + log_method, + name, + native_value, + symbol, + to_address, + token_value, + tx_id from {{ ref('polygon_dbt__udm_events')}} WHERE 1=1 {% if is_incremental() %} diff --git a/models/terra/silver/silver_terra__blocks.sql b/models/terra/silver/silver_terra__blocks.sql index 5bb2d9ee..0f93f535 100644 --- a/models/terra/silver/silver_terra__blocks.sql +++ b/models/terra/silver/silver_terra__blocks.sql @@ -8,7 +8,13 @@ ) }} -select * +select + system_created_at, + chain_id, + block_id, + block_timestamp, + blockchain, + proposer_address from {{ ref('terra_dbt__blocks')}} WHERE 1=1 {% if is_incremental() %} diff --git a/models/terra/silver/silver_terra__msg_events.sql b/models/terra/silver/silver_terra__msg_events.sql index 86e1bea6..feca3b5c 100644 --- a/models/terra/silver/silver_terra__msg_events.sql +++ b/models/terra/silver/silver_terra__msg_events.sql @@ -8,7 +8,22 @@ ) }} -select * +select + system_created_at, + blockchain, + block_id, + block_timestamp, + chain_id, + tx_id, + tx_module, + tx_status, + tx_type, + msg_index, + msg_type, + msg_module, + event_type, + event_index, + event_attributes from {{ ref('terra_dbt__msg_events')}} WHERE 1=1 {% if is_incremental() %} diff --git a/models/terra/silver/silver_terra__msgs.sql b/models/terra/silver/silver_terra__msgs.sql index bf9149b6..35ae3474 100644 --- a/models/terra/silver/silver_terra__msgs.sql +++ b/models/terra/silver/silver_terra__msgs.sql @@ -8,7 +8,20 @@ ) }} -select * +select + system_created_at, + blockchain, + block_id, + block_timestamp, + chain_id, + tx_id, + tx_type, + tx_status, + tx_module, + msg_index, + msg_type, + msg_module, + msg_value from {{ ref('terra_dbt__msgs')}} WHERE 1=1 {% if is_incremental() %} diff --git a/models/terra/silver/silver_terra__transactions.sql b/models/terra/silver/silver_terra__transactions.sql index 02d979a8..adf7e19e 100644 --- a/models/terra/silver/silver_terra__transactions.sql +++ b/models/terra/silver/silver_terra__transactions.sql @@ -8,7 +8,22 @@ ) }} -select * +select + system_created_at, + blockchain, + block_id, + block_timestamp, + chain_id, + codespace, + tx_id, + tx_type, + tx_module, + tx_status, + tx_status_msg, + tx_code, + fee, + gas_wanted, + gas_used from {{ ref('terra_dbt__transactions')}} WHERE 1=1 {% if is_incremental() %} diff --git a/models/terra/silver/silver_terra__transitions.sql b/models/terra/silver/silver_terra__transitions.sql index e22b0e14..d606d36f 100644 --- a/models/terra/silver/silver_terra__transitions.sql +++ b/models/terra/silver/silver_terra__transitions.sql @@ -8,7 +8,16 @@ ) }} -select * +select + system_created_at, + blockchain, + block_id, + block_timestamp, + chain_id, + event, + index, + transition_type, + event_attributes from {{ ref('terra_dbt__transitions')}} WHERE 1=1 {% if is_incremental() %} diff --git a/models/terra/terra__reward.sql b/models/terra/terra__reward.sql index 87c61497..45671c61 100644 --- a/models/terra/terra__reward.sql +++ b/models/terra/terra__reward.sql @@ -76,9 +76,37 @@ SELECT a.amount * price_usd as event_amount_usd, p.symbol AS currency FROM ( - SELECT * FROM withdraw_delegator_rewards + SELECT + blockchain, + chain_id, + tx_status, + block_id, + block_timestamp, + tx_id, + msg_index, + action, + amount, + currency, + validator, + delegator + FROM withdraw_delegator_rewards + UNION ALL - SELECT * FROM withdraw_validator_commission + + SELECT + blockchain, + chain_id, + tx_status, + block_id, + block_timestamp, + tx_id, + msg_index, + action, + amount, + currency, + validator, + delegator + FROM withdraw_validator_commission ) a LEFT OUTER JOIN prices p ON p.currency = a.currency diff --git a/models/terra/terra__staking.sql b/models/terra/terra__staking.sql index c4105d06..ab94e223 100644 --- a/models/terra/terra__staking.sql +++ b/models/terra/terra__staking.sql @@ -87,11 +87,51 @@ SELECT a.amount * price_usd as event_amount_usd, p.symbol AS currency FROM ( - SELECT * FROM delegate + SELECT + blockchain, + chain_id, + tx_status, + block_id, + block_timestamp, + tx_id, + action, + delegator_address, + validator_address, + amount, + currency + FROM delegate + UNION ALL - SELECT * FROM undelegate + + SELECT + blockchain, + chain_id, + tx_status, + block_id, + block_timestamp, + tx_id, + action, + delegator_address, + validator_address, + amount, + currency + FROM undelegate + UNION ALL - SELECT * FROM redelegate + + SELECT + blockchain, + chain_id, + tx_status, + block_id, + block_timestamp, + tx_id, + action, + delegator_address, + validator_address, + amount, + currency + FROM redelegate ) a LEFT OUTER JOIN prices p diff --git a/models/terra/terra_dbt__blocks.sql b/models/terra/terra_dbt__blocks.sql index b1d57375..2ab89571 100644 --- a/models/terra/terra_dbt__blocks.sql +++ b/models/terra/terra_dbt__blocks.sql @@ -8,7 +8,9 @@ }} with base_tables as ( - select * + select + record_metadata, + record_content from {{source('bronze', 'prod_terra_sink_645110886')}} where record_content:model:name::string = 'terra_block_model' {% if is_incremental() %} diff --git a/models/terra/terra_dbt__msg_events.sql b/models/terra/terra_dbt__msg_events.sql index 28e4bde7..23e0a792 100644 --- a/models/terra/terra_dbt__msg_events.sql +++ b/models/terra/terra_dbt__msg_events.sql @@ -8,7 +8,9 @@ }} with base_tables as ( - select * + select + record_metadata, + record_content from {{source('bronze', 'prod_terra_sink_645110886')}} where record_content:model:name::string = 'terra_msg_event_model' {% if is_incremental() %} diff --git a/models/terra/terra_dbt__msgs.sql b/models/terra/terra_dbt__msgs.sql index 8417f5bf..913633b8 100644 --- a/models/terra/terra_dbt__msgs.sql +++ b/models/terra/terra_dbt__msgs.sql @@ -8,7 +8,9 @@ }} with base_tables as ( - select * + select + record_metadata, + record_content from {{source('bronze', 'prod_terra_sink_645110886')}} where record_content:model:name::string = 'terra_msg_model' {% if is_incremental() %} diff --git a/models/terra/terra_dbt__transactions.sql b/models/terra/terra_dbt__transactions.sql index c1801fcc..64444968 100644 --- a/models/terra/terra_dbt__transactions.sql +++ b/models/terra/terra_dbt__transactions.sql @@ -8,7 +8,9 @@ }} with base_tables as ( - select * + select + record_metadata, + record_content from {{source('bronze', 'prod_terra_sink_645110886')}} where record_content:model:name::string = 'terra_tx_model' {% if is_incremental() %} diff --git a/models/terra/terra_dbt__transitions.sql b/models/terra/terra_dbt__transitions.sql index 85836e54..50af0633 100644 --- a/models/terra/terra_dbt__transitions.sql +++ b/models/terra/terra_dbt__transitions.sql @@ -8,7 +8,9 @@ }} with base_tables as ( - select * + select + record_metadata, + record_content from {{source('bronze', 'prod_terra_sink_645110886')}} where record_content:model:name::string = 'terra_transition_model' {% if is_incremental() %} diff --git a/models/thorchain/thorchain__bond_actions.sql b/models/thorchain/thorchain__bond_actions.sql index e701420d..6b301cf5 100644 --- a/models/thorchain/thorchain__bond_actions.sql +++ b/models/thorchain/thorchain__bond_actions.sql @@ -17,7 +17,20 @@ WITH block_prices AS ( ), bond_events AS ( - SELECT * FROM {{ ref('thorchain__bond_events') }} + SELECT + block_timestamp, + block_id, + event_id, + tx_id, + to_addres, + from_address, + MEMO, + ASSET, + blockchain, + BOND_TYPE, + E8, + ASSET_E8 + FROM {{ ref('thorchain__bond_events') }} WHERE TRUE {% if is_incremental() %} AND block_timestamp >= getdate() - interval '2 days' diff --git a/models/thorchain/thorchain__liquidity_actions.sql b/models/thorchain/thorchain__liquidity_actions.sql index 72ad5f8c..a43ead27 100644 --- a/models/thorchain/thorchain__liquidity_actions.sql +++ b/models/thorchain/thorchain__liquidity_actions.sql @@ -9,7 +9,20 @@ }} WITH stakes AS ( - SELECT * FROM {{ ref('thorchain__stake_events') }} + SELECT + block_timestamp, + block_id, + event_id, + rune_tx_id, + pool_name, + RUNE_E8, + rune_address, + STAKE_UNITS, + asset_tx_id, + ASSET_E8, + asset_address, + asset_blockchain + FROM {{ ref('thorchain__stake_events') }} WHERE TRUE {% if is_incremental() %} AND block_timestamp >= getdate() - interval '2 days' @@ -18,7 +31,25 @@ WITH stakes AS ( {% endif %} ), unstakes AS ( - SELECT * FROM {{ ref('thorchain__unstake_events') }} + SELECT + block_timestamp, + block_id, + event_id, + tx_id, + blockchain, + pool_name, + to_address, + from_address, + ASSET, + EMIT_RUNE_E8, + ASYMMETRY, + ASSET_E8, + STAKE_UNITS, + MEMO, + EMIT_ASSET_E8, + IMP_LOSS_PROTECTION_E8, + BASIS_POINTS + FROM {{ ref('thorchain__unstake_events') }} WHERE TRUE {% if is_incremental() %} AND block_timestamp >= getdate() - interval '2 days' diff --git a/models/thorchain/thorchain__swaps.sql b/models/thorchain/thorchain__swaps.sql index 16c6b605..d0f5bffc 100644 --- a/models/thorchain/thorchain__swaps.sql +++ b/models/thorchain/thorchain__swaps.sql @@ -9,7 +9,24 @@ }} WITH swaps AS ( - SELECT * FROM {{ ref('thorchain__swap_events') }} + SELECT + block_timestamp, + block_id, + tx_id, + blockchain, + to_address, + from_address, + TO_ASSET, + FROM_ASSET, + SWAP_SLIP_BP, + LIQ_FEE_IN_RUNE_E8, + LIQ_FEE_E8, + TO_E8, + pool_name, + MEMO, + TO_E8_MIN, + FROM_E8 + FROM {{ ref('thorchain__swap_events') }} WHERE TRUE {% if is_incremental() %} AND block_timestamp >= getdate() - interval '2 days'