Skip to content

Commit 24463e4

Browse files
krishgkajeff-dude
andauthored
updated gas.fees model files due to changes in prices.usd_native (#8303)
* updated gas.fees model files due to changes in prices.usd_native * fixed syntax --------- Co-authored-by: jeff-dude <[email protected]>
1 parent 31323ff commit 24463e4

File tree

4 files changed

+83
-4
lines changed

4 files changed

+83
-4
lines changed

dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/apechain/gas_apechain_fees.sql

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,83 @@
1111
,incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')]
1212
)
1313
}}
14-
{{ arbitrum_orbit_stack_gas_fees(blockchain) }}
14+
15+
WITH base_model as (
16+
SELECT
17+
txns.block_time
18+
,txns.block_number
19+
,txns.hash AS tx_hash
20+
,txns."from" AS tx_from
21+
,txns.to AS tx_to
22+
,cast(gas_price as uint256) as gas_price
23+
,txns.gas_used as gas_used
24+
,cast(base_fee_per_gas as uint256) * cast(txns.gas_used as uint256) as tx_fee_raw
25+
,map(array['base_fee'], array[cast(base_fee_per_gas as uint256) * cast(txns.gas_used as uint256)]) as tx_fee_breakdown_raw
26+
,0x7f9fbf9bdd3f4105c478b996b648fe6e828a1e98 as tx_fee_currency
27+
,blocks.miner AS block_proposer
28+
,txns.max_fee_per_gas
29+
,txns.priority_fee_per_gas
30+
,txns.max_priority_fee_per_gas
31+
,blocks.base_fee_per_gas
32+
,txns.gas_limit
33+
,CASE --safe divide-by-zero
34+
WHEN txns.gas_limit = 0 THEN NULL
35+
WHEN txns.gas_limit != 0 THEN cast(txns.gas_used as double) / cast(txns.gas_limit as double)
36+
END AS gas_limit_usage
37+
{% if blockchain == 'apechain' %}
38+
,l1_gas_used
39+
{% endif %}
40+
FROM {{ source(blockchain, 'transactions') }} txns
41+
INNER JOIN {{ source(blockchain, 'blocks') }} blocks
42+
ON txns.block_number = blocks.number
43+
{% if is_incremental() %}
44+
AND {{ incremental_predicate('blocks.time') }}
45+
{% endif %}
46+
{% if test_short_ci %}
47+
WHERE {{ incremental_predicate('txns.block_time') }}
48+
OR txns.hash in (select tx_hash from {{ref('evm_gas_fees')}})
49+
{% elif is_incremental() %}
50+
WHERE {{ incremental_predicate('txns.block_time') }}
51+
{% endif %}
52+
)
53+
54+
SELECT
55+
'{{blockchain}}' as blockchain
56+
,CAST(date_trunc('month', block_time) AS DATE) AS block_month
57+
,CAST(date_trunc('day', block_time) AS DATE) AS block_date
58+
,block_time
59+
,block_number
60+
,tx_hash
61+
,tx_from
62+
,tx_to
63+
,gas_price
64+
,gas_used
65+
,p.symbol as currency_symbol
66+
,coalesce(tx_fee_raw, 0) as tx_fee_raw
67+
,coalesce(tx_fee_raw, 0) / pow(10,p.decimals) as tx_fee
68+
,coalesce(tx_fee_raw, 0) / pow(10,p.decimals) * p.price as tx_fee_usd
69+
,transform_values(tx_fee_breakdown_raw,
70+
(k,v) -> coalesce(v, cast(0 as uint256))) as tx_fee_breakdown_raw
71+
,transform_values(tx_fee_breakdown_raw,
72+
(k,v) -> coalesce(v, cast(0 as uint256)) / pow(10,p.decimals) ) as tx_fee_breakdown
73+
,transform_values(tx_fee_breakdown_raw,
74+
(k,v) -> coalesce(v, cast(0 as uint256)) / pow(10,p.decimals) * p.price) as tx_fee_breakdown_usd
75+
,tx_fee_currency
76+
,block_proposer
77+
,max_fee_per_gas
78+
,priority_fee_per_gas
79+
,max_priority_fee_per_gas
80+
,base_fee_per_gas
81+
,gas_limit
82+
,gas_limit_usage
83+
{% if blockchain == 'apechain' %}
84+
,l1_gas_used
85+
{% endif %}
86+
FROM base_model
87+
LEFT JOIN {{ ref('prices_usd_with_native') }} p
88+
ON p.blockchain = '{{blockchain}}'
89+
AND p.contract_address = tx_fee_currency
90+
AND p.minute = date_trunc('minute', block_time)
91+
{% if is_incremental() %}
92+
AND {{ incremental_predicate('p.minute') }}
93+
{% endif %}

dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/mantle/gas_mantle_fees.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ WITH base_model as (
3535
)
3636
end
3737
) as tx_fee_breakdown_raw
38-
,{{var('ETH_ERC20_ADDRESS')}} as tx_fee_currency
38+
,0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000 as tx_fee_currency
3939
,blocks.miner AS block_proposer
4040
,txns.max_fee_per_gas
4141
,txns.priority_fee_per_gas

dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/polygon/gas_polygon_fees.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ WITH base_model as (
3434
)
3535
end
3636
) as tx_fee_breakdown_raw
37-
,{{var('ETH_ERC20_ADDRESS')}} as tx_fee_currency
37+
,0x0000000000000000000000000000000000001010 as tx_fee_currency
3838
,blocks.miner AS block_proposer
3939
,txns.max_fee_per_gas
4040
,txns.priority_fee_per_gas

dbt_subprojects/hourly_spellbook/models/_sector/gas/fees/zksync/gas_zksync_fees.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ WITH base_model as (
2828
map()
2929
,map(array['base_fee'], array[(cast(gas_price as uint256) * cast(txns.gas_used as uint256))])
3030
) as tx_fee_breakdown_raw
31-
,{{var('ETH_ERC20_ADDRESS')}} as tx_fee_currency
31+
,0x000000000000000000000000000000000000800a as tx_fee_currency
3232
,blocks.miner AS block_proposer
3333
,txns.max_fee_per_gas
3434
,txns.priority_fee_per_gas

0 commit comments

Comments
 (0)