Diako999monthly_lending_stats_on_arbitrum
    Updated 2023-03-17
    with
    lending as (
    select distinct
    symbol,
    sum(asset_amount) as amount,
    sum(asset_amount_usd) as amount_usd,
    count(tx_hash) as transactions,
    count(distinct (depositor)) as depositors,
    action
    from
    arbitrum.sushi.ez_lending
    where
    symbol = 'USDT'
    or symbol = 'DAI'
    or symbol = 'USDC'
    or symbol = 'TUSD'
    or symbol = 'FRAX'
    group by
    symbol,
    action
    )
    select
    date_trunc('month', a.hour) as date,
    amount,
    amount_usd,
    transactions,
    transactions * a.price as volume,
    depositors,
    action
    from
    lending
    join ethereum.core.fact_hourly_token_prices a on lending.symbol = a.symbol
    group by
    date,
    amount,
    amount_usd,