SalehTotal
    Updated 2025-05-09
    with lst_deposit as (
    select
    block_timestamp::date as date
    ,tx_hash
    ,DEPOSITOR
    ,TOKEN_SYMBOL
    ,AMOUNT_USD
    from avalanche.defi.ez_lending_deposits
    where year(block_timestamp) in ('2024','2025')
    and PLATFORM='Benqi'
    )
    ,lst_withdraw as (
    select
    block_timestamp::date as date
    ,tx_hash
    ,DEPOSITOR
    ,TOKEN_SYMBOL
    ,-1*AMOUNT_USD
    from avalanche.defi.ez_lending_withdraws
    where year(block_timestamp) in ('2024','2025')
    and PLATFORM='Benqi'
    )
    ,lst_all as (
    select 'Deposit' as type, * from lst_deposit
    union all
    select 'Withdraw' as type, * from lst_withdraw
    )
    select
    count(DISTINCT tx_hash) as "Lending transactions"
    ,count(DISTINCT DEPOSITOR) as Depositors
    ,count(DISTINCT TOKEN_SYMBOL) as "Pools"
    ,sum(AMOUNT_USD) as "Net Lending Volume-USD"
    ,max(AMOUNT_USD) as "MAX.Lending Volume-USD"
    ,avg(AMOUNT_USD) as "AVG.Lending Volume-USD"
    from lst_all
    Last run: about 1 month ago
    Lending transactions
    DEPOSITORS
    Pools
    Net Lending Volume-USD
    MAX.Lending Volume-USD
    AVG.Lending Volume-USD
    1
    369234512771779832350.359999915391488.21206.424893235
    1
    62B
    2s