RayyykDeFi on Flow 2
Updated 2022-11-21Copy 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
›
⌄
with table_1 as (select date_trunc('day', timestamp) as date,
token_contract,
avg(price_usd) as asset_price
from flow.core.fact_prices
where symbol ilike '{{Ticker}}'
group by 1,2)
select date_trunc('week', block_timestamp) as week,
'Inbound' as bridge_direction,
sum(amount * asset_price) as usd_volume,
sum(usd_volume) over (partition by bridge_direction order by week) as cumu_usd_volume,
count(distinct(tx_id)) as swap_from_tx,
sum(swap_from_tx) over (partition by bridge_direction order by week) as cumu_tx_count,
count(distinct(flow_wallet_address)) as swap_from_wallets
from flow.core.ez_bridge_transactions a
join table_1 b on date_trunc('week', block_timestamp) = b.date
where a.token_contract in (select token_contract from table_1)
and direction = 'inbound'
and block_timestamp >= '{{Starting_Date}}'
group by 1
union
select date_trunc('week', block_timestamp) as week,
'Outbound' as bridge_direction,
sum(amount * asset_price) as usd_volume,
sum(usd_volume) over (partition by bridge_direction order by week) as cumu_usd_volume,
count(distinct(tx_id)) as swap_from_tx,
sum(swap_from_tx) over (partition by bridge_direction order by week) as cumu_tx_count,
count(distinct(flow_wallet_address)) as swap_from_wallets
from flow.core.ez_bridge_transactions a
join table_1 b on date_trunc('week', block_timestamp) = b.date
where a.token_contract in (select token_contract from table_1)
and direction = 'outbound'
and block_timestamp >= '{{Starting_Date}}'
group by 1
order by 1 desc
Run a query to Download Data