kingharald-ethProfitability vs. length of time
Updated 2022-08-26
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 list1 as (select
origin_from_address as address, sum(amount_usd) as add_liquidity_usd, min(block_timestamp) as created_at
from ethereum.core.ez_token_transfers a
where exists (
select * from ethereum.core.dim_dex_liquidity_pools b where
b.pool_address = a.to_address and
platform ='sushiswap'
)
and origin_to_address = '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f'
and block_timestamp::date >= current_date - interval '1 year'
and (
origin_function_signature = '0xded9382a' OR
origin_function_signature = '0xe8e33700' OR
origin_function_signature = '0xf305d719'
)
group by origin_from_address),
list2 as (
select origin_from_address as address, -1 * sum(amount_usd) as remove_liquidity_usd, max(block_timestamp) as deleted_at
from ethereum.core.ez_token_transfers
where (
origin_function_signature = '0xbaa2abde' OR
origin_function_signature = '0x02751cec' OR
origin_function_signature = '0xbaa2abde'
)
and origin_to_address = '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f'
and block_timestamp::date >= current_date - interval '1 year'
group by origin_from_address),
list3 as (
select list1.address as wallet_address, iff(remove_liquidity_usd is null, 0, remove_liquidity_usd) + iff(add_liquidity_usd is null, 0, add_liquidity_usd) as profit_usd, datediff('day', created_at, deleted_at) as days
from list2 left outer join list1 on list2.address = list1.address
where days > 0
)
Run a query to Download Data