Afonso_Diazgrouping fee
Updated 2024-01-18
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
›
⌄
with pricet as (
select
date_trunc('day', recorded_hour) as date,
symbol,
token_address,
avg(close) as price
from
solana.price.ez_token_prices_hourly
where
symbol in ('sol', 'eth')
group by
1,
2,
3
),
main as (
select
tx_id,
case
when swap_program ilike 'jupiter%' then 'Jupiter'
when swap_program ilike 'orca%' then 'Orca'
when swap_program ilike 'raydium%' then 'Raydium'
when swap_program ilike 'saber%' then 'Saber'
else initcap(swap_program)
end as program,
block_timestamp,
fee / 1e9 * pricet1.price as swap_fee
from
solana.defi.fact_swaps
join solana.core.fact_transactions using(tx_id, block_timestamp)
join pricet pricet1 on pricet1.date = date_trunc('day', block_timestamp :: date)
and symbol = 'sol'
where
block_timestamp :: date >= '2021-01-01'
and succeeded = 1
union
QueryRunArchived: QueryRun has been archived