Flipside Data Science90 day LTV Example for Ethereum
Updated 2024-07-30
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 addys as (
-- this is where you'd put a segment of user_addresses in
-- could pull directly from scores with something like
-- select user_address from DATASCIENCE.ONCHAIN_SCORES.ETHEREUM
-- where score_date = (current_date - 1)
-- and total_score > 5;
-- i'll give an example of addresses that have deposited to aave in last 10 days
select distinct decoded_log:caller::string as user_address
from ethereum.core.ez_decoded_event_logs logs
where block_timestamp > current_date - 31
and logs.contract_address in (select address from ethereum.core.dim_labels where label ilike '%aave%')
and logs.event_name ilike 'mint'
),
valid_tokens as (
select
token_out as token_address,
count(1) as n_swaps,
sum(amount_out_usd) as swap_vol,
count(distinct(origin_from_address)) as n_swappers
from ethereum.defi.ez_dex_swaps
where block_timestamp > current_date - 10
and amount_out_usd IS NOT NULL
group by 1
having n_swaps > 50
and n_swappers > 50
and swap_vol > 100000
),
token_vol as (
select
tt.origin_from_address as user_address,
sum(tt.amount_usd) as amount_spent
from ethereum.core.ez_token_transfers tt
join valid_tokens vt on vt.token_address = tt.contract_address
QueryRunArchived: QueryRun has been archived