mlhUntitled Query
Updated 2022-11-22Copy 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 block_timestamp::date as day,
swap_from_mint as token,
median (swap_to_amount/swap_from_amount) as USDPrice
from solana.fact_swaps
where swap_to_mint in ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',--USDC
'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB') --USDT
and swap_to_amount > 0
and swap_from_amount > 0
and block_timestamp >= CURRENT_DATE - 24
and succeeded = 'TRUE'
group by 1,2
),
users as (select d.USDPrice,
t.*
from (select b.value:parsed:info:amount/1e8 as token_amount,
b.value:parsed:info:mint as token_address,
a.instruction:accounts[0] as from_address,
c.address_name as token,
a.*
from solana.core.fact_events a, lateral flatten(input => inner_instruction:instructions) b
join solana.core.dim_labels c on b.value:parsed:info:mint = c.address
where program_id = 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb'
and block_timestamp >= CURRENT_DATE - 24
and b.value:parsed:type = 'burn'
) t join price d on t.token_address = d.token
and t.block_timestamp::date = d.day
)
select a.block_timestamp::date as date,
case when date >= '2022-11-08' then 'After FTX crisis'
else 'Before FTX crisis' end as period,
b.token as Token_Symbol,
count (distinct a.tx_id) as bridges,
count (distinct a.swapper) as bridgers,
sum (coalesce(swap_to_amount,0) * b.USDPrice) as USD_Volume,
Run a query to Download Data