h4wkHolders by Net Stake Volume
Updated 2024-06-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
›
⌄
-- forked from Holders by Net Stake Volume @ https://flipsidecrypto.xyz/edit/queries/d96c6f13-d0fd-4dec-b4e6-f300e6b7f736
-- forked from Arbitrum deUSDC Pool Net Staking Activity @ https://flipsidecrypto.xyz/edit/queries/725db840-091c-4132-89b4-063b07e5a828
-- forked from arb stable pool @ https://flipsidecrypto.xyz/edit/queries/353c1e89-db1d-443d-9635-0e6f0dc08b93
with base_raw as (
select block_timestamp,
case when from_address = '0x0000000000000000000000000000000000000000' then 'Deposit'
else 'Withdrawal' end as type,
raw_amount_precise::float/1e18 as token_amount,
origin_from_address,
tx_hash
-- count(distinct tx_hash) as tx_count,
-- count(distinct origin_from_address) as user_count,
-- sum(case when from_address = '0x0000000000000000000000000000000000000000' then raw_amount_precise::float/1e18 else 0 end) as deposit_vol,
-- sum(case when to_address = '0x0000000000000000000000000000000000000000' then -raw_amount_precise::float/1e18 else 0 end) as withdrawal_vol,
-- deposit_vol + withdrawal_vol as net_vol,
-- sum(net_vol) over (order by date) as TVL
from polygon.core.fact_token_transfers
where 1 = 1
-- and tx_hash = '0xc3869010f5f9a85ccd3d252c7640f8c937fb5f787118c893687386245dd7d383'
and contract_address = lower('0xDa43Bfd7Ecc6835AA6f1761ced30b986A574c0d2')
and (from_address = '0x0000000000000000000000000000000000000000'
or to_address = '0x0000000000000000000000000000000000000000')
-- group by 1,2
-- order by date desc
)
select
origin_from_address as "User Address",
-- count(distinct case when type = 'Deposit' then tx_hash end) as deposit_txs,
-- count(distinct case when type = 'Withdrawal' then tx_hash end) as withdrawal_txs,
round(sum(case when type = 'Deposit' then token_amount else 0 end), 2) as deposit,
round(sum(case when type = 'Withdrawal' then token_amount else 0 end), 2) as withdraw,
deposit - withdraw as net_volume,
round(100 * RATIO_TO_REPORT(net_volume) OVER (), 2) || '%' AS percent_holding,
min(block_timestamp) as "First Deposit TX"
QueryRunArchived: QueryRun has been archived