mlhcorrelation between profit vs. time of withdrawal
    Updated 2022-08-23
    select count(distinct user_wallet) as wallet_count,
    withdraw_date,
    n_days,
    pool_address,
    CASE WHEN profit < 0 THEN 'Loss'
    WHEN profit = 0 THEN 'zero'
    WHEN profit > 0 THEN 'profit'
    END as type
    from (select user_wallet,
    pool_address,
    min(date) as deposit_date,
    max(date) as withdraw_date,
    datediff('day', deposit_date, withdraw_date) as n_days,
    sum(add_liquidity_usd) as deposit_amount,
    sum(remove_liquidity_usd) as withdraw_amount,
    (deposit_amount - withdraw_amount) as profit
    from ((select *
    from ((SELECT date_trunc('day',e.block_timestamp) as date,
    e.tx_hash,
    e.origin_FROM_ADDRESS as user_wallet,
    EVENT_INPUTS:value / POW(10, 18) as amount,
    e.contract_address as pool_address,
    t.contract_address as token_address,
    e.*,
    t.amount_usd as add_liquidity_usd,
    0 as remove_liquidity_usd
    FROM ethereum.core.fact_event_logs e
    join ethereum.core.ez_token_transfers t on e.tx_hash = t.tx_hash
    WHERE e.origin_to_address = '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f'
    and event_name = 'Transfer'
    and event_inputs:from::string = '0x0000000000000000000000000000000000000000'
    and e.block_timestamp >= CURRENT_DATE - 365
    and e.origin_function_signature in ('0xe8e33700','0xf305d719')
    and t.amount_usd > 0
    )
    union
    Run a query to Download Data