CryptoIcicleSushi-89. Gas as a proxy of activity
Updated 2022-06-05
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
-- Payout 27.93 SUSHI
-- Grand Prize 83.8 SUSHI
-- Level Beginner
-- Q89. How much did sushi users pay for gas in 2022? Is there a correlation with the price of ETH? Can you comment on the spikes in the chart?
with
token_price as (
select
date_trunc('day', hour) as date,
avg(price) as price
from ethereum.token_prices_hourly
where token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' -- WETH
and hour >= '2022-01-01'
group by date
),
txns as (
select
t.gas_used,
price,
(t.gas_used * gas_price)/1e9 as gas_used_eth,
gas_used_eth * price as gas_used_usd,
s.*
from ethereum.sushi.ez_swaps s
join ethereum.core.fact_transactions t on s.tx_hash = t.tx_hash
join token_price p on p.date = s.block_timestamp::date
where t.block_timestamp >='2022-01-01' and s.block_timestamp >='2022-01-01'
)
select
block_timestamp::date as date,
avg(price) as eth_price,
sum(gas_used_eth) as daily_gas_used_eth,
sum(gas_used_usd) as daily_gas_used_usd,
sum(daily_gas_used_eth) over (order by date asc rows between unbounded preceding and current row) as cum_gas_used_eth,
sum(daily_gas_used_usd) over (order by date asc rows between unbounded preceding and current row) as cum_gas_used_usd
from txns
Run a query to Download Data