Sbhn_NPCorrelation between profitability vs. length of time- Yield Farmer
    Updated 2022-08-24
    with tb1 as (SELECT *
    from ethereum.core.dim_dex_liquidity_pools
    where PLATFORM='sushiswap'),

    tb2 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 ORIGIN_TO_ADDRESS='0xef0881ec094552b2e128cf945ef17a6752b4ec5d' and ORIGIN_FUNCTION_SIGNATURE='0x8dbdbe6d'
    and BLOCK_TIMESTAMP>=CURRENT_DATE-365
    group by 1),

    tb3 as (SELECT
    ORIGIN_FROM_ADDRESS as LP2,
    sum(amount_USD) as remove_usd,
    max(BLOCK_TIMESTAMP) as remove_time

    from ethereum.core.ez_token_transfers
    where ORIGIN_TO_ADDRESS='0xef0881ec094552b2e128cf945ef17a6752b4ec5d' and ORIGIN_FUNCTION_SIGNATURE='0x0ad58d2f'
    and BLOCK_TIMESTAMP>=CURRENT_DATE-365
    group by 1),


    tb4 as (select
    tb2.LP1 as LP,
    (remove_usd - ADD_USD) as USD_proit,
    datediff('day', add_time, remove_time) as days
    from tb3 left outer join tb2 on tb3.LP2=tb2.LP1
    where USD_proit is not null
    having days>0
    )

    select
    case
    Run a query to Download Data