freemartianDaily AAVE as Collateral
    Updated 2022-08-09
    with deposits as (
    select
    count(distinct origin_from_address) as depositors_count,
    sum(amount) as deposit_amount,
    block_timestamp::date as TIME
    from ethereum.core.ez_token_transfers
    where origin_to_address in ('0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9', '0x135896de8421be2ec868e0b811006171d9df802a')
    and to_address = '0xffc97d72e13e01096502cb8eb52dee56f74dad7b'
    and contract_address = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'
    group by TIME),
    withdraws as (
    select
    count(distinct origin_from_address) as Withdrawers_count,
    sum(amount) as withdraw_amount,
    block_timestamp::date as TIME
    from ethereum.core.ez_token_transfers
    where origin_to_address in ('0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9', '0x135896de8421be2ec868e0b811006171d9df802a')
    and to_address = '0x0000000000000000000000000000000000000000'
    and contract_address = '0xffc97d72e13e01096502cb8eb52dee56f74dad7b'
    group by TIME
    )

    select
    deposit_amount, withdraw_amount, d.TIME,
    sum(deposit_amount) over (order by d.TIME) as cumulative_deposit_amount,
    sum(withdraw_amount) over (order by w.TIME) as cumulative_withdraw_amount,
    sum(depositors_count) over (order by d.TIME) as cumulative_depositors,
    sum(withdrawers_count) over (order by w.TIME) as cumulative_withdrawers,
    deposit_amount - withdraw_amount as aave_balance, sum(aave_balance) over (order by w.TIME) as Cum_Sum
    from deposits d inner join withdraws w on w.TIME = d.TIME

    Run a query to Download Data