Sbhn_NPCorrelation between profit vs. time of withdrawal- 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)::date 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_profit,
    remove_time as days
    from tb3 left outer join tb2 on tb3.LP2=tb2.LP1
    where USD_profit is not null

    )

    select
    date_trunc ('week',days) as week,
    Run a query to Download Data