shadabPEPE trade per platform copy
Updated 2024-03-14
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
›
⌄
-- forked from Moe / PEPE trade per platform @ https://flipsidecrypto.xyz/Moe/q/JvtvTbrVu7Bs/pepe-trade-per-platform
with price as (
select
HOUR :: Date as day,
avg(PRICE) as price,
token_address
from
ethereum.price.ez_hourly_token_prices
group by
1,
token_address
),
mid as (
select
a.*,
case
when amount_in_usd is null then amount_in * b.price
else amount_in_usd
end as sell_usd,
case
when amount_out_usd is null then amount_out * c.price
else amount_out_usd
end as buy_usd
from
ethereum.defi.ez_dex_swaps a
left outer join price b on a.BLOCK_TIMESTAMP :: date = b.day
and a.token_in = b.token_address
left outer join price c on a.BLOCK_TIMESTAMP :: date = c.day
and a.token_out = c.token_address
)
select
-- date_trunc(day, BLOCK_TIMESTAMP) as date,
'Pepe' as token,
-- concat (SYMBOL_IN,'/',SYMBOL_OUT) as pair ,
PLATFORM,