dsaberUSDC ownership query
Updated 2022-09-29
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 daily_usdc_owners_pre AS (
SELECT block_date
,usdc_owner
,COALESCE(usdc_pre_amount, 0) AS usdc_pre_amount
FROM (
SELECT block_timestamp::DATE AS block_date
,t.value['owner'] AS usdc_owner
,t.value['uiTokenAmount']['amount']/1e6 AS usdc_pre_amount
,ROW_NUMBER() OVER (PARTITION BY t.value['owner'], block_timestamp::DATE ORDER BY block_timestamp) AS rnk
FROM solana.core.fact_transactions,
LATERAL FLATTEN(pre_token_balances) AS t
WHERE block_timestamp::DATE >= CURRENT_DATE - 30
AND block_timestamp::DATE < CURRENT_DATE
AND succeeded
AND array_size(pre_token_balances) >= 1
AND t.value['mint'] = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
)
WHERE rnk = 1
)
,daily_usdc_owners_post AS (
SELECT block_date
,usdc_owner
,COALESCE(usdc_post_amount, 0) AS usdc_post_amount
FROM (
SELECT block_timestamp::DATE AS block_date
,t.value['owner'] AS usdc_owner
,t.value['uiTokenAmount']['amount']/1e6 AS usdc_post_amount
,ROW_NUMBER() OVER (PARTITION BY t.value['owner'], block_timestamp::DATE ORDER BY block_timestamp DESC) AS rnk
FROM solana.core.fact_transactions,
LATERAL FLATTEN(post_token_balances) AS t
WHERE block_timestamp::DATE >= CURRENT_DATE - 30
AND block_timestamp::DATE < CURRENT_DATE
AND succeeded
AND array_size(post_token_balances) >= 1
AND t.value['mint'] = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
)