drone-mostafa2023-05-22 04:39 PM
Updated 2023-05-22
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
›
⌄
with mintable as (
select event_contract,
min (block_timestamp) as creation_Date
from flow.core.fact_events
group by 1 having creation_date >= '{{From_Date}}'),
pricet as (
select RECORDED_HOUR::date as day,
ID as token_contract,
avg (CLOSE) as USDPrice
from flow.core.fact_hourly_prices
group by 1,2),
volumetable as (
select tx_id,
event_type,
event_data:amount*usdprice as Volume1
from flow.core.fact_events t1 join pricet t2 on t1.block_timestamp::date = t2.day and t1.event_contract = t2.token_contract
where event_type in ('TokensWithdrawn','TokensDeposited','Deposit','Withdraw'))
select date_trunc ({{Date_Trunc}},t1.block_timestamp) as date,
count (distinct t1.event_contract) as Active_Contracts,
sum (Volume1) as Volume,
avg (Volume1) as Average_Volume,
sum (Volume) over (order by date) as Total_Volume
from flow.core.fact_events t1 join mintable t2 on t1.event_contract = t2.event_contract
join volumetable t4 on t1.tx_id = t4.tx_id
where t1.tx_succeeded = 'TRUE'
group by 1
order by 1 desc
Run a query to Download Data