SocioAnalyticaMetaPool - Daily Total Value Locked copy
Updated 2024-02-26
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
›
⌄
-- forked from Yousefi_1994 / MetaPool - Daily Total Value Locked @ https://flipsidecrypto.xyz/Yousefi_1994/q/U4ajxvAs7JfE/metapool---daily-total-value-locked
with
near_price as (
SELECT
TO_TIMESTAMP(value[0]::string) as days,
value[1] as price_usd
FROM (
SELECT livequery.live.udf_api(
'https://api.coingecko.com/api/v3/coins/near/market_chart?vs_currency=usd&days=max&interval=daily&precision=3') as response
),LATERAL FLATTEN (input => response:data:prices)
),
metapool_stake_v1 as (
select
receipts.block_timestamp,
receipts.tx_hash,
receipts.actions:predecessor_id as user_address,
(
receipts.actions:receipt:Action:actions[0]:FunctionCall:deposit
) * pow(10, -24) as amount
from
near.core.fact_receipts receipts
join near.core.fact_transactions transactions using (tx_hash)
where
receipts.receiver_id = 'meta-pool.near'
and receipts.actions:receipt:Action:actions[0]:FunctionCall:method_name in ('deposit_and_stake')
and receipts.status_value:Failure is null
and transactions.tx_status = 'Success'
),
metapool_add_liquidity_v1 as (
select
receipts.block_timestamp,
receipts.tx_hash,
receipts.actions:predecessor_id as user_address,
(
receipts.actions:receipt:Action:actions[0]:FunctionCall:deposit
QueryRunArchived: QueryRun has been archived