Abbas_ra21Daily 2
    Updated 2025-02-03
    -- forked from Daily 2 @ https://flipsidecrypto.xyz/edit/queries/ba26e0cb-af0e-4834-9976-d105f99c5d23

    with main AS (select
    date_trunc('Week',block_timestamp) AS Week,
    'Deposit' AS "Event Name",
    sum(case when Amount_USD is not null then Amount_USD else Amount*Price end) AS Volume
    from
    base.defi.ez_lending_deposits A
    inner join base.price.ez_prices_hourly B on B.TOKEN_ADDRESS=A.TOKEN_ADDRESS and HOUR=date_trunc('hour',BLOCK_TIMESTAMP)
    where
    PLATFORM = 'Moonwell'
    group by 1
    union ALL
    select
    date_trunc('Week',block_timestamp) AS Week,
    'Borrow' AS "Event Name",
    sum(case when Amount_USD is not null then Amount_USD else Amount*Price end) AS Volume
    from
    base.defi.ez_lending_borrows A
    inner join base.price.ez_prices_hourly B on B.TOKEN_ADDRESS=A.TOKEN_ADDRESS and HOUR=date_trunc('hour',BLOCK_TIMESTAMP)
    where
    PLATFORM = 'Moonwell'
    group by 1
    union ALL
    select
    date_trunc('Week',block_timestamp) AS Week,
    'Repayment' AS "Event Name",
    sum(case when Amount_USD is not null then Amount_USD else Amount*Price end) AS Volume
    from
    base.defi.ez_lending_repayments A
    inner join base.price.ez_prices_hourly B on B.TOKEN_ADDRESS=A.TOKEN_ADDRESS and HOUR=date_trunc('hour',BLOCK_TIMESTAMP)
    where
    PLATFORM = 'Moonwell'
    group by 1
    union ALL
    select
    Last run: 25 days ago
    WEEK
    Event Name
    VOLUME
    Cumulative Volume
    1
    2024-09-30 00:00:00.000Deposit293545136.765298053168.82
    2
    2024-09-30 00:00:00.000Borrow292911236.33598355093.03
    3
    2024-09-30 00:00:00.000Repayment283442502.133485000417.43
    4
    2024-09-30 00:00:00.000Withdraw279710324.295108915612.96
    5
    2024-10-28 00:00:00.000Deposit1085825277.588089497926.23
    6
    2024-10-14 00:00:00.000Deposit515278272.286139910545.8
    7
    2025-01-06 00:00:00.000Deposit478328012.4216828230457.75
    8
    2025-01-06 00:00:00.000Borrow3631594827.5751791684493.88
    9
    2024-10-28 00:00:00.000Borrow2080488656.977847846945.9
    10
    2024-10-14 00:00:00.000Borrow518893935.344400036736.22
    11
    2024-10-28 00:00:00.000Repayment2020239978.437630805553.89
    12
    2025-01-06 00:00:00.000Repayment3637825764.5951621693666.92
    13
    2024-10-14 00:00:00.000Repayment501622794.44268512719.1
    14
    2024-10-28 00:00:00.000Withdraw1010257336.27774863902.52
    15
    2025-01-06 00:00:00.000Withdraw475982636.6516555208564.92
    16
    2024-10-14 00:00:00.000Withdraw498695867.645933092279.22
    17
    2024-01-15 00:00:00.000Deposit13573204.98378512760.76
    18
    2024-01-15 00:00:00.000Borrow5138169.41152446934.5
    19
    2024-01-15 00:00:00.000Repayment3062195.38129685042.61
    20
    2024-01-15 00:00:00.000Withdraw9762763.2343493708.85
    ...
    316
    20KB
    4s