pinehearstNEAR City - Citizen Score
Updated 2023-08-17
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 near_event AS (
SELECT
block_timestamp,
tx_hash,
receiver_id,
replace(value, 'EVENT_JSON:') as logs_cleaned,
split(logs_cleaned, ' ') as split_logs,
nvl(try_parse_json(logs_cleaned):event, try_parse_json(logs_cleaned):type) as event,
case
-- NFTs
when event = 'resolve_purchase' then 'buy_nft'
when event = 'add_market_data ' then 'list_nft'
when event = 'nft_mint' then 'mint_nft'
-- Staking NEAR
when receiver_id NOT IN ('nearton-staking.near', 'xtoken.ref-finance.near') and receiver_id like '%pool%' and split_logs[1] = 'staking' then 'stake_near'
when receiver_id = 'meta-pool.near' and event = 'STAKE' then 'liquid_stake_near'
when receiver_id = 'linear-protocol.near' and event = 'stake' then 'liquid_stake_near'
when receiver_id = 'nearx.stader-labs.near' and event = 'deposit_and_stake' then 'liquid_stake_near'
-- Swaps and LP
when split_logs[0] = 'Liquidity' and split_logs[1] = 'added' then 'add_liquidity' -- ["Liquidity","added","[\"93431266252061957642","6b175474e89094c44da98b954eedeac495271d0f.factory.bridge.near\",","\"10963734966355994317165693","wrap.near\"],","minted","475859342284254074428233","shares"]
when split_logs[0] = 'Swapped' then 'swap'
-- Mint USN
when receiver_id = 'usn' and event = 'ft_mint' then 'mint_usn'
when receiver_id = 'usn' and event = 'ft_transfer' then 'transfer_usn'
-- Burrow Finance
when receiver_id = 'contract.main.burrow.near' and event = 'borrow' then 'borrow'
when receiver_id = 'contract.main.burrow.near' and event = 'repay' then 'repay'
when receiver_id = 'contract.main.burrow.near' and event = 'increase_collateral' then 'increase_collateral'-- need to deposit then can increase collateral
when receiver_id = 'contract.main.burrow.near' and event = 'deposit' then 'deposit'
-- when receiver_id = 'contract.main.burrow.near' and event = 'withdraw_succeeded' then 'withdraw_succeeded'
-- else concat(event, ' ', receiver_id) end as event_action,
else null end as event_action,
regexp_substr(status_value, 'Success') as reg_success
FROM near.core.fact_receipts,
table(flatten(input =>logs))
WHERE reg_success IS NOT NULL
Run a query to Download Data