hessTop Tokens Based on Transactions
    Updated 2023-03-01
    with final as ( select symbol , 'Borrow' as type, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(BORROWER_ADDRESS)) as total_user,
    sum(BORROWED_USD) as total_volume, avg(BORROWED_USD) as avg_volume,
    median(BORROWED_USD) as median_volume, max(BORROWED_USD) as max_volume, min(BORROWED_USD) as min_volume
    from ethereum.aave.ez_borrows
    where block_timestamp::date >= CURRENT_DATE - {{N_Days}}
    group by 1
    UNION
    select symbol, 'Deposit' as type, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(DEPOSITOR_ADDRESS)) as total_user,
    sum(SUPPLIED_USD) as total_volume, avg(SUPPLIED_USD) as avg_volume,
    median(SUPPLIED_USD) as median_volume, max(SUPPLIED_USD) as max_volume, min(SUPPLIED_USD) as min_volume
    from ethereum.aave.ez_deposits
    where block_timestamp::date >= CURRENT_DATE - {{N_Days}}
    group by 1
    UNION
    select symbol, 'Repayment' as type, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(PAYER)) as total_user,
    sum(REPAYED_USD) as total_volume, avg(REPAYED_USD) as avg_volume,
    median(REPAYED_USD) as median_volume, max(REPAYED_USD) as max_volume, min(REPAYED_USD) as min_volume
    from ethereum.aave.ez_repayments
    where block_timestamp::date >= CURRENT_DATE - {{N_Days}}
    group by 1
    UNION
    select symbol, 'Withdraw' as type, count(DISTINCT(tx_hash)) as total_tx, count(DISTINCT(DEPOSITOR_ADDRESS)) as total_user,
    sum(WITHDRAWN_USD) as total_volume, avg(WITHDRAWN_USD) as avg_volume,
    median(WITHDRAWN_USD) as median_volume, max(WITHDRAWN_USD) as max_volume, min(WITHDRAWN_USD) as min_volume
    from ethereum.aave.ez_withdraws
    where block_timestamp::date >= CURRENT_DATE - {{N_Days}}
    group by 1)


    select symbol,type, total_volume, total_tx, rank() over (partition by type order by total_tx desc) as rank
    from final
    qualify rank <= 5

    Run a query to Download Data