forked from duneanalytics/spellbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'duneanalytics:main' into main
- Loading branch information
Showing
237 changed files
with
2,276 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 14 additions & 11 deletions
25
dbt_subprojects/daily_spellbook/models/_sector/gas/fees/gas_fees.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
dbt_subprojects/daily_spellbook/models/_sector/gas/fees/mantle/_schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: gas_mantle_fees | ||
meta: | ||
blockchain: mantle | ||
sector: gas | ||
contributors: soispoke, ilemi | ||
config: | ||
tags: ['mantle', 'gas', 'fees'] | ||
description: > | ||
Gas Fees on mantle rollup Layer 2 | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- block_number | ||
- tx_hash | ||
columns: | ||
- &blockchain | ||
name: blockchain | ||
description: "Blockchain name" | ||
- &block_time | ||
name: block_time | ||
description: "Timestamp for block event time in UTC" | ||
- &block_number | ||
name: block_number | ||
description: "Block number" | ||
- &tx_hash | ||
name: tx_hash | ||
description: "Primary key of the transaction" | ||
- &tx_sender | ||
name: tx_sender | ||
description: "Initiated the transaction" | ||
- &tx_receiver | ||
name: tx_receiver | ||
description: "Received the transaction" | ||
- &native_token_symbol | ||
name: native_token_symbol | ||
description: "Symbol of native token (ETH) for the Ethereum Blockchain" | ||
- &tx_amount_native | ||
name: tx_amount_native | ||
description: "Amount of native tokens (ETH) transferred from sender to recipient" | ||
- &tx_amount_usd | ||
name: tx_amount_usd | ||
description: "Amount of $USD transferred from sender to recipient" | ||
- &tx_fee_native | ||
name: tx_fee_native | ||
description: "Total amount of native tokens (ETH) paid in gas fees" | ||
- &tx_fee_usd | ||
name: tx_fee_usd | ||
description: "Total amount of $USD paid in gas fees" | ||
- &burned_native | ||
name: burned_native | ||
description: "Total amount of native tokens (ETH) burned for this transaction, not applicable to L2 because transactions only indirectly burn gas on L1" | ||
- &burned_usd | ||
name: burned_usd | ||
description: "Total amount of $USD burned for this transaction, not applicable to L2 because transactions only indirectly burn gas on L1" | ||
- &validator | ||
name: validator | ||
description: "Address of blockchain validator for this transaction within the block, also referred to as miner before the Merge when Ethereum's consensus mechanism was PoW" | ||
- &gas_price_gwei | ||
name: gas_price_gwei | ||
description: "Gas price (per gas unit) denoted in gwei" | ||
- &gas_price_usd | ||
name: gas_price_usd | ||
description: "Gas price (per gas unit) denoted in $USD" | ||
- &gas_used | ||
name: gas_used | ||
description: "Amount of L2 gas units consumed by the transaction" | ||
- &gas_limit | ||
name: gas_limit | ||
description: "Maximum amount of gas units that can be consumed by the transaction on zksync L2" | ||
- &gas_usage_percent | ||
name: gas_usage_percent | ||
description: "Percentage of Gas Used relative to the gas limit on zksync L2" | ||
- &type | ||
name: type | ||
description: "Legacy (Pre Typed-Transactions), AccessList (EIP-2930), DynamicFee (EIP-1559), EIP-712, or Priority (L1 -> L2 Transactions)" |
55 changes: 55 additions & 0 deletions
55
dbt_subprojects/daily_spellbook/models/_sector/gas/fees/mantle/gas_mantle_fees.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{{ config( | ||
tags = ['prod_exclude'], | ||
schema = 'gas_mantle', | ||
alias = 'fees', | ||
partition_by = ['block_month'], | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy='merge', | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], | ||
unique_key = ['tx_hash','block_number'] | ||
) | ||
}} | ||
|
||
SELECT | ||
'mantle' as blockchain, | ||
date_trunc('day', block_time) AS block_date, | ||
CAST(date_trunc('month', block_time) AS DATE) AS block_month, | ||
block_number, | ||
block_time, | ||
txns.hash AS tx_hash, | ||
txns."from" AS tx_sender, | ||
txns.to AS tx_receiver, | ||
'ETH' as native_token_symbol, | ||
value/1e18 AS tx_amount_native, | ||
value/1e18 * p.price AS tx_amount_usd, | ||
(l1_fee/1e18 + ((txns.gas_used/1e18) * txns.gas_price)) as tx_fee_native, | ||
(l1_fee/1e18 + ((txns.gas_used/1e18) * txns.gas_price)) * p.price AS tx_fee_usd, | ||
cast(NULL as double) AS burned_native, -- Not applicable for L2s | ||
cast(NULL as double) AS burned_usd, -- Not applicable for L2s | ||
cast(NULL as VARBINARY) as validator, -- Not applicable for L2s | ||
txns.gas_price/1e9 as gas_price_gwei, | ||
txns.gas_price/1e18 * p.price as gas_price_usd, | ||
txns.gas_used as gas_used, | ||
txns.gas_limit as gas_limit, | ||
CASE | ||
WHEN txns.gas_limit = 0 THEN NULL | ||
WHEN txns.gas_limit != 0 THEN txns.gas_used / txns.gas_limit * 100 | ||
END AS gas_usage_percent, | ||
type as transaction_type | ||
FROM {{ source('mantle','transactions') }} txns | ||
INNER JOIN {{ source('mantle','blocks') }} blocks | ||
ON blocks.number = txns.block_number | ||
{% if is_incremental() %} | ||
AND {{ incremental_predicate('blocks.time') }} | ||
{% endif %} | ||
LEFT JOIN {{ source('prices','usd') }} p | ||
ON p.minute = date_trunc('minute', txns.block_time) | ||
AND p.blockchain = 'mantle' | ||
AND p.symbol = 'WETH' | ||
{% if is_incremental() %} | ||
AND {{ incremental_predicate('p.minute') }} | ||
{% endif %} | ||
{% if is_incremental() %} | ||
WHERE {{ incremental_predicate('txns.block_time') }} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.