Skip to content

Commit

Permalink
add solana to metrics fees (duneanalytics#7071)
Browse files Browse the repository at this point in the history
* add solana to fees metrics

* force short runtime

* Revert "force short runtime"

This reverts commit 503f277.

* update to handle solana in gas.fees

---------

Co-authored-by: 0xRob <[email protected]>
  • Loading branch information
jeff-dude and 0xRobin authored Oct 31, 2024
1 parent 32be262 commit 4bad8d9
Showing 3 changed files with 46 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ models:
contributors: jeff-dude
config:
tags: ['metrics', 'fees', 'gas', 'daily']
description: "Sum of total fees spent per day across all chains available in raw gas.fees table"
description: "Sum of total fees spent per day across all chains available in gas.fees and gas_solana.fees tables"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
Original file line number Diff line number Diff line change
@@ -9,30 +9,58 @@
)
}}

with daily_data as (
select
blockchain
, block_date
, sum(tx_fee_usd) as gas_fees_usd
from
{{ source('gas', 'fees') }}
{% if is_incremental() %}
where
{{ incremental_predicate('block_date') }}
{% endif %}
group by
blockchain
, block_date
with fees as (
select
blockchain
, block_date
, sum(tx_fee_usd) as gas_fees_usd
from
{{ source('gas', 'fees') }}
{% if is_incremental() %}
where
{{ incremental_predicate('block_date') }}
{% endif %}
group by
blockchain
, block_date
), solana_vote_fees as (
-- solana vote fees are stored in a different spell due to data volume & lack of value-add for materializing the fee breakdown
select
blockchain
, block_date
, sum(tx_fee_usd) as gas_fees_usd
from
{{ source('gas_solana', 'vote_fees') }}
{% if is_incremental() %}
where
{{ incremental_predicate('block_date') }}
{% endif %}
group by
blockchain
, block_date
), combined_fees as (
select
fees.blockchain
, fees.block_date
, fees.gas_fees_usd + coalesce(solana_vote_fees.gas_fees_usd, 0) as gas_fees_usd
from
fees
left join
solana_vote_fees
on
fees.blockchain = solana_vote_fees.blockchain
and fees.block_date = solana_vote_fees.block_date
)


select
blockchain
,block_date
,case when blockchain = 'tron'
then gas_fees_usd * coalesce(t.trx_fee_ratio,0.0) -- apply correction to account for subsidized fees
else gas_fees_usd end
as gas_fees_usd
from daily_data
from combined_fees
left join {{ref('tron_fee_correction')}} t
on block_date = t.day
and blockchain = 'tron'
3 changes: 2 additions & 1 deletion sources/_subprojects_outputs/solana/_sources.yml
Original file line number Diff line number Diff line change
@@ -3,4 +3,5 @@ version: 2
sources:
- name: gas_solana
tables:
- name: fees
- name: fees
- name: vote_fees

0 comments on commit 4bad8d9

Please sign in to comment.