superflyUntitled Query
Updated 2022-08-25Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
›
⌄
with tabelw as (SELECT * from ethereum.core.dim_dex_liquidity_pools where PLATFORM='sushiswap'), wmw as (SELECT ORIGIN_FROM_ADDRESS as LP1, sum(amount_USD) as ADD_USD, min(BLOCK_TIMESTAMP) as add_time
from ethereum.core.ez_token_transfers
where TO_ADDRESS in (select POOL_ADDRESS from tabelw)
and ORIGIN_TO_ADDRESS='0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f' and BLOCK_TIMESTAMP::date >= '2021-09-01'
and origin_function_signature in ('0xe8e33700', '0xded9382a', '0xf305d719')
group by 1), satar as (SELECT ORIGIN_FROM_ADDRESS as LP2, sum(amount_USD) as remove_usd, max(BLOCK_TIMESTAMP)::date as remove_time
from ethereum.core.ez_token_transfers
where ORIGIN_TO_ADDRESS='0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f' and BLOCK_TIMESTAMP::date >= '2021-09-01'
and origin_function_signature in ('0xbaa2abde', '0x2195995c', '0x02751cec')group by 1),
kazem as (select wmw.LP1 as LP, (remove_usd - ADD_USD) as USD_proit, remove_time as days from satar left outer join wmw on satar.LP2=wmw.LP1 where USD_proit is not null)
select date_trunc ('week',days) as week, sum(USD_proit) as profit from kazem group by 1
Run a query to Download Data