afonsoUntitled Query
Updated 2023-01-20Copy 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
›
⌄
with t as (
select
coalesce(try_parse_json(replace(value, 'EVENT_JSON:')):event, try_parse_json(replace(value, 'EVENT_JSON:')):type) as event_name,
block_timestamp,
tx_hash,
receiver_id,
case
when split(replace(value, 'EVENT_JSON:'), ' ')[0] = 'Swapped' then 'Swap'
when split(replace(value, 'EVENT_JSON:'), ' ')[0] = 'Liquidity' then 'Add Liquidity'
when event_name ilike any ('deposit_and_stake', 'stake%') then 'Stake'
when event_name = 'nft_mint' then 'Mint NFT'
when event_name = 'borrow' and receiver_id = 'contract.main.burrow.near' then 'Borrow'
when event_name = 'repay' and receiver_id = 'contract.main.burrow.near' then 'Repay'
when event_name = 'increase_collateral' and receiver_id = 'contract.main.burrow.near' then 'Lend Collateral'
when event_name = 'deposit' and receiver_id = 'contract.main.burrow.near' then 'Deposit'
when event_name = 'ft_mint' and receiver_id = 'usn' then 'Minting USN'
else null end as action
from near.core.fact_receipts, table(flatten(input =>logs))
where action is not null
and try_parse_json(status_value):SuccessValue != ''
)
select
action,
count(distinct tx_hash) as txns_count,
count(distinct tx_signer) as users_count
from t
join near.core.fact_transactions a
using (tx_hash)
where a.block_timestamp >= '2022-12-01'
group by action
order by txns_count desc
limit 10
Run a query to Download Data