adambala8531
Updated 2022-12-07
999
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 a as
(
with base as (
select block_timestamp,
'Sushiswap' as platform ,
tx_hash ,
origin_from_address swapper,
(amount_in_usd) as AMOUNT_IN_USD
from optimism.sushi.ez_swaps
where block_timestamp >= '2022-01-01'
-- and token_in = '0x4200000000000000000000000000000000000042' or token_out = '0x4200000000000000000000000000000000000042'
union all
select block_timestamp,
'Uniswap' as platform,
a.tx_hash,
a.origin_from_address swapper,
((c.price * b.raw_amount)/pow(10, c.decimals)) as AMOUNT_IN_USD
from optimism.core.fact_event_logs a
join optimism.core.fact_token_transfers b using(tx_hash)
join optimism.core.fact_hourly_token_prices c on c.token_address = b.contract_address and date_trunc('hour', b.block_timestamp) = c.hour
where a.event_name = 'Swap'
and a.origin_to_address in ('0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45','0xe592427a0aece92de3edee1f18e0157c05861564')
and a.tx_status ='SUCCESS' and a.block_timestamp >= '2022-01-01' --and token_address = '0x4200000000000000000000000000000000000042'
union all
select
block_timestamp,
'Velodrome' as platform,
tx_hash,
Run a query to Download Data