pouya_22Optimistic Bears - Bridge volume
Updated 2022-08-10
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 bridges as (select
a.block_timestamp::date as date,
a.contract_address,
a.tx_hash,
b.raw_amount
from ethereum.core.fact_event_logs a
join ethereum.core.fact_token_transfers b on a.tx_hash = b.tx_hash
where a.origin_to_address = lower('0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1')
and a.origin_function_signature = '0x58a997f6'
and date >= '2022-07-01'
and date <= '2022-07-31'),
prices as (select
hour::date as date,
symbol as asset,
token_address,
decimals,
avg(price) as price_usd
from ethereum.core.fact_hourly_token_prices
where date >= '2022-07-01'
and date <= '2022-07-31'
group by 1,2,3,4)
select
a.date,
asset,
sum((raw_amount / power(10, decimals)) * price_usd) as volume,
sum(volume) over(partition by asset order by a.date) as total_volume
from bridges a
join prices b on a.date = b.date and contract_address = token_address
group by 1,2
having asset is not null
Run a query to Download Data