Sbhn_NPwhole-lime
    Updated 2025-02-09
    with price as (
    select hour::date as datee,
    token_address ,
    avg(price) as usdprice
    from aptos.price.ez_prices_hourly
    group by 1,2
    )

    select
    date_trunc('day',block_timestamp) as date,
    symbol,
    count(DISTINCT ACCOUNT_ADDRESS) as users,
    sum(amount/pow(10,decimals)*usdprice) as borrowed
    from aptos.core.fact_transfers a
    join aptos.core.fact_transactions using(tx_hash)
    join price p on block_timestamp::date=datee and a.token_address=p.token_address
    left join aptos.core.dim_tokens t on a.token_address=t.token_address
    where payload:function = '0xeab7ea4d635b6b6add79d5045c4a45d8148d88287b1cfa1c3b6a4b56f46839ed::router::borrow_simple'
    and transfer_event = 'DepositEvent'
    and date >= '2024-10-10'
    group by 1,2
    Last run: 3 months ago
    DATE
    SYMBOL
    USERS
    BORROWED
    1
    2024-12-28 00:00:00.000USDC87221.699221389
    2
    2024-12-20 00:00:00.000USDC830834.873075069
    3
    2024-11-25 00:00:00.000APT4860.2628125
    4
    2024-10-24 00:00:00.000USDC10824.026823537
    5
    2024-11-21 00:00:00.000APT3425.295
    6
    2024-12-17 00:00:00.000aBTC332.992421667
    7
    2024-12-09 00:00:00.000USDT51330.953770732
    8
    2024-12-23 00:00:00.000aBTC33575.595002388
    9
    2024-12-26 00:00:00.000APT2143.674798691
    10
    2024-11-08 00:00:00.000aBTC71847.600982482
    11
    2024-11-12 00:00:00.000USDT2515519.597845414
    12
    2024-10-26 00:00:00.000APT4238.289
    13
    2024-10-18 00:00:00.000APT1993.333333333
    14
    2024-11-01 00:00:00.000USDC71805.416909057
    15
    2024-12-30 00:00:00.000USDT279.860323333
    16
    2024-12-31 00:00:00.000USDC914308.256373739
    17
    2025-01-12 00:00:00.000USDC186932.041078969
    18
    2024-10-30 00:00:00.000aBTC82250.159693531
    19
    2024-12-18 00:00:00.000USDC2513101.271602625
    20
    2024-10-23 00:00:00.000USDT116682.258391267
    ...
    363
    18KB
    269s