cheeyoung-kekVolume 3
Updated 2022-08-24Copy 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with price as (
select DISTINCT symbol,decimals, token_address, avg(price) price_usd
from optimism.core.fact_hourly_token_prices
where token_address in ('0x7f5c764cbc14f9669b88837ca1490cca17c31607',
'0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9',
'0xda10009cbd5d07dd0cecc66161fc93d7c9000da1',
'0x94b008aa00579c1307b0ef2c499ad98a8ce58e58')
group by 1,2,3
),
raw as (
select
date_trunc('day',block_timestamp) day,
tx_hash,
origin_from_address as wallet,
contract_address,
raw_amount,
symbol,
decimals,
raw_amount / pow(10, decimals) as volume,
volume * price_usd as volume_after_usd
from optimism.core.fact_token_transfers a
left join price b ON a.contract_address = b.token_address
where origin_to_address = lower('0x170a5714112daeff20e798b6e92e25b86ea603c1')
and origin_from_address = from_address
AND origin_to_address = to_address AND
day >= CURRENT_DATE - 14
having symbol is not null
union
select
date_trunc('day',block_timestamp) day,
tx_hash,
Run a query to Download Data