Alexaylast moth v2 withdraw
    Updated 2023-04-13
    with
    eth_deposits as ( select sum(event_inputs:amount/1e18) as deposit
    from ethereum.core.fact_event_logs
    where block_timestamp>=CURRENT_DATE-30 and
    event_name = 'Deposit' and contract_address = lower('0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9')
    and event_inputs:reserve = lower('0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9')), -- Aave Token
    eth_withdraws as ( select -sum(event_inputs:amount/1e18) as withdraw
    from ethereum.core.fact_event_logs
    where block_timestamp >= CURRENT_DATE-30 AND
    event_name='Withdraw' and contract_address = lower('0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9') --aave address
    and event_inputs:token = lower('0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9')),

    pol_deposits as ( select sum(event_inputs:amount/1e18) as deposit
    from polygon.core.fact_event_logs
    where block_timestamp>=CURRENT_DATE-30 and
    event_name = 'Deposit' and contract_address = '0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf'
    and event_inputs:reserve = '0xd6df932a45c0f255f85145f286ea0b292b21c90b'),
    pol_withdraws as ( select -sum(event_inputs:amount/1e18) as withdraw
    from polygon.core.fact_event_logs
    where block_timestamp >= CURRENT_DATE-30 AND
    event_name='Withdraw' and contract_address ='0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf' --aave address
    and event_inputs:token = '0xd6df932a45c0f255f85145f286ea0b292b21c90b'),

    avax_deposits as ( select sum(event_inputs:amount/ 1e18) as deposit
    from avalanche.core.fact_event_logs
    where block_timestamp >= CURRENT_DATE-30 AND
    contract_Address='0x4f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c' and event_name = 'Deposit'
    and event_inputs:reserve = '0x63a72806098bd3d9520cc43356dd78afe5d386d9'),

    avax_withdraws as ( select -sum(event_inputs:amount/ 1e18) withdraw
    from avalanche.core.fact_event_logs
    where block_timestamp >= CURRENT_DATE-30 AND
    contract_address='0x4f01aed16d97e3ab5ab2b501154dc9bb0f1a5a2c' and event_name = 'Withdraw'
    and event_inputs:token= '0x63a72806098bd3d9520cc43356dd78afe5d386d9'),
    Run a query to Download Data