scottincryptoAave APR for BAL, CRV, CVX
    Updated 2023-04-26

    with poly_symbols as (
    select
    '0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3' as address
    , 'BAL' as symbol
    union all
    select
    '0x172370d5cd63279efa6d502dab29171933a610af' as address
    , 'CRV' as symbol
    )


    -- Ethereum V2
    select
    date_trunc('day', block_timestamp) as block_day
    , 'ethereum' as chain
    , 2 as version
    , event_inputs:reserve as reserve
    , symbol
    , avg(event_inputs:liquidityRate::numeric / 1e27) as deposit_apr
    , avg(event_inputs:variableBorrowRate::numeric / 1e27) as borrow_apr
    from ethereum.core.fact_event_logs l
    left join ethereum.core.dim_contracts c on (l.event_inputs:reserve = c.address)
    where 1=1
    and block_timestamp > '2022-06-12'
    and contract_address = '0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9' -- eth V2 pool
    and event_name = 'ReserveDataUpdated'
    and event_inputs:reserve in ('0xba100000625a3754423978a60c9317c58a424e3d' --BAL
    , '0xd533a949740bb3306d119cc777fa900ba034cd52' --CRV
    , '0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b' --CVX
    )
    group by 1,2,3,4,5
    union all
    -- Polygon V2
    Run a query to Download Data