matejchiNet flows borrows
    Updated 2025-04-12
    with borrows as
    (
    select
    date_trunc('month', block_timestamp) as month,
    blockchain,
    sum(amount_usd) as borrows_monthly,
    sum(borrows_monthly) over (partition by blockchain order by month asc) as borrows_cumulative
    from crosschain.defi.ez_lending_borrows
    where
    blockchain in ('base', 'arbitrum', 'optimism')
    and month < date_trunc('month', current_date)
    group by month, blockchain
    ),
    repayments as
    (
    select
    date_trunc('month', block_timestamp) as month,
    blockchain,
    sum(amount_usd) as repayments_monthly,
    sum(repayments_monthly) over (partition by blockchain order by month asc) as repayments_cumulative
    from crosschain.defi.ez_lending_repayments
    where
    blockchain in ('base', 'arbitrum', 'optimism')
    and month < date_trunc('month', current_date)
    group by month, blockchain
    )
    select
    b.month,
    b.blockchain,
    b.borrows_cumulative,
    r.repayments_cumulative,
    b.borrows_cumulative - r.repayments_cumulative as net_borrows
    from borrows b
    join repayments r
    on b.month = r.month
    and b.blockchain = r.blockchain
    Last run: 3 months ago
    MONTH
    BLOCKCHAIN
    BORROWS_CUMULATIVE
    REPAYMENTS_CUMULATIVE
    NET_BORROWS
    1
    2021-09-01 00:00:00.000arbitrum44851444.5931896813.5312954631.06
    2
    2021-10-01 00:00:00.000arbitrum69113943.2363272093.075841850.15999999
    3
    2021-11-01 00:00:00.000arbitrum88391286.9279836326.688554960.23999998
    4
    2021-12-01 00:00:00.000arbitrum95581056.4487216757.948364298.49999997
    5
    2022-01-01 00:00:00.000arbitrum104639730.2298828367.045811363.17999998
    6
    2022-02-01 00:00:00.000arbitrum134511369.96128490775.196020594.76999998
    7
    2022-03-01 00:00:00.000arbitrum155773118.28148745168.177027950.10999998
    8
    2022-03-01 00:00:00.000optimism260177.41124300.75135876.66
    9
    2022-04-01 00:00:00.000arbitrum172429861.63162883113.399546748.23999998
    10
    2022-04-01 00:00:00.000optimism1090711.27669553.4421157.87
    11
    2022-05-01 00:00:00.000arbitrum194951923.75188497550.296454373.45999998
    12
    2022-05-01 00:00:00.000optimism3972582.712862499.471110083.24
    13
    2022-06-01 00:00:00.000arbitrum206109361.4198124978.327984383.07999998
    14
    2022-06-01 00:00:00.000optimism13087688.3810640212.612447475.77
    15
    2022-07-01 00:00:00.000arbitrum478624051.43426253871.7752370179.66
    16
    2022-07-01 00:00:00.000optimism20738784.3517939687.842799096.50999999
    17
    2022-08-01 00:00:00.000arbitrum756276749.04685511246.8170765502.23
    18
    2022-08-01 00:00:00.000optimism1013692974.23686043180.65327649793.58
    19
    2022-09-01 00:00:00.000arbitrum856959953.31821170977.0635788976.25
    20
    2022-09-01 00:00:00.000optimism1356538357.441060567758.23295970599.21
    100
    8KB
    4s