Salehhere_stake_fin_date_tvl_usde_last_near_price
Updated 2024-09-28
999
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 lst_price as (
select top 1
date_trunc(hour,HOUR) as price_date
-- ,token_contract
,avg(CLOSE) as avg_price
from near.price.fact_prices_ohlc_hourly
-- where token_contract='wrap.near'
where ASSET_ID='wrapped-near'
and price_date is not null
group by 1
order by price_date desc
)
,lst_check as (
select
tx_hash
from near.core.fact_transactions
where TX_SUCCEEDED=true
)
,lst_stake as (
select
'Stake' as type
,block_timestamp::date as date_a
,tx_hash
,SIGNER_ID as wallet
,RECEIVER_ID
,DEPOSIT/1e24 as amount
from near.core.fact_actions_events_function_call
join lst_check using(tx_hash)
where RECEIVER_ID='storage.herewallet.near'
and METHOD_NAME in( 'deposit','storage_deposit')
and RECEIPT_SUCCEEDED=true
)
,lst_unstake_tg as (
select
'Unstake_TG' as type
QueryRunArchived: QueryRun has been archived