0xtableauAAVE CHART
    Updated 2023-03-27
    with aave_stats as (
    select
    distinct date_trunc('day', block_hour) as date
    ,aave_market
    ,blockchain
    ,lending_pool_add
    ,reserve_name
    ,atoken_address
    ,stable_debt_token_address
    ,variable_debt_token_address
    ,aave_version
    ,round(last_value(total_liquidity_usd) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as total_liquidity_usd
    ,round(last_value(reserve_price) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as reserve_price
    ,round(last_value(atoken_price) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as atoken_price
    ,round(last_value(total_liquidity_token) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as total_liquidity_token
    ,round(last_value(total_stable_debt_token) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as total_stable_debt_token
    ,round(last_value(total_variable_debt_token) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as total_variable_debt_token
    ,round(last_value(total_stable_debt_usd) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as total_stable_debt_usd
    ,round(last_value(total_variable_debt_usd) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as total_variable_debt_usd
    ,round(last_value(supply_rate) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as supply_rate
    ,round(last_value(borrow_rate_stable) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as borrow_rate_stable
    ,round(last_value(borrow_rate_variable) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as borrow_rate_variable
    ,round(last_value(aave_price) over (PARTITION BY date, aave_market, blockchain, reserve_name, atoken_address, aave_version order by block_hour) ,4) as aave_price

    from aave.market_stats
    where block_hour > getdate() - interval '6 months'
    and date_trunc('day',block_hour) <> (select date_trunc('day',max(block_hour)) from aave.market_stats)
    and total_liquidity_usd > 0
    order by 1 desc, 3 asc)

    select date,
    blockchain,
    aave_version,
    reserve_name,
    total_liquidity_usd as amount,
    'total_liquidity_usd' as type
    Run a query to Download Data