RamaharOptimism DEXs general
Updated 2022-10-26Copy Reference Fork
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 op_dexs as (SELECT
'Uniswap' as DEX,
l.block_timestamp,
l.tx_hash,
l.origin_from_address,
l.contract_address,
t.tx_fee,
t.gas_price,
t.gas_used,
p.symbol,
((p.price * m.raw_amount) / POW(10, p.decimals)) as amount_usd
FROM optimism.core.fact_event_logs l
join optimism.core.fact_transactions t on l.tx_hash = t.tx_hash
join optimism.core.fact_token_transfers m on l.tx_hash = m.tx_hash
join optimism.core.fact_hourly_token_prices p ON m.contract_address = p.token_address AND date_trunc('hour', m.block_timestamp) = p.hour
where l.origin_to_address in ('0xe592427a0aece92de3edee1f18e0157c05861564','0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45')
and l.tx_status = 'SUCCESS' and l.event_name = 'Swap'
and l.block_timestamp >= CURRENT_DATE - {{period}}
UNION ALL
SELECT
'0x Splits' as DEX,
l.block_timestamp,
l.tx_hash,
l.origin_from_address,
l.contract_address,
t.tx_fee,
t.gas_price,
t.gas_used,
p.symbol,
((p.price * m.raw_amount) / POW(10, p.decimals)) as amount_usd
FROM optimism.core.fact_event_logs l
join optimism.core.fact_transactions t on l.tx_hash = t.tx_hash
Run a query to Download Data