mamad-5XN3k3Aptos CEX 2
Updated 2024-08-06
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
›
⌄
-- forked from Aptos CEX @ https://flipsidecrypto.xyz/studio/queries/ac48434f-f71e-47a1-b34d-c6f54db1bafc
with pricet as (
SELECT
TO_TIMESTAMP(value[0]::string) as p_date,
'APT' as symbol,
value[1] as usd_price
from (
SELECT livequery.live.udf_api(
'https://api.coingecko.com/api/v3/coins/aptos/market_chart?vs_currency=usd&days=90&interval=daily&precision=3') as resp)
,LATERAL FLATTEN (input => resp:data:prices)
WHERE p_date >= Current_date() - 90
),
cext as (
SELECT
DISTINCT ADDRESS ,
ADDRESS_NAME
FROM aptos.core.dim_labels
where LABEL_TYPE = 'cex'
and LABEL_SUBTYPE = 'hot_wallet'
)
SELECT
'OutFlow' as type,
--rtrim(BLOCK_TIMESTAMP::date) as date,
ADDRESS_NAME,
count(DISTINCT TX_HASH) as txs,
count(DISTINCT TO_ADDRESS) as users,
sum(AMOUNT/1e8) as amount,
sum((AMOUNT/1e8) * usd_price) as usd_amount
FROM aptos.core.ez_native_transfers
JOIN pricet on BLOCK_TIMESTAMP::date = p_date
join cext on FROM_ADDRESS = ADDRESS
WHERE TOKEN_ADDRESS = '0x1::aptos_coin::AptosCoin'
and SUCCESS = 'TRUE'
QueryRunArchived: QueryRun has been archived