Updated 2022-07-14
    with kashi_deposit as ( select trunc(block_timestamp,'day') as day ,sum(amount_usd) as deposit_volume , sum(amount_usd*0.024647)/100 as deposit_fee
    from polygon.sushi.ez_lending
    where block_timestamp::date>= CURRENT_DATE - 180 and action = 'Deposit'
    group by day)
    ,
    kashi_withdraw as ( select trunc(block_timestamp,'day') as day1 ,sum(amount_usd) as withdraw_volume , sum(amount_usd*0.024647)/100 as withdraw_fee
    from polygon.sushi.ez_lending
    where block_timestamp::date>= CURRENT_DATE - 180 and action = 'Withdraw'
    group by day1)
    ,
    kashi_borrow as ( select trunc(block_timestamp,'day') as day2 ,sum(amount_usd) as borrow_volume , sum(amount_usd*0.024647)/100 as borrow_fee
    from polygon.sushi.ez_borrowing
    where block_timestamp::date>= CURRENT_DATE - 180 and action = 'Borrow'
    group by day2)
    ,
    kashi_repay as ( select trunc(block_timestamp,'day') as day3 ,sum(amount_usd) as repay_volume , sum(amount_usd*0.024647)/100 as repay_fee
    from polygon.sushi.ez_borrowing
    where block_timestamp::date>= CURRENT_DATE - 180 and action = 'Repay'
    group by day3)

    select day , deposit_volume , withdraw_volume , borrow_volume , repay_volume , deposit_fee, withdraw_fee , borrow_fee , repay_fee
    from kashi_deposit a left outer join kashi_withdraw b on a.day = b.day1
    left outer join kashi_borrow c on a.day = c.day2
    left outer join kashi_repay d on a.day = d.day3
    order by 1
    Run a query to Download Data