MLDZMNus3
Updated 2023-08-25
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 all_txn as (
select tx_hash,block_timestamp,origin_from_address as user
from ethereum.core.ez_token_transfers
where contract_address = lower('0xae7ab96520de3a18e5e111b5eaab095312d7fe84')
and from_address = '0x0000000000000000000000000000000000000000'
and symbol = 'stETH'
union all
select tx_hash,block_timestamp, eth_to_address as user
from ethereum.core.ez_eth_transfers
where eth_from_address = lower('0x889edc2edab5f40e902b864ad4d7ade8e412f9b1')
-- and user not in (select address from crosschain.core.address_labels
-- where project_name ilike '%lido%')
),
tb1 as (select
origin_from_address as user,
min(block_timestamp) over (partition by user)::date as first_deposit
from ethereum.core.ez_token_transfers
where contract_address = lower('0xae7ab96520de3a18e5e111b5eaab095312d7fe84')
and from_address = '0x0000000000000000000000000000000000000000'
and symbol = 'stETH'
and block_timestamp >= current_date - interval '12 months'
),
tb2 as (select
distinct user,
case
when first_deposit>=current_date - interval '12 months' and first_deposit<=current_date - interval '11 months' then 'Cohort 1'
when first_deposit>=current_date - interval '11 months' and first_deposit<=current_date - interval '10 months' then 'Cohort 2'
when first_deposit>=current_date - interval '10 months' and first_deposit<=current_date - interval '9 months' then 'Cohort 3'
when first_deposit>=current_date - interval '9 months' and first_deposit<=current_date - interval '8 months' then 'Cohort 4'
when first_deposit>=current_date - interval '8 months' and first_deposit<=current_date - interval '7 months' then 'Cohort 5'
when first_deposit>=current_date - interval '7 months' and first_deposit<=current_date - interval '6 months' then 'Cohort 6'
when first_deposit>=current_date - interval '6 months' and first_deposit<=current_date - interval '5 months' then 'Cohort 7'
when first_deposit>=current_date - interval '5 months' and first_deposit<=current_date - interval '4 months' then 'Cohort 8'
when first_deposit>=current_date - interval '4 months' and first_deposit<=current_date - interval '3 months' then 'Cohort 9'
Run a query to Download Data