Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dags/ethereumetl_airflow/build_partition_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,19 @@ def enrich_task(ds, **kwargs):
and (call_type not in ('delegatecall', 'callcode', 'staticcall') or call_type is null)
union all
-- transaction fees debits
select miner as address, sum(cast(receipt_gas_used as numeric) * cast(gas_price as numeric)) as value
select
miner as address,
sum(cast(receipt_gas_used as numeric) * cast((receipt_effective_gas_price - coalesce(base_fee_per_gas, 0)) as numeric)) as value
from `{public_project_id}.{public_dataset_name}.transactions` as transactions
join `{public_project_id}.{public_dataset_name}.blocks` as blocks on blocks.number = transactions.block_number
where true
and date(transactions.block_timestamp) > '{ds}'
group by blocks.miner
group by blocks.number, blocks.miner
union all
-- transaction fees credits
select from_address as address, -(cast(receipt_gas_used as numeric) * cast(gas_price as numeric)) as value
select
from_address as address,
-(cast(receipt_gas_used as numeric) * cast(receipt_effective_gas_price as numeric)) as value
from `{public_project_id}.{public_dataset_name}.transactions`
where true
and date(block_timestamp) > '{ds}'
Expand Down