nitsOptimism Gas fee per swap
Updated 2022-11-04Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
›
⌄
with op_fees as
(SELECT * from optimism.core.fact_transactions
where tx_hash in
(SELECT tx_hash from optimism.sushi.ez_swaps)),
eth_prices as
(SELECT date(hour) as day, avg(price) as avg_price
from ethereum.core.fact_hourly_token_prices
where symbol = 'WETH' and day >= CURRENT_DATE -90
GROUP by 1 )
SELECT *, total_fees* avg_price as fee_usd,
sum(fee_usd) over (order by day ) as cum_fees,
sum(total_txs) over (order by day ) as cum_txs,
cum_fees/cum_txs as avg_fee_per_tx
from
(SELECT date(block_timestamp) as day_, count(DISTINCT tx_hash) as total_txs,
sum(tx_fee) as total_fees
from op_fees
GROUP by 1)
inner join eth_prices
on day = day_
limit 100
Run a query to Download Data