Skip to content

Commit 7dc65c7

Browse files
author
sam
committed
feat(gas): gwei specific queries
new directory specifically for gas measurements, etc.
1 parent 4f37697 commit 7dc65c7

17 files changed

+1074
-236
lines changed

.github/workflows/autoformat.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
name: "Formatting queries"
22
on: # rebuild any PRs and master branch changes
3-
pull_request:
4-
push:
5-
branches:
6-
- master
3+
pull_request:
4+
push:
5+
branches:
6+
- master
77

88
jobs:
9-
test: # make sure the action works on a clean machine without building
10-
name: Run auto formatter
11-
runs-on: ubuntu-latest
9+
test: # make sure the action works on a clean machine without building
10+
name: Run auto formatter
11+
runs-on: ubuntu-latest
1212

13-
steps:
14-
- name: Check out Git repository
15-
uses: actions/checkout@v2
13+
steps:
14+
- name: Check out Git repository
15+
uses: actions/checkout@v2
1616

17-
- name: Install zetasql
18-
run: |
19-
wget https://github.com/Matts966/zetasql-formatter/releases/latest/download/zetasql-formatter_linux_x86_64.zip
20-
sudo unzip zetasql-formatter_linux_x86_64.zip -d /usr/local/bin
21-
rm zetasql-formatter_linux_x86_64.zip
17+
- name: Install zetasql
18+
run: |
19+
wget https://github.com/Matts966/zetasql-formatter/releases/latest/download/zetasql-formatter_linux_x86_64.zip
20+
sudo unzip zetasql-formatter_linux_x86_64.zip -d /usr/local/bin
21+
rm zetasql-formatter_linux_x86_64.zip
2222
23-
- name: SQLAutoFormatter
24-
uses: yoheikikuta/[email protected]
25-
with:
26-
github_token: ${{ secrets.github_token }}
23+
- name: SQLAutoFormatter
24+
uses: yoheikikuta/[email protected]
25+
with:
26+
github_token: ${{ secrets.github_token }}

.nojekyll

Whitespace-only changes.

README.md

Lines changed: 198 additions & 213 deletions
Large diffs are not rendered by default.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SELECT
2+
DATE_TRUNC('hour',block_time) AS dt
3+
, (PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS _25_gas_price_gwei
4+
, (PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS median_gas_price_gwei
5+
, (PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS _75_gas_price_gwei
6+
FROM ethereum.transactions
7+
WHERE
8+
block_time >= (DATE_TRUNC('hour',CURRENT_TIMESTAMP) - '3 days'::INTERVAL)
9+
GROUP BY 1
10+
ORDER BY 1;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
SELECT
2+
DATE_TRUNC('day', t.block_time) AS dt,
3+
sum(t.gas_used / 12000000) / (60*60*24/14) as daily_gas_used_ratio
4+
FROM ethereum.transactions t
5+
WHERE t."to" = '\x860bd2dba9Cd475A61E6d1b45e16c365F6D78F66'
6+
OR t."to" = '\xb958a8f59ac6145851729f73c7a6968311d8b633'
7+
OR t."to" = '\x85c5c26dc2af5546341fc1988b9d178148b4838b'
8+
OR t."to" = '\x8018280076d7fa2caa1147e441352e8a89e1ddbe'
9+
OR t."to" = '\x693c188e40f760ecf00d2946ef45260b84fbc43e'
10+
OR t."to" = '\x0000000000c90bc353314b6911180ed7e06019a9'
11+
OR t."to" = '\xce5702e94ad38c061e44a4a049cc29261f992846'
12+
OR t."to" = '\x514fd3b8109cfb7cde4b17e4912fd56690c23145'
13+
OR t."to" = '\xa57bd00134b2850b2a1c55860c9e9ea100fdd6cf'
14+
OR t."to" = '\x8977c88d021882ef712200142062ed636031a3fd'
15+
OR t."to" = '\x985149cf58af5d2f50dee363a52ed4e0acc10cf1'
16+
OR t."to" = '\xb14a74c43ce0bf8f7912f7f1f8feb90b4b5f466b'
17+
OR t."to" = '\xc2a694c5ced27e3d3a5a8bd515a42f2b89665003'
18+
OR t."to" = '\x00000000b1786c9698c160d78232c78d6f6474fe'
19+
OR t."to" = '\x000000000000deab340f067535869a0e5226e58a'
20+
OR t."to" = '\x28f2914ebb7ac98feefa7f6008a76e70bfa7963c'
21+
OR t."to" = '\x9799b475dec92bd99bbdd943013325c36157f383'
22+
OR t."to" = '\xf6fb09a41fa6c18cebc1e7c6f75a8664d69e4d48'
23+
OR t."to" = '\xe9519677e6ec8d2d6bfab92a059529fea6075d37'
24+
OR t."to" = '\x000000000000006f6502b7f2bbac8c30a3f67e9a'
25+
OR t."to" = '\xf1ad4bfdf8829d55ec0ce7900ef9d122b2610673'
26+
OR t."to" = '\x8a3960472b3d63894b68df3f10f58f11828d6fd9'
27+
OR t."to" = '\x762ed657b76372f8c08c6f7e0aa4170658c4ca35'
28+
OR t."to" = '\x78a55b9b3bbeffb36a43d9905f654d2769dc55e8'
29+
OR t."to" = '\xf443253607dbde5bda77c358c9b9f244d819e25c'
30+
OR t."to" = '\xe33c8e3a0d14a81f0dd7e174830089e82f65fc85'
31+
GROUP BY 1

dune/gas/BlocksFilledAvgPerHr.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SELECT
2+
date_trunc('hour', time) as day,
3+
AVG(gas_used * 100 / gas_limit) as avg_block_filled
4+
FROM ethereum."blocks"
5+
WHERE time > now() - interval '14 days'
6+
GROUP BY 1
7+
ORDER BY 1 DESC
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
WITH
2+
median_gas_price AS (
3+
SELECT
4+
(PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY gas_price)) AS median_gas_price
5+
FROM ethereum.transactions
6+
WHERE
7+
block_time >= (CURRENT_TIMESTAMP - '15 minutes'::INTERVAL)
8+
)
9+
, eth_price AS (
10+
SELECT DISTINCT
11+
LAST_VALUE(price)
12+
OVER
13+
(
14+
ORDER BY minute
15+
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
16+
) AS price
17+
FROM prices.layer1_usd_eth
18+
WHERE
19+
minute > (CURRENT_DATE - '1 days'::INTERVAL)
20+
)
21+
SELECT
22+
mgp.median_gas_price / 1e9 AS median_gas_price
23+
, ((mgp.median_gas_price * 21000) / 1e18) * ep.price AS cost_of_eth_transfer
24+
-- https://explore.duneanalytics.com/queries/7870/source#15683
25+
, ((mgp.median_gas_price * 44358) / 1e18) * ep.price AS cost_of_erc20_approval
26+
, ((mgp.median_gas_price * 41209) / 1e18) * ep.price AS cost_of_erc20_transfer
27+
, ((mgp.median_gas_price * 126899) / 1e18) * ep.price AS cost_of_uniswap_trade
28+
, ((mgp.median_gas_price * 189275) / 1e18) * ep.price AS cost_of_compound_erc20_deposit
29+
--, ((mgp.median_gas_price * 225000) / 1e18) * ep.price AS cost_of_0x_fill
30+
--, ((mgp.median_gas_price * 471097) / 1e18) * ep.price AS cost_of_kyber_trade
31+
FROM median_gas_price mgp
32+
CROSS JOIN eth_price ep;

dune/gas/GasPriceRanges_hourly.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SELECT
2+
(PERCENTILE_CONT(0.1) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS _10_gas_price_gwei
3+
,(PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS _25_gas_price_gwei
4+
,(PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS median_gas_price_gwei
5+
,(PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS _75_gas_price_gwei
6+
,(PERCENTILE_CONT(0.90) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS _90_gas_price_gwei
7+
FROM ethereum.transactions
8+
WHERE
9+
block_time >= (DATE_TRUNC('minute',CURRENT_TIMESTAMP) - '1 hour'::INTERVAL)

dune/gas/MEV_ZeroCostTx.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
select t.*, b.miner --t.block_time, t.success, t."hash", t."from", t."to", b.miner, t.index, t.gas_used, t.nonce, t.block_number, t.block_hash, t.gas_limit, t.gas_price, t.data
2+
from ethereum.transactions t
3+
join ethereum.blocks b
4+
on t.block_hash = b.hash
5+
where t.gas_price = 0
6+
and t.block_time >= '2021-01-01'

dune/gas/MedianGasPrice_24hrs.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT
2+
DATE_TRUNC('hour',block_time) AS dt
3+
, (PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY gas_price)) / 1e9 AS median_gas_price_gwei
4+
FROM ethereum.transactions
5+
WHERE
6+
block_time >= (DATE_TRUNC('hour',CURRENT_TIMESTAMP) - '1 days'::INTERVAL)
7+
GROUP BY 1
8+
ORDER BY 1;

0 commit comments

Comments
 (0)