mastercheth-bWgp_-Getting Started
    Updated 2023-11-06
    with lending_union as (
    SELECT
    'Borrow' as action,
    date_trunc('year',
    block_timestamp) as year,
    date_trunc('quarter',
    block_timestamp) as quarter,
    date_trunc('month',
    block_timestamp) as month,
    date_trunc('week',
    block_timestamp) as week,
    token_symbol,
    event_name,
    platform,
    tx_hash,
    origin_from_address,
    sum(amount) as amount,
    sum(amount_usd) amount_usd,
    avg(amount_usd) amount_usd_avg,
    count(*) as txn_count,
    count(distinct(origin_from_address)) as distinct_lenders

    from
    ethereum.defi.ez_lending_borrows
    group by 1,2,3,4,5,6,7,8,9,10
    UNION ALL
    SELECT
    'Deposits' as action,
    date_trunc('year',
    block_timestamp) as year,
    date_trunc('quarter',
    block_timestamp) as quarter,
    date_trunc('month',
    block_timestamp) as month,
    date_trunc('week',
    block_timestamp) as week,
    Run a query to Download Data